FIX: limit the max width of DropDown
jira: STUDIO-4503 limit the max width of DropDown for filament when user preset text is too long. Signed-off-by: wenjie.guo <wenjie.guo@bambulab.com> Change-Id: I6778fce131fb3bee38acb116fea9cbbf9baeddb7 (cherry picked from commit d5da07988e28d6c506e315dbe1ab24954c2a8a55)
This commit is contained in:
parent
a61352e613
commit
87b8388f3b
|
@ -632,7 +632,7 @@ bool PresetComboBox::selection_is_changed_according_to_physical_printers()
|
|||
PlaterPresetComboBox::PlaterPresetComboBox(wxWindow *parent, Preset::Type preset_type) :
|
||||
PresetComboBox(parent, preset_type, wxSize(25 * wxGetApp().em_unit(), 30 * wxGetApp().em_unit() / 10))
|
||||
{
|
||||
GetDropDown().SetUseContentWidth(true);
|
||||
GetDropDown().SetUseContentWidth(true,true);
|
||||
|
||||
if (m_type == Preset::TYPE_FILAMENT)
|
||||
{
|
||||
|
|
|
@ -141,11 +141,12 @@ void DropDown::SetSelectorBackgroundColor(StateColor const &color)
|
|||
paintNow();
|
||||
}
|
||||
|
||||
void DropDown::SetUseContentWidth(bool use)
|
||||
void DropDown::SetUseContentWidth(bool use, bool limit_max_content_width)
|
||||
{
|
||||
if (use_content_width == use)
|
||||
return;
|
||||
use_content_width = use;
|
||||
this->limit_max_content_width = limit_max_content_width;
|
||||
need_sync = true;
|
||||
messureSize();
|
||||
}
|
||||
|
@ -350,6 +351,11 @@ void DropDown::messureSize()
|
|||
szContent.x = x;
|
||||
}
|
||||
rowSize = szContent;
|
||||
if (limit_max_content_width) {
|
||||
wxSize parent_size = GetParent()->GetSize();
|
||||
if (rowSize.x > parent_size.x * 2)
|
||||
rowSize.x = 2 * parent_size.x;
|
||||
}
|
||||
szContent.y *= std::min((size_t)15, texts.size());
|
||||
szContent.y += texts.size() > 15 ? rowSize.y / 2 : 0;
|
||||
wxWindow::SetSize(szContent);
|
||||
|
|
|
@ -22,6 +22,7 @@ class DropDown : public PopupWindow
|
|||
|
||||
double radius = 0;
|
||||
bool use_content_width = false;
|
||||
bool limit_max_content_width = false;
|
||||
bool align_icon = false;
|
||||
bool text_off = false;
|
||||
|
||||
|
@ -74,7 +75,7 @@ public:
|
|||
|
||||
void SetSelectorBackgroundColor(StateColor const &color);
|
||||
|
||||
void SetUseContentWidth(bool use);
|
||||
void SetUseContentWidth(bool use, bool limit_max_content_width = false);
|
||||
|
||||
void SetAlignIcon(bool align);
|
||||
|
||||
|
|
Loading…
Reference in New Issue