FIX: clapse filament list min height & adjust filament groups
Change-Id: Ie4c41b2977addcac4359f161daa46f34dd35054e Jira: STUDIO-12082, STUDIO-12084, STUDIO-12077 (cherry picked from commit 973399104f9877afd8d5796d7cfa241a05957706)
This commit is contained in:
@@ -36,7 +36,8 @@ DropDown::DropDown(std::vector<Item> &items)
|
||||
: items(items)
|
||||
, state_handler(this)
|
||||
, border_color(0xDBDBDB)
|
||||
, text_color(0x363636)
|
||||
, text_color(std::make_pair(0x909090, (int) StateColor::Disabled),
|
||||
std::make_pair(0x363636, (int) StateColor::Normal))
|
||||
, selector_border_color(std::make_pair(0x009688, (int) StateColor::Hovered),
|
||||
std::make_pair(*wxWHITE, (int) StateColor::Normal))
|
||||
, selector_background_color(std::make_pair(0xBFE1DE, (int) StateColor::Checked), // ORCA updated background color for checked item
|
||||
@@ -269,10 +270,11 @@ void DropDown::render(wxDC &dc)
|
||||
dc.DrawRoundedRectangle(0, 0, size.x, size.y, radius);
|
||||
|
||||
int selected_item = selectedItem();
|
||||
int hover_index = hoverIndex();
|
||||
|
||||
// draw hover rectangle
|
||||
wxRect rcContent = {{0, offset.y}, rowSize};
|
||||
if (hover_item >= 0 && (states & StateColor::Hovered) && !(items[hover_item].style & DD_ITEM_STYLE_SPLIT_ITEM)) {
|
||||
if (hover_item >= 0 && (states & StateColor::Hovered) && (hover_index < 0 || !(items[hover_index].style & DD_ITEM_STYLE_SPLIT_ITEM))) {
|
||||
rcContent.y += rowSize.y * hover_item;
|
||||
if (rcContent.GetBottom() > 0 && rcContent.y < size.y) {
|
||||
if (selected_item == hover_item)
|
||||
@@ -331,17 +333,29 @@ void DropDown::render(wxDC &dc)
|
||||
|
||||
std::set<wxString> groups;
|
||||
// draw texts & icons
|
||||
dc.SetTextForeground(text_color.colorForStates(states));
|
||||
int index = 0;
|
||||
for (int i = 0; i < items.size(); ++i) {
|
||||
auto &item = items[i];
|
||||
int states2 = states;
|
||||
if ((item.style & DD_ITEM_STYLE_DISABLED) != 0)
|
||||
states2 &= ~StateColor::Enabled;
|
||||
// Skip by group
|
||||
if (group.IsEmpty()) {
|
||||
if (!item.group.IsEmpty()) {
|
||||
if (groups.find(item.group) == groups.end())
|
||||
groups.insert(item.group);
|
||||
else
|
||||
if (groups.find(item.group) != groups.end())
|
||||
continue;
|
||||
groups.insert(item.group);
|
||||
if (!item.group.IsEmpty()) {
|
||||
bool disabled = true;
|
||||
for (int j = i + 1; j < items.size(); ++j) {
|
||||
if (items[i].group != item.group && (items[j].style & DD_ITEM_STYLE_DISABLED) == 0) {
|
||||
disabled = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!disabled)
|
||||
states2 |= StateColor::Enabled;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (item.group != group)
|
||||
@@ -393,6 +407,7 @@ void DropDown::render(wxDC &dc)
|
||||
}
|
||||
pt.y += (rcContent.height - textSize.y) / 2;
|
||||
dc.SetFont(GetFont());
|
||||
dc.SetTextForeground(text_color.colorForStates(states2));
|
||||
dc.DrawText(text, pt);
|
||||
if (group.IsEmpty() && !item.group.IsEmpty()) {
|
||||
auto szBmp = arrow_bitmap.GetBmpSize();
|
||||
@@ -495,6 +510,8 @@ void DropDown::messureSize()
|
||||
? (item.group.IsEmpty() ? item.text : item.group)
|
||||
: (item.text.StartsWith(group) ? item.text.substr(group.size()).Trim(false) : item.text);
|
||||
size1 = dc.GetMultiLineTextExtent(text);
|
||||
if (group.IsEmpty() && !item.group.IsEmpty())
|
||||
size1.x += 5 + arrow_bitmap.GetBmpWidth();
|
||||
}
|
||||
if (item.icon.IsOk()) {
|
||||
wxSize size2 = GetBmpSize(item.icon);
|
||||
@@ -623,10 +640,13 @@ void DropDown::mouseReleased(wxMouseEvent& event)
|
||||
pressedDown = false;
|
||||
if (HasCapture())
|
||||
ReleaseMouse();
|
||||
if (hover_item >= 0) { // not moved
|
||||
if (hover_item >= 0 && subDropDown == nullptr) { // not moved
|
||||
sendDropDownEvent();
|
||||
if (mainDropDown)
|
||||
mainDropDown->hover_item = -1; // To Dismiss mainDropDown
|
||||
DismissAndNotify();
|
||||
}
|
||||
} else if (subDropDown)
|
||||
subDropDown->Popup(subDropDown);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user