set_text(t);
}
-void Button::autosize_special(const Part &part, Geometry &ageom)
+void Button::autosize_special(const Part &part, Geometry &ageom) const
{
if(part.get_name()=="text")
text.autosize(part, ageom);
virtual const char *get_class() const { return "button"; }
private:
- virtual void autosize_special(const Part &, Geometry &);
+ virtual void autosize_special(const Part &, Geometry &) const;
public:
void set_text(const std::string &);
list.signal_autosize_changed.connect(sigc::mem_fun(this, &Dropdown::list_autosize_changed));
}
-void Dropdown::autosize_special(const Part &part, Geometry &ageom)
+void Dropdown::autosize_special(const Part &part, Geometry &ageom) const
{
if(part.get_name()=="list")
{
- list.autosize();
+ Geometry lgeom;
+ list.autosize(lgeom);
ageom.w = max(ageom.w, list.get_geometry().w);
}
else if(part.get_name()=="text")
unsigned line_height = static_cast<unsigned>((font.get_ascent()-font.get_descent())*font_size);
ageom.h = max(ageom.h, line_height+margin.top+margin.bottom);
}
-
- rebuild();
}
void Dropdown::set_selected_index(int index)
virtual const char *get_class() const { return "dropdown"; }
private:
- virtual void autosize_special(const Part &, Geometry &);
+ virtual void autosize_special(const Part &, Geometry &) const;
public:
void set_data(ListData &d) { list.set_data(d); }
set_text(t);
}
-void Entry::autosize_special(const Part &part, Geometry &ageom)
+void Entry::autosize_special(const Part &part, Geometry &ageom) const
{
if(part.get_name()=="text")
{
virtual const char *get_class() const { return "entry"; }
private:
- virtual void autosize_special(const Part &, Geometry &);
+ virtual void autosize_special(const Part &, Geometry &) const;
public:
void set_text(const std::string &);
slider_size(1)
{ }
-void HSlider::autosize_special(const Part &part, Geometry &ageom)
+void HSlider::autosize_special(const Part &part, Geometry &ageom) const
{
if(part.get_name()=="slider")
{
virtual const char *get_class() const { return "hslider"; }
private:
- virtual void autosize_special(const Part &, Geometry &);
+ virtual void autosize_special(const Part &, Geometry &) const;
virtual void rebuild_special(const Part &);
public:
focusable = false;
}
-void Image::autosize_special(const Part &part, Geometry &ageom)
+void Image::autosize_special(const Part &part, Geometry &ageom) const
{
if(part.get_name()=="image")
{
virtual const char *get_class() const { return "image"; }
private:
- virtual void autosize_special(const Part &, Geometry &);
+ virtual void autosize_special(const Part &, Geometry &) const;
public:
void set_image(const GL::Texture2D *);
rebuild();
}
-void Label::autosize_special(const Part &part, Geometry &ageom)
+void Label::autosize_special(const Part &part, Geometry &ageom) const
{
if(part.get_name()=="text")
text.autosize(part, ageom);
void set_text(const std::string &);
private:
- virtual void autosize_special(const Part &, Geometry &);
+ virtual void autosize_special(const Part &, Geometry &) const;
virtual void rebuild_special(const Part &);
virtual void on_style_change();
void Layout::Slot::autosize_changed()
{
- widget.autosize();
- autosize_geom = widget.get_geometry();
+ widget.autosize(autosize_geom);
if(!widget.is_visible() && !ghost)
return;
- // If the widget fits in the area it had, just leave it there.
- if(autosize_geom.w<=geom.w && autosize_geom.h<=geom.h)
- widget.set_geometry(geom);
- else
+ // Only trigger an update if the widget won't fit in its current area.
+ if(autosize_geom.w>geom.w || autosize_geom.h>geom.h)
{
layout.container->signal_autosize_changed.emit();
layout.update();
delete data;
}
-void List::autosize_special(const Part &part, Geometry &ageom)
+void List::autosize_special(const Part &part, Geometry &ageom) const
{
if(part.get_name()=="items")
{
}
-void List::Item::autosize_special(const Part &part, Geometry &ageom)
+void List::Item::autosize_special(const Part &part, Geometry &ageom) const
{
if(part.get_name()=="children")
{
virtual const char *get_class() const { return "listitem"; }
protected:
- virtual void autosize_special(const Part &, Geometry &);
+ virtual void autosize_special(const Part &, Geometry &) const;
public:
void set_active(bool);
virtual const char *get_class() const { return "list"; }
private:
- virtual void autosize_special(const Part &, Geometry &);
+ virtual void autosize_special(const Part &, Geometry &) const;
public:
void set_data(ListData &);
layout = l;
}
-void Panel::autosize_special(const Part &part, Geometry &ageom)
+void Panel::autosize_special(const Part &part, Geometry &ageom) const
{
if(part.get_name()=="children" && layout)
layout->autosize(ageom);
Layout *get_layout() { return layout; }
protected:
- virtual void autosize_special(const Part &, Geometry &);
+ virtual void autosize_special(const Part &, Geometry &) const;
virtual void render_special(const Part &, GL::Renderer &) const;
virtual void on_geometry_change();
set_text(t);
}
-void Toggle::autosize_special(const Part &part, Geometry &ageom)
+void Toggle::autosize_special(const Part &part, Geometry &ageom) const
{
if(part.get_name()=="text")
text.autosize(part, ageom);
virtual const char *get_class() const { return "toggle"; }
private:
- virtual void autosize_special(const Part &, Geometry &);
+ virtual void autosize_special(const Part &, Geometry &) const;
public:
void set_text(const std::string &);
slider_size(1)
{ }
-void VSlider::autosize_special(const Part &part, Geometry &ageom)
+void VSlider::autosize_special(const Part &part, Geometry &ageom) const
{
if(part.get_name()=="slider")
{
virtual const char *get_class() const { return "vslider"; }
private:
- virtual void autosize_special(const Part &, Geometry &);
+ virtual void autosize_special(const Part &, Geometry &) const;
virtual void rebuild_special(const Part &);
public:
}
void Widget::autosize()
+{
+ Geometry ageom;
+ autosize(ageom);
+ set_geometry(ageom);
+}
+
+void Widget::autosize(Geometry &ageom) const
{
if(!style)
return;
- Geometry ageom;
- ageom.x = geom.x;
- ageom.y = geom.y;
+ ageom = Geometry(geom.x, geom.y, 0, 0);
const Style::PartSeq &parts = style->get_parts();
for(Style::PartSeq::const_iterator i=parts.begin(); i!=parts.end(); ++i)
{
else
autosize_special(*i, ageom);
}
-
- set_geometry(ageom);
}
void Widget::set_geometry(const Geometry &g)
void set_position(int, int);
void set_size(unsigned, unsigned);
void autosize();
+ void autosize(Geometry &) const;
protected:
- virtual void autosize_special(const Part &, Geometry &) { }
+ virtual void autosize_special(const Part &, Geometry &) const { };
public:
void set_geometry(const Geometry &);
const Geometry &get_geometry() const { return geom; }