Mercurial > libervia-web
diff src/browser/sat_browser/main_panel.py @ 654:40c72f3b7638 frontends_multi_profiles
browser_side: MainPanel is now based on a DockPanel, which allows to use less tables and also to remove some "window resized" listeners
author | souliane <souliane@mailoo.org> |
---|---|
date | Fri, 27 Feb 2015 02:39:43 +0100 |
parents | 6d3142b782c3 |
children | 048401e5c506 |
line wrap: on
line diff
--- a/src/browser/sat_browser/main_panel.py Fri Feb 27 01:45:34 2015 +0100 +++ b/src/browser/sat_browser/main_panel.py Fri Feb 27 02:39:43 2015 +0100 @@ -26,14 +26,14 @@ from sat.core.i18n import _ from sat_frontends.tools.strings import addURLToText -from pyjamas.ui.AbsolutePanel import AbsolutePanel +from pyjamas.ui.DockPanel import DockPanel from pyjamas.ui.HorizontalPanel import HorizontalPanel +from pyjamas.ui.VerticalPanel import VerticalPanel from pyjamas.ui.Button import Button from pyjamas.ui.HTML import HTML from pyjamas.ui.ClickListener import ClickHandler from pyjamas.Timer import Timer -from pyjamas import Window -from __pyjamas__ import doc +from pyjamas.ui import HasVerticalAlignment import base_menu @@ -128,10 +128,10 @@ def __init__(self, host, status=''): self.host = host - modifiedCb = lambda content: self.host.bridge.call('setStatus', None, self.host.status_panel.presence, content['text']) or True + modifiedCb = lambda content: self.host.bridge.call('setStatus', None, self.host.presence_status_panel.presence, content['text']) or True editor_widget.HTMLTextEditor.__init__(self, {'text': status}, modifiedCb, options={'no_xhtml': True, 'listen_focus': True, 'listen_click': True}) self.edit(False) - self.setStyleName('statusPanel') + self.setStyleName('marginAuto') @property def status(self): @@ -153,7 +153,7 @@ def setDisplayContent(self): status = self._original_content['text'] try: - presence = self.host.status_panel.presence + presence = self.host.presence_status_panel.presence except AttributeError: # during initialization presence = None if not status: @@ -199,7 +199,7 @@ panel.add(self.status_panel) panel.setCellVerticalAlignment(self.menu, 'baseline') panel.setCellVerticalAlignment(self.status_panel, 'baseline') - panel.setStyleName("marginAuto") + panel.setStyleName("presenceStatusPanel") self.add(panel) self.status_panel.edit(False) @@ -231,48 +231,41 @@ ### Panels managing the main area ### -class MainPanel(AbsolutePanel): +class MainPanel(DockPanel): """The panel which take the whole screen""" def __init__(self, host): self.host = host - AbsolutePanel.__init__(self) - - # menu - self.menu = menu.MainMenuPanel(host) + DockPanel.__init__(self, StyleName="mainPanel liberviaTabPanel") - # # unibox - # self.unibox_panel = UniBoxPanel(host) - # self.unibox_panel.setVisible(False) - + # menu and status panel + self.header = VerticalPanel(StyleName="header") + self.menu = menu.MainMenuBar(host) + self.header.add(self.menu) + # contacts - self._contacts = HorizontalPanel() - self._contacts.addStyleName('globalLeftArea') self.contacts_switch = Button(u'«', self._contactsSwitch) self.contacts_switch.addStyleName('contactsSwitch') - self._contacts.add(self.contacts_switch) - # tabs + # tab panel self.tab_panel = libervia_widget.MainTabPanel(host) self.tab_panel.addWidgetsTab(_(u"Discussions"), select=True, locked=True) - - self.header = AbsolutePanel() - self.header.add(self.menu) - # self.header.add(self.unibox_panel) - self.header.add(self.host.status_panel) - self.header.setStyleName('header') - self.add(self.header) - - self._hpanel = HorizontalPanel() - self._hpanel.add(self._contacts) - self._hpanel.add(self.tab_panel) - self.add(self._hpanel) - - self.setWidth("100%") - Window.addWindowResizeListener(self) + + # XXX: widget's addition order is important! + self.add(self.header, DockPanel.NORTH) + self.add(self.tab_panel, DockPanel.CENTER) + self.setCellWidth(self.tab_panel, '100%') + self.setCellHeight(self.tab_panel, '100%') + self.add(self.tab_panel.getTabBar(), DockPanel.SOUTH) + self.add(self.contacts_switch, DockPanel.WEST) def addContactList(self, contact_list): - self._contacts.add(contact_list) + self.add(contact_list, DockPanel.WEST) + + def addPresenceStatusPanel(self, panel): + self.header.add(panel) + self.header.setCellHeight(panel, '100%') + self.header.setCellVerticalAlignment(panel, HasVerticalAlignment.ALIGN_BOTTOM) def _contactsSwitch(self, btn=None): """ (Un)hide contacts panel """ @@ -294,15 +287,6 @@ self._contacts.removeFromParent() parent.insert(self._contacts, 0) - def onWindowResized(self, width, height): - _elts = doc().getElementsByClassName('gwt-TabBar') - if not _elts.length: - tab_bar_h = 0 - else: - tab_bar_h = _elts.item(0).offsetHeight - ideal_height = Window.getClientHeight() - tab_bar_h - self.setHeight("%s%s" % (ideal_height, "px")) - def refresh(self): """Refresh the main panel""" self.unibox_panel.refresh()