add a special fallback for toolbar button style
This commit is contained in:
parent
6ce5a31ea8
commit
f2599d87f6
4 changed files with 43 additions and 6 deletions
|
@ -1,5 +1,8 @@
|
|||
(Format: Year/Month/Day)
|
||||
Changes for 0.9.10:
|
||||
*04/08/27:
|
||||
* Improve fallback if toolbar button style item missing (Simon)
|
||||
ButtonTheme.hh/cc ToolFactory.cc
|
||||
*04/08/26:
|
||||
* Tiny unification (Mathias)
|
||||
- theme.cfg and style.cfg allowed
|
||||
|
|
|
@ -4,12 +4,16 @@
|
|||
//!! TODO: still missing *.pressed.picColor
|
||||
ButtonTheme::ButtonTheme(int screen_num,
|
||||
const std::string &name,
|
||||
const std::string &alt_name):
|
||||
const std::string &alt_name,
|
||||
const std::string &extra_fallback,
|
||||
const std::string &extra_fallback_alt):
|
||||
ToolTheme(screen_num, name, alt_name),
|
||||
m_pic_color(*this, name + ".picColor", alt_name + ".PicColor"),
|
||||
m_pressed_texture(*this, name + ".pressed", alt_name + ".Pressed"),
|
||||
m_gc(RootWindow(FbTk::App::instance()->display(), screen_num)),
|
||||
m_scale(*this, name + ".scale", alt_name + ".Scale") {
|
||||
m_scale(*this, name + ".scale", alt_name + ".Scale"),
|
||||
m_name(name),
|
||||
m_fallbackname(extra_fallback), m_altfallbackname(extra_fallback_alt) {
|
||||
|
||||
}
|
||||
|
||||
|
@ -24,9 +28,31 @@ bool ButtonTheme::fallback(FbTk::ThemeItem_base &item) {
|
|||
return FbTk::ThemeManager::instance().loadItem(item, "borderColor", "BorderColor");
|
||||
}
|
||||
*/
|
||||
if (item.name().find(".pressed") != std::string::npos) {
|
||||
if (item.name() == name()) {
|
||||
// default to the toolbar label style
|
||||
return FbTk::ThemeManager::instance().loadItem(item,
|
||||
m_fallbackname,
|
||||
m_altfallbackname);
|
||||
|
||||
} else if (item.name().find(".picColor") != std::string::npos) {
|
||||
// if we've fallen back to alternate name, and it doesn't have a picColor,
|
||||
// try its text color instead
|
||||
return FbTk::ThemeManager::instance().loadItem(item,
|
||||
m_fallbackname + ".picColor",
|
||||
m_altfallbackname + ".picColor") ||
|
||||
FbTk::ThemeManager::instance().loadItem(item,
|
||||
m_fallbackname + ".textColor",
|
||||
m_altfallbackname + ".TextColor");
|
||||
} else if (item.name().find(".pressed") != std::string::npos) {
|
||||
// copy texture
|
||||
*m_pressed_texture = texture();
|
||||
// invert the bevel if it has one!
|
||||
unsigned long type = m_pressed_texture->type();
|
||||
unsigned long bevels = (FbTk::Texture::SUNKEN | FbTk::Texture::RAISED);
|
||||
if ((type & bevels) != 0) {
|
||||
type ^= bevels;
|
||||
m_pressed_texture->setType(type);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,9 @@
|
|||
class ButtonTheme: public ToolTheme {
|
||||
public:
|
||||
ButtonTheme(int screen_num,
|
||||
const std::string &name, const std::string &alt_name);
|
||||
const std::string &name, const std::string &alt_name,
|
||||
const std::string &extra_fallback,
|
||||
const std::string &extra_fallback_alt);
|
||||
virtual ~ButtonTheme() { }
|
||||
|
||||
bool fallback(FbTk::ThemeItem_base &item);
|
||||
|
@ -17,11 +19,16 @@ public:
|
|||
inline const FbTk::Texture &pressed() const { return *m_pressed_texture; }
|
||||
inline GC gc() const { return m_gc.gc(); }
|
||||
inline int scale() const { return *m_scale; } // scale factor for inside objects
|
||||
inline const std::string &name() { return m_name; }
|
||||
|
||||
private:
|
||||
FbTk::ThemeItem<FbTk::Color> m_pic_color;
|
||||
FbTk::ThemeItem<FbTk::Texture> m_pressed_texture;
|
||||
FbTk::GContext m_gc;
|
||||
FbTk::ThemeItem<int> m_scale;
|
||||
const std::string m_name;
|
||||
const std::string m_fallbackname;
|
||||
const std::string m_altfallbackname;
|
||||
};
|
||||
|
||||
#endif // BUTTONTHEME_HH
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// $Id: ToolFactory.cc,v 1.5 2004/08/25 17:16:40 rathnor Exp $
|
||||
// $Id: ToolFactory.cc,v 1.6 2004/08/27 14:14:42 rathnor Exp $
|
||||
|
||||
#include "ToolFactory.hh"
|
||||
|
||||
|
@ -75,7 +75,8 @@ private:
|
|||
|
||||
ToolFactory::ToolFactory(BScreen &screen):m_screen(screen),
|
||||
m_clock_theme(screen.screenNumber(), "toolbar.clock", "Toolbar.Clock"),
|
||||
m_button_theme(new ButtonTheme(screen.screenNumber(), "toolbar.button", "Toolbar.Button")),
|
||||
m_button_theme(new ButtonTheme(screen.screenNumber(), "toolbar.button", "Toolbar.Button",
|
||||
"toolbar.workspace", "Toolbar.Workspace")),
|
||||
m_workspace_theme(new WorkspaceNameTheme(screen.screenNumber(), "toolbar.workspace", "Toolbar.Workspace")),
|
||||
m_iconbar_theme(screen.screenNumber(), "toolbar.iconbar", "Toolbar.Iconbar") {
|
||||
|
||||
|
|
Loading…
Reference in a new issue