GUI2/Canvas: consolidate set_width and set_height into a single function

This is to enable me to do some testing with high DPI support.
Also there's never a situation where you'd only want to set one of these.
This commit is contained in:
Charles Dang 2018-04-14 21:15:53 +11:00
parent c43f801aff
commit dbb56599c5
3 changed files with 10 additions and 13 deletions

View file

@ -1578,6 +1578,14 @@ void canvas::clear_shapes(const bool force)
drawn_shapes_.erase(iter, drawn_shapes_.end());
}
void canvas::set_size(unsigned w, unsigned h)
{
update_size(w_, w);
update_size(h_, h);
invalidate_cache();
}
void canvas::update_size(unsigned int& value, unsigned int new_value)
{
if(value != new_value) {

View file

@ -144,23 +144,13 @@ public:
/***** ***** ***** setters / getters for members ***** ****** *****/
void set_width(const unsigned width)
{
update_size(w_, width);
invalidate_cache();
}
void set_size(unsigned w, unsigned h);
unsigned get_width() const
{
return w_;
}
void set_height(const unsigned height)
{
update_size(h_, height);
invalidate_cache();
}
unsigned get_height() const
{
return h_;

View file

@ -267,8 +267,7 @@ void styled_widget::place(const point& origin, const point& size)
// resize canvasses
for(auto & canvas : canvases_)
{
canvas.set_width(size.x);
canvas.set_height(size.y);
canvas.set_size(size.x, size.y);
}
// Note we assume that the best size has been queried but otherwise it