From 5e22dcd9ff8cb8a173992bf57b592a7f8cfd66f5 Mon Sep 17 00:00:00 2001 From: simonb Date: Wed, 22 Mar 2006 13:06:00 +0000 Subject: more external tab work, tidying and tab width config option --- ChangeLog | 1 + src/Container.cc | 5 ++++- src/FbWinFrame.cc | 36 +++++++++++++++++++++++++----------- src/FbWinFrame.hh | 3 +-- src/Screen.cc | 17 ++++++++++++++--- src/Screen.hh | 4 +++- src/Window.cc | 7 ------- 7 files changed, 48 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1073ad7..0fdce70 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,7 @@ Changes for 0.9.16: * More external tabs work (Simon) - Can now be placed TopLeft/TopRight/BottomLeft/BottomRight - New "Tab Options" config menu, with (efficient) runtime updating + - New tab.width config option to control external tab width - edge snapping includes tabs - decoration fixes where some missed the tab option - label text color was not updated diff --git a/src/Container.cc b/src/Container.cc index 76d8d52..be3a57b 100644 --- a/src/Container.cc +++ b/src/Container.cc @@ -260,7 +260,10 @@ void Container::setSelected(int pos) { } void Container::setMaxSizePerClient(unsigned int size) { - m_max_size_per_client = size; + if (size != m_max_size_per_client) { + m_max_size_per_client = size; + repositionItems(); + } } void Container::setMaxTotalSize(unsigned int size) { diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc index 5ccfe12..1d9c862 100644 --- a/src/FbWinFrame.cc +++ b/src/FbWinFrame.cc @@ -80,13 +80,12 @@ FbWinFrame::FbWinFrame(BScreen &screen, FbWinFrameTheme &theme, FbTk::ImageContr EnterWindowMask | LeaveWindowMask), m_bevel(1), m_use_titlebar(true), - m_tabplacement(BOTTOMRIGHT), m_use_tabs(true), m_use_handle(true), m_focused(false), m_visible(false), m_button_pm(0), - m_tabmode(NOTSET), + m_tabmode(screen.getDefaultInternalTabs()?INTERNAL:EXTERNAL), m_need_render(true), m_themelistener(*this), m_shape(new Shape(m_window, theme.shapePlace())) { @@ -129,6 +128,8 @@ bool FbWinFrame::setTabMode(TabMode tabmode) { m_tabmode = tabmode; + m_tab_container.setUpdateLock(true); + // reparent tab container if (tabmode == EXTERNAL) { m_label.show(); @@ -145,7 +146,7 @@ bool FbWinFrame::setTabMode(TabMode tabmode) { XUngrabButton(m_tab_container.display(), Button1, Mod1Mask|Mod2Mask|Mod3Mask, m_tab_container.window()); int tabx, taby; - switch (m_tabplacement) { + switch (m_screen.getTabPlacement()) { case TOPLEFT: m_tab_container.setAlignment(Container::LEFT); tabx = x(); @@ -173,9 +174,14 @@ bool FbWinFrame::setTabMode(TabMode tabmode) { m_layeritem.addWindow(m_tab_container); } - m_tab_container.setMaxSizePerClient(64); //!!TODO make this a setting + m_tab_container.setMaxSizePerClient(m_screen.getTabWidth()); + m_tab_container.setUpdateLock(false); m_tab_container.setMaxTotalSize(window().width()); + renderTabContainer(); + applyTabContainer(); + m_tab_container.clear(); + // TODO: tab position if (m_use_tabs && m_visible) m_tab_container.show(); @@ -194,7 +200,13 @@ bool FbWinFrame::setTabMode(TabMode tabmode) { } m_tab_container.setBorderWidth(0); m_tab_container.setMaxTotalSize(0); + m_tab_container.setUpdateLock(false); m_tab_container.setMaxSizePerClient(0); + + renderTabContainer(); + applyTabContainer(); + m_tab_container.clear(); + if (!m_use_tabs) m_tab_container.show(); else @@ -310,7 +322,7 @@ void FbWinFrame::moveResize(int x, int y, unsigned int width, unsigned int heigh m_window.resize(width, height); } - if (move || resize && m_tabplacement != TOPLEFT) + if (move || resize && m_screen.getTabPlacement() != TOPLEFT) alignTabs(); if (resize) { @@ -333,8 +345,10 @@ void FbWinFrame::alignTabs() { if (m_tabmode != EXTERNAL) return; + m_tab_container.setMaxSizePerClient(m_screen.getTabWidth()); + int tabx = 0, taby = 0; - switch (m_tabplacement) { + switch (m_screen.getTabPlacement()) { case TOPLEFT: tabx = x(); taby = y() - yOffset(); @@ -877,8 +891,10 @@ void FbWinFrame::reconfigure() { } else m_titlebar.lower(); - if (m_tabmode == EXTERNAL) + if (m_tabmode == EXTERNAL) { m_tab_container.resize(m_tab_container.width(), buttonHeight()); + alignTabs(); + } // leave client+grips alone if we're shaded (it'll get fixed when we unshade) if (!m_shaded) { @@ -1271,9 +1287,7 @@ void FbWinFrame::init() { m_label.setBorderWidth(0); m_shaded = false; - // TODO: configurable default (on compile, for backwards compat) -// setTabMode(EXTERNAL); - setTabMode(INTERNAL); + setTabMode(NOTSET); m_label.setEventMask(ExposureMask | ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | @@ -1605,7 +1619,7 @@ int FbWinFrame::yOffset() const { if (m_tabmode != EXTERNAL || !m_use_tabs) return 0; - switch (m_tabplacement) { + switch (m_screen.getTabPlacement()) { case TOPLEFT: case TOPRIGHT: return m_tab_container.height() + m_window.borderWidth(); diff --git a/src/FbWinFrame.hh b/src/FbWinFrame.hh index 10cd98f..900af07 100644 --- a/src/FbWinFrame.hh +++ b/src/FbWinFrame.hh @@ -125,7 +125,7 @@ public: inline void setFocusTitle(const std::string &str) { m_label.setText(str); } void setDoubleClickTime(unsigned int time); bool setTabMode(TabMode tabmode); - inline void setTabPlacement(TabPlacement tabplacement) { m_tabplacement = tabplacement; alignTabs(); } + inline void updateTabProperties() { alignTabs(); } /// add a button to the left of the label void addLeftButton(FbTk::Button *btn); @@ -367,7 +367,6 @@ private: //@} TabMode m_tabmode; - TabPlacement m_tabplacement; bool m_need_render; int m_button_size; ///< size for all titlebar buttons diff --git a/src/Screen.cc b/src/Screen.cc index 851e407..a69e7fe 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -270,6 +270,7 @@ BScreen::ScreenResource::ScreenResource(FbTk::ResourceManager &rm, menu_alpha(rm, 255, scrname+".menu.alpha", altscrname+".Menu.Alpha"), menu_delay(rm, 0, scrname + ".menuDelay", altscrname+".MenuDelay"), menu_delay_close(rm, 0, scrname + ".menuDelayClose", altscrname+".MenuDelayClose"), + tab_width(rm, 64, scrname + ".tab.width", altscrname+".Tab.Width"), menu_mode(rm, FbTk::MenuTheme::DELAY_OPEN, scrname+".menuMode", altscrname+".MenuMode"), gc_line_width(rm, 1, scrname+".overlay.lineWidth", altscrname+".Overlay.LineWidth"), @@ -287,7 +288,7 @@ BScreen::ScreenResource::ScreenResource(FbTk::ResourceManager &rm, altscrname+".overlay.CapStyle"), scroll_action(rm, "", scrname+".windowScrollAction", altscrname+".WindowScrollAction"), scroll_reverse(rm, false, scrname+".windowScrollReverse", altscrname+".WindowScrollReverse"), - default_internal_tabs(rm, false /* TODO: autoconf option? */ , scrname+".tabs.intitlebar", altscrname+".Tabs.InTitlebar") { + default_internal_tabs(rm, true /* TODO: autoconf option? */ , scrname+".tabs.intitlebar", altscrname+".Tabs.InTitlebar") { } @@ -900,7 +901,7 @@ void BScreen::reconfigureTabs() { Workspace::Windows::iterator win_it = (*w_it)->windowList().begin(); const Workspace::Windows::iterator win_it_end = (*w_it)->windowList().end(); for (; win_it != win_it_end; ++win_it) { - (*win_it)->frame().setTabPlacement(*resource.tab_placement); + (*win_it)->frame().updateTabProperties(); if (*resource.default_internal_tabs) (*win_it)->frame().setTabMode(FbWinFrame::INTERNAL); else @@ -1642,11 +1643,21 @@ void BScreen::setupConfigmenu(FbTk::Menu &menu) { "Tabs in Titlebar", "Tabs in Titlebar", *resource.default_internal_tabs, save_and_reconftabs); + FbTk::MenuItem *tab_width_item = + new IntResMenuItem(_FBTEXT(Configmenu, ExternalTabWidth, + "External Tab Width", + "Width of external-style tabs"), + resource.tab_width, 10, 3000, /* silly number */ + *tab_menu); + tab_width_item->setCommand(save_and_reconftabs); + tab_menu->insert(tab_width_item); + + typedef pair PlacementP; typedef list Placements; Placements place_menu; - // menu is 3 wide, 5 down + // menu is 2 wide, 2 down place_menu.push_back(PlacementP(_FBTEXT(Align, TopLeft, "Top Left", "Top Left"), FbWinFrame::TOPLEFT)); place_menu.push_back(PlacementP(_FBTEXT(Align, BottomLeft, "Bottom Left", "Bottom Left"), FbWinFrame::BOTTOMLEFT)); place_menu.push_back(PlacementP(_FBTEXT(Align, TopRight, "Top Right", "Top Right"), FbWinFrame::TOPRIGHT)); diff --git a/src/Screen.hh b/src/Screen.hh index 738fe1a..2d20efd 100644 --- a/src/Screen.hh +++ b/src/Screen.hh @@ -142,6 +142,8 @@ public: inline const bool getScrollReverse() const { return *resource.scroll_reverse; } inline const bool getDefaultInternalTabs() const { return *resource.default_internal_tabs; } + inline unsigned int getTabWidth() const { return *resource.tab_width; } + inline Slit *slit() { return m_slit.get(); } inline const Slit *slit() const { return m_slit.get(); } @@ -445,7 +447,7 @@ private: FbTk::Resource follow_model; bool ordered_dither; FbTk::Resource workspaces, edge_snap_threshold, focused_alpha, - unfocused_alpha, menu_alpha, menu_delay, menu_delay_close; + unfocused_alpha, menu_alpha, menu_delay, menu_delay_close, tab_width; FbTk::Resource menu_mode; FbTk::Resource gc_line_width; diff --git a/src/Window.cc b/src/Window.cc index e1cf224..a275e43 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -394,13 +394,6 @@ void FluxboxWindow::init() { frame().setUseShape(!m_shaped); - frame().setTabPlacement(screen().getTabPlacement()); - if (screen().getDefaultInternalTabs()) { - frame().setTabMode(FbWinFrame::INTERNAL); - } else { - frame().setTabMode(FbWinFrame::EXTERNAL); - } - //!! TODO init of client should be better // we don't want to duplicate code here and in attachClient m_clientlist.push_back(m_client); -- cgit v0.11.2