stacked cycling menu works now. add a highlighted flag to otk widgets
Dana Jansens danakj@orodu.net
5 files changed,
29 insertions(+),
20 deletions(-)
M
otk/label.cc
→
otk/label.cc
@@ -16,7 +16,8 @@ Label::Label(Widget *parent)
: Widget(parent), _text(""), _justify_horz(RenderStyle::LeftTopJustify), - _justify_vert(RenderStyle::LeftTopJustify) + _justify_vert(RenderStyle::LeftTopJustify), + _highlight(true) { styleChanged(*RenderStyle::style(screen())); }@@ -34,6 +35,13 @@
void Label::setVerticalJustify(RenderStyle::Justify j) { _justify_vert = j; + refresh(); +} + +void Label::setHighlighted(bool h) +{ + _highlight = h; + styleChanged(*RenderStyle::style(screen())); refresh(); }@@ -77,8 +85,13 @@ }
void Label::styleChanged(const RenderStyle &style) { - _texture = style.labelFocusBackground(); - _forecolor = style.textFocusColor(); + if (_highlight) { + _texture = style.labelFocusBackground(); + _forecolor = style.textFocusColor(); + } else { + _texture = style.labelUnfocusBackground(); + _forecolor = style.textUnfocusColor(); + } _font = style.labelFont(); Widget::styleChanged(style); calcDefaultSizes();
M
otk/label.hh
→
otk/label.hh
@@ -20,6 +20,9 @@
inline const ustring& getText(void) const { return _text; } void setText(const ustring &text); + virtual inline bool isHighlighted() const { return _highlight; } + virtual void setHighlighted(bool h); + RenderStyle::Justify horizontalJustify() const { return _justify_horz; } virtual void setHorizontalJustify(RenderStyle::Justify j); RenderStyle::Justify verticalJustify() const { return _justify_vert; }@@ -53,6 +56,8 @@ //! The vertical justification used for drawing text
RenderStyle::Justify _justify_vert; //! The drawing offset for the text int _drawx; + //! If the widget is highlighted or not + bool _highlight; }; }
M
scripts/stackedcycle.py
→
scripts/stackedcycle.py
@@ -112,10 +112,10 @@
w = otk.Label(self.widget) if current and c.window() == current.window(): self.menupos = i - #w.focus() XXX + w.setHighlighted(1) pass else: - #w.unfocus() XXX + w.setHighlighted(0) pass self.menuwidgets.append(w)@@ -192,7 +192,7 @@ ob.mgrab(self.screen.number())
if not len(self.clients): return # don't both doing anything - #self.menuwidgets[self.menupos].unfocus() XXX + self.menuwidgets[self.menupos].setHighlighted(0) if forward: self.menupos += 1 else:@@ -200,7 +200,7 @@ self.menupos -= 1
# wrap around if self.menupos < 0: self.menupos = len(self.clients) - 1 elif self.menupos >= len(self.clients): self.menupos = 0 - #self.menuwidgets[self.menupos].focus() XXX + self.menuwidgets[self.menupos].setHighlighted(1) if ACTIVATE_WHILE_CYCLING: self.activatetarget(0) # activate, but dont deiconify/unshade/raise