all repos — openbox @ 75e8fc2705d9c606a702eb7057e9e503be90618b

openbox fork - make it a bit more like ryudo

hardcoded renderstyle
Dana Jansens danakj@orodu.net
commit

75e8fc2705d9c606a702eb7057e9e503be90618b

parent

c487295c75094be3858b76b23fc9863ec9d46b59

5 files changed, 174 insertions(+), 54 deletions(-)

jump to
M otk/rendercolor.ccotk/rendercolor.cc

@@ -33,17 +33,6 @@ {

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),
M otk/rendercolor.hhotk/rendercolor.hh

@@ -11,6 +11,7 @@

namespace otk { class RenderColor { +public: struct RGB { int r; int g;

@@ -22,7 +23,8 @@ : r((color >> 16) & 0xff),

g((color >> 8) & 0xff), b((color) & 0xff) {} }; - + +private: struct CacheItem { GC gc; int count;
M otk/renderstyle.ccotk/renderstyle.cc

@@ -5,17 +5,18 @@ # include "../config.h"

#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 @@ _client_border_color_focus = new RenderColor(_screen, 0x858687);

_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 @@ false,

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 @@ false,

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 @@ RenderTexture::Vertical,

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 @@ RenderTexture::CrossDiagonal,

false, 0x555657, 0x272a2f, - //XXX, - //XXX, 0x0, 0x0); - _handle_focus = new RenderTexture(false, + _handle_focus = new RenderTexture(_screen, + false, RenderTexture::Flat, RenderTexture::Bevel1, true,

@@ -83,11 +81,10 @@ RenderTexture::Vertical,

false, 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 @@ false,

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; } }
M otk/renderstyle.hhotk/renderstyle.hh

@@ -3,6 +3,8 @@ #ifndef __renderstyle_hh

#define __renderstyle_hh #include "rendertexture.hh" +#include "rendercolor.hh" +#include "font.hh" #include <string>

@@ -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 @@

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 @@

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; }
M otk/rendertexture.hhotk/rendertexture.hh

@@ -31,6 +31,8 @@ Elliptic

}; 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 @@ //! if it is true

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 @@

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; }