FIX: failed to limit the max width of DropDown

Jira: STUDIO-4503

Signed-off-by: wenjie.guo <wenjie.guo@bambulab.com>
Change-Id: Id9352d16f4bc016daade72a9c8d3d90164a1cb3d
This commit is contained in:
wenjie.guo 2023-11-06 18:23:52 +08:00 committed by Lane.Wei
parent 7fa96cfd0d
commit f63146e6f4
1 changed files with 3 additions and 1 deletions

View File

@ -353,8 +353,10 @@ void DropDown::messureSize()
rowSize = szContent; rowSize = szContent;
if (limit_max_content_width) { if (limit_max_content_width) {
wxSize parent_size = GetParent()->GetSize(); wxSize parent_size = GetParent()->GetSize();
if (rowSize.x > parent_size.x * 2) if (rowSize.x > parent_size.x * 2) {
rowSize.x = 2 * parent_size.x; rowSize.x = 2 * parent_size.x;
szContent = rowSize;
}
} }
szContent.y *= std::min((size_t)15, texts.size()); szContent.y *= std::min((size_t)15, texts.size());
szContent.y += texts.size() > 15 ? rowSize.y / 2 : 0; szContent.y += texts.size() > 15 ? rowSize.y / 2 : 0;