aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/FbTk/Container.cc14
-rw-r--r--src/FbTk/Container.hh2
-rw-r--r--src/FbWinFrame.cc47
-rw-r--r--src/FbWinFrame.hh8
-rw-r--r--src/Screen.cc51
5 files changed, 102 insertions, 20 deletions
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() {
319 // if we have a max total size, then we must also resize ourself 319 // if we have a max total size, then we must also resize ourself
320 // within that bound 320 // within that bound
321 Alignment align = alignment(); 321 Alignment align = alignment();
322 if (m_max_total_size && (align == RIGHT || align == LEFT)) { 322 if (m_max_total_size && align != RELATIVE) {
323 total_width = (max_width_per_client + borderW) * num_items - borderW; 323 total_width = (max_width_per_client + borderW) * num_items - borderW;
324 if (total_width > m_max_total_size) { 324 if (total_width > m_max_total_size) {
325 total_width = m_max_total_size; 325 total_width = m_max_total_size;
@@ -332,14 +332,21 @@ void Container::repositionItems() {
332 // calling Container::resize here risks infinite loops 332 // calling Container::resize here risks infinite loops
333 unsigned int neww = total_width, newh = height; 333 unsigned int neww = total_width, newh = height;
334 translateSize(m_orientation, neww, newh); 334 translateSize(m_orientation, neww, newh);
335 if ((align == RIGHT && m_orientation != ROT270) || 335 if (!(align == LEFT && (m_orientation == ROT0 ||
336 (align == LEFT && m_orientation == ROT270)) { 336 m_orientation == ROT90)) &&
337 !(align == RIGHT && (m_orientation == ROT180 ||
338 m_orientation == ROT270))) {
337 int deltax = 0; 339 int deltax = 0;
338 int deltay = 0; 340 int deltay = 0;
339 if (m_orientation == ROT0 || m_orientation == ROT180) 341 if (m_orientation == ROT0 || m_orientation == ROT180)
340 deltax = - (total_width - cur_width); 342 deltax = - (total_width - cur_width);
341 else 343 else
342 deltay = - (total_width - cur_width); 344 deltay = - (total_width - cur_width);
345 // TODO: rounding errors could accumulate in this process
346 if (align == CENTER) {
347 deltax = deltax/2;
348 deltay = deltay/2;
349 }
343 350
344 FbWindow::moveResize(x() + deltax, y() + deltay, neww, newh); 351 FbWindow::moveResize(x() + deltax, y() + deltay, neww, newh);
345 } else { 352 } else {
@@ -405,6 +412,7 @@ void Container::repositionItems() {
405unsigned int Container::maxWidthPerClient() const { 412unsigned int Container::maxWidthPerClient() const {
406 switch (alignment()) { 413 switch (alignment()) {
407 case RIGHT: 414 case RIGHT:
415 case CENTER:
408 case LEFT: 416 case LEFT:
409 return m_max_size_per_client; 417 return m_max_size_per_client;
410 break; 418 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 {
38public: 38public:
39 // LEFT, RIGHT => fixed total width, fixed icon size 39 // LEFT, RIGHT => fixed total width, fixed icon size
40 // RELATIVE => fixed total width, relative/variable icon size 40 // RELATIVE => fixed total width, relative/variable icon size
41 enum Alignment { LEFT, RELATIVE, RIGHT }; 41 enum Alignment { LEFT, CENTER, RIGHT, RELATIVE };
42 typedef Button * Item; 42 typedef Button * Item;
43 typedef const Button * ConstItem; 43 typedef const Button * ConstItem;
44 typedef std::list<Item> ItemList; 44 typedef std::list<Item> 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
265 m_window.resize(width, height); 265 m_window.resize(width, height);
266 } 266 }
267 267
268 if (move || (resize && m_screen.getTabPlacement() != TOPLEFT)) 268 if (move || (resize && m_screen.getTabPlacement() != TOPLEFT &&
269 m_screen.getTabPlacement() != LEFTTOP))
269 alignTabs(); 270 alignTabs();
270 271
271 if (resize) { 272 if (resize) {
@@ -273,6 +274,8 @@ void FbWinFrame::moveResize(int x, int y, unsigned int width, unsigned int heigh
273 switch(m_screen.getTabPlacement()) { 274 switch(m_screen.getTabPlacement()) {
274 case LEFTTOP: 275 case LEFTTOP:
275 case RIGHTTOP: 276 case RIGHTTOP:
277 case LEFT:
278 case RIGHT:
276 case LEFTBOTTOM: 279 case LEFTBOTTOM:
277 case RIGHTBOTTOM: 280 case RIGHTBOTTOM:
278 m_tab_container.setMaxTotalSize(height); 281 m_tab_container.setMaxTotalSize(height);
@@ -294,6 +297,8 @@ void FbWinFrame::quietMoveResize(int x, int y,
294 switch(m_screen.getTabPlacement()) { 297 switch(m_screen.getTabPlacement()) {
295 case LEFTTOP: 298 case LEFTTOP:
296 case RIGHTTOP: 299 case RIGHTTOP:
300 case LEFT:
301 case RIGHT:
297 case LEFTBOTTOM: 302 case LEFTBOTTOM:
298 case RIGHTBOTTOM: 303 case RIGHTBOTTOM:
299 m_tab_container.setMaxTotalSize(height); 304 m_tab_container.setMaxTotalSize(height);
@@ -327,6 +332,14 @@ void FbWinFrame::alignTabs() {
327 tabx = x(); 332 tabx = x();
328 taby = y() - yOffset(); 333 taby = y() - yOffset();
329 break; 334 break;
335 case TOP:
336 if (orig_orient != FbTk::ROT0) m_tab_container.hide();
337 m_tab_container.setOrientation(FbTk::ROT0);
338 m_tab_container.setAlignment(FbTk::Container::CENTER);
339 m_tab_container.setMaxTotalSize(m_window.width());
340 tabx = x() + (width() - m_tab_container.width())/2;
341 taby = y() - yOffset();
342 break;
330 case TOPRIGHT: 343 case TOPRIGHT:
331 if (orig_orient != FbTk::ROT0) m_tab_container.hide(); 344 if (orig_orient != FbTk::ROT0) m_tab_container.hide();
332 m_tab_container.setOrientation(FbTk::ROT0); 345 m_tab_container.setOrientation(FbTk::ROT0);
@@ -343,6 +356,14 @@ void FbWinFrame::alignTabs() {
343 tabx = x() - xOffset(); 356 tabx = x() - xOffset();
344 taby = y(); 357 taby = y();
345 break; 358 break;
359 case LEFT:
360 if (orig_orient != FbTk::ROT270) m_tab_container.hide();
361 m_tab_container.setOrientation(FbTk::ROT270);
362 m_tab_container.setAlignment(FbTk::Container::CENTER);
363 m_tab_container.setMaxTotalSize(m_window.height());
364 tabx = x() - xOffset();
365 taby = y() + (height() - m_tab_container.height())/2;
366 break;
346 case LEFTBOTTOM: 367 case LEFTBOTTOM:
347 if (orig_orient != FbTk::ROT270) m_tab_container.hide(); 368 if (orig_orient != FbTk::ROT270) m_tab_container.hide();
348 m_tab_container.setOrientation(FbTk::ROT270); 369 m_tab_container.setOrientation(FbTk::ROT270);
@@ -359,6 +380,14 @@ void FbWinFrame::alignTabs() {
359 tabx = x() + width() + m_window.borderWidth(); 380 tabx = x() + width() + m_window.borderWidth();
360 taby = y(); 381 taby = y();
361 break; 382 break;
383 case RIGHT:
384 if (orig_orient != FbTk::ROT90) m_tab_container.hide();
385 m_tab_container.setOrientation(FbTk::ROT90);
386 m_tab_container.setAlignment(FbTk::Container::CENTER);
387 m_tab_container.setMaxTotalSize(m_window.height());
388 tabx = x() + width() + m_window.borderWidth();
389 taby = y() + (height() - m_tab_container.height())/2;
390 break;
362 case RIGHTBOTTOM: 391 case RIGHTBOTTOM:
363 if (orig_orient != FbTk::ROT90) m_tab_container.hide(); 392 if (orig_orient != FbTk::ROT90) m_tab_container.hide();
364 m_tab_container.setOrientation(FbTk::ROT90); 393 m_tab_container.setOrientation(FbTk::ROT90);
@@ -375,6 +404,14 @@ void FbWinFrame::alignTabs() {
375 tabx = x(); 404 tabx = x();
376 taby = y() + height() + m_window.borderWidth(); 405 taby = y() + height() + m_window.borderWidth();
377 break; 406 break;
407 case BOTTOM:
408 if (orig_orient != FbTk::ROT0) m_tab_container.hide();
409 m_tab_container.setOrientation(FbTk::ROT0);
410 m_tab_container.setAlignment(FbTk::Container::CENTER);
411 m_tab_container.setMaxTotalSize(m_window.width());
412 tabx = x() + (width() - m_tab_container.width())/2;
413 taby = y() + height() + m_window.borderWidth();
414 break;
378 case BOTTOMRIGHT: 415 case BOTTOMRIGHT:
379 if (orig_orient != FbTk::ROT0) m_tab_container.hide(); 416 if (orig_orient != FbTk::ROT0) m_tab_container.hide();
380 m_tab_container.setOrientation(FbTk::ROT0); 417 m_tab_container.setOrientation(FbTk::ROT0);
@@ -878,8 +915,10 @@ void FbWinFrame::reconfigure() {
878 unsigned int neww, newh; 915 unsigned int neww, newh;
879 switch (m_screen.getTabPlacement()) { 916 switch (m_screen.getTabPlacement()) {
880 case TOPLEFT: 917 case TOPLEFT:
918 case TOP:
881 case TOPRIGHT: 919 case TOPRIGHT:
882 case BOTTOMLEFT: 920 case BOTTOMLEFT:
921 case BOTTOM:
883 case BOTTOMRIGHT: 922 case BOTTOMRIGHT:
884 neww = m_tab_container.width(); 923 neww = m_tab_container.width();
885 newh = buttonHeight(); 924 newh = buttonHeight();
@@ -1653,6 +1692,8 @@ int FbWinFrame::widthOffset() const {
1653 switch (m_screen.getTabPlacement()) { 1692 switch (m_screen.getTabPlacement()) {
1654 case LEFTTOP: 1693 case LEFTTOP:
1655 case RIGHTTOP: 1694 case RIGHTTOP:
1695 case LEFT:
1696 case RIGHT:
1656 case LEFTBOTTOM: 1697 case LEFTBOTTOM:
1657 case RIGHTBOTTOM: 1698 case RIGHTBOTTOM:
1658 return m_tab_container.width() + m_window.borderWidth(); 1699 return m_tab_container.width() + m_window.borderWidth();
@@ -1669,8 +1710,10 @@ int FbWinFrame::heightOffset() const {
1669 1710
1670 switch (m_screen.getTabPlacement()) { 1711 switch (m_screen.getTabPlacement()) {
1671 case TOPLEFT: 1712 case TOPLEFT:
1713 case TOP:
1672 case TOPRIGHT: 1714 case TOPRIGHT:
1673 case BOTTOMLEFT: 1715 case BOTTOMLEFT:
1716 case BOTTOM:
1674 case BOTTOMRIGHT: 1717 case BOTTOMRIGHT:
1675 return m_tab_container.height() + m_window.borderWidth(); 1718 return m_tab_container.height() + m_window.borderWidth();
1676 break; 1719 break;
@@ -1686,6 +1729,7 @@ int FbWinFrame::xOffset() const {
1686 1729
1687 switch (m_screen.getTabPlacement()) { 1730 switch (m_screen.getTabPlacement()) {
1688 case LEFTTOP: 1731 case LEFTTOP:
1732 case LEFT:
1689 case LEFTBOTTOM: 1733 case LEFTBOTTOM:
1690 return m_tab_container.width() + m_window.borderWidth(); 1734 return m_tab_container.width() + m_window.borderWidth();
1691 break; 1735 break;
@@ -1701,6 +1745,7 @@ int FbWinFrame::yOffset() const {
1701 1745
1702 switch (m_screen.getTabPlacement()) { 1746 switch (m_screen.getTabPlacement()) {
1703 case TOPLEFT: 1747 case TOPLEFT:
1748 case TOP:
1704 case TOPRIGHT: 1749 case TOPRIGHT:
1705 return m_tab_container.height() + m_window.borderWidth(); 1750 return m_tab_container.height() + m_window.borderWidth();
1706 break; 1751 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:
61 /// Toolbar placement on the screen 61 /// Toolbar placement on the screen
62 enum TabPlacement{ 62 enum TabPlacement{
63 // top and bottom placement 63 // top and bottom placement
64 TOPLEFT = 1, BOTTOMLEFT, 64 TOPLEFT = 1, TOP, TOPRIGHT,
65 TOPRIGHT, BOTTOMRIGHT, 65 BOTTOMLEFT, BOTTOM, BOTTOMRIGHT,
66 // left and right placement 66 // left and right placement
67 LEFTBOTTOM, LEFTTOP, 67 LEFTBOTTOM, LEFT, LEFTTOP,
68 RIGHTBOTTOM, RIGHTTOP 68 RIGHTBOTTOM, RIGHT, RIGHTTOP
69 }; 69 };
70 70
71 /** 71 /**
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 {
207template<> 207template<>
208void FbTk::Resource<FbWinFrame::TabPlacement>:: 208void FbTk::Resource<FbWinFrame::TabPlacement>::
209setFromString(const char *strval) { 209setFromString(const char *strval) {
210 if (strcasecmp(strval, "TopLeft")==0) 210 if (strcasecmp(strval, "TopLeft") == 0)
211 m_value = FbWinFrame::TOPLEFT; 211 m_value = FbWinFrame::TOPLEFT;
212 else if (strcasecmp(strval, "BottomLeft")==0) 212 else if (strcasecmp(strval, "BottomLeft") == 0)
213 m_value = FbWinFrame::BOTTOMLEFT; 213 m_value = FbWinFrame::BOTTOMLEFT;
214 else if (strcasecmp(strval, "TopRight")==0) 214 else if (strcasecmp(strval, "Top") == 0)
215 m_value = FbWinFrame::TOP;
216 else if (strcasecmp(strval, "Bottom") == 0)
217 m_value = FbWinFrame::BOTTOM;
218 else if (strcasecmp(strval, "TopRight") == 0)
215 m_value = FbWinFrame::TOPRIGHT; 219 m_value = FbWinFrame::TOPRIGHT;
216 else if (strcasecmp(strval, "BottomRight")==0) 220 else if (strcasecmp(strval, "BottomRight") == 0)
217 m_value = FbWinFrame::BOTTOMRIGHT; 221 m_value = FbWinFrame::BOTTOMRIGHT;
218 else if (strcasecmp(strval, "LeftTop") == 0) 222 else if (strcasecmp(strval, "LeftTop") == 0)
219 m_value = FbWinFrame::LEFTTOP; 223 m_value = FbWinFrame::LEFTTOP;
224 else if (strcasecmp(strval, "Left") == 0)
225 m_value = FbWinFrame::LEFT;
220 else if (strcasecmp(strval, "LeftBottom") == 0) 226 else if (strcasecmp(strval, "LeftBottom") == 0)
221 m_value = FbWinFrame::LEFTBOTTOM; 227 m_value = FbWinFrame::LEFTBOTTOM;
222 else if (strcasecmp(strval, "RightTop") == 0) 228 else if (strcasecmp(strval, "RightTop") == 0)
223 m_value = FbWinFrame::RIGHTTOP; 229 m_value = FbWinFrame::RIGHTTOP;
230 else if (strcasecmp(strval, "Right") == 0)
231 m_value = FbWinFrame::RIGHT;
224 else if (strcasecmp(strval, "RightBottom") == 0) 232 else if (strcasecmp(strval, "RightBottom") == 0)
225 m_value = FbWinFrame::RIGHTBOTTOM; 233 m_value = FbWinFrame::RIGHTBOTTOM;
226 else 234 else
@@ -237,6 +245,12 @@ getString() const {
237 case FbWinFrame::BOTTOMLEFT: 245 case FbWinFrame::BOTTOMLEFT:
238 return string("BottomLeft"); 246 return string("BottomLeft");
239 break; 247 break;
248 case FbWinFrame::TOP:
249 return string("Top");
250 break;
251 case FbWinFrame::BOTTOM:
252 return string("Bottom");
253 break;
240 case FbWinFrame::TOPRIGHT: 254 case FbWinFrame::TOPRIGHT:
241 return string("TopRight"); 255 return string("TopRight");
242 break; 256 break;
@@ -246,12 +260,18 @@ getString() const {
246 case FbWinFrame::LEFTTOP: 260 case FbWinFrame::LEFTTOP:
247 return string("LeftTop"); 261 return string("LeftTop");
248 break; 262 break;
263 case FbWinFrame::LEFT:
264 return string("Left");
265 break;
249 case FbWinFrame::LEFTBOTTOM: 266 case FbWinFrame::LEFTBOTTOM:
250 return string("LeftBottom"); 267 return string("LeftBottom");
251 break; 268 break;
252 case FbWinFrame::RIGHTTOP: 269 case FbWinFrame::RIGHTTOP:
253 return string("RightTop"); 270 return string("RightTop");
254 break; 271 break;
272 case FbWinFrame::RIGHT:
273 return string("Right");
274 break;
255 case FbWinFrame::RIGHTBOTTOM: 275 case FbWinFrame::RIGHTBOTTOM:
256 return string("RightBottom"); 276 return string("RightBottom");
257 break; 277 break;
@@ -1691,25 +1711,34 @@ void BScreen::setupConfigmenu(FbTk::Menu &menu) {
1691 typedef list<PlacementP> Placements; 1711 typedef list<PlacementP> Placements;
1692 Placements place_menu; 1712 Placements place_menu;
1693 1713
1694 // menu is 2 wide, 2 down 1714 // menu is 3 wide, 5 down
1695 place_menu.push_back(PlacementP(_FB_XTEXT(Align, TopLeft, "Top Left", "Top Left"), FbWinFrame::TOPLEFT)); 1715 place_menu.push_back(PlacementP(_FB_XTEXT(Align, TopLeft, "Top Left", "Top Left"), FbWinFrame::TOPLEFT));
1696 place_menu.push_back(PlacementP(_FB_XTEXT(Align, LeftTop, "Left Top", "Left Top"), FbWinFrame::LEFTTOP)); 1716 place_menu.push_back(PlacementP(_FB_XTEXT(Align, LeftTop, "Left Top", "Left Top"), FbWinFrame::LEFTTOP));
1717 place_menu.push_back(PlacementP(_FB_XTEXT(Align, LeftCenter, "Left Center", "Left Center"), FbWinFrame::LEFT));
1697 place_menu.push_back(PlacementP(_FB_XTEXT(Align, LeftBottom, "Left Bottom", "Left Bottom"), FbWinFrame::LEFTBOTTOM)); 1718 place_menu.push_back(PlacementP(_FB_XTEXT(Align, LeftBottom, "Left Bottom", "Left Bottom"), FbWinFrame::LEFTBOTTOM));
1698 place_menu.push_back(PlacementP(_FB_XTEXT(Align, BottomLeft, "Bottom Left", "Bottom Left"), FbWinFrame::BOTTOMLEFT)); 1719 place_menu.push_back(PlacementP(_FB_XTEXT(Align, BottomLeft, "Bottom Left", "Bottom Left"), FbWinFrame::BOTTOMLEFT));
1720 place_menu.push_back(PlacementP(_FB_XTEXT(Align, TopCenter, "Top Center", "Top Center"), FbWinFrame::TOP));
1721 place_menu.push_back(PlacementP("", FbWinFrame::TOPLEFT));
1722 place_menu.push_back(PlacementP("", FbWinFrame::TOPLEFT));
1723 place_menu.push_back(PlacementP("", FbWinFrame::TOPLEFT));
1724 place_menu.push_back(PlacementP(_FB_XTEXT(Align, BottomCenter, "Bottom Center", "Bottom Center"), FbWinFrame::BOTTOM));
1699 place_menu.push_back(PlacementP(_FB_XTEXT(Align, TopRight, "Top Right", "Top Right"), FbWinFrame::TOPRIGHT)); 1725 place_menu.push_back(PlacementP(_FB_XTEXT(Align, TopRight, "Top Right", "Top Right"), FbWinFrame::TOPRIGHT));
1700 place_menu.push_back(PlacementP(_FB_XTEXT(Align, RightTop, "Right Top", "Right Top"), FbWinFrame::RIGHTTOP)); 1726 place_menu.push_back(PlacementP(_FB_XTEXT(Align, RightTop, "Right Top", "Right Top"), FbWinFrame::RIGHTTOP));
1727 place_menu.push_back(PlacementP(_FB_XTEXT(Align, RightCenter, "Right Center", "Right Center"), FbWinFrame::RIGHT));
1701 place_menu.push_back(PlacementP(_FB_XTEXT(Align, RightBottom, "Right Bottom", "Right Bottom"), FbWinFrame::RIGHTBOTTOM)); 1728 place_menu.push_back(PlacementP(_FB_XTEXT(Align, RightBottom, "Right Bottom", "Right Bottom"), FbWinFrame::RIGHTBOTTOM));
1702 place_menu.push_back(PlacementP(_FB_XTEXT(Align, BottomRight, "Bottom Right", "Bottom Right"), FbWinFrame::BOTTOMRIGHT)); 1729 place_menu.push_back(PlacementP(_FB_XTEXT(Align, BottomRight, "Bottom Right", "Bottom Right"), FbWinFrame::BOTTOMRIGHT));
1703 1730
1704 tabplacement_menu->setMinimumSublevels(2); 1731 tabplacement_menu->setMinimumSublevels(3);
1705 // create items in sub menu 1732 // create items in sub menu
1706 size_t i=0; 1733 for (size_t i=0; i<15; ++i) {
1707 while (!place_menu.empty()) {
1708 i++;
1709 FbTk::FbString &str = place_menu.front().first; 1734 FbTk::FbString &str = place_menu.front().first;
1710 FbWinFrame::TabPlacement placement = place_menu.front().second; 1735 FbWinFrame::TabPlacement placement = place_menu.front().second;
1711 1736 if (str == "") {
1712 tabplacement_menu->insert(new TabPlacementMenuItem(str, *this, placement, save_and_reconftabs)); 1737 tabplacement_menu->insert("");
1738 tabplacement_menu->setItemEnabled(i, false);
1739 } else {
1740 tabplacement_menu->insert(new TabPlacementMenuItem(str, *this, placement, save_and_reconftabs));
1741 }
1713 place_menu.pop_front(); 1742 place_menu.pop_front();
1714 } 1743 }
1715 tabplacement_menu->updateMenu(); 1744 tabplacement_menu->updateMenu();