diff options
Diffstat (limited to 'src/FbWinFrame.cc')
-rw-r--r-- | src/FbWinFrame.cc | 168 |
1 files changed, 149 insertions, 19 deletions
diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc index e9c14c4..160bb2b 100644 --- a/src/FbWinFrame.cc +++ b/src/FbWinFrame.cc | |||
@@ -41,9 +41,8 @@ | |||
41 | 41 | ||
42 | 42 | ||
43 | #include <algorithm> | 43 | #include <algorithm> |
44 | #include <iostream> | ||
45 | #include <X11/X.h> | 44 | #include <X11/X.h> |
46 | 45 | #include <iostream> | |
47 | using namespace std; | 46 | using namespace std; |
48 | 47 | ||
49 | FbWinFrame::FbWinFrame(BScreen &screen, FbWinFrameTheme &theme, FbTk::ImageControl &imgctrl, | 48 | FbWinFrame::FbWinFrame(BScreen &screen, FbWinFrameTheme &theme, FbTk::ImageControl &imgctrl, |
@@ -146,26 +145,63 @@ bool FbWinFrame::setTabMode(TabMode tabmode) { | |||
146 | XUngrabButton(m_tab_container.display(), Button1, Mod1Mask|Mod2Mask|Mod3Mask, m_tab_container.window()); | 145 | XUngrabButton(m_tab_container.display(), Button1, Mod1Mask|Mod2Mask|Mod3Mask, m_tab_container.window()); |
147 | 146 | ||
148 | int tabx, taby; | 147 | int tabx, taby; |
148 | unsigned int maxtotal; | ||
149 | switch (m_screen.getTabPlacement()) { | 149 | switch (m_screen.getTabPlacement()) { |
150 | case TOPLEFT: | 150 | case TOPLEFT: |
151 | m_tab_container.setAlignment(Container::LEFT); | 151 | m_tab_container.setAlignment(Container::LEFT); |
152 | m_tab_container.setOrientation(FbTk::ROT0); | ||
152 | tabx = x(); | 153 | tabx = x(); |
153 | taby = y() - yOffset(); | 154 | taby = y() - yOffset(); |
155 | maxtotal = m_window.width(); | ||
154 | break; | 156 | break; |
155 | case TOPRIGHT: | 157 | case TOPRIGHT: |
156 | m_tab_container.setAlignment(Container::RIGHT); | 158 | m_tab_container.setAlignment(Container::RIGHT); |
159 | m_tab_container.setOrientation(FbTk::ROT0); | ||
157 | tabx = x() + width() - m_tab_container.width(); | 160 | tabx = x() + width() - m_tab_container.width(); |
158 | taby = y() - yOffset(); | 161 | taby = y() - yOffset(); |
162 | maxtotal = m_window.width(); | ||
163 | break; | ||
164 | case LEFTTOP: | ||
165 | m_tab_container.setAlignment(Container::RIGHT); | ||
166 | m_tab_container.setOrientation(FbTk::ROT270); | ||
167 | tabx = x() - xOffset(); | ||
168 | taby = y(); | ||
169 | maxtotal = m_window.height(); | ||
170 | break; | ||
171 | case LEFTBOTTOM: | ||
172 | m_tab_container.setAlignment(Container::LEFT); | ||
173 | m_tab_container.setOrientation(FbTk::ROT270); | ||
174 | tabx = x() - xOffset(); | ||
175 | taby = y() + height() - m_tab_container.height(); | ||
176 | maxtotal = m_window.height(); | ||
177 | break; | ||
178 | case RIGHTTOP: | ||
179 | m_tab_container.setAlignment(Container::LEFT); | ||
180 | m_tab_container.setOrientation(FbTk::ROT90); | ||
181 | tabx = x() + width(); | ||
182 | taby = y(); | ||
183 | maxtotal = m_window.height(); | ||
184 | break; | ||
185 | case RIGHTBOTTOM: | ||
186 | m_tab_container.setAlignment(Container::RIGHT); | ||
187 | m_tab_container.setOrientation(FbTk::ROT90); | ||
188 | tabx = x() + width(); | ||
189 | taby = y() + height() - m_tab_container.height(); | ||
190 | maxtotal = m_window.height(); | ||
159 | break; | 191 | break; |
160 | case BOTTOMLEFT: | 192 | case BOTTOMLEFT: |
161 | m_tab_container.setAlignment(Container::LEFT); | 193 | m_tab_container.setAlignment(Container::LEFT); |
194 | m_tab_container.setOrientation(FbTk::ROT0); | ||
162 | tabx = x(); | 195 | tabx = x(); |
163 | taby = y() + height() + m_window.borderWidth(); | 196 | taby = y() + height() + m_window.borderWidth(); |
197 | maxtotal = m_window.width(); | ||
164 | break; | 198 | break; |
165 | case BOTTOMRIGHT: | 199 | case BOTTOMRIGHT: |
166 | m_tab_container.setAlignment(Container::RIGHT); | 200 | m_tab_container.setAlignment(Container::RIGHT); |
201 | m_tab_container.setOrientation(FbTk::ROT0); | ||
167 | tabx = x() + width() - m_tab_container.width(); | 202 | tabx = x() + width() - m_tab_container.width(); |
168 | taby = y() + height() + m_window.borderWidth(); | 203 | taby = y() + height() + m_window.borderWidth(); |
204 | maxtotal = m_window.width(); | ||
169 | break; | 205 | break; |
170 | } | 206 | } |
171 | 207 | ||
@@ -176,7 +212,7 @@ bool FbWinFrame::setTabMode(TabMode tabmode) { | |||
176 | 212 | ||
177 | m_tab_container.setMaxSizePerClient(m_screen.getTabWidth()); | 213 | m_tab_container.setMaxSizePerClient(m_screen.getTabWidth()); |
178 | m_tab_container.setUpdateLock(false); | 214 | m_tab_container.setUpdateLock(false); |
179 | m_tab_container.setMaxTotalSize(window().width()); | 215 | m_tab_container.setMaxTotalSize(maxtotal); |
180 | 216 | ||
181 | renderTabContainer(); | 217 | renderTabContainer(); |
182 | applyTabContainer(); | 218 | applyTabContainer(); |
@@ -192,6 +228,7 @@ bool FbWinFrame::setTabMode(TabMode tabmode) { | |||
192 | 228 | ||
193 | } else { | 229 | } else { |
194 | m_tab_container.setAlignment(Container::RELATIVE); | 230 | m_tab_container.setAlignment(Container::RELATIVE); |
231 | m_tab_container.setOrientation(FbTk::ROT0); | ||
195 | if (m_tab_container.parent()->window() == m_screen.rootWindow().window()) { | 232 | if (m_tab_container.parent()->window() == m_screen.rootWindow().window()) { |
196 | m_layeritem.removeWindow(m_tab_container); | 233 | m_layeritem.removeWindow(m_tab_container); |
197 | m_tab_container.reparent(m_titlebar, m_label.x(), m_label.y()); | 234 | m_tab_container.reparent(m_titlebar, m_label.x(), m_label.y()); |
@@ -329,8 +366,19 @@ void FbWinFrame::moveResize(int x, int y, unsigned int width, unsigned int heigh | |||
329 | alignTabs(); | 366 | alignTabs(); |
330 | 367 | ||
331 | if (resize) { | 368 | if (resize) { |
332 | if (m_tabmode == EXTERNAL) | 369 | if (m_tabmode == EXTERNAL) { |
333 | m_tab_container.setMaxTotalSize(width); | 370 | switch(m_screen.getTabPlacement()) { |
371 | case LEFTTOP: | ||
372 | case RIGHTTOP: | ||
373 | case LEFTBOTTOM: | ||
374 | case RIGHTBOTTOM: | ||
375 | m_tab_container.setMaxTotalSize(height); | ||
376 | break; | ||
377 | default: | ||
378 | m_tab_container.setMaxTotalSize(width); | ||
379 | break; | ||
380 | } | ||
381 | } | ||
334 | reconfigure(); | 382 | reconfigure(); |
335 | } | 383 | } |
336 | } | 384 | } |
@@ -339,7 +387,18 @@ void FbWinFrame::quietMoveResize(int x, int y, | |||
339 | unsigned int width, unsigned int height) { | 387 | unsigned int width, unsigned int height) { |
340 | m_window.moveResize(x, y, width, height); | 388 | m_window.moveResize(x, y, width, height); |
341 | if (m_tabmode == EXTERNAL) { | 389 | if (m_tabmode == EXTERNAL) { |
342 | m_tab_container.setMaxTotalSize(width); | 390 | |
391 | switch(m_screen.getTabPlacement()) { | ||
392 | case LEFTTOP: | ||
393 | case RIGHTTOP: | ||
394 | case LEFTBOTTOM: | ||
395 | case RIGHTBOTTOM: | ||
396 | m_tab_container.setMaxTotalSize(height); | ||
397 | break; | ||
398 | default: | ||
399 | m_tab_container.setMaxTotalSize(width); | ||
400 | break; | ||
401 | } | ||
343 | alignTabs(); | 402 | alignTabs(); |
344 | } | 403 | } |
345 | } | 404 | } |
@@ -357,18 +416,42 @@ void FbWinFrame::alignTabs() { | |||
357 | int tabx = 0, taby = 0; | 416 | int tabx = 0, taby = 0; |
358 | switch (m_screen.getTabPlacement()) { | 417 | switch (m_screen.getTabPlacement()) { |
359 | case TOPLEFT: | 418 | case TOPLEFT: |
419 | m_tab_container.setOrientation(FbTk::ROT0); | ||
360 | tabx = x(); | 420 | tabx = x(); |
361 | taby = y() - yOffset(); | 421 | taby = y() - yOffset(); |
362 | break; | 422 | break; |
363 | case TOPRIGHT: | 423 | case TOPRIGHT: |
424 | m_tab_container.setOrientation(FbTk::ROT0); | ||
364 | tabx = x() + width() - m_tab_container.width(); | 425 | tabx = x() + width() - m_tab_container.width(); |
365 | taby = y() - yOffset(); | 426 | taby = y() - yOffset(); |
366 | break; | 427 | break; |
428 | case LEFTTOP: | ||
429 | m_tab_container.setOrientation(FbTk::ROT270); | ||
430 | tabx = x() - xOffset(); | ||
431 | taby = y(); | ||
432 | break; | ||
433 | case LEFTBOTTOM: | ||
434 | m_tab_container.setOrientation(FbTk::ROT270); | ||
435 | tabx = x() - xOffset(); | ||
436 | taby = y() + height() - m_tab_container.height(); | ||
437 | break; | ||
438 | case RIGHTTOP: | ||
439 | m_tab_container.setOrientation(FbTk::ROT90); | ||
440 | tabx = x() + width(); | ||
441 | taby = y(); | ||
442 | break; | ||
443 | case RIGHTBOTTOM: | ||
444 | m_tab_container.setOrientation(FbTk::ROT90); | ||
445 | tabx = x() + width(); | ||
446 | taby = y() + height() - m_tab_container.height(); | ||
447 | break; | ||
367 | case BOTTOMLEFT: | 448 | case BOTTOMLEFT: |
449 | m_tab_container.setOrientation(FbTk::ROT0); | ||
368 | tabx = x(); | 450 | tabx = x(); |
369 | taby = y() + height() + m_window.borderWidth(); | 451 | taby = y() + height() + m_window.borderWidth(); |
370 | break; | 452 | break; |
371 | case BOTTOMRIGHT: | 453 | case BOTTOMRIGHT: |
454 | m_tab_container.setOrientation(FbTk::ROT0); | ||
372 | tabx = x() + width() - m_tab_container.width(); | 455 | tabx = x() + width() - m_tab_container.width(); |
373 | taby = y() + height() + m_window.borderWidth(); | 456 | taby = y() + height() + m_window.borderWidth(); |
374 | break; | 457 | break; |
@@ -899,7 +982,21 @@ void FbWinFrame::reconfigure() { | |||
899 | m_titlebar.lower(); | 982 | m_titlebar.lower(); |
900 | 983 | ||
901 | if (m_tabmode == EXTERNAL) { | 984 | if (m_tabmode == EXTERNAL) { |
902 | m_tab_container.resize(m_tab_container.width(), buttonHeight()); | 985 | unsigned int neww, newh; |
986 | switch (m_screen.getTabPlacement()) { | ||
987 | case TOPLEFT: | ||
988 | case TOPRIGHT: | ||
989 | case BOTTOMLEFT: | ||
990 | case BOTTOMRIGHT: | ||
991 | neww = m_tab_container.width(); | ||
992 | newh = buttonHeight(); | ||
993 | break; | ||
994 | default: | ||
995 | neww = buttonHeight(); | ||
996 | newh = m_tab_container.height(); | ||
997 | break; | ||
998 | } | ||
999 | m_tab_container.resize(neww, newh); | ||
903 | alignTabs(); | 1000 | alignTabs(); |
904 | } | 1001 | } |
905 | 1002 | ||
@@ -1112,23 +1209,23 @@ void FbWinFrame::renderTabContainer() { | |||
1112 | 1209 | ||
1113 | render(m_theme.labelFocusTexture(), m_tabcontainer_focused_color, | 1210 | render(m_theme.labelFocusTexture(), m_tabcontainer_focused_color, |
1114 | m_tabcontainer_focused_pm, | 1211 | m_tabcontainer_focused_pm, |
1115 | m_tab_container.width(), m_tab_container.height()); | 1212 | m_tab_container.width(), m_tab_container.height(), m_tab_container.orientation()); |
1116 | 1213 | ||
1117 | render(m_theme.labelUnfocusTexture(), m_tabcontainer_unfocused_color, | 1214 | render(m_theme.labelUnfocusTexture(), m_tabcontainer_unfocused_color, |
1118 | m_tabcontainer_unfocused_pm, | 1215 | m_tabcontainer_unfocused_pm, |
1119 | m_tab_container.width(), m_tab_container.height()); | 1216 | m_tab_container.width(), m_tab_container.height(), m_tab_container.orientation()); |
1120 | 1217 | ||
1121 | render(m_theme.labelFocusTexture(), m_labelbutton_focused_color, | 1218 | render(m_theme.labelFocusTexture(), m_labelbutton_focused_color, |
1122 | m_labelbutton_focused_pm, | 1219 | m_labelbutton_focused_pm, |
1123 | m_tab_container.width(), m_tab_container.height()); | 1220 | m_tab_container.width(), m_tab_container.height(), m_tab_container.orientation()); |
1124 | 1221 | ||
1125 | render(m_theme.labelUnfocusTexture(), m_labelbutton_unfocused_color, | 1222 | render(m_theme.labelUnfocusTexture(), m_labelbutton_unfocused_color, |
1126 | m_labelbutton_unfocused_pm, | 1223 | m_labelbutton_unfocused_pm, |
1127 | m_tab_container.width(), m_tab_container.height()); | 1224 | m_tab_container.width(), m_tab_container.height(), m_tab_container.orientation()); |
1128 | 1225 | ||
1129 | render(m_theme.labelActiveTexture(), m_labelbutton_active_color, | 1226 | render(m_theme.labelActiveTexture(), m_labelbutton_active_color, |
1130 | m_labelbutton_active_pm, | 1227 | m_labelbutton_active_pm, |
1131 | m_tab_container.width(), m_tab_container.height()); | 1228 | m_tab_container.width(), m_tab_container.height(), m_tab_container.orientation()); |
1132 | 1229 | ||
1133 | } | 1230 | } |
1134 | 1231 | ||
@@ -1338,14 +1435,14 @@ void FbWinFrame::applyButton(FbTk::Button &btn) { | |||
1338 | } | 1435 | } |
1339 | 1436 | ||
1340 | void FbWinFrame::render(const FbTk::Texture &tex, FbTk::Color &col, Pixmap &pm, | 1437 | void FbWinFrame::render(const FbTk::Texture &tex, FbTk::Color &col, Pixmap &pm, |
1341 | unsigned int w, unsigned int h) { | 1438 | unsigned int w, unsigned int h, FbTk::Orientation orient) { |
1342 | 1439 | ||
1343 | Pixmap tmp = pm; | 1440 | Pixmap tmp = pm; |
1344 | if (!tex.usePixmap()) { | 1441 | if (!tex.usePixmap()) { |
1345 | pm = None; | 1442 | pm = None; |
1346 | col = tex.color(); | 1443 | col = tex.color(); |
1347 | } else { | 1444 | } else { |
1348 | pm = m_imagectrl.renderImage(w, h, tex); | 1445 | pm = m_imagectrl.renderImage(w, h, tex, orient); |
1349 | } | 1446 | } |
1350 | 1447 | ||
1351 | if (tmp) | 1448 | if (tmp) |
@@ -1610,27 +1707,60 @@ void FbWinFrame::gravityTranslate(int &x, int &y, unsigned int width, unsigned i | |||
1610 | } | 1707 | } |
1611 | } | 1708 | } |
1612 | 1709 | ||
1613 | int FbWinFrame::heightOffset() const { | 1710 | int FbWinFrame::widthOffset() const { |
1614 | if (m_tabmode != EXTERNAL || !m_use_tabs) | 1711 | if (m_tabmode != EXTERNAL || !m_use_tabs) |
1615 | return 0; | 1712 | return 0; |
1616 | 1713 | ||
1617 | // same height offset for top and bottom tabs | 1714 | // same height offset for top and bottom tabs |
1618 | return m_tab_container.height() + m_window.borderWidth(); | 1715 | switch (m_screen.getTabPlacement()) { |
1716 | case LEFTTOP: | ||
1717 | case RIGHTTOP: | ||
1718 | case LEFTBOTTOM: | ||
1719 | case RIGHTBOTTOM: | ||
1720 | return m_tab_container.width() + m_window.borderWidth(); | ||
1721 | break; | ||
1722 | } | ||
1723 | return 0; | ||
1619 | } | 1724 | } |
1620 | 1725 | ||
1621 | int FbWinFrame::yOffset() const { | 1726 | int FbWinFrame::heightOffset() const { |
1622 | if (m_tabmode != EXTERNAL || !m_use_tabs) | 1727 | if (m_tabmode != EXTERNAL || !m_use_tabs) |
1623 | return 0; | 1728 | return 0; |
1624 | 1729 | ||
1625 | switch (m_screen.getTabPlacement()) { | 1730 | switch (m_screen.getTabPlacement()) { |
1626 | case TOPLEFT: | 1731 | case TOPLEFT: |
1627 | case TOPRIGHT: | 1732 | case TOPRIGHT: |
1628 | return m_tab_container.height() + m_window.borderWidth(); | ||
1629 | break; | ||
1630 | case BOTTOMLEFT: | 1733 | case BOTTOMLEFT: |
1631 | case BOTTOMRIGHT: | 1734 | case BOTTOMRIGHT: |
1735 | return m_tab_container.height() + m_window.borderWidth(); | ||
1736 | break; | ||
1737 | } | ||
1738 | return 0; | ||
1739 | } | ||
1740 | |||
1741 | int FbWinFrame::xOffset() const { | ||
1742 | if (m_tabmode != EXTERNAL || !m_use_tabs) | ||
1632 | return 0; | 1743 | return 0; |
1744 | |||
1745 | switch (m_screen.getTabPlacement()) { | ||
1746 | case LEFTTOP: | ||
1747 | case LEFTBOTTOM: | ||
1748 | return m_tab_container.width() + m_window.borderWidth(); | ||
1749 | break; | ||
1750 | } | ||
1751 | return 0; | ||
1752 | } | ||
1753 | |||
1754 | int FbWinFrame::yOffset() const { | ||
1755 | if (m_tabmode != EXTERNAL || !m_use_tabs) | ||
1756 | return 0; | ||
1757 | |||
1758 | switch (m_screen.getTabPlacement()) { | ||
1759 | case TOPLEFT: | ||
1760 | case TOPRIGHT: | ||
1761 | return m_tab_container.height() + m_window.borderWidth(); | ||
1633 | break; | 1762 | break; |
1634 | } | 1763 | } |
1764 | return 0; | ||
1635 | } | 1765 | } |
1636 | 1766 | ||