Ui refactor and drag to crop (#245)

* Drag to crop rebase step (#244)

* 1.1.0

* 1.2.0

* added plugin

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>

* drag to crop enabled

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>

* fix

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>

* improvement

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>

* done dragToCrop

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>

* done with updated ui

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>

* solved bug for multiple consecutive crops

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>

* fixed and updated

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>

* externalized image area select code

* major refactoring of crop drag and demo ui modules

* work on crop module and ui refactor

* completed Step drag ui refactor

* revert unbuilt to rebase

* built and version bump

* various fixes
This commit is contained in:
Jeffrey Warren
2018-05-04 14:27:48 -04:00
committed by GitHub
parent 51524f747a
commit 768e2ce95d
12 changed files with 696 additions and 397 deletions

View File

@@ -13,47 +13,65 @@
* y = options.y
* y = options.y + options.h
*/
module.exports = function CropModule(options,UI) {
module.exports = function CropModule(options, UI) {
// TODO: we could also set this to {} if nil in AddModule.js to avoid this line:
options = options || {};
// TODO: we could also set this to {} if nil in AddModule.js to avoid this line:
options = options || {};
// Tell the UI that a step has been added
UI.onSetup(options.step);
var output;
// Tell the UI that a step has been added
UI.onSetup(options.step); // we should get UI to return the image thumbnail so we can attach our own UI extensions
// This function is caled everytime the step has to be redrawn
function draw(input,callback) {
// add our custom in-module html ui:
if (options.step.inBrowser) var ui = require('./Ui.js')(options.step, UI);
var output,
setupComplete = false;
// Tell the UI that the step has been triggered
UI.onDraw(options.step);
var step = this;
// This function is caled everytime the step has to be redrawn
function draw(input,callback) {
require('./Crop')(input,options,function(out,format){
// Tell the UI that the step has been triggered
UI.onDraw(options.step);
var step = this;
// This output is accessible to Image Sequencer
step.output = {
src: out,
format: format
}
// save the input image;
// TODO: this should be moved to module API to persist the input image
options.step.input = input.src;
// This output is accessible to the UI
options.step.output = out;
require('./Crop')(input, options, function(out, format){
// Tell the UI that the step has been drawn
UI.onComplete(options.step);
// This output is accessible to Image Sequencer
step.output = {
src: out,
format: format
}
// Tell Image Sequencer that step has been drawn
callback();
// This output is accessible to the UI
options.step.output = out;
});
// Tell the UI that the step has been drawn
UI.onComplete(options.step);
}
// we should do this via event/listener:
if (ui && ui.hide) ui.hide();
return {
options: options,
draw: draw,
output: output,
UI: UI
}
}
// start custom UI setup (draggable UI)
// only once we have an input image
if (setupComplete === false && options.step.inBrowser) {
setupComplete = true;
ui.setup();
}
// Tell Image Sequencer that step has been drawn
callback();
});
}
return {
options: options,
draw: draw,
output: output,
UI: UI
}
}