diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index cf14fc735..37b3f60cc 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -1388,24 +1388,41 @@ void GUI_App::update_label_colours() tab->update_label_colours(); } +static bool is_focused(HWND hWnd) +{ + HWND hFocusedWnd = ::GetFocus(); + return hFocusedWnd && hWnd == hFocusedWnd; +} + void GUI_App::UpdateDarkUI(wxWindow* window, bool highlited/* = false*/, bool just_font/* = false*/) { #ifdef _WIN32 + bool is_focused_button = false; if (wxButton* btn = dynamic_cast(window)) { if (!(btn->GetWindowStyle() & wxNO_BORDER)) { btn->SetWindowStyle(btn->GetWindowStyle() | wxNO_BORDER); highlited = true; } - // hovering for buttons + // button marking { - auto focus_button = [this, btn](const bool focus) { - btn->SetForegroundColour(focus ? m_color_hovered_btn_label : m_color_label_default); + auto mark_button = [this, btn, highlited](const bool mark) { + if (btn->GetLabel().IsEmpty()) + btn->SetBackgroundColour(mark ? m_color_selected_btn_bg : highlited ? m_color_highlight_default : m_color_window_default); + else + btn->SetForegroundColour(mark ? m_color_hovered_btn_label : m_color_label_default); btn->Refresh(); btn->Update(); }; - btn->Bind(wxEVT_ENTER_WINDOW, [focus_button](wxMouseEvent& event) { focus_button(true); event.Skip(); }); - btn->Bind(wxEVT_LEAVE_WINDOW, [focus_button](wxMouseEvent& event) { focus_button(false); event.Skip(); }); + // hovering + btn->Bind(wxEVT_ENTER_WINDOW, [mark_button](wxMouseEvent& event) { mark_button(true); event.Skip(); }); + btn->Bind(wxEVT_LEAVE_WINDOW, [mark_button, btn](wxMouseEvent& event) { mark_button(is_focused(btn->GetHWND())); event.Skip(); }); + // focusing + btn->Bind(wxEVT_SET_FOCUS, [mark_button](wxFocusEvent& event) { mark_button(true); event.Skip(); }); + btn->Bind(wxEVT_KILL_FOCUS, [mark_button](wxFocusEvent& event) { mark_button(false); event.Skip(); }); + + if (is_focused_button = is_focused(btn->GetHWND())) + mark_button(true); } } else if (wxTextCtrl* text = dynamic_cast(window)) { @@ -1427,7 +1444,8 @@ void GUI_App::UpdateDarkUI(wxWindow* window, bool highlited/* = false*/, bool ju if (!just_font) window->SetBackgroundColour(highlited ? m_color_highlight_default : m_color_window_default); - window->SetForegroundColour(m_color_label_default); + if (!is_focused_button) + window->SetForegroundColour(m_color_label_default); #endif }