Compare commits

...

3 Commits

Author SHA1 Message Date
crschmidt
98759ba74d Tag RC2.
git-svn-id: http://svn.openlayers.org/tags/openlayers/release-2.1-rc2@1482 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-18 18:49:23 +00:00
crschmidt
5f8dc06823 Pullup fixes to mouse controls since 2.1-rc1, along with a fix for
zooming. 


git-svn-id: http://svn.openlayers.org/branches/openlayers/2.1@1481 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-18 18:48:29 +00:00
crschmidt
130e527702 Branch for 2.1
git-svn-id: http://svn.openlayers.org/branches/openlayers/2.1@1452 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-09-14 16:33:48 +00:00
7 changed files with 83 additions and 32 deletions

View File

@@ -12,7 +12,6 @@ of different layers.
clone() -- {OpenLayers.Layer} -- create a clone of the layer. clone() -- {OpenLayers.Layer} -- create a clone of the layer.
setName({String|name}) -- none -- Set the name of the layer to something different. setName({String|name}) -- none -- Set the name of the layer to something different.
moveTo({OpenLayers.Bounds|bounds}, {Boolean|zoomChanged}) -- none -- Not implemented here, but the general function called on dragging or setCenter, to move the Layer to a new geographic location. moveTo({OpenLayers.Bounds|bounds}, {Boolean|zoomChanged}) -- none -- Not implemented here, but the general function called on dragging or setCenter, to move the Layer to a new geographic location.
reproject() -- none -- Subclassed by vector layers to redraw vectors when base layer changes.
setMap(map) -- none -- Set the map property of the layer. Also set the parameters which are inherited from the map. setMap(map) -- none -- Set the map property of the layer. Also set the parameters which are inherited from the map.
getVisibility() -- {Boolean} -- Return true or false based on visibility of the layer. getVisibility() -- {Boolean} -- Return true or false based on visibility of the layer.
setVisibility({Boolean|visible}) -- none -- Set the layer visibility, and trigger the appropriate events. setVisibility({Boolean|visible}) -- none -- Set the layer visibility, and trigger the appropriate events.

View File

@@ -141,9 +141,12 @@ OpenLayers.Control.MouseDefaults.prototype =
* @param {Event} evt * @param {Event} evt
*/ */
defaultMouseOut: function (evt) { defaultMouseOut: function (evt) {
if (this.mouseDragStart != null if (this.mouseDragStart != null &&
&& OpenLayers.Util.mouseLeft(evt, this.map.div)) { OpenLayers.Util.mouseLeft(evt, this.map.div)) {
this.defaultMouseUp(evt); if (this.zoomBox) {
this.removeZoomBox();
}
this.mouseDragStart = null;
} }
}, },
@@ -188,9 +191,16 @@ OpenLayers.Control.MouseDefaults.prototype =
(end.lat) (end.lat)
), this.map.getZoom() + 1); ), this.map.getZoom() + 1);
} }
this.removeZoomBox();
}
},
/**
* Remove the zoombox from the screen and nullify our reference to it.
*/
removeZoomBox: function() {
this.map.viewPortDiv.removeChild(this.zoomBox); this.map.viewPortDiv.removeChild(this.zoomBox);
this.zoomBox = null; this.zoomBox = null;
}
}, },

View File

