Home Information - Your home, your data, organized.
Python
Added better mouse and hover handling for SVG entities.
Anthony Cassandra60ad4f3c2aa3
diff --git a/src/hi/apps/common/svg_models.py b/src/hi/apps/common/svg_models.pyindex cf465d4b..19b8694c 100644--- a/src/hi/apps/common/svg_models.py+++ b/src/hi/apps/common/svg_models.py@@ -146,6 +146,10 @@ class SvgPathItem:fill_color : strfill_opacity : float+ @property+ def is_closed(self):+ return bool( self.svg_path and ( self.svg_path[-1].lower() == 'z' ))+class SvgDecimalField( models.DecimalField ):"""diff --git a/src/hi/apps/location/templates/location/panes/svg_icon_item.html b/src/hi/apps/location/templates/location/panes/svg_icon_item.htmlindex d909e7ea..68cc6ae7 100644--- a/src/hi/apps/location/templates/location/panes/svg_icon_item.html+++ b/src/hi/apps/location/templates/location/panes/svg_icon_item.html@@ -1,5 +1,9 @@-<g id="{{ svg_icon_item.html_id }}" class="selectable draggable {{ svg_icon_item.css_class }}"+<g id="{{ svg_icon_item.html_id }}"+ class="selectable draggable {{ svg_icon_item.css_class }}"status="{{ svg_icon_item.status_value }}"- data-type="svg-icon" transform="{{ svg_icon_item.transform_str }}">+ data-type="svg-icon"+ onmouseover="this.setAttribute('hover','true');"+ onmouseout="this.removeAttribute('hover');"+ transform="{{ svg_icon_item.transform_str }}">{% include svg_icon_item.template_name %}</g>diff --git a/src/hi/apps/location/templates/location/panes/svg_path_item.html b/src/hi/apps/location/templates/location/panes/svg_path_item.htmlindex dad6a5f3..580ce185 100644--- a/src/hi/apps/location/templates/location/panes/svg_path_item.html+++ b/src/hi/apps/location/templates/location/panes/svg_path_item.html@@ -5,5 +5,8 @@stroke="{{ svg_path_item.stroke_color }}"stroke-width="{{ svg_path_item.stroke_width }}"vector-effect="non-scaling-stroke"+ {% if not svg_path_item.is_closed %}open-path="true"{% endif %}+ onmouseover="this.style.strokeWidth='10';"+ onmouseout="this.style.strokeWidth='{{ svg_path_item.stroke_width }}';"d="{{ svg_path_item.svg_path }}"></path></g>diff --git a/src/hi/static/css/main.css b/src/hi/static/css/main.cssindex bf094af4..d7fac895 100644--- a/src/hi/static/css/main.css+++ b/src/hi/static/css/main.css@@ -211,6 +211,9 @@ a.underline:visited {text-align: center;}+path[open-path] {+ pointer-events: stroke;+}svg[action-state="move"] {cursor: move;}@@ -224,7 +227,10 @@ svg[action-state="scale"] {svg .highlighted {filter: drop-shadow(0 0 10px red);}-+g[hover] {+ outline: 2px solid blue;+ filter: drop-shadow(0 0 5px blue);+}g[status="active"] {outline: 2px solid red;filter: drop-shadow(0 0 5px red);