diff options
author | Mark Tiefenbruck <mark@fluxbox.org> | 2007-12-27 04:42:10 (GMT) |
---|---|---|
committer | Mark Tiefenbruck <mark@fluxbox.org> | 2007-12-27 04:42:10 (GMT) |
commit | 1f5cd12facc662de240b36bf3c5c14f40adf391b (patch) | |
tree | d468908abf2e988265b0c2295dbd265d82ef89b6 /src/FbWinFrame.cc | |
parent | f5024351e79e92d551d561e9756f0869e51af505 (diff) | |
download | fluxbox_pavel-1f5cd12facc662de240b36bf3c5c14f40adf391b.zip fluxbox_pavel-1f5cd12facc662de240b36bf3c5c14f40adf391b.tar.bz2 |
simplify the window transparency menu and handling a bit
Diffstat (limited to 'src/FbWinFrame.cc')
-rw-r--r-- | src/FbWinFrame.cc | 62 |
1 files changed, 23 insertions, 39 deletions
diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc index e96b72f..a0de468 100644 --- a/src/FbWinFrame.cc +++ b/src/FbWinFrame.cc | |||
@@ -87,7 +87,6 @@ FbWinFrame::FbWinFrame(BScreen &screen, FbWinFrameTheme &theme, FbTk::ImageContr | |||
87 | m_use_handle(true), | 87 | m_use_handle(true), |
88 | m_focused(false), | 88 | m_focused(false), |
89 | m_visible(false), | 89 | m_visible(false), |
90 | m_use_default_alpha(2), | ||
91 | m_button_pm(0), | 90 | m_button_pm(0), |
92 | m_tabmode(screen.getDefaultInternalTabs()?INTERNAL:EXTERNAL), | 91 | m_tabmode(screen.getDefaultInternalTabs()?INTERNAL:EXTERNAL), |
93 | m_active_gravity(0), | 92 | m_active_gravity(0), |
@@ -96,8 +95,8 @@ FbWinFrame::FbWinFrame(BScreen &screen, FbWinFrameTheme &theme, FbTk::ImageContr | |||
96 | m_button_size(1), | 95 | m_button_size(1), |
97 | m_height_before_shade(1), | 96 | m_height_before_shade(1), |
98 | m_shaded(false), | 97 | m_shaded(false), |
99 | m_focused_alpha(0), | 98 | m_focused_alpha(theme, &FbWinFrameTheme::focusedAlpha), |
100 | m_unfocused_alpha(0), | 99 | m_unfocused_alpha(theme, &FbWinFrameTheme::unfocusedAlpha), |
101 | m_themelistener(*this), | 100 | m_themelistener(*this), |
102 | m_shape(m_window, theme.shapePlace()), | 101 | m_shape(m_window, theme.shapePlace()), |
103 | m_disable_themeshape(false) { | 102 | m_disable_themeshape(false) { |
@@ -509,50 +508,19 @@ void FbWinFrame::setFocus(bool newvalue) { | |||
509 | } | 508 | } |
510 | 509 | ||
511 | void FbWinFrame::setAlpha(bool focused, unsigned char alpha) { | 510 | void FbWinFrame::setAlpha(bool focused, unsigned char alpha) { |
512 | if (m_use_default_alpha == 2) { | ||
513 | /// Set basic defaults | ||
514 | m_focused_alpha = getAlpha(true); | ||
515 | m_unfocused_alpha = getAlpha(false); | ||
516 | } | ||
517 | m_use_default_alpha = 0; | ||
518 | |||
519 | if (focused) | 511 | if (focused) |
520 | m_focused_alpha = alpha; | 512 | m_focused_alpha = alpha; |
521 | else | 513 | else |
522 | m_unfocused_alpha = alpha; | 514 | m_unfocused_alpha = alpha; |
523 | 515 | ||
524 | if (m_focused == focused) { | 516 | if (m_focused == focused) |
525 | if (FbTk::Transparent::haveComposite()) | 517 | applyAlpha(); |
526 | m_window.setOpaque(alpha); | ||
527 | else { | ||
528 | // don't need to setAlpha, since apply updates them anyway | ||
529 | applyAll(); | ||
530 | clearAll(); | ||
531 | } | ||
532 | } | ||
533 | } | 518 | } |
534 | 519 | ||
535 | unsigned char FbWinFrame::getAlpha(bool focused) const | 520 | void FbWinFrame::applyAlpha() { |
536 | { | 521 | unsigned char alpha = getAlpha(m_focused); |
537 | return getUseDefaultAlpha() ? | ||
538 | (focused ? theme().focusedAlpha() : theme().unfocusedAlpha()) | ||
539 | : (focused ? m_focused_alpha : m_unfocused_alpha); | ||
540 | } | ||
541 | |||
542 | void FbWinFrame::setUseDefaultAlpha(bool default_alpha) | ||
543 | { | ||
544 | if (getUseDefaultAlpha() == default_alpha) | ||
545 | return; | ||
546 | |||
547 | if (!default_alpha && m_use_default_alpha == 2) { | ||
548 | m_focused_alpha = theme().focusedAlpha(); | ||
549 | m_unfocused_alpha = theme().unfocusedAlpha(); | ||
550 | } | ||
551 | |||
552 | m_use_default_alpha = default_alpha; | ||
553 | |||
554 | if (FbTk::Transparent::haveComposite()) | 522 | if (FbTk::Transparent::haveComposite()) |
555 | m_window.setOpaque(getAlpha(m_focused)); | 523 | m_window.setOpaque(alpha); |
556 | else { | 524 | else { |
557 | // don't need to setAlpha, since apply updates them anyway | 525 | // don't need to setAlpha, since apply updates them anyway |
558 | applyAll(); | 526 | applyAll(); |
@@ -560,6 +528,22 @@ void FbWinFrame::setUseDefaultAlpha(bool default_alpha) | |||
560 | } | 528 | } |
561 | } | 529 | } |
562 | 530 | ||
531 | unsigned char FbWinFrame::getAlpha(bool focused) const { | ||
532 | return focused ? m_focused_alpha : m_unfocused_alpha; | ||
533 | } | ||
534 | |||
535 | void FbWinFrame::setDefaultAlpha() { | ||
536 | if (getUseDefaultAlpha()) | ||
537 | return; | ||
538 | m_focused_alpha.restoreDefault(); | ||
539 | m_unfocused_alpha.restoreDefault(); | ||
540 | applyAlpha(); | ||
541 | } | ||
542 | |||
543 | bool FbWinFrame::getUseDefaultAlpha() const { | ||
544 | return m_focused_alpha.isDefault() && m_unfocused_alpha.isDefault(); | ||
545 | } | ||
546 | |||
563 | void FbWinFrame::addLeftButton(FbTk::Button *btn) { | 547 | void FbWinFrame::addLeftButton(FbTk::Button *btn) { |
564 | if (btn == 0) // valid button? | 548 | if (btn == 0) // valid button? |
565 | return; | 549 | return; |