# HG changeset patch # User souliane # Date 1448916761 -3600 # Node ID fc941d0d97f80c09280bfdd6f559510cc19ae57e # Parent 31c682149d522895ea3ab199b44be02d9dd5f43f browser_side: fixed ContactsPanel scrolling diff -r 31c682149d52 -r fc941d0d97f8 src/browser/public/libervia.css --- a/src/browser/public/libervia.css Mon Nov 30 16:26:31 2015 +0100 +++ b/src/browser/public/libervia.css Mon Nov 30 21:52:41 2015 +0100 @@ -541,6 +541,15 @@ background-color: rgb(175, 175, 175); } +.gwt-ScrollPanel { + padding-right: 15px; /* avoid systematic horizontal scroll when only the vertical one is needed */ +} + +.xmlui-JidsListWidget { + padding-right: 20px; /* avoid systematic horizontal scroll when only the vertical one is needed */ + height: 300px; +} + /* Contacts in MUC */ .muc_contact { diff -r 31c682149d52 -r fc941d0d97f8 src/browser/sat_browser/chat.py --- a/src/browser/sat_browser/chat.py Mon Nov 30 16:26:31 2015 +0100 +++ b/src/browser/sat_browser/chat.py Mon Nov 30 21:52:41 2015 +0100 @@ -35,6 +35,7 @@ from pyjamas.ui.KeyboardListener import KEY_ENTER, KeyboardHandler from pyjamas.ui.HTMLPanel import HTMLPanel from pyjamas import DOM +from pyjamas import Window from datetime import datetime from time import time @@ -107,7 +108,8 @@ self.host.addListener('presence', self.presenceListener, [C.PROF_KEY_NONE]) self.avatarListener = self.onAvatarUpdate host.addListener('avatar', self.avatarListener, [C.PROF_KEY_NONE]) - + Window.addWindowResizeListener(self) + self._body.add(chat_area) self.content = AbsolutePanel() self.content.setStyleName('chatContent') @@ -128,6 +130,10 @@ if type_ == C.CHAT_ONE2ONE: self.historyPrint(profile=self.profile) + def onWindowResized(self, width=None, height=None): + ideal_height = self.content_scroll.getOffsetHeight() + self.occupants_panel.setHeight("%s%s" % (ideal_height, "px")) + @property def target(self): # FIXME: for unknow reason, pyjamas doesn't use the method inherited from QuickChat @@ -285,6 +291,8 @@ if 'chat_state' in states.keys(): # start/stop sending "composing" state from now self.chat_state_machine.started = not not states['chat_state'] + self.onWindowResized() # be sure to set the good height + def addGamePanel(self, widget): """Insert a game panel to this Chat dialog. diff -r 31c682149d52 -r fc941d0d97f8 src/browser/sat_browser/contact_list.py --- a/src/browser/sat_browser/contact_list.py Mon Nov 30 16:26:31 2015 +0100 +++ b/src/browser/sat_browser/contact_list.py Mon Nov 30 21:52:41 2015 +0100 @@ -123,6 +123,7 @@ SimplePanel.__init__(self) self.host = host self.scroll_panel = ScrollPanel() + self.scroll_panel.addStyleName("gwt-ScrollPanel") # XXX: no class is set by Pyjamas self.vPanel = VerticalPanel() _title = ContactTitleLabel(host, 'Contacts') DOM.setStyleAttribute(_title.getElement(), "cursor", "pointer") @@ -132,7 +133,6 @@ self.removeAlerts(contact_jid, True) self._contacts_panel = contact_panel.ContactsPanel(host, contacts_click=on_click, contacts_menus=(C.MENU_JID_CONTEXT, C.MENU_ROSTER_JID_CONTEXT)) - self._contacts_panel.setStyleName('contactPanel') # FIXME: style doesn't exists ! self._group_panel = GroupPanel(self) self.vPanel.add(_title) diff -r 31c682149d52 -r fc941d0d97f8 src/browser/sat_browser/contact_panel.py --- a/src/browser/sat_browser/contact_panel.py Mon Nov 30 16:26:31 2015 +0100 +++ b/src/browser/sat_browser/contact_panel.py Mon Nov 30 21:52:41 2015 +0100 @@ -24,13 +24,14 @@ log = getLogger(__name__) from sat_frontends.tools import jid +from pyjamas.ui.ScrollPanel import ScrollPanel from pyjamas.ui.VerticalPanel import VerticalPanel import contact_widget from constants import Const as C -class ContactsPanel(VerticalPanel): +class ContactsPanel(ScrollPanel): """ContactList graphic representation Special features like popup menu panel or changing the contact states must be done in a sub-class. @@ -51,14 +52,17 @@ @param contacts_display (tuple): prioritize the display methods of the contact's label with values in ("jid", "nick", "bare", "resource") """ - VerticalPanel.__init__(self) + self.panel = VerticalPanel() + ScrollPanel.__init__(self, self.panel) + self.addStyleName("gwt-ScrollPanel") # XXX: no class is set by Pyjamas + self.host = host self.merge_resources = merge_resources self._contacts = {} # entity jid to ContactBox map - self.click_listener = None + self.panel.click_listener = None if contacts_click is not None: - self.onClick = contacts_click + self.panel.onClick = contacts_click self.contacts_style = contacts_style self.contacts_menus = contacts_menus @@ -83,7 +87,7 @@ def clear(self): """Clear all contacts.""" self._contacts.clear() - VerticalPanel.clear(self) + VerticalPanel.clear(self.panel) def setList(self, jids): """set all contacts in the list in one shot. @@ -91,7 +95,7 @@ @param jids (list[jid.JID]): jids to display (the order is kept) @param name (unicode): optional name of the contact """ - current_jids = [box.jid for box in self.children if isinstance(box, contact_widget.ContactBox)] + current_jids = [box.jid for box in self.panel.children if isinstance(box, contact_widget.ContactBox)] if current_jids == jids: # the display doesn't change return @@ -132,9 +136,9 @@ plugin_menu_context=self.contacts_menus) self._contacts[self._key(contact_jid)] = box if index: - VerticalPanel.insert(self, box, index) + VerticalPanel.insert(self.panel, box, index) else: - VerticalPanel.append(self, box) + VerticalPanel.append(self.panel, box) return box def removeContactBox(self, contact_jid): @@ -144,4 +148,4 @@ """ box = self._contacts.pop(self._key(contact_jid), None) if box: - VerticalPanel.remove(self, box) + VerticalPanel.remove(self.panel, box) diff -r 31c682149d52 -r fc941d0d97f8 src/browser/sat_browser/main_panel.py --- a/src/browser/sat_browser/main_panel.py Mon Nov 30 16:26:31 2015 +0100 +++ b/src/browser/sat_browser/main_panel.py Mon Nov 30 21:52:41 2015 +0100 @@ -294,8 +294,5 @@ self._contacts.removeFromParent() parent.insert(self._contacts, 0) - def refresh(self): - """Refresh the main panel""" - self.host.contact_panel.refresh() diff -r 31c682149d52 -r fc941d0d97f8 src/browser/sat_browser/xmlui.py --- a/src/browser/sat_browser/xmlui.py Mon Nov 30 16:26:31 2015 +0100 +++ b/src/browser/sat_browser/xmlui.py Mon Nov 30 21:52:41 2015 +0100 @@ -234,6 +234,7 @@ def __init__(self, xmlui_main, xmlui_parent, jids, styles): contact_panel.ContactsPanel.__init__(self, xmlui_main.host, merge_resources=False) + self.addStyleName("xmlui-JidsListWidget") self.setList([jid.JID(jid_) for jid_ in jids]) def _xmluiGetSelectedValues(self):