diff src/browser/sat_browser/base_widget.py @ 594:a099990f77a6 frontends_multi_profiles

browser side: border widgets are now visible on drag start + they float right or left in the cell
author Goffi <goffi@goffi.org>
date Fri, 06 Feb 2015 19:11:02 +0100
parents a5019e62c3e9
children 9054793ab60d
line wrap: on
line diff
--- a/src/browser/sat_browser/base_widget.py	Fri Feb 06 17:49:04 2015 +0100
+++ b/src/browser/sat_browser/base_widget.py	Fri Feb 06 19:11:02 2015 +0100
@@ -47,23 +47,42 @@
 
 class DragLabel(DragWidget):
 
-    def __init__(self, text, _type):
+    def __init__(self, text, type_, host=None):
+        """Base of Drag n Drop mecanism in Libervia
+
+        @param text: data embedded with in drag n drop operation
+        @param type_: type of data that we are dragging
+        @param host: if not None, the host will be use to highlight BorderWidgets
+        """
         DragWidget.__init__(self)
+        self.host = host
         self._text = text
-        self._type = _type
+        self.type_ = type_
 
     def onDragStart(self, event):
         dt = event.dataTransfer
-        dt.setData('text/plain', "%s\n%s" % (self._text, self._type))
+        dt.setData('text/plain', "%s\n%s" % (self._text, self.type_))
         dt.setDragImage(self.getElement(), 15, 15)
+        if self.host is not None:
+            current_panel = self.host.tab_panel.getCurrentPanel()
+            for widget in current_panel.widgets:
+                if isinstance(widget, BorderWidget):
+                    widget.addStyleName('borderWidgetOnDrag')
+
+    def onDragEnd(self, event):
+        if self.host is not None:
+            current_panel = self.host.tab_panel.getCurrentPanel()
+            for widget in current_panel.widgets:
+                if isinstance(widget, BorderWidget):
+                    widget.removeStyleName('borderWidgetOnDrag')
 
 
 class LiberviaDragWidget(DragLabel):
     """ A DragLabel which keep the widget being dragged as class value """
     current = None  # widget currently dragged
 
-    def __init__(self, text, _type, widget):
-        DragLabel.__init__(self, text, _type)
+    def __init__(self, text, type_, widget):
+        DragLabel.__init__(self, text, type_, widget.host)
         self.widget = widget
 
     def onDragStart(self, event):
@@ -71,6 +90,7 @@
         DragLabel.onDragStart(self, event)
 
     def onDragEnd(self, event):
+        DragLabel.onDragEnd(self, event)
         LiberviaDragWidget.current = None