Skip to content

Commit

Permalink
#25 connect selection controller to tool bar
Browse files Browse the repository at this point in the history
  • Loading branch information
gyuque committed Feb 3, 2014
1 parent 78b385e commit 7150dcb
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
5 changes: 5 additions & 0 deletions inner/js/Mobmap2App.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ if (!window.mobmap) { window.mobmap={}; }
this.selectionController.clear();
},

getSelectionController: function() {
return this.selectionController;
},

// -----------------------------------------------------
// Screen builder
setupScreen: function() {
Expand All @@ -160,6 +164,7 @@ if (!window.mobmap) { window.mobmap={}; }
var targetPaneElement = this.appScreen.getToolsPaneElement();
this.toolPane = new mobmap.ToolPane(targetPaneElement);
this.toolPane.observeContainerEvents(this.appScreen);
this.toolPane.connectToSelectionController(this.selectionController);
},

setupMapPane: function() {
Expand Down
30 changes: 28 additions & 2 deletions inner/js/selection/selection-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,38 @@ if (!window.mobmap) { window.mobmap={}; }

this.responders.push(r);
return true;
},

startRectSelectionSession: function() {

},

fireNewSession: function() { this.callResponders('selWillStartNewSession'); },

callResponders: function(methodName, arg1, arg2) {
var required = SelectionControllerResponderMethodList[methodName] || false;
var ls = this.responders;
var len = ls.length;

for (var i = 0;i < len;++i) {
var recv = ls[i];
var hasMethod = !!recv[methodName];

if (!hasMethod && required) {
throw "Responder must implement " + methodName;
}

if (hasMethod) {
recv[methodName](arg1, arg2);
}
}
}
};

var SelectionControllerResponderMethodList = {
// name | required
selWillStart : false
// name | required
selWillDisposeCurrentSession : false,
selWillStartNewSession : false
};

aGlobal.mobmap.SelectionController = SelectionController;
Expand Down
4 changes: 4 additions & 0 deletions inner/js/ui/tool-pane.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ if (!window.mobmap) { window.mobmap={}; }
this.controlPanel.setApp(a);
this.editToolBar.setApp(a);
},

connectToSelectionController: function(selcon) {
selcon.addResponder(this.editToolBar);
},

observeContainerEvents: function(app3PanesView) {
app3PanesView.eventDispatcher().bind(mobmap.Mobmap3PanesScreen.RESIZE_EVENT,
Expand Down

0 comments on commit 7150dcb

Please sign in to comment.