diff --git a/src/gui/widgets/control.cpp b/src/gui/widgets/control.cpp index 57067c24631..8e8a30234a3 100644 --- a/src/gui/widgets/control.cpp +++ b/src/gui/widgets/control.cpp @@ -145,6 +145,35 @@ void tcontrol::NEW_layout_init(const bool full_initialization) } } +void tcontrol::NEW_request_reduce_width(const unsigned maximum_width) +{ + // Inherited. + twidget::NEW_request_reduce_width(maximum_width); + + assert(config_); + + if(!label_.empty() && can_wrap()) { + + tpoint size = get_best_text_size( + tpoint(0,0), + tpoint(maximum_width - config_->text_extra_width, 0)); + + size.x += config_->text_extra_width; + size.y += config_->text_extra_height; + + set_layout_size(size); + + DBG_GUI_L << "tcontrol(" + get_control_type() + ") " + __func__ + ":" + << " maximum_width " << maximum_width + << " result " << size + << ".\n"; + + } else { + DBG_GUI_L << "tcontrol(" + get_control_type() + ") " + __func__ + ":" + << " failed; either no label or wrapping not allowed.\n"; + } +} + void tcontrol::layout_wrap(const unsigned maximum_width) { // Inherited. diff --git a/src/gui/widgets/control.hpp b/src/gui/widgets/control.hpp index f0d78dd0a67..e794a839983 100644 --- a/src/gui/widgets/control.hpp +++ b/src/gui/widgets/control.hpp @@ -154,6 +154,9 @@ public: void layout_init2(const bool full_initialization); void NEW_layout_init(const bool full_initialization); + /** Inherited from twidget. */ + void NEW_request_reduce_width(const unsigned maximum_width); + /** Inherited from twidget. */ void layout_wrap(const unsigned maximum_width);