GUI2: allow labels to shrink to avoid scrollbars
This adds a new can_shrink key to widgets that allows the 'no label' codepath of styled_widget::request_reduce_width to be called. In this case, it allows labels to shrink without forcing window scrollbars.
This commit is contained in:
parent
23884387bd
commit
22eebc6983
5 changed files with 11 additions and 1 deletions
|
@ -481,6 +481,11 @@
|
|||
type="unsigned"
|
||||
default=0
|
||||
[/key]
|
||||
[key]
|
||||
name="can_shrink"
|
||||
type="bool"
|
||||
default=false
|
||||
[/key]
|
||||
[tag]
|
||||
name="linked_group"
|
||||
min="0"
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
max_width = 0
|
||||
max_height = 0
|
||||
|
||||
can_shrink = true
|
||||
|
||||
text_font_family = {FONT_FAMILY}
|
||||
text_font_size = {FONT_SIZE}
|
||||
text_font_style = {FONT_STYLE}
|
||||
|
|
|
@ -98,6 +98,7 @@ resolution_definition::resolution_definition(const config& cfg)
|
|||
, default_height(cfg["default_height"])
|
||||
, max_width(cfg["max_width"])
|
||||
, max_height(cfg["max_height"])
|
||||
, can_shrink(cfg["can_shrink"].to_bool())
|
||||
, linked_groups()
|
||||
, text_extra_width(cfg["text_extra_width"])
|
||||
, text_extra_height(cfg["text_extra_height"])
|
||||
|
|
|
@ -57,6 +57,8 @@ struct resolution_definition
|
|||
unsigned max_width;
|
||||
unsigned max_height;
|
||||
|
||||
bool can_shrink;
|
||||
|
||||
std::vector<linked_group_definition> linked_groups;
|
||||
|
||||
unsigned text_extra_width;
|
||||
|
|
|
@ -219,7 +219,7 @@ void styled_widget::request_reduce_width(const unsigned maximum_width)
|
|||
<< "' maximum_width " << maximum_width << " result " << size
|
||||
<< ".\n";
|
||||
|
||||
} else if(label_.empty()) {
|
||||
} else if(label_.empty() || config_->can_shrink) {
|
||||
point size = get_best_size();
|
||||
point min_size = get_config_minimum_size();
|
||||
size.x = std::min(size.x, std::max<int>(maximum_width, min_size.x));
|
||||
|
|
Loading…
Add table
Reference in a new issue