aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathias Gumz <akira@fluxbox.org>2015-01-23 14:23:02 (GMT)
committerMathias Gumz <akira@fluxbox.org>2015-01-23 14:23:02 (GMT)
commit63d9d695be8156530fabf1d2e033225bfa71bab1 (patch)
tree51c0195272efd5321dc674fa1e10a3007dde1ef2
parent0d8a3dfb6b47753577881b11f25b2a95163ce158 (diff)
downloadfluxbox-63d9d695be8156530fabf1d2e033225bfa71bab1.zip
fluxbox-63d9d695be8156530fabf1d2e033225bfa71bab1.tar.bz2
Refactor FbWinFrame
FbWinFrame is now simpler to read due to less overall noise.
-rw-r--r--src/FbWinFrame.cc777
-rw-r--r--src/FbWinFrame.hh63
2 files changed, 321 insertions, 519 deletions
diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc
index 937f87f..5501413 100644
--- a/src/FbWinFrame.cc
+++ b/src/FbWinFrame.cc
@@ -21,6 +21,13 @@
21 21
22#include "FbWinFrame.hh" 22#include "FbWinFrame.hh"
23 23
24#include "Keys.hh"
25#include "FbWinFrameTheme.hh"
26#include "Screen.hh"
27#include "FocusableTheme.hh"
28#include "IconButton.hh"
29#include "RectangleUtil.hh"
30
24#include "FbTk/ImageControl.hh" 31#include "FbTk/ImageControl.hh"
25#include "FbTk/EventManager.hh" 32#include "FbTk/EventManager.hh"
26#include "FbTk/App.hh" 33#include "FbTk/App.hh"
@@ -31,16 +38,9 @@
31#include "FbTk/TextUtils.hh" 38#include "FbTk/TextUtils.hh"
32#include "FbTk/STLUtil.hh" 39#include "FbTk/STLUtil.hh"
33 40
34#include "FbWinFrameTheme.hh"
35#include "Screen.hh"
36#include "FocusableTheme.hh"
37#include "IconButton.hh"
38#include "RectangleUtil.hh"
39
40#include <algorithm>
41#include <X11/X.h> 41#include <X11/X.h>
42 42
43#include "Keys.hh" 43#include <algorithm>
44 44
45using std::max; 45using std::max;
46using std::mem_fun; 46using std::mem_fun;
@@ -48,6 +48,63 @@ using std::string;
48 48
49using FbTk::STLUtil::forAll; 49using FbTk::STLUtil::forAll;
50 50
51namespace {
52
53enum { UNFOCUS = 0, FOCUS, PRESSED };
54
55const long _mask = ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | EnterWindowMask | LeaveWindowMask;
56
57const struct {
58 FbWinFrame::TabPlacement where;
59 FbTk::Orientation orient;
60 FbTk::Container::Alignment align;
61 bool is_horizontal;
62} _values[] = {
63 { /* unused */ },
64 { FbWinFrame::TOPLEFT, FbTk::ROT0, FbTk::Container::LEFT, true },
65 { FbWinFrame::TOP, FbTk::ROT0, FbTk::Container::CENTER, true },
66 { FbWinFrame::TOPRIGHT, FbTk::ROT0, FbTk::Container::RIGHT, true },
67 { FbWinFrame::BOTTOMLEFT, FbTk::ROT0, FbTk::Container::LEFT, true },
68 { FbWinFrame::BOTTOM, FbTk::ROT0, FbTk::Container::CENTER, true },
69 { FbWinFrame::BOTTOMRIGHT,FbTk::ROT0, FbTk::Container::RIGHT, true },
70 { FbWinFrame::LEFTTOP, FbTk::ROT270, FbTk::Container::RIGHT, false },
71 { FbWinFrame::LEFT, FbTk::ROT270, FbTk::Container::CENTER, false },
72 { FbWinFrame::LEFTBOTTOM, FbTk::ROT270, FbTk::Container::LEFT, false },
73 { FbWinFrame::RIGHTTOP, FbTk::ROT90, FbTk::Container::LEFT, false },
74 { FbWinFrame::RIGHT, FbTk::ROT90, FbTk::Container::LEFT, false },
75 { FbWinFrame::RIGHTBOTTOM,FbTk::ROT90, FbTk::Container::LEFT, false },
76};
77
78/// renders to pixmap or sets color
79void render(FbTk::Color &col, Pixmap &pm, unsigned int width, unsigned int height,
80 const FbTk::Texture &tex,
81 FbTk::ImageControl& ictl,
82 FbTk::Orientation orient = FbTk::ROT0) {
83
84 Pixmap tmp = pm;
85 if (!tex.usePixmap()) {
86 pm = None;
87 col = tex.color();
88 } else {
89 pm = ictl.renderImage(width, height, tex, orient);
90 }
91
92 if (tmp)
93 ictl.removeImage(tmp);
94
95}
96
97void bg_pm_or_color(FbTk::FbWindow& win, Pixmap& pm, FbTk::Color& color) {
98 if (pm) {
99 win.setBackgroundPixmap(pm);
100 } else {
101 win.setBackgroundColor(color);
102 }
103}
104
105
106} // end anonymous
107
51FbWinFrame::FbWinFrame(BScreen &screen, unsigned int client_depth, 108FbWinFrame::FbWinFrame(BScreen &screen, unsigned int client_depth,
52 WindowState &state, 109 WindowState &state,
53 FocusableTheme<FbWinFrameTheme> &theme): 110 FocusableTheme<FbWinFrameTheme> &theme):
@@ -55,61 +112,41 @@ FbWinFrame::FbWinFrame(BScreen &screen, unsigned int client_depth,
55 m_theme(theme), 112 m_theme(theme),
56 m_imagectrl(screen.imageControl()), 113 m_imagectrl(screen.imageControl()),
57 m_state(state), 114 m_state(state),
58 m_window(theme->screenNum(), state.x, state.y, state.width, state.height, 115 m_window(theme->screenNum(), state.x, state.y, state.width, state.height, _mask, true, false,
59 ButtonPressMask | ButtonReleaseMask | 116 client_depth, InputOutput,
60 ButtonMotionMask | EnterWindowMask | 117 ((client_depth == 32) && (screen.rootWindow().depth() == 32) ? screen.rootWindow().visual() : CopyFromParent),
61 LeaveWindowMask, true, false, 118 ((client_depth == 32) && (screen.rootWindow().depth() == 32) ? screen.rootWindow().colormap() : CopyFromParent)),
62 client_depth, InputOutput,
63 ((client_depth == 32) && (screen.rootWindow().depth() == 32) ? screen.rootWindow().visual() : CopyFromParent),
64 ((client_depth == 32) && (screen.rootWindow().depth() == 32) ? screen.rootWindow().colormap() : CopyFromParent)),
65 m_layeritem(window(), *screen.layerManager().getLayer(ResourceLayer::NORMAL)), 119 m_layeritem(window(), *screen.layerManager().getLayer(ResourceLayer::NORMAL)),
66 m_titlebar(m_window, 0, 0, 100, 16, 120 m_titlebar(m_window, 0, 0, 100, 16, _mask, false, false,
67 ButtonPressMask | ButtonReleaseMask | 121 screen.rootWindow().decorationDepth(), InputOutput,
68 ButtonMotionMask | ExposureMask | 122 screen.rootWindow().decorationVisual(),
69 EnterWindowMask | LeaveWindowMask, 123 screen.rootWindow().decorationColormap()),
70 false, false, screen.rootWindow().decorationDepth(), InputOutput,
71 screen.rootWindow().decorationVisual(),
72 screen.rootWindow().decorationColormap()),
73 m_tab_container(m_titlebar), 124 m_tab_container(m_titlebar),
74 m_label(m_titlebar, m_theme->font(), FbTk::BiDiString("")), 125 m_label(m_titlebar, m_theme->font(), FbTk::BiDiString("")),
75 m_handle(m_window, 0, 0, 100, 5, 126 m_handle(m_window, 0, 0, 100, 5, _mask, false, false,
76 ButtonPressMask | ButtonReleaseMask | 127 screen.rootWindow().decorationDepth(), InputOutput,
77 ButtonMotionMask | ExposureMask | 128 screen.rootWindow().decorationVisual(),
78 EnterWindowMask | LeaveWindowMask, 129 screen.rootWindow().decorationColormap()),
79 false, false, screen.rootWindow().decorationDepth(), InputOutput, 130 m_grip_right(m_handle, 0, 0, 10, 4, _mask, false, false,
80 screen.rootWindow().decorationVisual(), 131 screen.rootWindow().decorationDepth(), InputOutput,
81 screen.rootWindow().decorationColormap()), 132 screen.rootWindow().decorationVisual(),
82 m_grip_right(m_handle, 0, 0, 10, 4, 133 screen.rootWindow().decorationColormap()),
83 ButtonPressMask | ButtonReleaseMask | 134 m_grip_left(m_handle, 0, 0, 10, 4, _mask, false, false,
84 ButtonMotionMask | ExposureMask | 135 screen.rootWindow().decorationDepth(), InputOutput,
85 EnterWindowMask | LeaveWindowMask, 136 screen.rootWindow().decorationVisual(),
86 false, false, screen.rootWindow().decorationDepth(), InputOutput, 137 screen.rootWindow().decorationColormap()),
87 screen.rootWindow().decorationVisual(), 138 m_clientarea(m_window, 0, 0, 100, 100, _mask),
88 screen.rootWindow().decorationColormap()),
89 m_grip_left(m_handle, 0, 0, 10, 4,
90 ButtonPressMask | ButtonReleaseMask |
91 ButtonMotionMask | ExposureMask |
92 EnterWindowMask | LeaveWindowMask,
93 false, false, screen.rootWindow().decorationDepth(), InputOutput,
94 screen.rootWindow().decorationVisual(),
95 screen.rootWindow().decorationColormap()),
96 m_clientarea(m_window, 0, 0, 100, 100,
97 ButtonPressMask | ButtonReleaseMask |
98 ButtonMotionMask | ExposureMask |
99 EnterWindowMask | LeaveWindowMask),
100 m_bevel(1), 139 m_bevel(1),
101 m_use_titlebar(true), 140 m_use_titlebar(true),
102 m_use_tabs(true), 141 m_use_tabs(true),
103 m_use_handle(true), 142 m_use_handle(true),
104 m_visible(false), 143 m_visible(false),
105 m_button_pm(0),
106 m_tabmode(screen.getDefaultInternalTabs()?INTERNAL:EXTERNAL), 144 m_tabmode(screen.getDefaultInternalTabs()?INTERNAL:EXTERNAL),
107 m_active_orig_client_bw(0), 145 m_active_orig_client_bw(0),
108 m_need_render(true), 146 m_need_render(true),
109 m_button_size(1), 147 m_button_size(1),
110 m_focused_alpha(AlphaAcc(*theme.focusedTheme(), &FbWinFrameTheme::alpha)),
111 m_unfocused_alpha(AlphaAcc(*theme.unfocusedTheme(), &FbWinFrameTheme::alpha)),
112 m_shape(m_window, theme->shapePlace()) { 148 m_shape(m_window, theme->shapePlace()) {
149
113 init(); 150 init();
114} 151}
115 152
@@ -198,7 +235,7 @@ void FbWinFrame::show() {
198 235
199 if (m_need_render) { 236 if (m_need_render) {
200 renderAll(); 237 renderAll();
201 applyAll(); 238 applyAll();
202 clearAll(); 239 clearAll();
203 } 240 }
204 241
@@ -269,19 +306,11 @@ void FbWinFrame::moveResize(int x, int y, unsigned int width, unsigned int heigh
269 306
270 if (resize) { 307 if (resize) {
271 if (m_tabmode == EXTERNAL) { 308 if (m_tabmode == EXTERNAL) {
272 switch(m_screen.getTabPlacement()) { 309 unsigned int s = width;
273 case LEFTTOP: 310 if (!_values[m_screen.getTabPlacement()].is_horizontal) {
274 case RIGHTTOP: 311 s = height;
275 case LEFT:
276 case RIGHT:
277 case LEFTBOTTOM:
278 case RIGHTBOTTOM:
279 m_tab_container.setMaxTotalSize(height);
280 break;
281 default:
282 m_tab_container.setMaxTotalSize(width);
283 break;
284 } 312 }
313 m_tab_container.setMaxTotalSize(s);
285 } 314 }
286 reconfigure(); 315 reconfigure();
287 } 316 }
@@ -293,20 +322,11 @@ void FbWinFrame::quietMoveResize(int x, int y,
293 m_state.saveGeometry(window().x(), window().y(), 322 m_state.saveGeometry(window().x(), window().y(),
294 window().width(), window().height()); 323 window().width(), window().height());
295 if (m_tabmode == EXTERNAL) { 324 if (m_tabmode == EXTERNAL) {
296 325 unsigned int s = width;
297 switch(m_screen.getTabPlacement()) { 326 if (!_values[m_screen.getTabPlacement()].is_horizontal) {
298 case LEFTTOP: 327 s = height;
299 case RIGHTTOP:
300 case LEFT:
301 case RIGHT:
302 case LEFTBOTTOM:
303 case RIGHTBOTTOM:
304 m_tab_container.setMaxTotalSize(height);
305 break;
306 default:
307 m_tab_container.setMaxTotalSize(width);
308 break;
309 } 328 }
329 m_tab_container.setMaxTotalSize(s);
310 alignTabs(); 330 alignTabs();
311 } 331 }
312} 332}
@@ -316,131 +336,67 @@ void FbWinFrame::alignTabs() {
316 return; 336 return;
317 337
318 338
319 FbTk::Orientation orig_orient = m_tab_container.orientation(); 339 FbTk::Container& tabs = tabcontainer();
320 unsigned int orig_tabwidth = m_tab_container.maxWidthPerClient(); 340 FbTk::Orientation orig_orient = tabs.orientation();
341 unsigned int orig_tabwidth = tabs.maxWidthPerClient();
321 342
322 if (orig_tabwidth != m_screen.getTabWidth()) 343 if (orig_tabwidth != m_screen.getTabWidth())
323 m_tab_container.setMaxSizePerClient(m_screen.getTabWidth()); 344 tabs.setMaxSizePerClient(m_screen.getTabWidth());
324 345
325 int tabx = 0, taby = 0; 346 int bw = window().borderWidth();
326 switch (m_screen.getTabPlacement()) { 347 int size = width();
327 case TOPLEFT: 348 int tab_x = x();
328 if (orig_orient != FbTk::ROT0) m_tab_container.hide(); 349 int tab_y = y();
329 m_tab_container.setOrientation(FbTk::ROT0);
330 m_tab_container.setAlignment(FbTk::Container::LEFT);
331 m_tab_container.setMaxTotalSize(m_window.width());
332 tabx = x();
333 taby = y() - yOffset();
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;
343 case TOPRIGHT:
344 if (orig_orient != FbTk::ROT0) m_tab_container.hide();
345 m_tab_container.setOrientation(FbTk::ROT0);
346 m_tab_container.setAlignment(FbTk::Container::RIGHT);
347 m_tab_container.setMaxTotalSize(m_window.width());
348 tabx = x() + width() - m_tab_container.width();
349 taby = y() - yOffset();
350 break;
351 case LEFTTOP:
352 if (orig_orient != FbTk::ROT270) m_tab_container.hide();
353 m_tab_container.setOrientation(FbTk::ROT270);
354 m_tab_container.setAlignment(FbTk::Container::RIGHT);
355 m_tab_container.setMaxTotalSize(m_window.height());
356 tabx = x() - xOffset();
357 taby = y();
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;
367 case LEFTBOTTOM:
368 if (orig_orient != FbTk::ROT270) m_tab_container.hide();
369 m_tab_container.setOrientation(FbTk::ROT270);
370 m_tab_container.setAlignment(FbTk::Container::LEFT);
371 m_tab_container.setMaxTotalSize(m_window.height());
372 tabx = x() - xOffset();
373 taby = y() + height() - m_tab_container.height();
374 break;
375 case RIGHTTOP:
376 if (orig_orient != FbTk::ROT90) m_tab_container.hide();
377 m_tab_container.setOrientation(FbTk::ROT90);
378 m_tab_container.setAlignment(FbTk::Container::LEFT);
379 m_tab_container.setMaxTotalSize(m_window.height());
380 tabx = x() + width() + m_window.borderWidth();
381 taby = y();
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;
391 case RIGHTBOTTOM:
392 if (orig_orient != FbTk::ROT90) m_tab_container.hide();
393 m_tab_container.setOrientation(FbTk::ROT90);
394 m_tab_container.setAlignment(FbTk::Container::RIGHT);
395 m_tab_container.setMaxTotalSize(m_window.height());
396 tabx = x() + width() + m_window.borderWidth();
397 taby = y() + height() - m_tab_container.height();
398 break;
399 case BOTTOMLEFT:
400 if (orig_orient != FbTk::ROT0) m_tab_container.hide();
401 m_tab_container.setOrientation(FbTk::ROT0);
402 m_tab_container.setAlignment(FbTk::Container::LEFT);
403 m_tab_container.setMaxTotalSize(m_window.width());
404 tabx = x();
405 taby = y() + height() + m_window.borderWidth();
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;
415 case BOTTOMRIGHT:
416 if (orig_orient != FbTk::ROT0) m_tab_container.hide();
417 m_tab_container.setOrientation(FbTk::ROT0);
418 m_tab_container.setAlignment(FbTk::Container::RIGHT);
419 m_tab_container.setMaxTotalSize(m_window.width());
420 tabx = x() + width() - m_tab_container.width();
421 taby = y() + height() + m_window.borderWidth();
422 break;
423 }
424 350
425 unsigned int w = m_window.width(), h = m_window.height(); 351 TabPlacement p = m_screen.getTabPlacement();
426 translateSize(m_tab_container.orientation(), w, h); 352 if (orig_orient != _values[p].orient) {
353 tabs.hide();
354 }
355 if (!_values[p].is_horizontal) {
356 size = height();
357 }
358 tabs.setOrientation(_values[p].orient);
359 tabs.setAlignment(_values[p].align);
360 tabs.setMaxTotalSize(size);
361
362 int w = static_cast<int>(width());
363 int h = static_cast<int>(height());
364 int xo = xOffset();
365 int yo = yOffset();
366 int tw = static_cast<int>(tabs.width());
367 int th = static_cast<int>(tabs.height());
368
369 switch (p) {
370 case TOPLEFT: tab_y -= yo; break;
371 case TOP: tab_x += (w - tw)/2; tab_y -= yo; break;
372 case TOPRIGHT: tab_x += w - tw; tab_y -= yo; break;
373 case BOTTOMLEFT: tab_y += h + bw; break;
374 case BOTTOM: tab_x += (w - tw)/2; tab_y += h + bw; break;
375 case BOTTOMRIGHT: tab_x += w - tw; tab_y += h + bw; break;
376 case LEFTTOP: tab_x -= xo; break;
377 case LEFT: tab_x -= xo; tab_y += (h - th)/2; break;
378 case LEFTBOTTOM: tab_x -= xo; tab_y += h - th; break;
379 case RIGHTTOP: tab_x += w + bw; break;
380 case RIGHT: tab_x += w + bw; tab_y += (h - th)/2; break;
381 case RIGHTBOTTOM: tab_x += w + bw; tab_y += h - th; break;
382 }
427 383
428 if (m_tab_container.orientation() != orig_orient || 384 if (tabs.orientation() != orig_orient ||
429 m_tab_container.maxWidthPerClient() != orig_tabwidth) { 385 tabs.maxWidthPerClient() != orig_tabwidth) {
430 renderTabContainer(); 386 renderTabContainer();
431 if (m_visible && m_use_tabs) { 387 if (m_visible && m_use_tabs) {
432 applyTabContainer(); 388 applyTabContainer();
433 m_tab_container.clear(); 389 tabs.clear();
434 m_tab_container.show(); 390 tabs.show();
435 } 391 }
436 } 392 }
437 393
438 if (m_tab_container.parent()->window() != m_screen.rootWindow().window()) { 394 if (tabs.parent()->window() != m_screen.rootWindow().window()) {
439 m_tab_container.reparent(m_screen.rootWindow(), tabx, taby); 395 tabs.reparent(m_screen.rootWindow(), tab_x, tab_y);
440 m_label.clear(); 396 tabs.clear();
441 m_layeritem.addWindow(m_tab_container); 397 m_layeritem.addWindow(tabs);
442 } else { 398 } else {
443 m_tab_container.move(tabx, taby); 399 tabs.move(tab_x, tab_y);
444 } 400 }
445} 401}
446 402
@@ -499,16 +455,16 @@ void FbWinFrame::setFocus(bool newvalue) {
499 455
500 m_state.focused = newvalue; 456 m_state.focused = newvalue;
501 457
502 if (FbTk::Transparent::haveRender() && 458 if (FbTk::Transparent::haveRender() &&
503 getAlpha(true) != getAlpha(false)) { // different alpha for focused and unfocused 459 getAlpha(true) != getAlpha(false)) { // different alpha for focused and unfocused
460
504 int alpha = getAlpha(m_state.focused); 461 int alpha = getAlpha(m_state.focused);
505 if (FbTk::Transparent::haveComposite()) { 462 int opaque = 255;
506 m_tab_container.setAlpha(255); 463 if (!FbTk::Transparent::haveComposite()) {
507 m_window.setOpaque(alpha); 464 std::swap(alpha, opaque);
508 } else {
509 m_tab_container.setAlpha(alpha);
510 m_window.setOpaque(255);
511 } 465 }
466 m_tab_container.setAlpha(alpha);
467 m_window.setOpaque(opaque);
512 } 468 }
513 469
514 setBorderWidth(); 470 setBorderWidth();
@@ -556,11 +512,7 @@ void FbWinFrame::applyState() {
556} 512}
557 513
558void FbWinFrame::setAlpha(bool focused, int alpha) { 514void FbWinFrame::setAlpha(bool focused, int alpha) {
559 if (focused) 515 m_alpha[focused] = alpha;
560 m_focused_alpha = alpha;
561 else
562 m_unfocused_alpha = alpha;
563
564 if (m_state.focused == focused) 516 if (m_state.focused == focused)
565 applyAlpha(); 517 applyAlpha();
566} 518}
@@ -577,22 +529,25 @@ void FbWinFrame::applyAlpha() {
577} 529}
578 530
579int FbWinFrame::getAlpha(bool focused) const { 531int FbWinFrame::getAlpha(bool focused) const {
580 if (focused) 532 return m_alpha[focused];
581 return m_focused_alpha;
582 else
583 return m_unfocused_alpha;
584} 533}
585 534
586void FbWinFrame::setDefaultAlpha() { 535void FbWinFrame::setDefaultAlpha() {
587 if (getUseDefaultAlpha()) 536 if (getUseDefaultAlpha())
588 return; 537 return;
589 m_focused_alpha.restoreDefault(); 538 m_alpha[UNFOCUS] = theme().unfocusedTheme()->alpha();
590 m_unfocused_alpha.restoreDefault(); 539 m_alpha[FOCUS] = theme().unfocusedTheme()->alpha();
591 applyAlpha(); 540 applyAlpha();
592} 541}
593 542
594bool FbWinFrame::getUseDefaultAlpha() const { 543bool FbWinFrame::getUseDefaultAlpha() const {
595 return m_focused_alpha.isDefault() && m_unfocused_alpha.isDefault(); 544 if (m_alpha[UNFOCUS] != theme().unfocusedTheme()->alpha()) {
545 return false;
546 } else if (m_alpha[FOCUS] != theme().focusedTheme()->alpha()) {
547 return false;
548 }
549
550 return true;
596} 551}
597 552
598void FbWinFrame::addLeftButton(FbTk::Button *btn) { 553void FbWinFrame::addLeftButton(FbTk::Button *btn) {
@@ -737,14 +692,15 @@ bool FbWinFrame::hideTitlebar() {
737 692
738 m_titlebar.hide(); 693 m_titlebar.hide();
739 m_use_titlebar = false; 694 m_use_titlebar = false;
740 if (static_cast<signed int>(m_window.height() - m_titlebar.height() - 695
741 m_titlebar.borderWidth()) <= 0) { 696 int h = height();
742 m_window.resize(m_window.width(), 1); 697 int th = m_titlebar.height();
743 } else { 698 int tbw = m_titlebar.borderWidth();
744 // only take away one borderwidth (as the other border is still the "top" border) 699
745 m_window.resize(m_window.width(), m_window.height() - m_titlebar.height() - 700 // only take away one borderwidth (as the other border is still the "top"
746 m_titlebar.borderWidth()); 701 // border)
747 } 702 h = std::max(1, h - th - tbw);
703 m_window.resize(m_window.width(), h);
748 704
749 return true; 705 return true;
750} 706}
@@ -756,7 +712,8 @@ bool FbWinFrame::showTitlebar() {
756 m_titlebar.show(); 712 m_titlebar.show();
757 m_use_titlebar = true; 713 m_use_titlebar = true;
758 714
759 // only add one borderwidth (as the other border is still the "top" border) 715 // only add one borderwidth (as the other border is still the "top"
716 // border)
760 m_window.resize(m_window.width(), m_window.height() + m_titlebar.height() + 717 m_window.resize(m_window.width(), m_window.height() + m_titlebar.height() +
761 m_titlebar.borderWidth()); 718 m_titlebar.borderWidth());
762 719
@@ -767,22 +724,22 @@ bool FbWinFrame::showTitlebar() {
767bool FbWinFrame::hideHandle() { 724bool FbWinFrame::hideHandle() {
768 if (!m_use_handle) 725 if (!m_use_handle)
769 return false; 726 return false;
727
770 m_handle.hide(); 728 m_handle.hide();
771 m_grip_left.hide(); 729 m_grip_left.hide();
772 m_grip_right.hide(); 730 m_grip_right.hide();
773 m_use_handle = false; 731 m_use_handle = false;
774 732
775 if (static_cast<signed int>(m_window.height() - m_handle.height() - 733 int h = m_window.height();
776 m_handle.borderWidth()) <= 0) { 734 int hh = m_handle.height();
777 m_window.resize(m_window.width(), 1); 735 int hbw = m_handle.borderWidth();
778 } else {
779 // only take away one borderwidth (as the other border is still the "top" border)
780 m_window.resize(m_window.width(), m_window.height() - m_handle.height() -
781 m_handle.borderWidth());
782 }
783 736
784 return true; 737 // only take away one borderwidth (as the other border is still the "top"
738 // border)
739 h = std::max(1, h - hh - hbw);
740 m_window.resize(m_window.width(), h);
785 741
742 return true;
786} 743}
787 744
788bool FbWinFrame::showHandle() { 745bool FbWinFrame::showHandle() {
@@ -833,18 +790,19 @@ void FbWinFrame::removeEventHandler() {
833} 790}
834 791
835void FbWinFrame::exposeEvent(XExposeEvent &event) { 792void FbWinFrame::exposeEvent(XExposeEvent &event) {
793 FbTk::FbWindow* win = 0;
836 if (m_titlebar == event.window) { 794 if (m_titlebar == event.window) {
837 m_titlebar.clearArea(event.x, event.y, event.width, event.height); 795 win = &m_titlebar;
838 } else if (m_tab_container == event.window) { 796 } else if (m_tab_container == event.window) {
839 m_tab_container.clearArea(event.x, event.y, event.width, event.height); 797 win = &m_tab_container;
840 } else if (m_label == event.window) { 798 } else if (m_label == event.window) {
841 m_label.clearArea(event.x, event.y, event.width, event.height); 799 win = &m_label;
842 } else if (m_handle == event.window) { 800 } else if (m_handle == event.window) {
843 m_handle.clearArea(event.x, event.y, event.width, event.height); 801 win = &m_handle;
844 } else if (m_grip_left == event.window) { 802 } else if (m_grip_left == event.window) {
845 m_grip_left.clearArea(event.x, event.y, event.width, event.height); 803 win = &m_grip_left;
846 } else if (m_grip_right == event.window) { 804 } else if (m_grip_right == event.window) {
847 m_grip_right.clearArea(event.x, event.y, event.width, event.height); 805 win = &m_grip_right;
848 } else { 806 } else {
849 807
850 if (m_tab_container.tryExposeEvent(event)) 808 if (m_tab_container.tryExposeEvent(event))
@@ -869,8 +827,11 @@ void FbWinFrame::exposeEvent(XExposeEvent &event) {
869 827
870 if (it != m_buttons_right.end()) 828 if (it != m_buttons_right.end())
871 (*it)->exposeEvent(event); 829 (*it)->exposeEvent(event);
830
831 return;
872 } 832 }
873 833
834 win->clearArea(event.x, event.y, event.width, event.height);
874} 835}
875 836
876void FbWinFrame::handleEvent(XEvent &event) { 837void FbWinFrame::handleEvent(XEvent &event) {
@@ -912,23 +873,13 @@ void FbWinFrame::reconfigure() {
912 m_titlebar.lower(); 873 m_titlebar.lower();
913 874
914 if (m_tabmode == EXTERNAL) { 875 if (m_tabmode == EXTERNAL) {
915 unsigned int neww, newh; 876 unsigned int h = buttonHeight();
916 switch (m_screen.getTabPlacement()) { 877 unsigned int w = m_tab_container.width();
917 case TOPLEFT: 878 if (!_values[m_screen.getTabPlacement()].is_horizontal) {
918 case TOP: 879 w = m_tab_container.height();
919 case TOPRIGHT: 880 std::swap(w, h);
920 case BOTTOMLEFT:
921 case BOTTOM:
922 case BOTTOMRIGHT:
923 neww = m_tab_container.width();
924 newh = buttonHeight();
925 break;
926 default:
927 neww = buttonHeight();
928 newh = m_tab_container.height();
929 break;
930 } 881 }
931 m_tab_container.resize(neww, newh); 882 m_tab_container.resize(w, h);
932 alignTabs(); 883 alignTabs();
933 } 884 }
934 885
@@ -989,13 +940,12 @@ void FbWinFrame::reconfigure() {
989 // update transparency settings 940 // update transparency settings
990 if (FbTk::Transparent::haveRender()) { 941 if (FbTk::Transparent::haveRender()) {
991 int alpha = getAlpha(m_state.focused); 942 int alpha = getAlpha(m_state.focused);
992 if (FbTk::Transparent::haveComposite()) { 943 int opaque = 255;
993 m_tab_container.setAlpha(255); 944 if (!FbTk::Transparent::haveComposite()) {
994 m_window.setOpaque(alpha); 945 std::swap(alpha, opaque);
995 } else {
996 m_tab_container.setAlpha(alpha);
997 m_window.setOpaque(255);
998 } 946 }
947 m_tab_container.setAlpha(alpha);
948 m_window.setOpaque(opaque);
999 } 949 }
1000 renderAll(); 950 renderAll();
1001 applyAll(); 951 applyAll();
@@ -1084,8 +1034,7 @@ void FbWinFrame::reconfigureTitlebar() {
1084 1034
1085 m_tab_container.invalidateBackground(); 1035 m_tab_container.invalidateBackground();
1086 if (m_tabmode == INTERNAL) 1036 if (m_tabmode == INTERNAL)
1087 m_tab_container.moveResize(next_x, m_bevel, 1037 m_tab_container.moveResize(next_x, m_bevel, space_left, button_size);
1088 space_left, button_size);
1089 else { 1038 else {
1090 if (m_use_tabs) { 1039 if (m_use_tabs) {
1091 if (m_tab_container.orientation() == FbTk::ROT0) { 1040 if (m_tab_container.orientation() == FbTk::ROT0) {
@@ -1132,25 +1081,24 @@ void FbWinFrame::renderTitlebar() {
1132 return; 1081 return;
1133 } 1082 }
1134 1083
1084 typedef FbTk::ThemeProxy<FbWinFrameTheme> TP;
1085 TP& ft = theme().focusedTheme();
1086 TP& uft = theme().unfocusedTheme();
1087
1135 // render pixmaps 1088 // render pixmaps
1136 render(theme().focusedTheme()->titleTexture(), m_title_focused_color, 1089 render(m_title_face.color[FOCUS], m_title_face.pm[FOCUS], m_titlebar.width(), m_titlebar.height(),
1137 m_title_focused_pm, 1090 ft->titleTexture(), m_imagectrl);
1138 m_titlebar.width(), m_titlebar.height());
1139 1091
1140 render(theme().unfocusedTheme()->titleTexture(), m_title_unfocused_color, 1092 render(m_title_face.color[UNFOCUS], m_title_face.pm[UNFOCUS], m_titlebar.width(), m_titlebar.height(),
1141 m_title_unfocused_pm, 1093 uft->titleTexture(), m_imagectrl);
1142 m_titlebar.width(), m_titlebar.height());
1143 1094
1144 //!! TODO: don't render label if internal tabs 1095 //!! TODO: don't render label if internal tabs
1145 1096
1146 render(theme().focusedTheme()->iconbarTheme()->texture(), 1097 render(m_label_face.color[FOCUS], m_label_face.pm[FOCUS], m_label.width(), m_label.height(),
1147 m_label_focused_color, m_label_focused_pm, 1098 ft->iconbarTheme()->texture(), m_imagectrl);
1148 m_label.width(), m_label.height());
1149
1150 render(theme().unfocusedTheme()->iconbarTheme()->texture(),
1151 m_label_unfocused_color, m_label_unfocused_pm,
1152 m_label.width(), m_label.height());
1153 1099
1100 render(m_label_face.color[UNFOCUS], m_label_face.pm[UNFOCUS], m_label.width(), m_label.height(),
1101 uft->iconbarTheme()->texture(), m_imagectrl);
1154} 1102}
1155 1103
1156void FbWinFrame::renderTabContainer() { 1104void FbWinFrame::renderTabContainer() {
@@ -1159,21 +1107,23 @@ void FbWinFrame::renderTabContainer() {
1159 return; 1107 return;
1160 } 1108 }
1161 1109
1162 const FbTk::Texture *tc_focused = &theme().focusedTheme()->iconbarTheme()->texture(); 1110 typedef FbTk::ThemeProxy<FbWinFrameTheme> TP;
1163 const FbTk::Texture *tc_unfocused = &theme().unfocusedTheme()->iconbarTheme()->texture(); 1111 TP& ft = theme().focusedTheme();
1112 TP& uft = theme().unfocusedTheme();
1113 FbTk::Container& tabs = tabcontainer();
1114 const FbTk::Texture *tc_focused = &ft->iconbarTheme()->texture();
1115 const FbTk::Texture *tc_unfocused = &uft->iconbarTheme()->texture();
1164 1116
1165 if (m_tabmode == EXTERNAL && tc_focused->type() & FbTk::Texture::PARENTRELATIVE) 1117 if (m_tabmode == EXTERNAL && tc_focused->type() & FbTk::Texture::PARENTRELATIVE)
1166 tc_focused = &theme().focusedTheme()->titleTexture(); 1118 tc_focused = &ft->titleTexture();
1167 if (m_tabmode == EXTERNAL && tc_unfocused->type() & FbTk::Texture::PARENTRELATIVE) 1119 if (m_tabmode == EXTERNAL && tc_unfocused->type() & FbTk::Texture::PARENTRELATIVE)
1168 tc_unfocused = &theme().unfocusedTheme()->titleTexture(); 1120 tc_unfocused = &uft->titleTexture();
1169 1121
1170 render(*tc_focused, m_tabcontainer_focused_color, 1122 render(m_tabcontainer_face.color[FOCUS], m_tabcontainer_face.pm[FOCUS],
1171 m_tabcontainer_focused_pm, 1123 tabs.width(), tabs.height(), *tc_focused, m_imagectrl, tabs.orientation());
1172 m_tab_container.width(), m_tab_container.height(), m_tab_container.orientation());
1173 1124
1174 render(*tc_unfocused, m_tabcontainer_unfocused_color, 1125 render(m_tabcontainer_face.color[UNFOCUS], m_tabcontainer_face.pm[UNFOCUS],
1175 m_tabcontainer_unfocused_pm, 1126 tabs.width(), tabs.height(), *tc_unfocused, m_imagectrl, tabs.orientation());
1176 m_tab_container.width(), m_tab_container.height(), m_tab_container.orientation());
1177 1127
1178 renderButtons(); 1128 renderButtons();
1179 1129
@@ -1181,15 +1131,8 @@ void FbWinFrame::renderTabContainer() {
1181 1131
1182void FbWinFrame::applyTitlebar() { 1132void FbWinFrame::applyTitlebar() {
1183 1133
1184 // set up pixmaps for titlebar windows 1134 int f = m_state.focused;
1185 Pixmap label_pm = None; 1135 int alpha = getAlpha(f);
1186 Pixmap title_pm = None;
1187 FbTk::Color label_color;
1188 FbTk::Color title_color;
1189 getCurrentFocusPixmap(label_pm, title_pm,
1190 label_color, title_color);
1191
1192 int alpha = getAlpha (m_state.focused);
1193 m_titlebar.setAlpha(alpha); 1136 m_titlebar.setAlpha(alpha);
1194 m_label.setAlpha(alpha); 1137 m_label.setAlpha(alpha);
1195 1138
@@ -1197,17 +1140,10 @@ void FbWinFrame::applyTitlebar() {
1197 m_label.setGC(theme()->iconbarTheme()->text().textGC()); 1140 m_label.setGC(theme()->iconbarTheme()->text().textGC());
1198 m_label.setJustify(theme()->iconbarTheme()->text().justify()); 1141 m_label.setJustify(theme()->iconbarTheme()->text().justify());
1199 1142
1200 if (label_pm != 0) 1143 bg_pm_or_color(m_label, m_label_face.pm[f], m_label_face.color[f]);
1201 m_label.setBackgroundPixmap(label_pm);
1202 else
1203 m_label.setBackgroundColor(label_color);
1204 } 1144 }
1205 1145
1206 if (title_pm != 0) 1146 bg_pm_or_color(m_titlebar, m_title_face.pm[f], m_title_face.color[f]);
1207 m_titlebar.setBackgroundPixmap(title_pm);
1208 else
1209 m_titlebar.setBackgroundColor(title_color);
1210
1211 applyButtons(); 1147 applyButtons();
1212} 1148}
1213 1149
@@ -1221,64 +1157,39 @@ void FbWinFrame::renderHandles() {
1221 return; 1157 return;
1222 } 1158 }
1223 1159
1224 render(theme().focusedTheme()->handleTexture(), m_handle_focused_color, 1160 typedef FbTk::ThemeProxy<FbWinFrameTheme> TP;
1225 m_handle_focused_pm, 1161 TP& ft = theme().focusedTheme();
1226 m_handle.width(), m_handle.height()); 1162 TP& uft = theme().unfocusedTheme();
1227 1163
1228 render(theme().unfocusedTheme()->handleTexture(), m_handle_unfocused_color, 1164 render(m_handle_face.color[FOCUS], m_handle_face.pm[FOCUS],
1229 m_handle_unfocused_pm, 1165 m_handle.width(), m_handle.height(),
1230 m_handle.width(), m_handle.height()); 1166 ft->handleTexture(), m_imagectrl);
1231 1167
1232 render(theme().focusedTheme()->gripTexture(), m_grip_focused_color, 1168 render(m_handle_face.color[UNFOCUS], m_handle_face.pm[UNFOCUS],
1233 m_grip_focused_pm, 1169 m_handle.width(), m_handle.height(),
1234 m_grip_left.width(), m_grip_left.height()); 1170 uft->handleTexture(), m_imagectrl);
1235 1171
1236 render(theme().unfocusedTheme()->gripTexture(), m_grip_unfocused_color, 1172 render(m_grip_face.color[FOCUS], m_grip_face.pm[FOCUS],
1237 m_grip_unfocused_pm, 1173 m_grip_left.width(), m_grip_left.height(),
1238 m_grip_left.width(), m_grip_left.height()); 1174 ft->handleTexture(), m_imagectrl);
1239 1175
1176 render(m_grip_face.color[UNFOCUS], m_grip_face.pm[UNFOCUS],
1177 m_grip_left.width(), m_grip_left.height(),
1178 uft->handleTexture(), m_imagectrl);
1240} 1179}
1241 1180
1242void FbWinFrame::applyHandles() { 1181void FbWinFrame::applyHandles() {
1243 1182
1183 bool f = m_state.focused;
1244 int alpha = getAlpha(m_state.focused); 1184 int alpha = getAlpha(m_state.focused);
1185
1245 m_handle.setAlpha(alpha); 1186 m_handle.setAlpha(alpha);
1187 bg_pm_or_color(m_handle, m_handle_face.pm[f], m_handle_face.color[f]);
1188
1246 m_grip_left.setAlpha(alpha); 1189 m_grip_left.setAlpha(alpha);
1247 m_grip_right.setAlpha(alpha); 1190 m_grip_right.setAlpha(alpha);
1248 1191 bg_pm_or_color(m_grip_left, m_grip_face.pm[f], m_grip_face.color[f]);
1249 if (m_state.focused) { 1192 bg_pm_or_color(m_grip_right, m_grip_face.pm[f], m_grip_face.color[f]);
1250
1251 if (m_handle_focused_pm) {
1252 m_handle.setBackgroundPixmap(m_handle_focused_pm);
1253 } else {
1254 m_handle.setBackgroundColor(m_handle_focused_color);
1255 }
1256
1257 if (m_grip_focused_pm) {
1258 m_grip_left.setBackgroundPixmap(m_grip_focused_pm);
1259 m_grip_right.setBackgroundPixmap(m_grip_focused_pm);
1260 } else {
1261 m_grip_left.setBackgroundColor(m_grip_focused_color);
1262 m_grip_right.setBackgroundColor(m_grip_focused_color);
1263 }
1264
1265 } else {
1266
1267 if (m_handle_unfocused_pm) {
1268 m_handle.setBackgroundPixmap(m_handle_unfocused_pm);
1269 } else {
1270 m_handle.setBackgroundColor(m_handle_unfocused_color);
1271 }
1272
1273 if (m_grip_unfocused_pm) {
1274 m_grip_left.setBackgroundPixmap(m_grip_unfocused_pm);
1275 m_grip_right.setBackgroundPixmap(m_grip_unfocused_pm);
1276 } else {
1277 m_grip_left.setBackgroundColor(m_grip_unfocused_color);
1278 m_grip_right.setBackgroundColor(m_grip_unfocused_color);
1279 }
1280 }
1281
1282} 1193}
1283 1194
1284void FbWinFrame::renderButtons() { 1195void FbWinFrame::renderButtons() {
@@ -1288,17 +1199,22 @@ void FbWinFrame::renderButtons() {
1288 return; 1199 return;
1289 } 1200 }
1290 1201
1291 render(theme().focusedTheme()->buttonTexture(), m_button_color, 1202 typedef FbTk::ThemeProxy<FbWinFrameTheme> TP;
1292 m_button_pm, 1203 TP& ft = theme().focusedTheme();
1293 m_button_size, m_button_size); 1204 TP& uft = theme().unfocusedTheme();
1205
1206 render(m_button_face.color[UNFOCUS], m_button_face.pm[UNFOCUS],
1207 m_button_size, m_button_size,
1208 uft->buttonTexture(), m_imagectrl);
1209
1210 render(m_button_face.color[FOCUS], m_button_face.pm[FOCUS],
1211 m_button_size, m_button_size,
1212 ft->buttonTexture(), m_imagectrl);
1294 1213
1295 render(theme().unfocusedTheme()->buttonTexture(), m_button_unfocused_color, 1214 render(m_button_face.color[PRESSED], m_button_face.pm[PRESSED],
1296 m_button_unfocused_pm, 1215 m_button_size, m_button_size,
1297 m_button_size, m_button_size); 1216 theme()->buttonPressedTexture(), m_imagectrl);
1298 1217
1299 render(theme()->buttonPressedTexture(), m_button_pressed_color,
1300 m_button_pressed_pm,
1301 m_button_size, m_button_size);
1302} 1218}
1303 1219
1304void FbWinFrame::applyButtons() { 1220void FbWinFrame::applyButtons() {
@@ -1315,15 +1231,18 @@ void FbWinFrame::init() {
1315 if (theme()->handleWidth() == 0) 1231 if (theme()->handleWidth() == 0)
1316 m_use_handle = false; 1232 m_use_handle = false;
1317 1233
1234 m_alpha[UNFOCUS] = theme().unfocusedTheme()->alpha();
1235 m_alpha[FOCUS] = theme().focusedTheme()->alpha();
1236
1318 m_handle.showSubwindows(); 1237 m_handle.showSubwindows();
1319 1238
1320 // clear pixmaps 1239 // clear pixmaps
1321 m_title_focused_pm = m_title_unfocused_pm = 0; 1240 m_title_face.pm[UNFOCUS] = m_title_face.pm[FOCUS] = 0;
1322 m_label_focused_pm = m_label_unfocused_pm = 0; 1241 m_label_face.pm[UNFOCUS] = m_label_face.pm[FOCUS] = 0;
1323 m_tabcontainer_focused_pm = m_tabcontainer_unfocused_pm = 0; 1242 m_tabcontainer_face.pm[UNFOCUS] = m_tabcontainer_face.pm[FOCUS] = 0;
1324 m_handle_focused_pm = m_handle_unfocused_pm = 0; 1243 m_handle_face.pm[UNFOCUS] = m_handle_face.pm[FOCUS] = 0;
1325 m_button_pm = m_button_unfocused_pm = m_button_pressed_pm = 0; 1244 m_button_face.pm[UNFOCUS] = m_button_face.pm[FOCUS] = m_button_face.pm[PRESSED] = 0;
1326 m_grip_unfocused_pm = m_grip_focused_pm = 0; 1245 m_grip_face.pm[UNFOCUS] = m_grip_face.pm[FOCUS] = 0;
1327 1246
1328 m_button_size = 26; 1247 m_button_size = 26;
1329 1248
@@ -1351,84 +1270,28 @@ void FbWinFrame::init() {
1351 Setups upp background, pressed pixmap/color of the button to current theme 1270 Setups upp background, pressed pixmap/color of the button to current theme
1352*/ 1271*/
1353void FbWinFrame::applyButton(FbTk::Button &btn) { 1272void FbWinFrame::applyButton(FbTk::Button &btn) {
1354 if (m_button_pressed_pm)
1355 btn.setPressedPixmap(m_button_pressed_pm);
1356 else
1357 btn.setPressedColor(m_button_pressed_color);
1358 1273
1359 Pixmap pm = m_state.focused ? m_button_pm : m_button_unfocused_pm; 1274 if (m_button_face.pm[PRESSED]) {
1360 btn.setAlpha(getAlpha(m_state.focused)); 1275 btn.setPressedPixmap(m_button_face.pm[PRESSED]);
1361 btn.setGC(theme()->buttonPicGC());
1362 if (pm)
1363 btn.setBackgroundPixmap(pm);
1364 else
1365 btn.setBackgroundColor(m_state.focused ? m_button_color
1366 : m_button_unfocused_color);
1367}
1368
1369void FbWinFrame::render(const FbTk::Texture &tex, FbTk::Color &col, Pixmap &pm,
1370 unsigned int w, unsigned int h, FbTk::Orientation orient) {
1371
1372 Pixmap tmp = pm;
1373 if (!tex.usePixmap()) {
1374 pm = None;
1375 col = tex.color();
1376 } else { 1276 } else {
1377 pm = m_imagectrl.renderImage(w, h, tex, orient); 1277 btn.setPressedColor(m_button_face.color[PRESSED]);
1378 } 1278 }
1379 1279
1380 if (tmp) 1280 bool f = m_state.focused;
1381 m_imagectrl.removeImage(tmp);
1382
1383}
1384
1385void FbWinFrame::getCurrentFocusPixmap(Pixmap &label_pm, Pixmap &title_pm,
1386 FbTk::Color &label_color, FbTk::Color &title_color) {
1387 if (m_state.focused) {
1388 if (m_label_focused_pm != 0)
1389 label_pm = m_label_focused_pm;
1390 else
1391 label_color = m_label_focused_color;
1392 1281
1393 if (m_title_focused_pm != 0) 1282 btn.setAlpha(getAlpha(f));
1394 title_pm = m_title_focused_pm; 1283 btn.setGC(theme()->buttonPicGC());
1395 else
1396 title_color = m_title_focused_color;
1397 } else {
1398 if (m_label_unfocused_pm != 0)
1399 label_pm = m_label_unfocused_pm;
1400 else
1401 label_color = m_label_unfocused_color;
1402 1284
1403 if (m_title_unfocused_pm != 0) 1285 bg_pm_or_color(btn, m_button_face.pm[f], m_button_face.color[f]);
1404 title_pm = m_title_unfocused_pm;
1405 else
1406 title_color = m_title_unfocused_color;
1407 }
1408} 1286}
1409 1287
1410void FbWinFrame::applyTabContainer() {
1411 m_tab_container.setAlpha(getAlpha(m_state.focused));
1412 1288
1413 // do the parent container 1289void FbWinFrame::applyTabContainer() {
1414 Pixmap tabcontainer_pm = None;
1415 FbTk::Color *tabcontainer_color = NULL;
1416 if (m_state.focused) {
1417 if (m_tabcontainer_focused_pm != 0)
1418 tabcontainer_pm = m_tabcontainer_focused_pm;
1419 else
1420 tabcontainer_color = &m_tabcontainer_focused_color;
1421 } else {
1422 if (m_tabcontainer_unfocused_pm != 0)
1423 tabcontainer_pm = m_tabcontainer_unfocused_pm;
1424 else
1425 tabcontainer_color = &m_tabcontainer_unfocused_color;
1426 }
1427 1290
1428 if (tabcontainer_pm != 0) 1291 m_tab_container.setAlpha(getAlpha(m_state.focused));
1429 m_tab_container.setBackgroundPixmap(tabcontainer_pm); 1292 bg_pm_or_color(m_tab_container,
1430 else 1293 m_tabcontainer_face.pm[m_state.focused],
1431 m_tab_container.setBackgroundColor(*tabcontainer_color); 1294 m_tabcontainer_face.color[m_state.focused]);
1432 1295
1433 // and the labelbuttons in it 1296 // and the labelbuttons in it
1434 FbTk::Container::ItemList::iterator btn_it = m_tab_container.begin(); 1297 FbTk::Container::ItemList::iterator btn_it = m_tab_container.begin();
@@ -1641,54 +1504,28 @@ void FbWinFrame::gravityTranslate(int &x, int &y,
1641int FbWinFrame::widthOffset() const { 1504int FbWinFrame::widthOffset() const {
1642 if (m_tabmode != EXTERNAL || !m_use_tabs) 1505 if (m_tabmode != EXTERNAL || !m_use_tabs)
1643 return 0; 1506 return 0;
1644 1507 if (_values[m_screen.getTabPlacement()].is_horizontal) {
1645 // same height offset for top and bottom tabs 1508 return 0;
1646 switch (m_screen.getTabPlacement()) {
1647 case LEFTTOP:
1648 case RIGHTTOP:
1649 case LEFT:
1650 case RIGHT:
1651 case LEFTBOTTOM:
1652 case RIGHTBOTTOM:
1653 return m_tab_container.width() + m_window.borderWidth();
1654 break;
1655 default: // kill warning
1656 break;
1657 } 1509 }
1658 return 0; 1510 return m_tab_container.width() + m_window.borderWidth();
1659} 1511}
1660 1512
1661int FbWinFrame::heightOffset() const { 1513int FbWinFrame::heightOffset() const {
1662 if (m_tabmode != EXTERNAL || !m_use_tabs) 1514 if (m_tabmode != EXTERNAL || !m_use_tabs)
1663 return 0; 1515 return 0;
1664 1516
1665 switch (m_screen.getTabPlacement()) { 1517 if (!_values[m_screen.getTabPlacement()].is_horizontal) {
1666 case TOPLEFT: 1518 return 0;
1667 case TOP:
1668 case TOPRIGHT:
1669 case BOTTOMLEFT:
1670 case BOTTOM:
1671 case BOTTOMRIGHT:
1672 return m_tab_container.height() + m_window.borderWidth();
1673 break;
1674 default: // kill warning
1675 break;
1676 } 1519 }
1677 return 0; 1520 return m_tab_container.height() + m_window.borderWidth();
1678} 1521}
1679 1522
1680int FbWinFrame::xOffset() const { 1523int FbWinFrame::xOffset() const {
1681 if (m_tabmode != EXTERNAL || !m_use_tabs) 1524 if (m_tabmode != EXTERNAL || !m_use_tabs)
1682 return 0; 1525 return 0;
1683 1526 TabPlacement p = m_screen.getTabPlacement();
1684 switch (m_screen.getTabPlacement()) { 1527 if (p == LEFTTOP || p == LEFT || p == LEFTBOTTOM) {
1685 case LEFTTOP:
1686 case LEFT:
1687 case LEFTBOTTOM:
1688 return m_tab_container.width() + m_window.borderWidth(); 1528 return m_tab_container.width() + m_window.borderWidth();
1689 break;
1690 default: // kill warning
1691 break;
1692 } 1529 }
1693 return 0; 1530 return 0;
1694} 1531}
@@ -1696,15 +1533,9 @@ int FbWinFrame::xOffset() const {
1696int FbWinFrame::yOffset() const { 1533int FbWinFrame::yOffset() const {
1697 if (m_tabmode != EXTERNAL || !m_use_tabs) 1534 if (m_tabmode != EXTERNAL || !m_use_tabs)
1698 return 0; 1535 return 0;
1699 1536 TabPlacement p = m_screen.getTabPlacement();
1700 switch (m_screen.getTabPlacement()) { 1537 if (p == TOPLEFT || p == TOP || p == TOPRIGHT) {
1701 case TOPLEFT:
1702 case TOP:
1703 case TOPRIGHT:
1704 return m_tab_container.height() + m_window.borderWidth(); 1538 return m_tab_container.height() + m_window.borderWidth();
1705 break;
1706 default: // kill warning
1707 break;
1708 } 1539 }
1709 return 0; 1540 return 0;
1710} 1541}
@@ -1725,7 +1556,7 @@ void FbWinFrame::displaySize(unsigned int width, unsigned int height) const {
1725} 1556}
1726 1557
1727bool FbWinFrame::insideTitlebar(Window win) const { 1558bool FbWinFrame::insideTitlebar(Window win) const {
1728 return 1559 return
1729 gripLeft().window() != win && 1560 gripLeft().window() != win &&
1730 gripRight().window() != win && 1561 gripRight().window() != win &&
1731 window().window() != win; 1562 window().window() != win;
@@ -1740,14 +1571,14 @@ int FbWinFrame::getContext(Window win, int x, int y, int last_x, int last_y, boo
1740 int borderw = window().borderWidth(); 1571 int borderw = window().borderWidth();
1741 if ( // if mouse is currently on the window border, ignore it 1572 if ( // if mouse is currently on the window border, ignore it
1742 ( 1573 (
1743 ! insideBorder(window(), x, y, borderw) 1574 ! insideBorder(window(), x, y, borderw)
1744 && ( externalTabMode() 1575 && ( externalTabMode()
1745 || ! insideBorder(tabcontainer(), x, y, borderw) ) 1576 || ! insideBorder(tabcontainer(), x, y, borderw) )
1746 ) 1577 )
1747 || // or if mouse was on border when it was last clicked 1578 || // or if mouse was on border when it was last clicked
1748 ( 1579 (
1749 ! insideBorder(window(), last_x, last_y, borderw) 1580 ! insideBorder(window(), last_x, last_y, borderw)
1750 && ( externalTabMode() 1581 && ( externalTabMode()
1751 || ! insideBorder(tabcontainer(), last_x, last_y, borderw ) ) 1582 || ! insideBorder(tabcontainer(), last_x, last_y, borderw ) )
1752 ) 1583 )
1753 ) context = Keys::ON_WINDOWBORDER; 1584 ) context = Keys::ON_WINDOWBORDER;
diff --git a/src/FbWinFrame.hh b/src/FbWinFrame.hh
index 46c6a7c..f8961c8 100644
--- a/src/FbWinFrame.hh
+++ b/src/FbWinFrame.hh
@@ -30,7 +30,6 @@
30#include "FbTk/Color.hh" 30#include "FbTk/Color.hh"
31#include "FbTk/LayerItem.hh" 31#include "FbTk/LayerItem.hh"
32#include "FbTk/TextButton.hh" 32#include "FbTk/TextButton.hh"
33#include "FbTk/DefaultValue.hh"
34#include "FbTk/Container.hh" 33#include "FbTk/Container.hh"
35#include "FbTk/Shape.hh" 34#include "FbTk/Shape.hh"
36#include "FbTk/Signal.hh" 35#include "FbTk/Signal.hh"
@@ -73,12 +72,6 @@ public:
73 FbWinFrame(BScreen &screen, unsigned int client_depth, WindowState &state, 72 FbWinFrame(BScreen &screen, unsigned int client_depth, WindowState &state,
74 FocusableTheme<FbWinFrameTheme> &theme); 73 FocusableTheme<FbWinFrameTheme> &theme);
75 74
76/* /// create a frame window inside another FbWindow, NOT IMPLEMENTED!
77 FbWinFrame(BScreen &screen, FbWinFrameTheme &theme, FbTk::ImageControl &imgctrl,
78 const FbTk::FbWindow &parent,
79 int x, int y,
80 unsigned int width, unsigned int height);
81*/
82 /// destroy frame 75 /// destroy frame
83 ~FbWinFrame(); 76 ~FbWinFrame();
84 77
@@ -119,8 +112,8 @@ public:
119 112
120 /// Alpha settings 113 /// Alpha settings
121 void setAlpha(bool focused, int value); 114 void setAlpha(bool focused, int value);
122 void applyAlpha();
123 int getAlpha(bool focused) const; 115 int getAlpha(bool focused) const;
116 void applyAlpha();
124 117
125 void setDefaultAlpha(); 118 void setDefaultAlpha();
126 bool getUseDefaultAlpha() const; 119 bool getUseDefaultAlpha() const;
@@ -258,10 +251,6 @@ private:
258 251
259 void renderButtons(); // subset of renderTitlebar - don't call directly 252 void renderButtons(); // subset of renderTitlebar - don't call directly
260 253
261 /// renders to pixmap or sets color
262 void render(const FbTk::Texture &tex, FbTk::Color &col, Pixmap &pm,
263 unsigned int width, unsigned int height, FbTk::Orientation orient = FbTk::ROT0);
264
265 //@} 254 //@}
266 255
267 // these return true/false for if something changed 256 // these return true/false for if something changed
@@ -286,8 +275,10 @@ private:
286 void applyTabContainer(); // and label buttons 275 void applyTabContainer(); // and label buttons
287 void applyButtons(); // only called within applyTitlebar 276 void applyButtons(); // only called within applyTitlebar
288 277
278#if 0
289 void getCurrentFocusPixmap(Pixmap &label_pm, Pixmap &title_pm, 279 void getCurrentFocusPixmap(Pixmap &label_pm, Pixmap &title_pm,
290 FbTk::Color &label_color, FbTk::Color &title_color); 280 FbTk::Color &label_color, FbTk::Color &title_color);
281#endif
291 282
292 /// initiate inserted button for current theme 283 /// initiate inserted button for current theme
293 void applyButton(FbTk::Button &btn); 284 void applyButton(FbTk::Button &btn);
@@ -338,36 +329,19 @@ private:
338 @name pixmaps and colors for rendering 329 @name pixmaps and colors for rendering
339 */ 330 */
340 //@{ 331 //@{
341 Pixmap m_title_focused_pm; ///< pixmap for focused title 332
342 FbTk::Color m_title_focused_color; ///< color for focused title 333 // 0-unfocus, 1-focus
343 Pixmap m_title_unfocused_pm; ///< pixmap for unfocused title 334 struct Face { Pixmap pm[2]; FbTk::Color color[2]; };
344 FbTk::Color m_title_unfocused_color; ///< color for unfocused title 335 // 0-unfocus, 1-focus, 2-pressed
345 336 struct BtnFace { Pixmap pm[3]; FbTk::Color color[3]; };
346 Pixmap m_label_focused_pm; ///< pixmap for focused label (only visible with external tabs) 337
347 FbTk::Color m_label_focused_color; ///< color for focused label 338 Face m_title_face;
348 Pixmap m_label_unfocused_pm; ///< pixmap for unfocused label 339 Face m_label_face;
349 FbTk::Color m_label_unfocused_color; ///< color for unfocused label 340 Face m_tabcontainer_face;
350 341 Face m_handle_face;
351 Pixmap m_tabcontainer_focused_pm; ///< pixmap for focused tab container 342 Face m_grip_face;
352 FbTk::Color m_tabcontainer_focused_color; ///< color for focused tab container 343 BtnFace m_button_face;
353 Pixmap m_tabcontainer_unfocused_pm; ///< pixmap for unfocused tab container 344
354 FbTk::Color m_tabcontainer_unfocused_color; ///< color for unfocused tab container
355
356 FbTk::Color m_handle_focused_color, m_handle_unfocused_color;
357 Pixmap m_handle_focused_pm, m_handle_unfocused_pm;
358
359
360 Pixmap m_button_pm; ///< normal button
361 FbTk::Color m_button_color; ///< normal color button
362 Pixmap m_button_unfocused_pm; ///< unfocused button
363 FbTk::Color m_button_unfocused_color; ///< unfocused color button
364 Pixmap m_button_pressed_pm; ///< pressed button
365 FbTk::Color m_button_pressed_color; ///< pressed button color
366
367 Pixmap m_grip_focused_pm;
368 FbTk::Color m_grip_focused_color; ///< if no pixmap is given for grip, use this color
369 Pixmap m_grip_unfocused_pm; ///< unfocused pixmap for grip
370 FbTk::Color m_grip_unfocused_color; ///< unfocused color for grip if no pixmap is given
371 //@} 345 //@}
372 346
373 TabMode m_tabmode; 347 TabMode m_tabmode;
@@ -376,10 +350,7 @@ private:
376 350
377 bool m_need_render; 351 bool m_need_render;
378 int m_button_size; ///< size for all titlebar buttons 352 int m_button_size; ///< size for all titlebar buttons
379 /// alpha values 353 int m_alpha[2]; // 0-unfocused, 1-focused
380 typedef FbTk::ConstObjectAccessor<int, FbWinFrameTheme> AlphaAcc;
381 FbTk::DefaultValue<int, AlphaAcc> m_focused_alpha;
382 FbTk::DefaultValue<int, AlphaAcc> m_unfocused_alpha;
383 354
384 FbTk::Shape m_shape; 355 FbTk::Shape m_shape;
385}; 356};