From a30a14ef36bda4ecfd8116963f641e8729350ab8 Mon Sep 17 00:00:00 2001 From: Mark Tiefenbruck Date: Mon, 18 Aug 2008 01:45:44 -0700 Subject: add top, left, right, and bottom center tab placement options --- ChangeLog | 4 ++++ doc/asciidoc/fluxbox.1 | 46 +++++-------------------------------------- doc/asciidoc/fluxbox.txt | 22 ++------------------- doc/fluxbox.1.in | 46 +++++-------------------------------------- src/FbTk/Container.cc | 14 ++++++++++--- src/FbTk/Container.hh | 2 +- src/FbWinFrame.cc | 47 +++++++++++++++++++++++++++++++++++++++++++- src/FbWinFrame.hh | 8 ++++---- src/Screen.cc | 51 +++++++++++++++++++++++++++++++++++++----------- 9 files changed, 118 insertions(+), 122 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3b37ef0..6c0b78c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ (Format: Year/Month/Day) Changes for 1.1 +*08/08/18: + * Add Top Center, Left Center, Right Center, and Bottom Center tab placement + options (Mark) + FbWinFrame.cc/hh Screen.cc FbTk/Container.cc/hh *08/08/17: * Add new key commands SetTitle and SetTitleDialog (thanks Matteo Galiazzo) CommandDialog.cc/hh TextDialog.cc/hh CurrentWindowCmd.cc/hh Makefile.am diff --git a/doc/asciidoc/fluxbox.1 b/doc/asciidoc/fluxbox.1 index ee0d276..d9337c6 100644 --- a/doc/asciidoc/fluxbox.1 +++ b/doc/asciidoc/fluxbox.1 @@ -1,11 +1,11 @@ .\" Title: fluxbox .\" Author: .\" Generator: DocBook XSL Stylesheets v1.73.2 -.\" Date: 08/05/2008 +.\" Date: 08/18/2008 .\" Manual: .\" Source: .\" -.TH "FLUXBOX" "1" "08/05/2008" "" "" +.TH "FLUXBOX" "1" "08/18/2008" "" "" .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) @@ -1161,45 +1161,9 @@ This section of fluxbox configuration menu lets you configure many features of t .sp .RS 4 \h'-04'\(bu\h'+03' -\fBPlacement\fR: You can choose where the external tabs must be positioned\. The options are: -.sp -.RS 4 -\h'-04'\(bu\h'+03'Top Left: tabs are located on the left side of the top border of the window\. -.RE -.sp -.RS 4 -\h'-04'\(bu\h'+03'Top Right: tabs are located on the right side of the top border of the window\. -.RE -.sp -.RS 4 -\h'-04'\(bu\h'+03'Left Top: tabs are located on the top part of the left border of the window\. -.RE -.sp -.RS 4 -\h'-04'\(bu\h'+03'Right Top: tabs are located on the top part of the right border of the window\. -.RE -.sp -.RS 4 -\h'-04'\(bu\h'+03'Left Bottom: tabs are located on the bottom part of the left border of the window\. -.RE -.sp -.RS 4 -\h'-04'\(bu\h'+03'Right Bottom: tabs are located on the bottom part of the right border of the window\. -.RE -.sp -.RS 4 -\h'-04'\(bu\h'+03'Bottom Left: tabs are located on the left side of the bottom border of the window\. -.RE -.sp -.RS 4 -\h'-04'\(bu\h'+03'Bottom Right: tabs are located on the right side of the bottom border of the window\. -.sp -.RS 4 -.nf -For these options to work \'Tabs in Titlebar\' must be off\. -.fi -.RE -.RE +\fBPlacement\fR: You can choose where the external tabs will be positioned relative to the window\. For these options to work, +\fITabs in Titlebar\fR +must be off\. .RE .sp .RS 4 diff --git a/doc/asciidoc/fluxbox.txt b/doc/asciidoc/fluxbox.txt index 7083911..60e4006 100644 --- a/doc/asciidoc/fluxbox.txt +++ b/doc/asciidoc/fluxbox.txt @@ -1075,26 +1075,8 @@ This section of fluxbox configuration menu lets you configure many features of tabs. Inside of it there are three main options: - *Placement*: - You can choose where the external tabs must be positioned. The options are: - - * Top Left: tabs are located on the left side of the top border of the - window. - * Top Right: tabs are located on the right side of the top border of the - window. - * Left Top: tabs are located on the top part of the left border of the - window. - * Right Top: tabs are located on the top part of the right border of the - window. - * Left Bottom: tabs are located on the bottom part of the left border of the - window. - * Right Bottom: tabs are located on the bottom part of the right border of - the window. - * Bottom Left: tabs are located on the left side of the bottom border of the - window. - * Bottom Right: tabs are located on the right side of the bottom border of - the window. - - For these options to work 'Tabs in Titlebar' must be off. + You can choose where the external tabs will be positioned relative to the + window. For these options to work, 'Tabs in Titlebar' must be off. - *Tabs in Titlebar*: When this option is on, tabs are fixed in window titlebar and the width diff --git a/doc/fluxbox.1.in b/doc/fluxbox.1.in index ee0d276..d9337c6 100644 --- a/doc/fluxbox.1.in +++ b/doc/fluxbox.1.in @@ -1,11 +1,11 @@ .\" Title: fluxbox .\" Author: .\" Generator: DocBook XSL Stylesheets v1.73.2 -.\" Date: 08/05/2008 +.\" Date: 08/18/2008 .\" Manual: .\" Source: .\" -.TH "FLUXBOX" "1" "08/05/2008" "" "" +.TH "FLUXBOX" "1" "08/18/2008" "" "" .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) @@ -1161,45 +1161,9 @@ This section of fluxbox configuration menu lets you configure many features of t .sp .RS 4 \h'-04'\(bu\h'+03' -\fBPlacement\fR: You can choose where the external tabs must be positioned\. The options are: -.sp -.RS 4 -\h'-04'\(bu\h'+03'Top Left: tabs are located on the left side of the top border of the window\. -.RE -.sp -.RS 4 -\h'-04'\(bu\h'+03'Top Right: tabs are located on the right side of the top border of the window\. -.RE -.sp -.RS 4 -\h'-04'\(bu\h'+03'Left Top: tabs are located on the top part of the left border of the window\. -.RE -.sp -.RS 4 -\h'-04'\(bu\h'+03'Right Top: tabs are located on the top part of the right border of the window\. -.RE -.sp -.RS 4 -\h'-04'\(bu\h'+03'Left Bottom: tabs are located on the bottom part of the left border of the window\. -.RE -.sp -.RS 4 -\h'-04'\(bu\h'+03'Right Bottom: tabs are located on the bottom part of the right border of the window\. -.RE -.sp -.RS 4 -\h'-04'\(bu\h'+03'Bottom Left: tabs are located on the left side of the bottom border of the window\. -.RE -.sp -.RS 4 -\h'-04'\(bu\h'+03'Bottom Right: tabs are located on the right side of the bottom border of the window\. -.sp -.RS 4 -.nf -For these options to work \'Tabs in Titlebar\' must be off\. -.fi -.RE -.RE +\fBPlacement\fR: You can choose where the external tabs will be positioned relative to the window\. For these options to work, +\fITabs in Titlebar\fR +must be off\. .RE .sp .RS 4 diff --git a/src/FbTk/Container.cc b/src/FbTk/Container.cc index 381f13f..3374266 100644 --- a/src/FbTk/Container.cc +++ b/src/FbTk/Container.cc @@ -319,7 +319,7 @@ void Container::repositionItems() { // if we have a max total size, then we must also resize ourself // within that bound Alignment align = alignment(); - if (m_max_total_size && (align == RIGHT || align == LEFT)) { + if (m_max_total_size && align != RELATIVE) { total_width = (max_width_per_client + borderW) * num_items - borderW; if (total_width > m_max_total_size) { total_width = m_max_total_size; @@ -332,14 +332,21 @@ void Container::repositionItems() { // calling Container::resize here risks infinite loops unsigned int neww = total_width, newh = height; translateSize(m_orientation, neww, newh); - if ((align == RIGHT && m_orientation != ROT270) || - (align == LEFT && m_orientation == ROT270)) { + if (!(align == LEFT && (m_orientation == ROT0 || + m_orientation == ROT90)) && + !(align == RIGHT && (m_orientation == ROT180 || + m_orientation == ROT270))) { int deltax = 0; int deltay = 0; if (m_orientation == ROT0 || m_orientation == ROT180) deltax = - (total_width - cur_width); else deltay = - (total_width - cur_width); + // TODO: rounding errors could accumulate in this process + if (align == CENTER) { + deltax = deltax/2; + deltay = deltay/2; + } FbWindow::moveResize(x() + deltax, y() + deltay, neww, newh); } else { @@ -405,6 +412,7 @@ void Container::repositionItems() { unsigned int Container::maxWidthPerClient() const { switch (alignment()) { case RIGHT: + case CENTER: case LEFT: return m_max_size_per_client; break; diff --git a/src/FbTk/Container.hh b/src/FbTk/Container.hh index 2a97f7f..00f2c88 100644 --- a/src/FbTk/Container.hh +++ b/src/FbTk/Container.hh @@ -38,7 +38,7 @@ class Container: public FbWindow, public EventHandler, private NotCopyable { public: // LEFT, RIGHT => fixed total width, fixed icon size // RELATIVE => fixed total width, relative/variable icon size - enum Alignment { LEFT, RELATIVE, RIGHT }; + enum Alignment { LEFT, CENTER, RIGHT, RELATIVE }; typedef Button * Item; typedef const Button * ConstItem; typedef std::list ItemList; diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc index d0d1e21..d4ca980 100644 --- a/src/FbWinFrame.cc +++ b/src/FbWinFrame.cc @@ -265,7 +265,8 @@ void FbWinFrame::moveResize(int x, int y, unsigned int width, unsigned int heigh m_window.resize(width, height); } - if (move || (resize && m_screen.getTabPlacement() != TOPLEFT)) + if (move || (resize && m_screen.getTabPlacement() != TOPLEFT && + m_screen.getTabPlacement() != LEFTTOP)) alignTabs(); if (resize) { @@ -273,6 +274,8 @@ void FbWinFrame::moveResize(int x, int y, unsigned int width, unsigned int heigh switch(m_screen.getTabPlacement()) { case LEFTTOP: case RIGHTTOP: + case LEFT: + case RIGHT: case LEFTBOTTOM: case RIGHTBOTTOM: m_tab_container.setMaxTotalSize(height); @@ -294,6 +297,8 @@ void FbWinFrame::quietMoveResize(int x, int y, switch(m_screen.getTabPlacement()) { case LEFTTOP: case RIGHTTOP: + case LEFT: + case RIGHT: case LEFTBOTTOM: case RIGHTBOTTOM: m_tab_container.setMaxTotalSize(height); @@ -327,6 +332,14 @@ void FbWinFrame::alignTabs() { tabx = x(); taby = y() - yOffset(); break; + case TOP: + if (orig_orient != FbTk::ROT0) m_tab_container.hide(); + m_tab_container.setOrientation(FbTk::ROT0); + m_tab_container.setAlignment(FbTk::Container::CENTER); + m_tab_container.setMaxTotalSize(m_window.width()); + tabx = x() + (width() - m_tab_container.width())/2; + taby = y() - yOffset(); + break; case TOPRIGHT: if (orig_orient != FbTk::ROT0) m_tab_container.hide(); m_tab_container.setOrientation(FbTk::ROT0); @@ -343,6 +356,14 @@ void FbWinFrame::alignTabs() { tabx = x() - xOffset(); taby = y(); break; + case LEFT: + if (orig_orient != FbTk::ROT270) m_tab_container.hide(); + m_tab_container.setOrientation(FbTk::ROT270); + m_tab_container.setAlignment(FbTk::Container::CENTER); + m_tab_container.setMaxTotalSize(m_window.height()); + tabx = x() - xOffset(); + taby = y() + (height() - m_tab_container.height())/2; + break; case LEFTBOTTOM: if (orig_orient != FbTk::ROT270) m_tab_container.hide(); m_tab_container.setOrientation(FbTk::ROT270); @@ -359,6 +380,14 @@ void FbWinFrame::alignTabs() { tabx = x() + width() + m_window.borderWidth(); taby = y(); break; + case RIGHT: + if (orig_orient != FbTk::ROT90) m_tab_container.hide(); + m_tab_container.setOrientation(FbTk::ROT90); + m_tab_container.setAlignment(FbTk::Container::CENTER); + m_tab_container.setMaxTotalSize(m_window.height()); + tabx = x() + width() + m_window.borderWidth(); + taby = y() + (height() - m_tab_container.height())/2; + break; case RIGHTBOTTOM: if (orig_orient != FbTk::ROT90) m_tab_container.hide(); m_tab_container.setOrientation(FbTk::ROT90); @@ -375,6 +404,14 @@ void FbWinFrame::alignTabs() { tabx = x(); taby = y() + height() + m_window.borderWidth(); break; + case BOTTOM: + if (orig_orient != FbTk::ROT0) m_tab_container.hide(); + m_tab_container.setOrientation(FbTk::ROT0); + m_tab_container.setAlignment(FbTk::Container::CENTER); + m_tab_container.setMaxTotalSize(m_window.width()); + tabx = x() + (width() - m_tab_container.width())/2; + taby = y() + height() + m_window.borderWidth(); + break; case BOTTOMRIGHT: if (orig_orient != FbTk::ROT0) m_tab_container.hide(); m_tab_container.setOrientation(FbTk::ROT0); @@ -878,8 +915,10 @@ void FbWinFrame::reconfigure() { unsigned int neww, newh; switch (m_screen.getTabPlacement()) { case TOPLEFT: + case TOP: case TOPRIGHT: case BOTTOMLEFT: + case BOTTOM: case BOTTOMRIGHT: neww = m_tab_container.width(); newh = buttonHeight(); @@ -1653,6 +1692,8 @@ int FbWinFrame::widthOffset() const { switch (m_screen.getTabPlacement()) { case LEFTTOP: case RIGHTTOP: + case LEFT: + case RIGHT: case LEFTBOTTOM: case RIGHTBOTTOM: return m_tab_container.width() + m_window.borderWidth(); @@ -1669,8 +1710,10 @@ int FbWinFrame::heightOffset() const { switch (m_screen.getTabPlacement()) { case TOPLEFT: + case TOP: case TOPRIGHT: case BOTTOMLEFT: + case BOTTOM: case BOTTOMRIGHT: return m_tab_container.height() + m_window.borderWidth(); break; @@ -1686,6 +1729,7 @@ int FbWinFrame::xOffset() const { switch (m_screen.getTabPlacement()) { case LEFTTOP: + case LEFT: case LEFTBOTTOM: return m_tab_container.width() + m_window.borderWidth(); break; @@ -1701,6 +1745,7 @@ int FbWinFrame::yOffset() const { switch (m_screen.getTabPlacement()) { case TOPLEFT: + case TOP: case TOPRIGHT: return m_tab_container.height() + m_window.borderWidth(); break; diff --git a/src/FbWinFrame.hh b/src/FbWinFrame.hh index 85f0c21..3f10f54 100644 --- a/src/FbWinFrame.hh +++ b/src/FbWinFrame.hh @@ -61,11 +61,11 @@ public: /// Toolbar placement on the screen enum TabPlacement{ // top and bottom placement - TOPLEFT = 1, BOTTOMLEFT, - TOPRIGHT, BOTTOMRIGHT, + TOPLEFT = 1, TOP, TOPRIGHT, + BOTTOMLEFT, BOTTOM, BOTTOMRIGHT, // left and right placement - LEFTBOTTOM, LEFTTOP, - RIGHTBOTTOM, RIGHTTOP + LEFTBOTTOM, LEFT, LEFTTOP, + RIGHTBOTTOM, RIGHT, RIGHTTOP }; /** diff --git a/src/Screen.cc b/src/Screen.cc index 271539d..c538d5e 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -207,20 +207,28 @@ namespace FbTk { template<> void FbTk::Resource:: setFromString(const char *strval) { - if (strcasecmp(strval, "TopLeft")==0) + if (strcasecmp(strval, "TopLeft") == 0) m_value = FbWinFrame::TOPLEFT; - else if (strcasecmp(strval, "BottomLeft")==0) + else if (strcasecmp(strval, "BottomLeft") == 0) m_value = FbWinFrame::BOTTOMLEFT; - else if (strcasecmp(strval, "TopRight")==0) + else if (strcasecmp(strval, "Top") == 0) + m_value = FbWinFrame::TOP; + else if (strcasecmp(strval, "Bottom") == 0) + m_value = FbWinFrame::BOTTOM; + else if (strcasecmp(strval, "TopRight") == 0) m_value = FbWinFrame::TOPRIGHT; - else if (strcasecmp(strval, "BottomRight")==0) + else if (strcasecmp(strval, "BottomRight") == 0) m_value = FbWinFrame::BOTTOMRIGHT; else if (strcasecmp(strval, "LeftTop") == 0) m_value = FbWinFrame::LEFTTOP; + else if (strcasecmp(strval, "Left") == 0) + m_value = FbWinFrame::LEFT; else if (strcasecmp(strval, "LeftBottom") == 0) m_value = FbWinFrame::LEFTBOTTOM; else if (strcasecmp(strval, "RightTop") == 0) m_value = FbWinFrame::RIGHTTOP; + else if (strcasecmp(strval, "Right") == 0) + m_value = FbWinFrame::RIGHT; else if (strcasecmp(strval, "RightBottom") == 0) m_value = FbWinFrame::RIGHTBOTTOM; else @@ -237,6 +245,12 @@ getString() const { case FbWinFrame::BOTTOMLEFT: return string("BottomLeft"); break; + case FbWinFrame::TOP: + return string("Top"); + break; + case FbWinFrame::BOTTOM: + return string("Bottom"); + break; case FbWinFrame::TOPRIGHT: return string("TopRight"); break; @@ -246,12 +260,18 @@ getString() const { case FbWinFrame::LEFTTOP: return string("LeftTop"); break; + case FbWinFrame::LEFT: + return string("Left"); + break; case FbWinFrame::LEFTBOTTOM: return string("LeftBottom"); break; case FbWinFrame::RIGHTTOP: return string("RightTop"); break; + case FbWinFrame::RIGHT: + return string("Right"); + break; case FbWinFrame::RIGHTBOTTOM: return string("RightBottom"); break; @@ -1691,25 +1711,34 @@ void BScreen::setupConfigmenu(FbTk::Menu &menu) { typedef list Placements; Placements place_menu; - // menu is 2 wide, 2 down + // menu is 3 wide, 5 down place_menu.push_back(PlacementP(_FB_XTEXT(Align, TopLeft, "Top Left", "Top Left"), FbWinFrame::TOPLEFT)); place_menu.push_back(PlacementP(_FB_XTEXT(Align, LeftTop, "Left Top", "Left Top"), FbWinFrame::LEFTTOP)); + place_menu.push_back(PlacementP(_FB_XTEXT(Align, LeftCenter, "Left Center", "Left Center"), FbWinFrame::LEFT)); place_menu.push_back(PlacementP(_FB_XTEXT(Align, LeftBottom, "Left Bottom", "Left Bottom"), FbWinFrame::LEFTBOTTOM)); place_menu.push_back(PlacementP(_FB_XTEXT(Align, BottomLeft, "Bottom Left", "Bottom Left"), FbWinFrame::BOTTOMLEFT)); + place_menu.push_back(PlacementP(_FB_XTEXT(Align, TopCenter, "Top Center", "Top Center"), FbWinFrame::TOP)); + place_menu.push_back(PlacementP("", FbWinFrame::TOPLEFT)); + place_menu.push_back(PlacementP("", FbWinFrame::TOPLEFT)); + place_menu.push_back(PlacementP("", FbWinFrame::TOPLEFT)); + place_menu.push_back(PlacementP(_FB_XTEXT(Align, BottomCenter, "Bottom Center", "Bottom Center"), FbWinFrame::BOTTOM)); place_menu.push_back(PlacementP(_FB_XTEXT(Align, TopRight, "Top Right", "Top Right"), FbWinFrame::TOPRIGHT)); place_menu.push_back(PlacementP(_FB_XTEXT(Align, RightTop, "Right Top", "Right Top"), FbWinFrame::RIGHTTOP)); + place_menu.push_back(PlacementP(_FB_XTEXT(Align, RightCenter, "Right Center", "Right Center"), FbWinFrame::RIGHT)); place_menu.push_back(PlacementP(_FB_XTEXT(Align, RightBottom, "Right Bottom", "Right Bottom"), FbWinFrame::RIGHTBOTTOM)); place_menu.push_back(PlacementP(_FB_XTEXT(Align, BottomRight, "Bottom Right", "Bottom Right"), FbWinFrame::BOTTOMRIGHT)); - tabplacement_menu->setMinimumSublevels(2); + tabplacement_menu->setMinimumSublevels(3); // create items in sub menu - size_t i=0; - while (!place_menu.empty()) { - i++; + for (size_t i=0; i<15; ++i) { FbTk::FbString &str = place_menu.front().first; FbWinFrame::TabPlacement placement = place_menu.front().second; - - tabplacement_menu->insert(new TabPlacementMenuItem(str, *this, placement, save_and_reconftabs)); + if (str == "") { + tabplacement_menu->insert(""); + tabplacement_menu->setItemEnabled(i, false); + } else { + tabplacement_menu->insert(new TabPlacementMenuItem(str, *this, placement, save_and_reconftabs)); + } place_menu.pop_front(); } tabplacement_menu->updateMenu(); -- cgit v0.11.2