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>2022-01-04 18:39:10 +0300
commit229df98386e5bd9ba7e2006059ac7ac0c78a88be (patch)
tree1efbba24e8483f3c6cdc3e8b6d7c51b043ef5837 /src/slic3r/GUI
parent34d9fbdc357fb3a4ea5ddbcf0c209e2be31214c6 (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 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<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
}