changeset 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 b97c85b8a47e
children d78126d82ca0
files src/browser/public/libervia.css src/browser/sat_browser/base_widget.py src/browser/sat_browser/contact_list.py
diffstat 3 files changed, 42 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/browser/public/libervia.css	Fri Feb 06 17:49:04 2015 +0100
+++ b/src/browser/public/libervia.css	Fri Feb 06 19:11:02 2015 +0100
@@ -813,6 +813,12 @@
 
 /* BorderWidgets */
 
+.borderWidgetOnDrag {
+    background-color: lightgray;
+    border: 1px dashed #000;
+    border-radius: 1em;
+}
+
 .bottomBorderWidget {
     height: 10px !important;
 }
@@ -821,6 +827,14 @@
     width: 10px !important;
 }
 
+.leftBorderWidget {
+    float: right;
+}
+
+.rightBorderWidget {
+    float: left;
+}
+
 /* Microblog */
 
 .microblogPanel {
--- 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
 
 
--- a/src/browser/sat_browser/contact_list.py	Fri Feb 06 17:49:04 2015 +0100
+++ b/src/browser/sat_browser/contact_list.py	Fri Feb 06 19:11:02 2015 +0100
@@ -73,10 +73,9 @@
 class GroupLabel(base_widget.DragLabel, Label, ClickHandler):
     def __init__(self, host, group):
         self.group = group
-        self.host = host
         Label.__init__(self, group)  # , Element=DOM.createElement('div')
         self.setStyleName('group')
-        base_widget.DragLabel.__init__(self, group, "GROUP")
+        base_widget.DragLabel.__init__(self, group, "GROUP", host)
         ClickHandler.__init__(self)
         self.addClickListener(self)
 
@@ -125,8 +124,7 @@
 
     def __init__(self, host, jid_, name=None, click_listener=None, handle_menu=None):
         VerticalPanel.__init__(self, StyleName='contactBox', VerticalAlignment='middle')
-        base_widget.DragLabel.__init__(self, jid_, "CONTACT")
-        self.host = host
+        base_widget.DragLabel.__init__(self, jid_, "CONTACT", host)
         self.jid = jid_
         self.label = ContactLabel(jid_, name)
         self.avatar = ContactMenuBar(self, host) if handle_menu else Image()
@@ -306,9 +304,8 @@
 class ContactTitleLabel(base_widget.DragLabel, Label, ClickHandler):
     def __init__(self, host, text):
         Label.__init__(self, text)  # , Element=DOM.createElement('div')
-        self.host = host
         self.setStyleName('contactTitle')
-        base_widget.DragLabel.__init__(self, text, "CONTACT_TITLE")
+        base_widget.DragLabel.__init__(self, text, "CONTACT_TITLE", host)
         ClickHandler.__init__(self)
         self.addClickListener(self)