all repos — openbox @ bb6ac36d410ba62bc8bb481dd6461a30aace42fd

openbox fork - make it a bit more like ryudo

working popups for moving/resizing
Dana Jansens danakj@orodu.net
commit

bb6ac36d410ba62bc8bb481dd6461a30aace42fd

parent

225d4302d0b2bd40d03d3bfa54116c0adfe3143e

6 files changed, 77 insertions(+), 4 deletions(-)

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

@@ -29,10 +29,37 @@ setTexture(style->labelFocusBackground());

setUnfocusTexture(style->labelUnfocusBackground()); } +void FocusLabel::fitString(const std::string &str) +{ + const Font *ft = style()->labelFont(); + fitSize(ft->measureString(str), ft->height()); +} + +void FocusLabel::fitSize(int w, int h) +{ + unsigned int sidemargin = style()->bevelWidth() * 2; + resize(w + sidemargin * 2, h); +} + +void FocusLabel::update() +{ + if (_dirty) { + int w = _rect.width(), h = _rect.height(); + const Font *ft = style()->labelFont(); + unsigned int sidemargin = style()->bevelWidth() * 2; + if (!_fixed_width) + w = ft->measureString(_text) + sidemargin * 2; + if (!_fixed_height) + h = ft->height(); + internalResize(w, h); + } + FocusWidget::update(); +} + void FocusLabel::renderForeground() { - otk::Widget::renderForeground(); + FocusWidget::renderForeground(); const Font *ft = style()->labelFont(); RenderColor *text_color = (isFocused() ? style()->textFocusColor()
M otk/focuslabel.hhotk/focuslabel.hh

@@ -18,6 +18,11 @@ void setText(const ustring &text) { _text = text; _dirty = true; }

virtual void renderForeground(); + virtual void update(); + + void fitString(const std::string &str); + void fitSize(int w, int h); + virtual void setStyle(RenderStyle *style); private:
M otk/label.ccotk/label.cc

@@ -25,10 +25,37 @@

setTexture(style->labelUnfocusBackground()); } +void Label::fitString(const std::string &str) +{ + const Font *ft = style()->labelFont(); + fitSize(ft->measureString(str), ft->height()); +} + +void Label::fitSize(int w, int h) +{ + unsigned int sidemargin = style()->bevelWidth() * 2; + resize(w + sidemargin * 2, h); +} + +void Label::update() +{ + if (_dirty) { + int w = _rect.width(), h = _rect.height(); + const Font *ft = style()->labelFont(); + unsigned int sidemargin = style()->bevelWidth() * 2; + if (!_fixed_width) + w = ft->measureString(_text) + sidemargin * 2; + if (!_fixed_height) + h = ft->height(); + internalResize(w, h); + } + Widget::update(); +} + void Label::renderForeground(void) { - otk::Widget::renderForeground(); + Widget::renderForeground(); const Font *ft = style()->labelFont(); unsigned int sidemargin = style()->bevelWidth() * 2;
M otk/label.hhotk/label.hh

@@ -18,6 +18,11 @@ void setText(const ustring &text) { _text = text; _dirty = true; }

virtual void renderForeground(void); + virtual void update(); + + void fitString(const std::string &str); + void fitSize(int w, int h); + virtual void setStyle(RenderStyle *style); private:
M scripts/focus.pyscripts/focus.py

@@ -203,12 +203,12 @@ if len(t) > 50: # limit the length of titles

t = t[:24] + "..." + t[-24:] titles.append(t) _list_windows.append(c) - l = font.measureString(t) + 10 # add margin + l = font.measureString(t) if l > longest: longest = l if len(titles) > 1: for t in titles: w = otk.FocusLabel(_list_widget) - w.resize(longest, height) + w.fitSize(longest, height) w.setText(t) w.unfocus() _list_labels.append(w)
M src/client.hhsrc/client.hh

@@ -569,6 +569,15 @@ inline bool maxHorz() const { return _max_horz; }

//! Returns the window's stacking layer inline StackLayer layer() const { return _layer; } + //! Returns the logical size of the window + /*! + The "logical" size of the window is refers to the user's perception of the + size of the window, and is the value that should be displayed to the user. + For example, with xterms, this value it the number of characters being + displayed in the terminal, instead of the number of pixels. + */ + const otk::Point &logicalSize() const { return _logical_size; } + //! Applies the states requested when the window mapped /*! This should be called only once, during the window mapping process. It