Fixed buttons not resized
This commit is contained in:
@@ -880,6 +880,7 @@ void NWidgetResizeBase::AdjustPaddingForZoom()
|
|||||||
if (!this->absolute) {
|
if (!this->absolute) {
|
||||||
this->min_x = ScaleGUITrad(this->uz_min_x);
|
this->min_x = ScaleGUITrad(this->uz_min_x);
|
||||||
this->min_y = std::max(ScaleGUITrad(this->uz_min_y), this->uz_text_lines * GetCharacterHeight(this->uz_text_size) + ScaleGUITrad(this->uz_text_spacing));
|
this->min_y = std::max(ScaleGUITrad(this->uz_min_y), this->uz_text_lines * GetCharacterHeight(this->uz_text_size) + ScaleGUITrad(this->uz_text_spacing));
|
||||||
|
this->SetMinimalSizeForSizingType();
|
||||||
}
|
}
|
||||||
NWidgetBase::AdjustPaddingForZoom();
|
NWidgetBase::AdjustPaddingForZoom();
|
||||||
}
|
}
|
||||||
@@ -895,6 +896,7 @@ void NWidgetResizeBase::SetMinimalSize(uint min_x, uint min_y)
|
|||||||
this->uz_min_y = std::max(this->uz_min_y, min_y);
|
this->uz_min_y = std::max(this->uz_min_y, min_y);
|
||||||
this->min_x = ScaleGUITrad(this->uz_min_x);
|
this->min_x = ScaleGUITrad(this->uz_min_x);
|
||||||
this->min_y = std::max(ScaleGUITrad(this->uz_min_y), this->uz_text_lines * GetCharacterHeight(this->uz_text_size) + ScaleGUITrad(this->uz_text_spacing));
|
this->min_y = std::max(ScaleGUITrad(this->uz_min_y), this->uz_text_lines * GetCharacterHeight(this->uz_text_size) + ScaleGUITrad(this->uz_text_spacing));
|
||||||
|
this->SetMinimalSizeForSizingType();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -907,6 +909,26 @@ void NWidgetResizeBase::SetMinimalSizeAbsolute(uint min_x, uint min_y)
|
|||||||
this->absolute = true;
|
this->absolute = true;
|
||||||
this->min_x = std::max(this->min_x, min_x);
|
this->min_x = std::max(this->min_x, min_x);
|
||||||
this->min_y = std::max(this->min_y, min_y);
|
this->min_y = std::max(this->min_y, min_y);
|
||||||
|
this->SetMinimalSizeForSizingType();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set minimal text lines for the widget.
|
||||||
|
* @param min_lines Number of text lines of the widget.
|
||||||
|
* @param spacing Extra spacing (eg WD_FRAMERECT_TOP + _BOTTOM) of the widget.
|
||||||
|
* @param size Font size of text.
|
||||||
|
*/
|
||||||
|
void NWidgetResizeBase::SetMinimalTextLines(uint8 min_lines, uint8 spacing, FontSize size)
|
||||||
|
{
|
||||||
|
this->uz_text_lines = min_lines;
|
||||||
|
this->uz_text_spacing = spacing;
|
||||||
|
this->uz_text_size = size;
|
||||||
|
this->min_y = std::max(ScaleGUITrad(this->uz_min_y), this->uz_text_lines * GetCharacterHeight(this->uz_text_size) + ScaleGUITrad(this->uz_text_spacing));
|
||||||
|
this->SetMinimalSizeForSizingType();
|
||||||
|
}
|
||||||
|
|
||||||
|
void NWidgetResizeBase::SetMinimalSizeForSizingType()
|
||||||
|
{
|
||||||
uint min_size = 0;
|
uint min_size = 0;
|
||||||
switch (this->sizing_type) {
|
switch (this->sizing_type) {
|
||||||
case NWST_NONE:
|
case NWST_NONE:
|
||||||
@@ -926,20 +948,6 @@ void NWidgetResizeBase::SetMinimalSizeAbsolute(uint min_x, uint min_y)
|
|||||||
this->min_y = std::max(this->min_y, min_size);
|
this->min_y = std::max(this->min_y, min_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set minimal text lines for the widget.
|
|
||||||
* @param min_lines Number of text lines of the widget.
|
|
||||||
* @param spacing Extra spacing (eg WD_FRAMERECT_TOP + _BOTTOM) of the widget.
|
|
||||||
* @param size Font size of text.
|
|
||||||
*/
|
|
||||||
void NWidgetResizeBase::SetMinimalTextLines(uint8 min_lines, uint8 spacing, FontSize size)
|
|
||||||
{
|
|
||||||
this->uz_text_lines = min_lines;
|
|
||||||
this->uz_text_spacing = spacing;
|
|
||||||
this->uz_text_size = size;
|
|
||||||
this->min_y = std::max(ScaleGUITrad(this->uz_min_y), this->uz_text_lines * GetCharacterHeight(this->uz_text_size) + ScaleGUITrad(this->uz_text_spacing));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the filling of the widget from initial size.
|
* Set the filling of the widget from initial size.
|
||||||
* @param fill_x Horizontal fill step size, \c 0 means no filling is allowed.
|
* @param fill_x Horizontal fill step size, \c 0 means no filling is allowed.
|
||||||
|
|||||||
@@ -267,6 +267,7 @@ public:
|
|||||||
void SetMinimalSize(uint min_x, uint min_y);
|
void SetMinimalSize(uint min_x, uint min_y);
|
||||||
void SetMinimalSizeAbsolute(uint min_x, uint min_y);
|
void SetMinimalSizeAbsolute(uint min_x, uint min_y);
|
||||||
void SetMinimalTextLines(uint8 min_lines, uint8 spacing, FontSize size);
|
void SetMinimalTextLines(uint8 min_lines, uint8 spacing, FontSize size);
|
||||||
|
void SetMinimalSizeForSizingType();
|
||||||
void SetFill(uint fill_x, uint fill_y);
|
void SetFill(uint fill_x, uint fill_y);
|
||||||
void SetResize(uint resize_x, uint resize_y);
|
void SetResize(uint resize_x, uint resize_y);
|
||||||
|
|
||||||
@@ -1036,6 +1037,10 @@ static inline NWidgetPart SetSizingType(NWidSizingType type)
|
|||||||
return part;
|
return part;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the minimal size of every clickable widget for touchscreen interface.
|
||||||
|
* @param size of graphics or text in pixels that must fit into the widget.
|
||||||
|
*/
|
||||||
uint GetMinButtonSize(uint min_1 = 0);
|
uint GetMinButtonSize(uint min_1 = 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user