From: Dana Jansens Date: Wed, 22 Jan 2003 22:20:26 +0000 (+0000) Subject: hardcoded renderstyle X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=75e8fc2705d9c606a702eb7057e9e503be90618b;p=chaz%2Fopenbox hardcoded renderstyle --- diff --git a/otk/rendercolor.cc b/otk/rendercolor.cc index 568e2c7c..bfc8d461 100644 --- a/otk/rendercolor.cc +++ b/otk/rendercolor.cc @@ -33,17 +33,6 @@ RenderColor::RenderColor(int screen, unsigned char red, create(); } -RenderColor::RenderColor(int screen, unsigned char red, - unsigned char green, unsigned char blue) - : _screen(screen), - _red(red), - _green(green), - _blue(blue), - _gc(0) -{ - create(); -} - RenderColor::RenderColor(int screen, RGB rgb) : _screen(screen), _red(rgb.r), diff --git a/otk/rendercolor.hh b/otk/rendercolor.hh index 6000646a..1152e767 100644 --- a/otk/rendercolor.hh +++ b/otk/rendercolor.hh @@ -11,6 +11,7 @@ extern "C" { namespace otk { class RenderColor { +public: struct RGB { int r; int g; @@ -22,7 +23,8 @@ class RenderColor { g((color >> 8) & 0xff), b((color) & 0xff) {} }; - + +private: struct CacheItem { GC gc; int count; diff --git a/otk/renderstyle.cc b/otk/renderstyle.cc index 8803c779..22622931 100644 --- a/otk/renderstyle.cc +++ b/otk/renderstyle.cc @@ -5,17 +5,18 @@ #endif // HAVE_CONFIG_H #include "renderstyle.hh" -#include "rendercolor.hh" -#include "rendertexture.hh" namespace otk { -RenderStyle(int screen, const std::string &stylefile) +RenderStyle::RenderStyle(int screen, const std::string &stylefile) : _screen(screen), _file(stylefile) { - _text_focus_color = new RenderColor(_screen, 0x272a2f); - _text_unfocus_color = new RenderColor(_screen, 0x676869); + _text_color_focus = new RenderColor(_screen, 0x272a2f); + _text_color_unfocus = new RenderColor(_screen, 0x676869); + + _button_color_focus = new RenderColor(_screen, 0x96ba86); + _button_color_unfocus = new RenderColor(_screen, 0x676869); _frame_border_color = new RenderColor(_screen, 0x181f24); _frame_border_width = 1; @@ -24,7 +25,8 @@ RenderStyle(int screen, const std::string &stylefile) _client_border_color_unfocus = new RenderColor(_screen, 0x555657); _client_border_width = 1; - _titlebar_focus = new RenderTexture(false, + _titlebar_focus = new RenderTexture(_screen, + false, RenderTexture::Flat, RenderTexture::Bevel1, false, @@ -33,10 +35,9 @@ RenderStyle(int screen, const std::string &stylefile) 0x858687, 0x373a3f, 0x0, - 0x0, - 0x0, 0x0); - _titlebar_unfocus = new RenderTexture(false, + _titlebar_unfocus = new RenderTexture(_screen, + false, RenderTexture::Flat, RenderTexture::Bevel1, false, @@ -45,11 +46,10 @@ RenderStyle(int screen, const std::string &stylefile) 0x555657, 0x171a1f, 0x0, - 0x0, - 0x0, 0x0); - _label_focus = new RenderTexture(false, + _label_focus = new RenderTexture(_screen, + false, RenderTexture::Flat, RenderTexture::Bevel1, true, @@ -57,11 +57,10 @@ RenderStyle(int screen, const std::string &stylefile) false, 0x858687, 0x373a3f, - 0x0, - 0x0, 0x181f24, 0x0); - _label_unfocus = new RenderTexture(false, + _label_unfocus = new RenderTexture(_screen, + false, RenderTexture::Sunken, RenderTexture::Bevel1, false, @@ -69,13 +68,12 @@ RenderStyle(int screen, const std::string &stylefile) false, 0x555657, 0x272a2f, - //XXX, - //XXX, 0x0, 0x0); - _handle_focus = new RenderTexture(false, + _handle_focus = new RenderTexture(_screen, + false, RenderTexture::Flat, RenderTexture::Bevel1, true, @@ -84,10 +82,9 @@ RenderStyle(int screen, const std::string &stylefile) 0x858687, 0x373a3f, 0x0, - 0x0, - 0x0, 0x0); - _handle_unfocus = new RenderTexture(false, + _handle_unfocus = new RenderTexture(_screen, + false, RenderTexture::Flat, RenderTexture::Bevel1, false, @@ -96,14 +93,112 @@ RenderStyle(int screen, const std::string &stylefile) 0x555657, 0x171a1f, 0x0, - 0x0, - 0x0, 0x0); + + _button_unpress_focus = new RenderTexture(_screen, + false, + RenderTexture::Raised, + RenderTexture::Bevel2, + false, + RenderTexture::CrossDiagonal, + false, + 0x858687, + 0x272a2f, + 0x0, + 0x0); + _button_unpress_unfocus = new RenderTexture(_screen, + false, + RenderTexture::Raised, + RenderTexture::Bevel2, + false, + RenderTexture::CrossDiagonal, + false, + 0x555657, + 0x171a1f, + 0x0, + 0x0); + + _button_press_focus = new RenderTexture(_screen, + false, + RenderTexture::Sunken, + RenderTexture::Bevel2, + false, + RenderTexture::CrossDiagonal, + false, + 0x96ba86, + 0x5a724c, + 0x0, + 0x0); + _button_press_unfocus = new RenderTexture(_screen, + false, + RenderTexture::Sunken, + RenderTexture::Bevel2, + false, + RenderTexture::CrossDiagonal, + false, + 0x555657, + 0x171a1f, + 0x0, + 0x0); + + _grip_focus = new RenderTexture(_screen, + false, + RenderTexture::Flat, + RenderTexture::Bevel1, + false, + RenderTexture::Vertical, + false, + 0x96ba86, + 0x5a724c, + 0x0, + 0x0); + _grip_unfocus = new RenderTexture(_screen, + false, + RenderTexture::Flat, + RenderTexture::Bevel1, + false, + RenderTexture::Vertical, + false, + 0x555657, + 0x171a1f, + 0x0, + 0x0); + + _label_font = new Font(_screen, "Arial,Sans-9:bold", true, 1, 0x40); } -virtual ~RenderStyle() +RenderStyle::~RenderStyle() { + delete _text_color_focus; + delete _text_color_unfocus; + + delete _button_color_focus; + delete _button_color_unfocus; + + delete _frame_border_color; + + delete _client_border_color_focus; + delete _client_border_color_unfocus; + + delete _titlebar_focus; + delete _titlebar_unfocus; + + delete _label_focus; + delete _label_unfocus; + + delete _handle_focus; + delete _handle_unfocus; + + delete _button_unpress_focus; + delete _button_unpress_unfocus; + delete _button_press_focus; + delete _button_press_unfocus; + + delete _grip_focus; + delete _grip_unfocus; + + delete _label_font; } } diff --git a/otk/renderstyle.hh b/otk/renderstyle.hh index 0ecb8e4d..c23d45aa 100644 --- a/otk/renderstyle.hh +++ b/otk/renderstyle.hh @@ -3,6 +3,8 @@ #define __renderstyle_hh #include "rendertexture.hh" +#include "rendercolor.hh" +#include "font.hh" #include @@ -20,11 +22,15 @@ private: int _screen; std::string _file; - RenderColor *_text_focus_color; - RenderColor *_text_unfocus_color; + RenderColor *_text_color_focus; + RenderColor *_text_color_unfocus; + + RenderColor *_button_color_focus; + RenderColor *_button_color_unfocus; RenderColor *_frame_border_color; - int _frame_border_wirth; + int _frame_border_width; + RenderColor *_client_border_color_focus; RenderColor *_client_border_color_unfocus; int _client_border_width; @@ -59,8 +65,13 @@ public: inline RenderColor *textFocusColor() const { return _text_color_focus; } inline RenderColor *textUnfocusColor() const { return _text_color_unfocus; } + inline RenderColor *buttonFocusColor() const { return _button_color_focus; } + inline RenderColor *buttonUnfocusColor() const + { return _button_color_unfocus; } + inline RenderColor *frameBorderColor() const { return _frame_border_color; } - inline int frameBorderWidth() const { return _frame_border_wirth; } + inline int frameBorderWidth() const { return _frame_border_width; } + inline RenderColor *clientBorderFocusColor() const { return _client_border_color_focus; } inline RenderColor *clientBorderUnfocusColor() const @@ -75,8 +86,9 @@ public: inline RenderTexture *labelFocusBackground() const { return _label_focus; } inline RenderTexture *labelUnfocusBackground() const { return _label_unfocus;} - inline RenderTexture *handleFocusBackground() const { _handle_focus; } - inline RenderTexture *handleUnfocusBackground() const { _handle_unfocus; } + inline RenderTexture *handleFocusBackground() const { return _handle_focus; } + inline RenderTexture *handleUnfocusBackground() const + { return _handle_unfocus; } inline RenderTexture *buttonUnpressFocusBackground() const { return _button_unpress_focus; } diff --git a/otk/rendertexture.hh b/otk/rendertexture.hh index 6afd6209..3a80a45e 100644 --- a/otk/rendertexture.hh +++ b/otk/rendertexture.hh @@ -31,6 +31,8 @@ public: }; private: + int _screen; + //! If true, the texture is not rendered at all, so all options are ignored bool _parent_relative; //! The relief type of the texture @@ -65,27 +67,47 @@ private: const RenderColor *_interlace_color; public: - RenderTexture(bool parent_relative, ReliefType relief, BevelType bevel, + RenderTexture(int screen, + bool parent_relative, ReliefType relief, BevelType bevel, bool border, GradientType gradient, bool interlaced, const RenderColor::RGB &color, const RenderColor::RGB &secondary_color, - const RenderColor::RGB &bevel_dark_color, - const RenderColor::RGB &bevel_light_color, const RenderColor::RGB &border_color, const RenderColor::RGB &interlace_color) - : _parent_relative(parent_relative), + : _screen(screen), + _parent_relative(parent_relative), _relief(relief), _bevel(bevel), _border(border), _gradient(gradient), _interlaced(interlaced), - _color(new RenderColor(color)), - _secondary_color(new RenderColor(secondary_color)), - _bevel_dark_color(new RenderColor(bevel_dark_color)), - _bevel_light_color(new RenderColor(bevel_light_color)), - _border_color(new RenderColor(border_color)), - _interlace_color(new RenderColor(interlace_color)) + _color(new RenderColor(screen, color)), + _secondary_color(new RenderColor(screen, secondary_color)), + _bevel_dark_color(0), + _bevel_light_color(0), + _border_color(new RenderColor(screen, border_color)), + _interlace_color(new RenderColor(screen, interlace_color)) { + if (_relief != Flat) { + unsigned char r, g, b; + + // calculate the light bevel color + r = _color->red() + _color->red() / 2; + g = _color->green() + _color->green() / 2; + b = _color->blue() + _color->blue() / 2; + // watch for wraparound + if (r < _color->red()) r = 0xff; + if (g < _color->green()) g = 0xff; + if (b < _color->blue()) b = 0xff; + _bevel_dark_color = new RenderColor(screen, r, g, b); + + // calculate the dark bevel color + r = _color->red() / 4 + _color->red() / 2; + g = _color->green() / 4 + _color->green() / 2; + b = _color->blue() / 4 + _color->blue() / 2; + _bevel_light_color = new RenderColor(screen, r, g, b); + } + assert(_relief == Flat || (_bevel_dark_color && _bevel_light_color)); assert(!_border || _border_color); assert(!_interlaced || _interlace_color); @@ -95,8 +117,8 @@ public: virtual ~RenderTexture() { delete _color; delete _secondary_color; - delete _bevel_dark_color; - delete _bevel_light_color; + if (_bevel_dark_color) delete _bevel_dark_color; + if (_bevel_dark_color) delete _bevel_light_color; delete _border_color; delete _interlace_color; }