aboutsummaryrefslogtreecommitdiff
path: root/src/FbWinFrame.cc
diff options
context:
space:
mode:
authorsimonb <simonb>2007-01-07 11:55:14 (GMT)
committersimonb <simonb>2007-01-07 11:55:14 (GMT)
commit1cc7b60aa2c2e7a26f9ff6f1461ca0b8a97be8de (patch)
tree1de2b149b23e589a36c81bd2aa51092db7b6e190 /src/FbWinFrame.cc
parentcfd33dd7a8f392253d8af9f418d86dc3083fc27d (diff)
downloadfluxbox_pavel-1cc7b60aa2c2e7a26f9ff6f1461ca0b8a97be8de.zip
fluxbox_pavel-1cc7b60aa2c2e7a26f9ff6f1461ca0b8a97be8de.tar.bz2
per-window transparency, including apps and menu support, plus some
infrastructure and related changes. Thanks for original patch from Julien Trolet, dmxen at sourceforge dot net
Diffstat (limited to 'src/FbWinFrame.cc')
-rw-r--r--src/FbWinFrame.cc68
1 files changed, 56 insertions, 12 deletions
diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc
index e41d1df..5d191d0 100644
--- a/src/FbWinFrame.cc
+++ b/src/FbWinFrame.cc
@@ -83,6 +83,7 @@ FbWinFrame::FbWinFrame(BScreen &screen, FbWinFrameTheme &theme, FbTk::ImageContr
83 m_use_handle(true), 83 m_use_handle(true),
84 m_focused(false), 84 m_focused(false),
85 m_visible(false), 85 m_visible(false),
86 m_use_default_alpha(2),
86 m_button_pm(0), 87 m_button_pm(0),
87 m_tabmode(screen.getDefaultInternalTabs()?INTERNAL:EXTERNAL), 88 m_tabmode(screen.getDefaultInternalTabs()?INTERNAL:EXTERNAL),
88 m_active_gravity(0), 89 m_active_gravity(0),
@@ -91,6 +92,9 @@ FbWinFrame::FbWinFrame(BScreen &screen, FbWinFrameTheme &theme, FbTk::ImageContr
91 m_button_size(1), 92 m_button_size(1),
92 m_width_before_shade(1), 93 m_width_before_shade(1),
93 m_height_before_shade(1), 94 m_height_before_shade(1),
95 m_shaded(false),
96 m_focused_alpha(0),
97 m_unfocused_alpha(0),
94 m_double_click_time(0), 98 m_double_click_time(0),
95 m_themelistener(*this), 99 m_themelistener(*this),
96 m_shape(new Shape(m_window, theme.shapePlace())), 100 m_shape(new Shape(m_window, theme.shapePlace())),
@@ -443,7 +447,7 @@ void FbWinFrame::alignTabs() {
443 447
444void FbWinFrame::notifyMoved(bool clear) { 448void FbWinFrame::notifyMoved(bool clear) {
445 // not important if no alpha... 449 // not important if no alpha...
446 unsigned char alpha = (m_focused?theme().focusedAlpha():theme().unfocusedAlpha()); 450 unsigned char alpha = getAlpha(m_focused);
447 if (alpha == 255) 451 if (alpha == 255)
448 return; 452 return;
449 453
@@ -505,8 +509,8 @@ void FbWinFrame::setFocus(bool newvalue) {
505 509
506 m_focused = newvalue; 510 m_focused = newvalue;
507 511
508 if (FbTk::Transparent::haveRender() && theme().focusedAlpha() != theme().unfocusedAlpha()) { 512 if (FbTk::Transparent::haveRender() && getAlpha(true) != getAlpha(false)) { // different alpha for focused and unfocused
509 unsigned char alpha = (m_focused?theme().focusedAlpha():theme().unfocusedAlpha()); 513 unsigned char alpha = getAlpha(m_focused);
510 if (FbTk::Transparent::haveComposite()) { 514 if (FbTk::Transparent::haveComposite()) {
511 m_tab_container.setAlpha(255); 515 m_tab_container.setAlpha(255);
512 m_window.setOpaque(alpha); 516 m_window.setOpaque(alpha);
@@ -527,6 +531,46 @@ void FbWinFrame::setFocus(bool newvalue) {
527 clearAll(); 531 clearAll();
528} 532}
529 533
534void FbWinFrame::setAlpha(bool focused, unsigned char alpha) {
535 if (m_use_default_alpha == 2)
536 {
537 /// Set basic defaults
538 m_focused_alpha = getAlpha(true);
539 m_unfocused_alpha = getAlpha(false);
540 }
541 m_use_default_alpha = 0;
542
543 if (focused)
544 m_focused_alpha = alpha;
545 else
546 m_unfocused_alpha = alpha;
547
548 if(m_focused == focused)
549 m_window.setOpaque(alpha);
550}
551
552unsigned char FbWinFrame::getAlpha(bool focused) const
553{
554 return getUseDefaultAlpha() ?
555 (focused ? theme().focusedAlpha() : theme().unfocusedAlpha())
556 : (focused ? m_focused_alpha : m_unfocused_alpha);
557}
558
559void FbWinFrame::setUseDefaultAlpha(bool default_alpha)
560{
561 if (getUseDefaultAlpha() == default_alpha)
562 return;
563
564 if (!default_alpha && m_use_default_alpha == 2) {
565 m_focused_alpha = theme().focusedAlpha();
566 m_unfocused_alpha = theme().unfocusedAlpha();
567 }
568
569 m_use_default_alpha = default_alpha;
570
571 m_window.setOpaque(getAlpha(m_focused));
572}
573
530void FbWinFrame::setDoubleClickTime(unsigned int time) { 574void FbWinFrame::setDoubleClickTime(unsigned int time) {
531 m_double_click_time = time; 575 m_double_click_time = time;
532} 576}
@@ -1056,7 +1100,7 @@ void FbWinFrame::reconfigure() {
1056 // update transparency settings 1100 // update transparency settings
1057 if (FbTk::Transparent::haveRender()) { 1101 if (FbTk::Transparent::haveRender()) {
1058 unsigned char alpha = 1102 unsigned char alpha =
1059 (m_focused ? theme().focusedAlpha() : theme().unfocusedAlpha()); 1103 getAlpha(m_focused);
1060 if (FbTk::Transparent::haveComposite()) { 1104 if (FbTk::Transparent::haveComposite()) {
1061 m_tab_container.setAlpha(255); 1105 m_tab_container.setAlpha(255);
1062 m_window.setOpaque(alpha); 1106 m_window.setOpaque(alpha);
@@ -1281,7 +1325,7 @@ void FbWinFrame::applyTitlebar() {
1281 getCurrentFocusPixmap(label_pm, title_pm, 1325 getCurrentFocusPixmap(label_pm, title_pm,
1282 label_color, title_color); 1326 label_color, title_color);
1283 1327
1284 unsigned char alpha = (m_focused?theme().focusedAlpha():theme().unfocusedAlpha()); 1328 unsigned char alpha = getAlpha (m_focused);
1285 m_titlebar.setAlpha(alpha); 1329 m_titlebar.setAlpha(alpha);
1286 m_label.setAlpha(alpha); 1330 m_label.setAlpha(alpha);
1287 1331
@@ -1332,7 +1376,7 @@ void FbWinFrame::renderHandles() {
1332 1376
1333void FbWinFrame::applyHandles() { 1377void FbWinFrame::applyHandles() {
1334 1378
1335 unsigned char alpha = (m_focused?theme().focusedAlpha():theme().unfocusedAlpha()); 1379 unsigned char alpha = getAlpha (m_focused);
1336 m_handle.setAlpha(alpha); 1380 m_handle.setAlpha(alpha);
1337 m_grip_left.setAlpha(alpha); 1381 m_grip_left.setAlpha(alpha);
1338 m_grip_right.setAlpha(alpha); 1382 m_grip_right.setAlpha(alpha);
@@ -1452,7 +1496,7 @@ void FbWinFrame::applyButton(FbTk::Button &btn) {
1452 btn.setPressedColor(m_button_pressed_color); 1496 btn.setPressedColor(m_button_pressed_color);
1453 1497
1454 if (focused()) { // focused 1498 if (focused()) { // focused
1455 btn.setAlpha(theme().focusedAlpha()); 1499 btn.setAlpha(getAlpha(true));
1456 1500
1457 btn.setGC(m_theme.buttonPicFocusGC()); 1501 btn.setGC(m_theme.buttonPicFocusGC());
1458 if (m_button_pm) 1502 if (m_button_pm)
@@ -1460,7 +1504,7 @@ void FbWinFrame::applyButton(FbTk::Button &btn) {
1460 else 1504 else
1461 btn.setBackgroundColor(m_button_color); 1505 btn.setBackgroundColor(m_button_color);
1462 } else { // unfocused 1506 } else { // unfocused
1463 btn.setAlpha(theme().unfocusedAlpha()); 1507 btn.setAlpha(getAlpha(false));
1464 1508
1465 btn.setGC(m_theme.buttonPicUnfocusGC()); 1509 btn.setGC(m_theme.buttonPicUnfocusGC());
1466 if (m_button_unfocused_pm) 1510 if (m_button_unfocused_pm)
@@ -1513,7 +1557,7 @@ void FbWinFrame::getCurrentFocusPixmap(Pixmap &label_pm, Pixmap &title_pm,
1513} 1557}
1514 1558
1515void FbWinFrame::applyTabContainer() { 1559void FbWinFrame::applyTabContainer() {
1516 m_tab_container.setAlpha(m_focused?theme().focusedAlpha():theme().unfocusedAlpha()); 1560 m_tab_container.setAlpha(getAlpha(m_focused));
1517 1561
1518 // do the parent container 1562 // do the parent container
1519 Pixmap tabcontainer_pm = None; 1563 Pixmap tabcontainer_pm = None;
@@ -1608,7 +1652,7 @@ void FbWinFrame::applyFocusLabel(FbTk::TextButton &button) {
1608 1652
1609 button.setGC(theme().labelTextFocusGC()); 1653 button.setGC(theme().labelTextFocusGC());
1610 button.setJustify(theme().justify()); 1654 button.setJustify(theme().justify());
1611 button.setAlpha(m_focused?theme().focusedAlpha():theme().unfocusedAlpha()); 1655 button.setAlpha(getAlpha(m_focused));
1612 1656
1613 if (m_labelbutton_focused_pm != 0) { 1657 if (m_labelbutton_focused_pm != 0) {
1614 button.setBackgroundPixmap(m_labelbutton_focused_pm); 1658 button.setBackgroundPixmap(m_labelbutton_focused_pm);
@@ -1621,7 +1665,7 @@ void FbWinFrame::applyActiveLabel(FbTk::TextButton &button) {
1621 1665
1622 button.setGC(theme().labelTextActiveGC()); 1666 button.setGC(theme().labelTextActiveGC());
1623 button.setJustify(theme().justify()); 1667 button.setJustify(theme().justify());
1624 button.setAlpha(m_focused?theme().focusedAlpha():theme().unfocusedAlpha()); 1668 button.setAlpha(getAlpha(m_focused));
1625 1669
1626 if (m_labelbutton_active_pm != 0) { 1670 if (m_labelbutton_active_pm != 0) {
1627 button.setBackgroundPixmap(m_labelbutton_active_pm); 1671 button.setBackgroundPixmap(m_labelbutton_active_pm);
@@ -1634,7 +1678,7 @@ void FbWinFrame::applyUnfocusLabel(FbTk::TextButton &button) {
1634 1678
1635 button.setGC(theme().labelTextUnfocusGC()); 1679 button.setGC(theme().labelTextUnfocusGC());
1636 button.setJustify(theme().justify()); 1680 button.setJustify(theme().justify());
1637 button.setAlpha(m_focused?theme().focusedAlpha():theme().unfocusedAlpha()); 1681 button.setAlpha(getAlpha(m_focused));
1638 1682
1639 if (m_labelbutton_unfocused_pm != 0) { 1683 if (m_labelbutton_unfocused_pm != 0) {
1640 button.setBackgroundPixmap(m_labelbutton_unfocused_pm); 1684 button.setBackgroundPixmap(m_labelbutton_unfocused_pm);