@@ -21,6 +21,9 @@ OpenLayers.Control.MouseToolbar.prototype =
direction: "vertical", direction: "vertical",
/** @type String */
buttonClicked: null,
initialize: function(position, direction) { initialize: function(position, direction) {
OpenLayers.Control.prototype.initialize.apply(this, arguments); OpenLayers.Control.prototype.initialize.apply(this, arguments);
this.position = new OpenLayers.Pixel(OpenLayers.Control.MouseToolbar.X, this.position = new OpenLayers.Pixel(OpenLayers.Control.MouseToolbar.X,
@@ -62,10 +65,10 @@ OpenLayers.Control.MouseToolbar.prototype =
btn.imgLocation = imgLocation; btn.imgLocation = imgLocation;
btn.activeImgLocation = activeImgLocation; btn.activeImgLocation = activeImgLocation;
btn.events = new OpenLayers.Events(this, btn); btn.events = new OpenLayers.Events(this, btn, null, true);
btn.events.register("mousedown", this, this.buttonClick); btn.events.register("mousedown", this, this.buttonDown);
btn.events.register("mouseup", this, Event.stop); btn.events.register("mouseup", this, this.buttonUp);
btn.events.register("click", this, Event.stop); btn.events.register("dblclick", this, Event.stop);
btn.action = id; btn.action = id;
btn.title = title; btn.title = title;
btn.alt = title; btn.alt = title;
@@ -76,12 +79,29 @@ OpenLayers.Control.MouseToolbar.prototype =
return btn; return btn;
}, },
buttonClick: function(evt) { /**
* @param {Event} evt
*/
buttonDown: function(evt) {
if (!Event.isLeftClick(evt)) return; if (!Event.isLeftClick(evt)) return;
this.switchModeTo(evt.element.action); this.buttonClicked = evt.element.action;
Event.stop(evt); Event.stop(evt);
}, },
/**
* @param {Event} evt
*/
buttonUp: function(evt) {
if (!Event.isLeftClick(evt)) return;
if (this.buttonClicked != null) {
if (this.buttonClicked == evt.element.action) {
this.switchModeTo(evt.element.action);
}
Event.stop(evt);
this.buttonClicked = null;
}
},
/** /**
* @param {Event} evt * @param {Event} evt
*/ */
@@ -89,7 +109,7 @@ OpenLayers.Control.MouseToolbar.prototype =
this.switchModeTo("pan"); this.switchModeTo("pan");
this.performedDrag = false; this.performedDrag = false;
var newCenter = this.map.getLonLatFromViewPortPx( evt.xy ); var newCenter = this.map.getLonLatFromViewPortPx( evt.xy );
this.map.setCenter(newCenter, this.map.zoom + 2); this.map.setCenter(newCenter, this.map.zoom + 1);
Event.stop(evt); Event.stop(evt);
return false; return false;
}, },
@@ -179,6 +199,8 @@ OpenLayers.Control.MouseToolbar.prototype =
switchModeTo: function(mode) { switchModeTo: function(mode) {
if (mode != this.mode) { if (mode != this.mode) {
if (this.mode && this.buttons[this.mode]) { if (this.mode && this.buttons[this.mode]) {
OpenLayers.Util.modifyAlphaImageDiv(this.buttons[this.mode], null, null, null, this.buttons[this.mode].imgLocation); OpenLayers.Util.modifyAlphaImageDiv(this.buttons[this.mode], null, null, null, this.buttons[this.mode].imgLocation);
} }
@@ -195,6 +217,15 @@ OpenLayers.Control.MouseToolbar.prototype =
if (this.buttons[mode]) { if (this.buttons[mode]) {
OpenLayers.Util.modifyAlphaImageDiv(this.buttons[mode], null, null, null, this.buttons[mode].activeImgLocation); OpenLayers.Util.modifyAlphaImageDiv(this.buttons[mode], null, null, null, this.buttons[mode].activeImgLocation);
} }
switch (this.mode) {
case "zoombox":
this.map.div.style.cursor = "crosshair";
break;
default:
this.map.div.style.cursor = "default";
break;
}
} }
}, },
@@ -254,12 +285,21 @@ OpenLayers.Control.MouseToolbar.prototype =
this.map.div.style.cursor = "default"; this.map.div.style.cursor = "default";
}, },
/**
* @param {Event} evt
*/
defaultMouseOut: function (evt) { defaultMouseOut: function (evt) {
if (this.mouseDragStart != null if (this.mouseDragStart != null
&& OpenLayers.Util.mouseLeft(evt, this.map.div)) { && OpenLayers.Util.mouseLeft(evt, this.map.div)) {
this.defaultMouseUp(evt); if (this.zoomBox) {
this.removeZoomBox();
if (this.startViaKeyboard) this.leaveMode();
}
this.mouseDragStart = null;
this.map.div.style.cursor = "default";
} }
}, },
defaultClick: function (evt) { defaultClick: function (evt) {
if (this.performedDrag) { if (this.performedDrag) {
this.performedDrag = false; this.performedDrag = false;

View File

@@ -86,7 +86,7 @@ OpenLayers.Control.PanZoomBar.prototype =
"absolute"); "absolute");
this.slider = slider; this.slider = slider;
this.sliderEvents = new OpenLayers.Events(this, slider); this.sliderEvents = new OpenLayers.Events(this, slider, null, true);
this.sliderEvents.register("mousedown", this, this.zoomBarDown); this.sliderEvents.register("mousedown", this, this.zoomBarDown);
this.sliderEvents.register("mousemove", this, this.zoomBarDrag); this.sliderEvents.register("mousemove", this, this.zoomBarDrag);
this.sliderEvents.register("mouseup", this, this.zoomBarUp); this.sliderEvents.register("mouseup", this, this.zoomBarUp);
@@ -116,7 +116,7 @@ OpenLayers.Control.PanZoomBar.prototype =
this.zoombarDiv = div; this.zoombarDiv = div;
this.divEvents = new OpenLayers.Events(this, div); this.divEvents = new OpenLayers.Events(this, div, null, true);
this.divEvents.register("mousedown", this, this.divClick); this.divEvents.register("mousedown", this, this.divClick);
this.divEvents.register("mousemove", this, this.passEventToSlider); this.divEvents.register("mousemove", this, this.passEventToSlider);
this.divEvents.register("dblclick", this, this.doubleClick); this.divEvents.register("dblclick", this, this.doubleClick);

View File

@@ -37,11 +37,14 @@ OpenLayers.Events.prototype = {
* is being added * is being added
* @param {DOMElement} element A dom element to respond to browser events * @param {DOMElement} element A dom element to respond to browser events
* @param {Array} eventTypes Array of custom application events * @param {Array} eventTypes Array of custom application events
* @param {Boolean} fallThrough Allow events to fall through after these
* have been handled?
*/ */
initialize: function (object, element, eventTypes) { initialize: function (object, element, eventTypes, fallThrough) {
this.object = object; this.object = object;
this.element = element; this.element = element;
this.eventTypes = eventTypes; this.eventTypes = eventTypes;
this.fallThrough = fallThrough;
this.listeners = new Object(); this.listeners = new Object();
// if eventTypes is specified, create a listeners list for each // if eventTypes is specified, create a listeners list for each
@@ -176,8 +179,10 @@ OpenLayers.Events.prototype = {
} }
} }
// don't fall through to other DOM elements // don't fall through to other DOM elements
if (!this.fallThrough) {
Event.stop(evt); Event.stop(evt);
} }
}
}, },
/** Basically just a wrapper to the triggerEvent() function, but takes /** Basically just a wrapper to the triggerEvent() function, but takes

View File

@@ -322,7 +322,6 @@ OpenLayers.Layer.prototype = {
this.resolutions.push(this.maxResolution / Math.pow(2, i)); this.resolutions.push(this.maxResolution / Math.pow(2, i));
} }
} }
this.resolutions = this.resolutions.sort().reverse();
}, },
/** /**

View File

@@ -250,17 +250,15 @@ OpenLayers.Popup.prototype = {
* hyperlinks or drag-selecting text. * hyperlinks or drag-selecting text.
*/ */
registerEvents:function() { registerEvents:function() {
Event.observe(this.div, "mousedown", this.events = new OpenLayers.Events(this, this.div, null, true);
this.onmousedown.bindAsEventListener(this));
Event.observe(this.div, "mousemove", this.events.register("mousedown", this, this.onmousedown);
this.onmousemove.bindAsEventListener(this)); this.events.register("mousemove", this, this.onmousemove);
Event.observe(this.div, "mouseup", this.events.register("mouseup", this, this.onmouseup);
this.onmouseup.bindAsEventListener(this)); this.events.register("click", this,
Event.observe(this.div, "click",
OpenLayers.Util.safeStopPropagation); OpenLayers.Util.safeStopPropagation);
Event.observe(this.div, "mouseout", this.events.register("mouseout", this, this.onmouseout);
this.onmouseout.bindAsEventListener(this)); this.events.register("dblclick", this,
Event.observe(this.div, "dblclick",
OpenLayers.Util.safeStopPropagation); OpenLayers.Util.safeStopPropagation);
}, },