mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-01 21:10:47 +08:00
Improved ComboBoxes in respect to the users feedback after release.
This commit is contained in:
parent
c63f0d2870
commit
4b265f088f
@ -131,7 +131,14 @@ bool ComboBox::SetBackgroundColour(const wxColour& colour)
|
|||||||
TextInput::SetBackgroundColour(colour);
|
TextInput::SetBackgroundColour(colour);
|
||||||
|
|
||||||
drop.SetBackgroundColour(colour);
|
drop.SetBackgroundColour(colour);
|
||||||
drop.SetSelectorBackgroundColor(background_color);
|
StateColor selector_colors( std::make_pair(clr_background_focused, (int)StateColor::Checked),
|
||||||
|
Slic3r::GUI::wxGetApp().dark_mode() ?
|
||||||
|
std::make_pair(clr_background_disabled_dark, (int)StateColor::Disabled) :
|
||||||
|
std::make_pair(clr_background_disabled_light, (int)StateColor::Disabled),
|
||||||
|
Slic3r::GUI::wxGetApp().dark_mode() ?
|
||||||
|
std::make_pair(clr_background_normal_dark, (int)StateColor::Normal) :
|
||||||
|
std::make_pair(clr_background_normal_light, (int)StateColor::Normal));
|
||||||
|
drop.SetSelectorBackgroundColor(selector_colors);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -286,8 +293,6 @@ void ComboBox::keyDown(wxKeyEvent& event)
|
|||||||
switch (key_code) {
|
switch (key_code) {
|
||||||
#ifndef __WXOSX__
|
#ifndef __WXOSX__
|
||||||
case WXK_RETURN:
|
case WXK_RETURN:
|
||||||
#endif
|
|
||||||
case WXK_SPACE:
|
|
||||||
if (drop_down) {
|
if (drop_down) {
|
||||||
drop.DismissAndNotify();
|
drop.DismissAndNotify();
|
||||||
} else if (drop.HasDismissLongTime()) {
|
} else if (drop.HasDismissLongTime()) {
|
||||||
@ -298,6 +303,7 @@ void ComboBox::keyDown(wxKeyEvent& event)
|
|||||||
GetEventHandler()->ProcessEvent(e);
|
GetEventHandler()->ProcessEvent(e);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
case WXK_UP:
|
case WXK_UP:
|
||||||
case WXK_DOWN:
|
case WXK_DOWN:
|
||||||
case WXK_LEFT:
|
case WXK_LEFT:
|
||||||
|
@ -211,6 +211,10 @@ void DropDown::SetTransparentBG(wxDC& dc, wxWindow* win)
|
|||||||
#endif //__WXMSW__
|
#endif //__WXMSW__
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constexpr int slider_width = 12;
|
||||||
|
constexpr int slider_step = 5;
|
||||||
|
constexpr int items_padding = 2;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Here we do the actual rendering. I put it in a separate
|
* Here we do the actual rendering. I put it in a separate
|
||||||
* method so that it can work no matter what type of DC
|
* method so that it can work no matter what type of DC
|
||||||
@ -243,11 +247,17 @@ void DropDown::render(wxDC &dc)
|
|||||||
|
|
||||||
// draw hover rectangle
|
// draw hover rectangle
|
||||||
wxRect rcContent = {{0, offset.y}, rowSize};
|
wxRect rcContent = {{0, offset.y}, rowSize};
|
||||||
|
const int text_size = int(texts.size());
|
||||||
|
|
||||||
|
const bool has_bar = rowSize.y * text_size > size.y;
|
||||||
|
if (has_bar)
|
||||||
|
rcContent.width -= slider_width;
|
||||||
|
|
||||||
if (hover_item >= 0 && (states & StateColor::Hovered)) {
|
if (hover_item >= 0 && (states & StateColor::Hovered)) {
|
||||||
rcContent.y += rowSize.y * hover_item;
|
rcContent.y += rowSize.y * hover_item;
|
||||||
if (rcContent.GetBottom() > 0 && rcContent.y < size.y) {
|
if (rcContent.GetBottom() > 0 && rcContent.y < size.y) {
|
||||||
if (selection == hover_item)
|
if (selection == hover_item)
|
||||||
dc.SetBrush(wxBrush(selector_background_color.colorForStates(states | StateColor::Checked)));
|
dc.SetBrush(wxBrush(selector_background_color.colorForStates(StateColor::Disabled)));
|
||||||
dc.SetPen(wxPen(selector_border_color.colorForStates(states)));
|
dc.SetPen(wxPen(selector_border_color.colorForStates(states)));
|
||||||
rcContent.Deflate(4, 1);
|
rcContent.Deflate(4, 1);
|
||||||
dc.DrawRectangle(rcContent);
|
dc.DrawRectangle(rcContent);
|
||||||
@ -259,7 +269,7 @@ void DropDown::render(wxDC &dc)
|
|||||||
if (selection >= 0 && (selection != hover_item || (states & StateColor::Hovered) == 0)) {
|
if (selection >= 0 && (selection != hover_item || (states & StateColor::Hovered) == 0)) {
|
||||||
rcContent.y += rowSize.y * selection;
|
rcContent.y += rowSize.y * selection;
|
||||||
if (rcContent.GetBottom() > 0 && rcContent.y < size.y) {
|
if (rcContent.GetBottom() > 0 && rcContent.y < size.y) {
|
||||||
dc.SetBrush(wxBrush(selector_background_color.colorForStates(states | StateColor::Checked)));
|
dc.SetBrush(wxBrush(selector_background_color.colorForStates(StateColor::Disabled)));
|
||||||
dc.SetPen(wxPen(selector_background_color.colorForStates(states)));
|
dc.SetPen(wxPen(selector_background_color.colorForStates(states)));
|
||||||
rcContent.Deflate(4, 1);
|
rcContent.Deflate(4, 1);
|
||||||
dc.DrawRectangle(rcContent);
|
dc.DrawRectangle(rcContent);
|
||||||
@ -274,15 +284,13 @@ void DropDown::render(wxDC &dc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// draw position bar
|
// draw position bar
|
||||||
const int text_size = int(texts.size());
|
if (has_bar) {
|
||||||
if (rowSize.y * text_size > size.y) {
|
|
||||||
int height = rowSize.y * text_size;
|
int height = rowSize.y * text_size;
|
||||||
wxRect rect = {size.x - 6, -offset.y * size.y / height, 4,
|
wxRect rect = {size.x - slider_width - 2, -offset.y * size.y / height + 2, slider_width,
|
||||||
size.y * size.y / height};
|
size.y * size.y / height - 3};
|
||||||
dc.SetPen(wxPen(border_color.defaultColor()));
|
dc.SetPen(wxPen(border_color.defaultColor()));
|
||||||
dc.SetBrush(wxBrush(*wxLIGHT_GREY));
|
dc.SetBrush(wxBrush(selector_background_color.colorForStates(states | StateColor::Checked)));
|
||||||
dc.DrawRoundedRectangle(rect, 2);
|
dc.DrawRoundedRectangle(rect, 2);
|
||||||
rcContent.width -= 6;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw check icon
|
// draw check icon
|
||||||
@ -373,7 +381,7 @@ void DropDown::messureSize()
|
|||||||
}
|
}
|
||||||
if (iconSize.x > 0) szContent.x += iconSize.x + (text_off ? 0 : 5);
|
if (iconSize.x > 0) szContent.x += iconSize.x + (text_off ? 0 : 5);
|
||||||
if (iconSize.y > szContent.y) szContent.y = iconSize.y;
|
if (iconSize.y > szContent.y) szContent.y = iconSize.y;
|
||||||
szContent.y += 10;
|
szContent.y += items_padding;
|
||||||
if (texts.size() > 15) szContent.x += 6;
|
if (texts.size() > 15) szContent.x += 6;
|
||||||
if (GetParent()) {
|
if (GetParent()) {
|
||||||
auto x = GetParent()->GetSize().x;
|
auto x = GetParent()->GetSize().x;
|
||||||
@ -432,6 +440,13 @@ void DropDown::mouseDown(wxMouseEvent& event)
|
|||||||
return;
|
return;
|
||||||
// force calc hover item again
|
// force calc hover item again
|
||||||
mouseMove(event);
|
mouseMove(event);
|
||||||
|
|
||||||
|
const wxSize size = GetSize();
|
||||||
|
const int height = rowSize.y * int(texts.size());
|
||||||
|
const wxRect rect = { size.x - slider_width, -offset.y * size.y / height, slider_width - 2,
|
||||||
|
size.y * size.y / height };
|
||||||
|
slider_grabbed = rect.Contains(event.GetPosition());
|
||||||
|
|
||||||
pressedDown = true;
|
pressedDown = true;
|
||||||
CaptureMouse();
|
CaptureMouse();
|
||||||
dragStart = event.GetPosition();
|
dragStart = event.GetPosition();
|
||||||
@ -442,6 +457,7 @@ void DropDown::mouseReleased(wxMouseEvent& event)
|
|||||||
if (pressedDown) {
|
if (pressedDown) {
|
||||||
dragStart = wxPoint();
|
dragStart = wxPoint();
|
||||||
pressedDown = false;
|
pressedDown = false;
|
||||||
|
slider_grabbed = false;
|
||||||
if (HasCapture())
|
if (HasCapture())
|
||||||
ReleaseMouse();
|
ReleaseMouse();
|
||||||
if (hover_item >= 0) { // not moved
|
if (hover_item >= 0) { // not moved
|
||||||
@ -462,7 +478,10 @@ void DropDown::mouseMove(wxMouseEvent &event)
|
|||||||
wxPoint pt = event.GetPosition();
|
wxPoint pt = event.GetPosition();
|
||||||
int text_size = int(texts.size());
|
int text_size = int(texts.size());
|
||||||
if (pressedDown) {
|
if (pressedDown) {
|
||||||
wxPoint pt2 = offset + pt - dragStart;
|
const int height = rowSize.y * text_size;
|
||||||
|
const int y_step = slider_grabbed ? -height / GetSize().y : 1;
|
||||||
|
|
||||||
|
wxPoint pt2 = offset + (pt - dragStart)*y_step;
|
||||||
dragStart = pt;
|
dragStart = pt;
|
||||||
if (pt2.y > 0)
|
if (pt2.y > 0)
|
||||||
pt2.y = 0;
|
pt2.y = 0;
|
||||||
@ -477,7 +496,7 @@ void DropDown::mouseMove(wxMouseEvent &event)
|
|||||||
}
|
}
|
||||||
if (!pressedDown || hover_item >= 0) {
|
if (!pressedDown || hover_item >= 0) {
|
||||||
int hover = (pt.y - offset.y) / rowSize.y;
|
int hover = (pt.y - offset.y) / rowSize.y;
|
||||||
if (hover >= text_size) hover = -1;
|
if (hover >= text_size || slider_grabbed) hover = -1;
|
||||||
if (hover == hover_item) return;
|
if (hover == hover_item) return;
|
||||||
hover_item = hover;
|
hover_item = hover;
|
||||||
if (hover >= 0)
|
if (hover >= 0)
|
||||||
@ -489,7 +508,7 @@ void DropDown::mouseMove(wxMouseEvent &event)
|
|||||||
void DropDown::mouseWheelMoved(wxMouseEvent &event)
|
void DropDown::mouseWheelMoved(wxMouseEvent &event)
|
||||||
{
|
{
|
||||||
auto delta = event.GetWheelRotation() > 0 ? rowSize.y : -rowSize.y;
|
auto delta = event.GetWheelRotation() > 0 ? rowSize.y : -rowSize.y;
|
||||||
wxPoint pt2 = offset + wxPoint{0, delta};
|
wxPoint pt2 = offset + wxPoint{0, slider_step * delta};
|
||||||
int text_size = int(texts.size());
|
int text_size = int(texts.size());
|
||||||
if (pt2.y > 0)
|
if (pt2.y > 0)
|
||||||
pt2.y = 0;
|
pt2.y = 0;
|
||||||
|
@ -41,6 +41,7 @@ class DropDown : public wxPopupTransientWindow
|
|||||||
ScalableBitmap check_bitmap;
|
ScalableBitmap check_bitmap;
|
||||||
|
|
||||||
bool pressedDown = false;
|
bool pressedDown = false;
|
||||||
|
bool slider_grabbed = false;
|
||||||
boost::posix_time::ptime dismissTime;
|
boost::posix_time::ptime dismissTime;
|
||||||
wxPoint offset; // x not used
|
wxPoint offset; // x not used
|
||||||
wxPoint dragStart;
|
wxPoint dragStart;
|
||||||
|
@ -24,10 +24,10 @@ StaticBox::StaticBox()
|
|||||||
{
|
{
|
||||||
border_color = StateColor(std::make_pair(clr_border_disabled, (int) StateColor::Disabled),
|
border_color = StateColor(std::make_pair(clr_border_disabled, (int) StateColor::Disabled),
|
||||||
#ifndef __WXMSW__
|
#ifndef __WXMSW__
|
||||||
std::make_pair(clr_border_nornal, (int) StateColor::Focused),
|
std::make_pair(clr_border_normal, (int) StateColor::Focused),
|
||||||
#endif
|
#endif
|
||||||
std::make_pair(clr_border_hovered, (int) StateColor::Hovered),
|
std::make_pair(clr_border_hovered, (int) StateColor::Hovered),
|
||||||
std::make_pair(clr_border_nornal, (int) StateColor::Normal));
|
std::make_pair(clr_border_normal, (int) StateColor::Normal));
|
||||||
#ifndef __WXMSW__
|
#ifndef __WXMSW__
|
||||||
border_color.setTakeFocusedAsHovered(false);
|
border_color.setTakeFocusedAsHovered(false);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
#ifndef slic3r_UI_Colors_hpp_
|
#ifndef slic3r_UI_Colors_hpp_
|
||||||
#define slic3r_UI_Colors_hpp_
|
#define slic3r_UI_Colors_hpp_
|
||||||
|
|
||||||
static const int clr_border_nornal = 0x646464;//0xDBDBDB;
|
static const int clr_border_normal = 0x646464;//0xDBDBDB;
|
||||||
static const int clr_border_hovered = 0xED6B21;//0x00AE42;
|
static const int clr_border_hovered = 0xED6B21;//0x00AE42;
|
||||||
static const int clr_border_disabled = 0x646464;//0xDBDBDB;
|
static const int clr_border_disabled = 0x646464;//0xDBDBDB;
|
||||||
|
|
||||||
static const int clr_background_nornal_light = 0xFFFFFF;
|
static const int clr_background_normal_light = 0xFFFFFF;
|
||||||
static const int clr_background_nornal_dark = 0x2B2B2B;//0x434343;
|
static const int clr_background_normal_dark = 0x2B2B2B;//0x434343;
|
||||||
static const int clr_background_focused = 0xED6B21;//0xEDFAF2;
|
static const int clr_background_focused = 0xED6B21;//0xEDFAF2;
|
||||||
static const int clr_background_disabled_dark = 0x404040;//0xF0F0F0;
|
static const int clr_background_disabled_dark = 0x404040;//0xF0F0F0;
|
||||||
static const int clr_background_disabled_light = 0xD9D9D9;//0xF0F0F0;
|
static const int clr_background_disabled_light = 0xD9D9D9;//0xF0F0F0;
|
||||||
|
|
||||||
static const int clr_foreground_nornal = 0x262E30;
|
static const int clr_foreground_normal = 0x262E30;
|
||||||
static const int clr_foreground_focused = 0x00AE42;
|
static const int clr_foreground_focused = 0x00AE42;
|
||||||
static const int clr_foreground_disabled = 0x909090;
|
static const int clr_foreground_disabled = 0x909090;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user