Commit 353e64db authored by Bas Lijnse's avatar Bas Lijnse

Merge branch 'master' into 259-editors-need-refinement

parents 47e4f146 bbe0706e
...@@ -71,7 +71,7 @@ toLeafletPerspective :: ContactMapPerspective -> LeafletPerspective ...@@ -71,7 +71,7 @@ toLeafletPerspective :: ContactMapPerspective -> LeafletPerspective
fromLeafletMap :: ContactMap LeafletMap -> ContactMap fromLeafletMap :: ContactMap LeafletMap -> ContactMap
fromLeafletPerspective :: LeafletPerspective -> ContactMapPerspective fromLeafletPerspective :: LeafletPerspective -> ContactMapPerspective
selectionFromLeafletMap :: LeafletMap -> [String] selectionFromLeafletMap :: LeafletMap -> [LeafletObjectID]
//Standard layers available to use in all map views //Standard layers available to use in all map views
standardPerspective :: Shared ContactMapPerspective standardPerspective :: Shared ContactMapPerspective
......
...@@ -215,8 +215,9 @@ where ...@@ -215,8 +215,9 @@ where
fromLeafletLayer cl ll = cl fromLeafletLayer cl ll = cl
*/ */
selectionFromLeafletMap :: LeafletMap -> [String] selectionFromLeafletMap :: LeafletMap -> [LeafletObjectID]
selectionFromLeafletMap {LeafletMap|objects} = [markerId \\ Marker {LeafletMarker|markerId,selected} <- objects | selected] selectionFromLeafletMap {LeafletMap|objects} =
[markerId \\ Marker {LeafletMarker|markerId,selected} <- objects | selected]
fromLeafletLatLng :: !LeafletLatLng -> (!Real,!Real) fromLeafletLatLng :: !LeafletLatLng -> (!Real,!Real)
fromLeafletLatLng {LeafletLatLng|lat,lng} = (lat,lng) fromLeafletLatLng {LeafletLatLng|lat,lng} = (lat,lng)
......
...@@ -605,7 +605,7 @@ where ...@@ -605,7 +605,7 @@ where
isSelected _ _ = False isSelected _ _ = False
updateSelection [] = Nothing updateSelection [] = Nothing
updateSelection [markerId:ms] updateSelection [LeafletObjectID markerId:ms]
| startsWith "c" markerId = Just (Left (toInt (subString 1 (textSize markerId) markerId))) | startsWith "c" markerId = Just (Left (toInt (subString 1 (textSize markerId) markerId)))
| startsWith "a" markerId = Just (Right (toInt (subString 1 (textSize markerId) markerId))) | startsWith "a" markerId = Just (Right (toInt (subString 1 (textSize markerId) markerId)))
= updateSelection ms = updateSelection ms
......
...@@ -117,9 +117,9 @@ toLeafletMap {ContactMap|perspective,markers} ...@@ -117,9 +117,9 @@ toLeafletMap {ContactMap|perspective,markers}
where where
convMarkers markers = [conv m \\ m=:{ContactMapMarker|position} <- markers] convMarkers markers = [conv m \\ m=:{ContactMapMarker|position} <- markers]
conv {ContactMapMarker|markerId,title,position,heading,type,selected} conv {ContactMapMarker|markerId,title,position,heading,type,selected}
= Marker {LeafletMarker|markerId = markerId, title = title, position = toLeafletLatLng position, icon = fmap (\t -> iconIndex heading t selected) type, selected = selected, popup = Nothing} = Marker {LeafletMarker|markerId = LeafletObjectID markerId, title = title, position = toLeafletLatLng position, icon = fmap (\t -> LeafletIconID (iconIndex heading t selected)) type, selected = selected, popup = Nothing}
icon i = {LeafletIcon|iconId=toString i,iconUrl ="/ship-icons/"+++toString i+++".png",iconSize=(24,24)} icon i = {LeafletIcon|iconId=LeafletIconID (toString i),iconUrl ="/ship-icons/"+++toString i+++".png",iconSize=(24,24)}
iconIndex heading type selected = toString (cat type + ( (maybe 24 (\d -> toInt d / 15) heading) + (if selected 25 0)) * 5) iconIndex heading type selected = toString (cat type + ( (maybe 24 (\d -> toInt d / 15) heading) + (if selected 25 0)) * 5)
toLeafletPerspective :: ContactMapPerspective -> LeafletPerspective toLeafletPerspective :: ContactMapPerspective -> LeafletPerspective
...@@ -139,7 +139,7 @@ fromLeafletMap {LeafletMap|perspective,objects} ...@@ -139,7 +139,7 @@ fromLeafletMap {LeafletMap|perspective,objects}
where where
toMarkers objects toMarkers objects
= [{ContactMapMarker|markerId=markerId,title=Nothing,position = fromLeafletLatLng position, type=Nothing,heading=Nothing,selected=selected} = [{ContactMapMarker|markerId=markerId,title=Nothing,position = fromLeafletLatLng position, type=Nothing,heading=Nothing,selected=selected}
\\ Marker {LeafletMarker|markerId,position,selected} <- objects] \\ Marker {LeafletMarker|markerId = LeafletObjectID markerId,position,selected} <- objects]
fromLeafletPerspective :: LeafletPerspective -> ContactMapPerspective fromLeafletPerspective :: LeafletPerspective -> ContactMapPerspective
fromLeafletPerspective {LeafletPerspective|center,cursor,zoom} fromLeafletPerspective {LeafletPerspective|center,cursor,zoom}
......
...@@ -43,7 +43,7 @@ where ...@@ -43,7 +43,7 @@ where
>>- \marker -> upd (\l=:{LeafletMap|objects} -> {LeafletMap|l & objects = objects ++ [marker]}) m >>- \marker -> upd (\l=:{LeafletMap|objects} -> {LeafletMap|l & objects = objects ++ [marker]}) m
toRandomMarker (rLat,rLng) toRandomMarker (rLat,rLng)
= Marker {markerId = markerId, position= {LeafletLatLng|lat = lat, lng = lng}, title = Just markerId, icon = Just icon, selected = False, popup = Nothing} = Marker {markerId = LeafletObjectID markerId, position= {LeafletLatLng|lat = lat, lng = lng}, title = Just markerId, icon = Just icon, selected = False, popup = Nothing}
where where
lat = 52.0 + (toReal (500 + (rLat rem 1000)) / 1000.0) lat = 52.0 + (toReal (500 + (rLat rem 1000)) / 1000.0)
lng = 6.0 + (toReal (500 + (rLng rem 1000)) / 1000.0) lng = 6.0 + (toReal (500 + (rLng rem 1000)) / 1000.0)
...@@ -53,7 +53,7 @@ where ...@@ -53,7 +53,7 @@ where
addMarkerConnectingLine m addMarkerConnectingLine m
= upd (\l=:{LeafletMap|objects} -> {LeafletMap|l & objects = objects ++ [line objects]}) m = upd (\l=:{LeafletMap|objects} -> {LeafletMap|l & objects = objects ++ [line objects]}) m
where where
line objects = Polyline { polylineId = "markerConnection" line objects = Polyline { polylineId = LeafletObjectID "markerConnection"
, style = [Style (LineStrokeColor "#f0f"), Style (LineStrokeWidth 4)] , style = [Style (LineStrokeColor "#f0f"), Style (LineStrokeWidth 4)]
, points = points objects , points = points objects
} }
...@@ -62,7 +62,7 @@ where ...@@ -62,7 +62,7 @@ where
addMarkerConnectingPolygon m addMarkerConnectingPolygon m
= upd (\l=:{LeafletMap|objects} -> {LeafletMap|l & objects = objects ++ [polygon objects]}) m = upd (\l=:{LeafletMap|objects} -> {LeafletMap|l & objects = objects ++ [polygon objects]}) m
where where
polygon objects = Polygon { polygonId = "markerConnection" polygon objects = Polygon { polygonId = LeafletObjectID "markerConnection"
, style = [ Style (PolygonLineStrokeColor "#000") , style = [ Style (PolygonLineStrokeColor "#000")
, Style (PolygonLineStrokeWidth 2) , Style (PolygonLineStrokeWidth 2)
, Style (PolygonFillColor "#0f0") , Style (PolygonFillColor "#0f0")
...@@ -75,6 +75,6 @@ where ...@@ -75,6 +75,6 @@ where
= upd (\l=:{LeafletMap|perspective={LeafletPerspective|cursor},objects} -> {LeafletMap|l & objects = withMarkerFromCursor cursor objects}) m = upd (\l=:{LeafletMap|perspective={LeafletPerspective|cursor},objects} -> {LeafletMap|l & objects = withMarkerFromCursor cursor objects}) m
where where
withMarkerFromCursor Nothing objects = objects withMarkerFromCursor Nothing objects = objects
withMarkerFromCursor (Just position) objects = objects ++ [Marker {markerId = "CURSOR", position= position, title = Nothing, icon = Nothing, selected = False, popup = Nothing}] withMarkerFromCursor (Just position) objects = objects ++ [Marker {markerId = LeafletObjectID "CURSOR", position= position, title = Nothing, icon = Nothing, selected = False, popup = Nothing}]
Start world = doTasks playWithMaps world Start world = doTasks playWithMaps world
...@@ -5,24 +5,24 @@ import iTasks ...@@ -5,24 +5,24 @@ import iTasks
leafletEditor :: Editor LeafletMap leafletEditor :: Editor LeafletMap
:: LeafletMap = :: LeafletMap =
{ perspective :: LeafletPerspective { perspective :: !LeafletPerspective
, tilesUrls :: [String] , tilesUrls :: ![String]
, objects :: [LeafletObject] //Markers, lines and polygon , objects :: ![LeafletObject] //Markers, lines and polygon
, icons :: [LeafletIcon] //Custom icons used by markers. They are indexed by 'iconId' string and cannot be changed once the map is loaded , icons :: ![LeafletIcon] //Custom icons used by markers. They are indexed by 'iconId' string and cannot be changed once the map is loaded
} }
:: LeafletPerspective = :: LeafletPerspective =
{ center :: LeafletLatLng { center :: !LeafletLatLng
, zoom :: Int , zoom :: !Int
, cursor :: Maybe LeafletLatLng , cursor :: !Maybe LeafletLatLng
, bounds :: Maybe LeafletBounds , bounds :: !Maybe LeafletBounds
} }
:: LeafletIconID :== String :: LeafletIconID =: LeafletIconID String
:: LeafletIcon = :: LeafletIcon =
{ iconId :: LeafletIconID { iconId :: !LeafletIconID
, iconUrl :: String , iconUrl :: !String
, iconSize :: (!Int,!Int) , iconSize :: !(!Int,!Int)
} }
:: LeafletLatLng = :: LeafletLatLng =
...@@ -41,7 +41,7 @@ leafletEditor :: Editor LeafletMap ...@@ -41,7 +41,7 @@ leafletEditor :: Editor LeafletMap
| Polygon !LeafletPolygon | Polygon !LeafletPolygon
| Window !LeafletWindow | Window !LeafletWindow
:: LeafletObjectID :== String :: LeafletObjectID =: LeafletObjectID String
:: LeafletMarker = :: LeafletMarker =
{ markerId :: !LeafletObjectID { markerId :: !LeafletObjectID
, position :: !LeafletLatLng , position :: !LeafletLatLng
...@@ -68,7 +68,7 @@ leafletEditor :: Editor LeafletMap ...@@ -68,7 +68,7 @@ leafletEditor :: Editor LeafletMap
, initPosition :: !LeafletWindowPos , initPosition :: !LeafletWindowPos
, title :: !String , title :: !String
, content :: !HtmlTag , content :: !HtmlTag
, relatedMarkers :: ![(LeafletObjectID, [LeafletStyleDef LeafletLineStyle])] // connecting lines are drawn between the window and the markers , relatedMarkers :: ![(!LeafletObjectID, ![LeafletStyleDef LeafletLineStyle])] // connecting lines are drawn between the window and the markers
// to visualise the relation // to visualise the relation
} }
...@@ -85,7 +85,7 @@ leafletEditor :: Editor LeafletMap ...@@ -85,7 +85,7 @@ leafletEditor :: Editor LeafletMap
| PolygonFillColor !String // html/css color definition | PolygonFillColor !String // html/css color definition
| PolygonFillOpacity !Real | PolygonFillOpacity !Real
:: CSSClass :== String :: CSSClass =: CSSClass String
:: LeafletStyleDef style = Style style :: LeafletStyleDef style = Style style
| Class CSSClass | Class CSSClass
...@@ -102,4 +102,3 @@ derive gEq LeafletMap, LeafletPerspective ...@@ -102,4 +102,3 @@ derive gEq LeafletMap, LeafletPerspective
derive gText LeafletMap, LeafletPerspective, LeafletLatLng derive gText LeafletMap, LeafletPerspective, LeafletLatLng
derive gEditor LeafletMap, LeafletPerspective, LeafletLatLng derive gEditor LeafletMap, LeafletPerspective, LeafletLatLng
derive class iTask LeafletIcon, LeafletBounds, LeafletObject, LeafletMarker, LeafletPolyline, LeafletPolygon, LeafletWindow, LeafletWindowPos, LeafletLineStyle, LeafletStyleDef, LeafletPolygonStyle derive class iTask LeafletIcon, LeafletBounds, LeafletObject, LeafletMarker, LeafletPolyline, LeafletPolygon, LeafletWindow, LeafletWindowPos, LeafletLineStyle, LeafletStyleDef, LeafletPolygonStyle
This diff is collapsed.
...@@ -4,9 +4,9 @@ implementation module iTasks.Extensions.GIS.LeafletNavalIcons ...@@ -4,9 +4,9 @@ implementation module iTasks.Extensions.GIS.LeafletNavalIcons
*/ */
from iTasks.Extensions.GIS.Leaflet import :: LeafletIcon(..), :: LeafletIconID(..) from iTasks.Extensions.GIS.Leaflet import :: LeafletIcon(..), :: LeafletIconID(..)
from StdFunc import o from StdFunc import o
import StdString, StdInt, StdList, Data.Maybe import StdString, StdInt, StdList, Data.Maybe, Text
URL iconId :== "/leaflet-naval-icons/" +++ iconId +++ ".png" URL (LeafletIconID iconId) :== concat ["/leaflet-naval-icons/", iconId, ".png"]
SIZE :== (24,24) SIZE :== (24,24)
instance toString ShipIconColor instance toString ShipIconColor
...@@ -29,6 +29,7 @@ where ...@@ -29,6 +29,7 @@ where
* Find the right icon based on a heading and color * Find the right icon based on a heading and color
*/ */
shipIconId :: (Maybe ShipIconHeading) ShipIconColor Bool -> LeafletIconID shipIconId :: (Maybe ShipIconHeading) ShipIconColor Bool -> LeafletIconID
shipIconId mbHeading color selected = toString color +++ if selected "-sel" "" +++ maybe "" toRoundedHeading mbHeading shipIconId mbHeading color selected =
LeafletIconID (concat [toString color, if selected "-sel" "", maybe "" toRoundedHeading mbHeading])
where where
toRoundedHeading h = "-" +++ toString (((h rem 360) / 15) * 15) toRoundedHeading h = "-" +++ toString (((h rem 360) / 15) * 15)
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -45,8 +45,10 @@ ...@@ -45,8 +45,10 @@
.leaflet-container .leaflet-marker-pane img, .leaflet-container .leaflet-marker-pane img,
.leaflet-container .leaflet-shadow-pane img, .leaflet-container .leaflet-shadow-pane img,
.leaflet-container .leaflet-tile-pane img, .leaflet-container .leaflet-tile-pane img,
.leaflet-container img.leaflet-image-layer { .leaflet-container img.leaflet-image-layer,
.leaflet-container .leaflet-tile {
max-width: none !important; max-width: none !important;
max-height: none !important;
} }
.leaflet-container.leaflet-touch-zoom { .leaflet-container.leaflet-touch-zoom {
...@@ -55,7 +57,10 @@ ...@@ -55,7 +57,10 @@
} }
.leaflet-container.leaflet-touch-drag { .leaflet-container.leaflet-touch-drag {
-ms-touch-action: pinch-zoom; -ms-touch-action: pinch-zoom;
} /* Fallback for FF which doesn't support pinch-zoom */
touch-action: none;
touch-action: pinch-zoom;
}
.leaflet-container.leaflet-touch-drag.leaflet-touch-zoom { .leaflet-container.leaflet-touch-drag.leaflet-touch-zoom {
-ms-touch-action: none; -ms-touch-action: none;
touch-action: none; touch-action: none;
...@@ -164,7 +169,6 @@ ...@@ -164,7 +169,6 @@
opacity: 0; opacity: 0;
-webkit-transition: opacity 0.2s linear; -webkit-transition: opacity 0.2s linear;
-moz-transition: opacity 0.2s linear; -moz-transition: opacity 0.2s linear;
-o-transition: opacity 0.2s linear;
transition: opacity 0.2s linear; transition: opacity 0.2s linear;
} }
.leaflet-fade-anim .leaflet-map-pane .leaflet-popup { .leaflet-fade-anim .leaflet-map-pane .leaflet-popup {
...@@ -181,14 +185,12 @@ ...@@ -181,14 +185,12 @@
.leaflet-zoom-anim .leaflet-zoom-animated { .leaflet-zoom-anim .leaflet-zoom-animated {
-webkit-transition: -webkit-transform 0.25s cubic-bezier(0,0,0.25,1); -webkit-transition: -webkit-transform 0.25s cubic-bezier(0,0,0.25,1);
-moz-transition: -moz-transform 0.25s cubic-bezier(0,0,0.25,1); -moz-transition: -moz-transform 0.25s cubic-bezier(0,0,0.25,1);
-o-transition: -o-transform 0.25s cubic-bezier(0,0,0.25,1);
transition: transform 0.25s cubic-bezier(0,0,0.25,1); transition: transform 0.25s cubic-bezier(0,0,0.25,1);
} }
.leaflet-zoom-anim .leaflet-tile, .leaflet-zoom-anim .leaflet-tile,
.leaflet-pan-anim .leaflet-tile { .leaflet-pan-anim .leaflet-tile {
-webkit-transition: none; -webkit-transition: none;
-moz-transition: none; -moz-transition: none;
-o-transition: none;
transition: none; transition: none;
} }
...@@ -205,6 +207,7 @@ ...@@ -205,6 +207,7 @@
.leaflet-grab { .leaflet-grab {
cursor: -webkit-grab; cursor: -webkit-grab;
cursor: -moz-grab; cursor: -moz-grab;
cursor: grab;
} }
.leaflet-crosshair, .leaflet-crosshair,
.leaflet-crosshair .leaflet-interactive { .leaflet-crosshair .leaflet-interactive {
...@@ -220,6 +223,7 @@ ...@@ -220,6 +223,7 @@
cursor: move; cursor: move;
cursor: -webkit-grabbing; cursor: -webkit-grabbing;
cursor: -moz-grabbing; cursor: -moz-grabbing;
cursor: grabbing;
} }
/* marker & overlays interactivity */ /* marker & overlays interactivity */
...@@ -366,6 +370,7 @@ ...@@ -366,6 +370,7 @@
} }
.leaflet-control-layers-scrollbar { .leaflet-control-layers-scrollbar {
overflow-y: scroll; overflow-y: scroll;
overflow-x: hidden;
padding-right: 5px; padding-right: 5px;
} }
.leaflet-control-layers-selector { .leaflet-control-layers-selector {
...@@ -489,7 +494,6 @@ ...@@ -489,7 +494,6 @@
-webkit-transform: rotate(45deg); -webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg); -moz-transform: rotate(45deg);
-ms-transform: rotate(45deg); -ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg); transform: rotate(45deg);
} }
.leaflet-popup-content-wrapper, .leaflet-popup-content-wrapper,
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
L.Window = L.Control.extend({ L.Window = L.Control.extend({
initialize: function (baseLayers, overlays, options) {
this._relatedMarkers = {};
},
options: { options: {
position: 'topleft' position: 'topleft'
}, },
...@@ -6,13 +9,71 @@ L.Window = L.Control.extend({ ...@@ -6,13 +9,71 @@ L.Window = L.Control.extend({
this._initPos = pos; this._initPos = pos;
}, },
setTitle: function(title) { setTitle: function(title) {
this._title = title; if (this._titleEl) {
this._titleEl.innerHTML = title;
} else {
this._initTitle = title;
}
}, },
setContent: function(content) { setContent: function(content) {
this._content = content; if (this._contentNode) {
this._contentNode.innerHTML = content;
} else {
this._initContent = content;
}
}, },
addRelatedMarker: function(markerId, options) { setRelatedMarkers: function(markers) {
if (!this._relatedMarkers) this._relatedMarkers = {}; // remove all markers
for (markerId in this._relatedMarkers) {
if (markerId in this._relatedMarkerConnectors) {
this._relatedMarkerConnectors[markerId].polyline.remove();
}
};
this._relatedMarkers = {};
this._relatedMarkerConnectors = {};
markers.forEach((marker) => this.addRelatedMarker(marker));
// this actually creates the connectors
this._map.eachLayer((l) => this._onLayerAdd({layer: l}));
},
addRelatedMarker: function(marker) {
const markerId = marker[0];
const lineStyles = marker[1];
var options = {};
lineStyles.forEach((lineStyle) => {
const lineStyleConstr = lineStyle[0];
const lineStyleConstrArg = lineStyle[1];
switch (lineStyleConstr) {
case "Style":
const lineStyleAttr = lineStyleConstrArg[0];
const lineStyleAttrVal = lineStyleConstrArg[1];
switch (lineStyleAttr) {
case "LineStrokeColor":
options.color = lineStyleAttrVal;
break;
case "LineStrokeWidth":
options.weight = lineStyleAttrVal;
break;
case "LineOpacity":
options.opacity = lineStyleAttrVal;
break;
case "LineDashArray":
options.dashArray = lineStyleAttrVal;
break;
default:
throw new Error("Unknown line style attribute: " + lineStyleAttr);
}
break;
case "Class":
options.className = lineStyleConstrArg;
break;
default:
throw new Error("Unknown line style constructor: " + lineStyleConstr);
}
});
this._relatedMarkers[markerId] = options; this._relatedMarkers[markerId] = options;
}, },
...@@ -29,11 +90,14 @@ L.Window = L.Control.extend({ ...@@ -29,11 +90,14 @@ L.Window = L.Control.extend({
L.DomEvent.on(closeButton, 'mouseup', this._onCloseButtonClick, this); L.DomEvent.on(closeButton, 'mouseup', this._onCloseButtonClick, this);
const titleSpan = L.DomUtil.create('span', '', titleBar); const titleSpan = L.DomUtil.create('span', '', titleBar);
titleSpan.innerHTML = this._title; titleSpan.innerHTML = this._initTitle;
delete this._initTitle;
this._titleEl = titleSpan;
// add content container // add content container
this._contentNode = L.DomUtil.create('div', '', container); this._contentNode = L.DomUtil.create('div', '', container);
this._contentNode.innerHTML = this._content; this._contentNode.innerHTML = this._initContent;
delete this._initContent;
// absolute -> otherwise windows influence each other if multiple are present // absolute -> otherwise windows influence each other if multiple are present
container.style = "margin: 0px; position: absolute;"; container.style = "margin: 0px; position: absolute;";
...@@ -44,14 +108,21 @@ L.Window = L.Control.extend({ ...@@ -44,14 +108,21 @@ L.Window = L.Control.extend({
L.DomEvent.on(container, 'contextmenu', L.DomEvent.stopPropagation); L.DomEvent.on(container, 'contextmenu', L.DomEvent.stopPropagation);
this.dragging = false; this.dragging = false;
L.DomEvent.on(titleBar, 'mousedown', function(e) { L.DomEvent.on(titleBar, 'mousedown', function(e) {
// store delta between left upper corner of window and mouse position // store current size of map container & title bar
const containerRect = this._container.getBoundingClientRect(); // required to prevent title var from being dragged out of view
this.dragging = [e.clientX - containerRect.left, e.clientY - containerRect.top]; const mapContainerSize = this._map.getSize();
L.DomUtil.disableTextSelection(); this._mapContainerWidth = mapContainerSize.x;
this._container.style.opacity = 0.6; this._mapContainerHeight = mapContainerSize.y;
L.DomUtil.toFront(container); this._titleBarWidth = titleBar.offsetWidth;
}, this._titleBarHeight = titleBar.offsetHeight;
this);
// store delta between left upper corner of window and mouse position
const containerRect = this._container.getBoundingClientRect();
this.dragging = [e.clientX - containerRect.left, e.clientY - containerRect.top];
L.DomUtil.disableTextSelection();
this._container.style.opacity = 0.6;
L.DomUtil.toFront(container);
}, this);
L.DomEvent.on(document, 'mouseup', this._mouseUp, this); L.DomEvent.on(document, 'mouseup', this._mouseUp, this);
L.DomEvent.on(document, 'mousemove', this._mouseMove, this); L.DomEvent.on(document, 'mousemove', this._mouseMove, this);
...@@ -73,8 +144,7 @@ L.Window = L.Control.extend({ ...@@ -73,8 +144,7 @@ L.Window = L.Control.extend({
// this is done after adding the window, // this is done after adding the window,
// as we need the content's size // as we need the content's size
// to position the connectors properly // to position the connectors properly
if (this._relatedMarkers) map.eachLayer((l) => this._onLayerAdd({layer: l}));
map.eachLayer((l) => this._onLayerAdd({layer: l}));
}, },
_onLayerAdd: function(e) { _onLayerAdd: function(e) {
const marker = e.layer; const marker = e.layer;
...@@ -109,11 +179,14 @@ L.Window = L.Control.extend({ ...@@ -109,11 +179,14 @@ L.Window = L.Control.extend({
this._container.style.opacity = 1.0; this._container.style.opacity = 1.0;
}, },
_mouseMove: function(e) { _mouseMove: function(e) {
var dragging = this.dragging; const dragging = this.dragging;
if (dragging) { if (dragging) {
const mapPos = this._map.mouseEventToContainerPoint(e); const mapPos = this._map.mouseEventToContainerPoint(e);
// delta (stored in 'dragging') to compensate for where inside title bar drag was started // delta (stored in 'dragging') to compensate for where inside title bar drag was started
this._setPos({x: mapPos.x - dragging[0], y: mapPos.y - dragging[1]}); // restrict position such that title bar is never dragged outside of map container
const x = Math.min(this._mapContainerWidth - this._titleBarWidth, Math.max(0, mapPos.x - dragging[0]));
const y = Math.min(this._mapContainerHeight - this._titleBarHeight, Math.max(0, mapPos.y - dragging[1]));
this._setPos({x: x, y: y});
this._updateRelatedMarkerConnectorPositions(); this._updateRelatedMarkerConnectorPositions();
} }
}, },
......
...@@ -2,12 +2,13 @@ implementation module iTasks.Extensions.SVG.SVGEditor ...@@ -2,12 +2,13 @@ implementation module iTasks.Extensions.SVG.SVGEditor
import Graphics.Scalable.Internal.Image` import Graphics.Scalable.Internal.Image`
import iTasks.UI.Definition, iTasks.UI.Editor, iTasks.UI.JS.Encoding import iTasks.UI.Definition, iTasks.UI.Editor, iTasks.UI.JS.Encoding
import StdArray, StdBool, StdEnum, StdInt, StdMisc, StdReal, StdTuple
from StdFunc import o import StdEnv
import Data.List, Data.GenEq, Data.Func import Data.List, Data.GenEq, Data.Func
import Data.Error import Data.Error
import Data.MapCollection import Data.MapCollection