From: Mikko Rasa Date: Mon, 28 Feb 2011 15:18:18 +0000 (+0000) Subject: Add a signal to notify when the automatic size of a widget changes X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=b92c878a286036af106e969a29b2689876aa5f65;p=libs%2Fgltk.git Add a signal to notify when the automatic size of a widget changes --- diff --git a/source/button.cpp b/source/button.cpp index 5095379..da2c433 100644 --- a/source/button.cpp +++ b/source/button.cpp @@ -51,6 +51,7 @@ void Button::autosize() void Button::set_text(const std::string &t) { text = t; + signal_autosize_changed.emit(); } void Button::set_icon(const GL::Texture2D *i) diff --git a/source/dropdown.cpp b/source/dropdown.cpp index 801c8a6..cff5387 100644 --- a/source/dropdown.cpp +++ b/source/dropdown.cpp @@ -24,6 +24,7 @@ Dropdown::Dropdown(): { add(list); list.signal_item_selected.connect(sigc::mem_fun(this, &Dropdown::list_item_selected)); + list.signal_autosize_changed.connect(sigc::mem_fun(this, &Dropdown::list_autosize_changed)); } void Dropdown::autosize() @@ -47,25 +48,21 @@ void Dropdown::autosize() void Dropdown::append(const string &item) { list.append(item); - resize_list(); } void Dropdown::insert(unsigned i, const string &v) { list.insert(i, v); - resize_list(); } void Dropdown::remove(unsigned i) { list.remove(i); - resize_list(); } void Dropdown::clear() { list.clear(); - resize_list(); } unsigned Dropdown::get_n_items() const @@ -129,6 +126,12 @@ void Dropdown::on_style_change() resize_list(); } +void Dropdown::list_autosize_changed() +{ + resize_list(); + signal_autosize_changed.emit(); +} + void Dropdown::resize_list() { list.autosize_all(); diff --git a/source/dropdown.h b/source/dropdown.h index 598ad80..7cacf22 100644 --- a/source/dropdown.h +++ b/source/dropdown.h @@ -60,6 +60,7 @@ private: virtual void on_geometry_change(); virtual void on_style_change(); + void list_autosize_changed(); void resize_list(); void list_item_selected(unsigned, const std::string &); }; diff --git a/source/image.cpp b/source/image.cpp index eb3bd6e..3c0cfa5 100644 --- a/source/image.cpp +++ b/source/image.cpp @@ -50,6 +50,7 @@ void Image::autosize() void Image::set_image(const GL::Texture2D *i) { image = i; + signal_autosize_changed.emit(); } void Image::set_keep_aspect(bool ka) diff --git a/source/label.cpp b/source/label.cpp index 30ccd62..e1015e8 100644 --- a/source/label.cpp +++ b/source/label.cpp @@ -38,6 +38,7 @@ void Label::autosize() void Label::set_text(const string &t) { text = t; + signal_autosize_changed.emit(); } void Label::render_special(const Part &part) const diff --git a/source/list.cpp b/source/list.cpp index ea3969c..f7cc4d7 100644 --- a/source/list.cpp +++ b/source/list.cpp @@ -91,6 +91,7 @@ void List::append(const string &v) { items.push_back(v); check_view_range(); + signal_autosize_changed.emit(); } void List::insert(unsigned i, const string &v) @@ -100,6 +101,7 @@ void List::insert(unsigned i, const string &v) items.insert(items.begin()+i, v); check_view_range(); + signal_autosize_changed.emit(); } void List::remove(unsigned i) @@ -114,6 +116,7 @@ void List::remove(unsigned i) sel_index = -1; check_view_range(); + signal_autosize_changed.emit(); } void List::clear() @@ -122,6 +125,7 @@ void List::clear() sel_index = -1; check_view_range(); + signal_autosize_changed.emit(); } void List::set_selected_index(int i) diff --git a/source/toggle.cpp b/source/toggle.cpp index 753257c..41e38cb 100644 --- a/source/toggle.cpp +++ b/source/toggle.cpp @@ -42,6 +42,7 @@ void Toggle::autosize() void Toggle::set_text(const string &t) { text = t; + signal_autosize_changed.emit(); } void Toggle::set_exclusive(bool e) diff --git a/source/widget.cpp b/source/widget.cpp index 4e0c489..17bc4e3 100644 --- a/source/widget.cpp +++ b/source/widget.cpp @@ -102,6 +102,7 @@ void Widget::update_style() } on_style_change(); + signal_autosize_changed.emit(); } void Widget::set_tooltip(const string &t) diff --git a/source/widget.h b/source/widget.h index 5522ba3..3653970 100644 --- a/source/widget.h +++ b/source/widget.h @@ -41,6 +41,7 @@ public: }; sigc::signal signal_visibility_changed; + sigc::signal signal_autosize_changed; sigc::signal signal_request_focus; sigc::signal signal_grab_pointer; sigc::signal signal_ungrab_pointer;