aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrathnor <rathnor>2004-08-27 14:14:42 (GMT)
committerrathnor <rathnor>2004-08-27 14:14:42 (GMT)
commitf2599d87f61ac4d2028698195024e082ed6f513a (patch)
tree5615c94f2b11262d26be54d573efaecde35246ee
parent6ce5a31ea8bb6dbf6f64260c62d9af153e9d7f30 (diff)
downloadfluxbox-f2599d87f61ac4d2028698195024e082ed6f513a.zip
fluxbox-f2599d87f61ac4d2028698195024e082ed6f513a.tar.bz2
add a special fallback for toolbar button style
-rw-r--r--ChangeLog3
-rw-r--r--src/ButtonTheme.cc32
-rw-r--r--src/ButtonTheme.hh9
-rw-r--r--src/ToolFactory.cc5
4 files changed, 43 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 1b84dbb..6627169 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
1(Format: Year/Month/Day) 1(Format: Year/Month/Day)
2Changes for 0.9.10: 2Changes for 0.9.10:
3*04/08/27:
4 * Improve fallback if toolbar button style item missing (Simon)
5 ButtonTheme.hh/cc ToolFactory.cc
3*04/08/26: 6*04/08/26:
4 * Tiny unification (Mathias) 7 * Tiny unification (Mathias)
5 - theme.cfg and style.cfg allowed 8 - theme.cfg and style.cfg allowed
diff --git a/src/ButtonTheme.cc b/src/ButtonTheme.cc
index abd8c24..f3bed1f 100644
--- a/src/ButtonTheme.cc
+++ b/src/ButtonTheme.cc
@@ -4,12 +4,16 @@
4//!! TODO: still missing *.pressed.picColor 4//!! TODO: still missing *.pressed.picColor
5ButtonTheme::ButtonTheme(int screen_num, 5ButtonTheme::ButtonTheme(int screen_num,
6 const std::string &name, 6 const std::string &name,
7 const std::string &alt_name): 7 const std::string &alt_name,
8 const std::string &extra_fallback,
9 const std::string &extra_fallback_alt):
8 ToolTheme(screen_num, name, alt_name), 10 ToolTheme(screen_num, name, alt_name),
9 m_pic_color(*this, name + ".picColor", alt_name + ".PicColor"), 11 m_pic_color(*this, name + ".picColor", alt_name + ".PicColor"),
10 m_pressed_texture(*this, name + ".pressed", alt_name + ".Pressed"), 12 m_pressed_texture(*this, name + ".pressed", alt_name + ".Pressed"),
11 m_gc(RootWindow(FbTk::App::instance()->display(), screen_num)), 13 m_gc(RootWindow(FbTk::App::instance()->display(), screen_num)),
12 m_scale(*this, name + ".scale", alt_name + ".Scale") { 14 m_scale(*this, name + ".scale", alt_name + ".Scale"),
15 m_name(name),
16 m_fallbackname(extra_fallback), m_altfallbackname(extra_fallback_alt) {
13 17
14} 18}
15 19
@@ -24,9 +28,31 @@ bool ButtonTheme::fallback(FbTk::ThemeItem_base &item) {
24 return FbTk::ThemeManager::instance().loadItem(item, "borderColor", "BorderColor"); 28 return FbTk::ThemeManager::instance().loadItem(item, "borderColor", "BorderColor");
25 } 29 }
26*/ 30*/
27 if (item.name().find(".pressed") != std::string::npos) { 31 if (item.name() == name()) {
32 // default to the toolbar label style
33 return FbTk::ThemeManager::instance().loadItem(item,
34 m_fallbackname,
35 m_altfallbackname);
36
37 } else if (item.name().find(".picColor") != std::string::npos) {
38 // if we've fallen back to alternate name, and it doesn't have a picColor,
39 // try its text color instead
40 return FbTk::ThemeManager::instance().loadItem(item,
41 m_fallbackname + ".picColor",
42 m_altfallbackname + ".picColor") ||
43 FbTk::ThemeManager::instance().loadItem(item,
44 m_fallbackname + ".textColor",
45 m_altfallbackname + ".TextColor");
46 } else if (item.name().find(".pressed") != std::string::npos) {
28 // copy texture 47 // copy texture
29 *m_pressed_texture = texture(); 48 *m_pressed_texture = texture();
49 // invert the bevel if it has one!
50 unsigned long type = m_pressed_texture->type();
51 unsigned long bevels = (FbTk::Texture::SUNKEN | FbTk::Texture::RAISED);
52 if ((type & bevels) != 0) {
53 type ^= bevels;
54 m_pressed_texture->setType(type);
55 }
30 return true; 56 return true;
31 } 57 }
32 58
diff --git a/src/ButtonTheme.hh b/src/ButtonTheme.hh
index 0df252c..cba4282 100644
--- a/src/ButtonTheme.hh
+++ b/src/ButtonTheme.hh
@@ -8,7 +8,9 @@
8class ButtonTheme: public ToolTheme { 8class ButtonTheme: public ToolTheme {
9public: 9public:
10 ButtonTheme(int screen_num, 10 ButtonTheme(int screen_num,
11 const std::string &name, const std::string &alt_name); 11 const std::string &name, const std::string &alt_name,
12 const std::string &extra_fallback,
13 const std::string &extra_fallback_alt);
12 virtual ~ButtonTheme() { } 14 virtual ~ButtonTheme() { }
13 15
14 bool fallback(FbTk::ThemeItem_base &item); 16 bool fallback(FbTk::ThemeItem_base &item);
@@ -17,11 +19,16 @@ public:
17 inline const FbTk::Texture &pressed() const { return *m_pressed_texture; } 19 inline const FbTk::Texture &pressed() const { return *m_pressed_texture; }
18 inline GC gc() const { return m_gc.gc(); } 20 inline GC gc() const { return m_gc.gc(); }
19 inline int scale() const { return *m_scale; } // scale factor for inside objects 21 inline int scale() const { return *m_scale; } // scale factor for inside objects
22 inline const std::string &name() { return m_name; }
23
20private: 24private:
21 FbTk::ThemeItem<FbTk::Color> m_pic_color; 25 FbTk::ThemeItem<FbTk::Color> m_pic_color;
22 FbTk::ThemeItem<FbTk::Texture> m_pressed_texture; 26 FbTk::ThemeItem<FbTk::Texture> m_pressed_texture;
23 FbTk::GContext m_gc; 27 FbTk::GContext m_gc;
24 FbTk::ThemeItem<int> m_scale; 28 FbTk::ThemeItem<int> m_scale;
29 const std::string m_name;
30 const std::string m_fallbackname;
31 const std::string m_altfallbackname;
25}; 32};
26 33
27#endif // BUTTONTHEME_HH 34#endif // BUTTONTHEME_HH
diff --git a/src/ToolFactory.cc b/src/ToolFactory.cc
index 011eb39..a2d6c2b 100644
--- a/src/ToolFactory.cc
+++ b/src/ToolFactory.cc
@@ -19,7 +19,7 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22// $Id: ToolFactory.cc,v 1.5 2004/08/25 17:16:40 rathnor Exp $ 22// $Id: ToolFactory.cc,v 1.6 2004/08/27 14:14:42 rathnor Exp $
23 23
24#include "ToolFactory.hh" 24#include "ToolFactory.hh"
25 25
@@ -75,7 +75,8 @@ private:
75 75
76ToolFactory::ToolFactory(BScreen &screen):m_screen(screen), 76ToolFactory::ToolFactory(BScreen &screen):m_screen(screen),
77 m_clock_theme(screen.screenNumber(), "toolbar.clock", "Toolbar.Clock"), 77 m_clock_theme(screen.screenNumber(), "toolbar.clock", "Toolbar.Clock"),
78 m_button_theme(new ButtonTheme(screen.screenNumber(), "toolbar.button", "Toolbar.Button")), 78 m_button_theme(new ButtonTheme(screen.screenNumber(), "toolbar.button", "Toolbar.Button",
79 "toolbar.workspace", "Toolbar.Workspace")),
79 m_workspace_theme(new WorkspaceNameTheme(screen.screenNumber(), "toolbar.workspace", "Toolbar.Workspace")), 80 m_workspace_theme(new WorkspaceNameTheme(screen.screenNumber(), "toolbar.workspace", "Toolbar.Workspace")),
80 m_iconbar_theme(screen.screenNumber(), "toolbar.iconbar", "Toolbar.Iconbar") { 81 m_iconbar_theme(screen.screenNumber(), "toolbar.iconbar", "Toolbar.Iconbar") {
81 82