Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuSanka <yusanka@gmail.com>2021-12-23 21:09:27 +0300
committerYuSanka <yusanka@gmail.com>2021-12-23 21:09:27 +0300
commit86657523e38f21955a490869d276207c7ee1ec87 (patch)
tree32016e6a56695221846f33e5f1de29342dd3ea28 /src/slic3r/GUI
parent2458c4339bed12cf5bad4a696ffe6a53eaab5ebc (diff)
MSW specific: Highlight a focused buttons
Fix for #7564 - Button in focus is not highlighted anymore in PS 2.4 (accessibility issue)
Diffstat (limited to 'src/slic3r/GUI')
-rw-r--r--src/slic3r/GUI/GUI_App.cpp30
1 files changed, 24 insertions, 6 deletions
diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp
index afd9ab0c3..5ebd5300a 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<wxButton*>(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<wxTextCtrl*>(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
}