Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide very minimum accessibility of PrusaSlicer #11651

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/slic3r/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ set(SLIC3R_GUI_SOURCES
GUI/ConfigSnapshotDialog.hpp
GUI/3DScene.cpp
GUI/3DScene.hpp
GUI/Accessibility.cpp
GUI/format.hpp
GUI/GLShadersManager.hpp
GUI/GLShadersManager.cpp
Expand Down
27 changes: 27 additions & 0 deletions src/slic3r/GUI/Accessibility.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
///|/ Copyright (c) Prusa Research 2023 Dawid Pieper @dawidpieper
///|/
///|/ PrusaSlicer is released under the terms of the AGPLv3 or higher
///|/

#include <wx/string.h>

#include "Accessibility.hpp"

namespace Slic3r { namespace GUI {

wxString Accessibility::GetLastLabelString() {return Accessibility::sLastLabel;}

void Accessibility::SetNextLabelString(wxString labelString) {
Accessibility::sLastLabel = labelString.Clone();
Accessibility::bLabelAvailable = true;
}

void Accessibility::ClearLabelString() {
Accessibility::sLastLabel = "";
Accessibility::bLabelAvailable = false;
}

bool Accessibility::IsLabelAvailable() {return Accessibility::bLabelAvailable;}

} // GUI
} // Slic3r
29 changes: 29 additions & 0 deletions src/slic3r/GUI/Accessibility.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
///|/ Copyright (c) Prusa Research 2023 Dawid Pieper @dawidpieper
///|/
///|/ PrusaSlicer is released under the terms of the AGPLv3 or higher
///|/
#ifndef SLIC3R_GUI_ACCESSIBILITY_HPP
#define SLIC3R_GUI_ACCESSIBILITY_HPP

#include <wx/string.h>

namespace Slic3r { namespace GUI {

class Accessibility {

public:
static wxString GetLastLabelString();
static void SetNextLabelString(wxString labelString);
static void ClearLabelString();
static bool IsLabelAvailable();

private:
inline static wxString sLastLabel = "";
inline static bool bLabelAvailable = false;

};

} // GUI
} // Slic3r

#endif /* SLIC3R_GUI_ACCESSIBILITY_HPP */
4 changes: 4 additions & 0 deletions src/slic3r/GUI/OptionsGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "OG_CustomCtrl.hpp"
#include "MsgDialog.hpp"
#include "format.hpp"
#include "Accessibility.hpp"

#include <utility>
#include <wx/bookctrl.h>
Expand Down Expand Up @@ -125,6 +126,8 @@ const t_field& OptionsGroup::build_field(const t_config_option_key& id, const Co
this->back_to_sys_value(opt_id);
};

Accessibility::ClearLabelString();

// assign function objects for callbacks, etc.
return field;
}
Expand Down Expand Up @@ -256,6 +259,7 @@ void OptionsGroup::append_separator()

void OptionsGroup::activate_line(Line& line)
{
if(!line.label.IsEmpty()) Accessibility::SetNextLabelString(line.label);
if (line.is_separator())
return;

Expand Down
2 changes: 1 addition & 1 deletion src/slic3r/GUI/Widgets/BitmapToggleButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

BitmapToggleButton::BitmapToggleButton(wxWindow* parent, const wxString& label, wxWindowID id)
{
const long style = wxBORDER_NONE | wxBU_EXACTFIT | wxBU_LEFT;
const long style = wxBORDER_NONE | wxBU_EXACTFIT | wxBU_LEFT | wxBU_NOTEXT;
if (label.IsEmpty())
wxBitmapToggleButton::Create(parent, id, wxNullBitmap, wxDefaultPosition, wxDefaultSize, style);
else {
Expand Down
8 changes: 8 additions & 0 deletions src/slic3r/GUI/Widgets/CheckBox.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "CheckBox.hpp"
#include "slic3r/GUI/Accessibility.hpp"

//#include "../wxExtensions.hpp"

Expand All @@ -13,6 +14,11 @@ CheckBox::CheckBox(wxWindow* parent, const wxString& name)
, m_on_focused(this, "check_on_focused", px_cnt)
, m_off_focused(this, "check_off_focused", px_cnt)
{
if(Slic3r::GUI::Accessibility::IsLabelAvailable())
m_accessibility_label = Slic3r::GUI::Accessibility::GetLastLabelString();
else
m_accessibility_label = "";

#ifdef __WXOSX__ // State not fully implement on MacOS
Bind(wxEVT_SET_FOCUS, &CheckBox::updateBitmap, this);
Bind(wxEVT_KILL_FOCUS, &CheckBox::updateBitmap, this);
Expand Down Expand Up @@ -57,6 +63,8 @@ void CheckBox::update()
if (GetBitmapMargins().GetWidth() == 0 && !GetLabelText().IsEmpty())
SetBitmapMargins(4, 0);
update_size();

this->SetLabel(m_accessibility_label+((val)?(" X"):("")));
}

#ifdef __WXMSW__
Expand Down
2 changes: 2 additions & 0 deletions src/slic3r/GUI/Widgets/CheckBox.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ class CheckBox : public BitmapToggleButton
ScalableBitmap m_off_disabled;
ScalableBitmap m_on_focused;
ScalableBitmap m_off_focused;

wxString m_accessibility_label;
};

#endif // !slic3r_GUI_CheckBox_hpp_
5 changes: 5 additions & 0 deletions src/slic3r/GUI/Widgets/SpinInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "UIColors.hpp"

#include "../GUI_App.hpp"
#include "../Accessibility.hpp"

#include <wx/dcgraph.h>
#include <wx/panel.h>
Expand Down Expand Up @@ -286,6 +287,10 @@ void SpinInput::Create(wxWindow *parent,
state_handler.attach({&label_color, &text_color});
state_handler.update_binds();

if(Slic3r::GUI::Accessibility::IsLabelAvailable())
wxStaticText *virtualLabel = new wxStaticText(
this, wxID_ANY, Slic3r::GUI::Accessibility::GetLastLabelString(), wxDefaultPosition, wxSize(0, 0), wxST_NO_AUTORESIZE
);
text_ctrl = new wxTextCtrl(this, wxID_ANY, text, {20, 4}, wxDefaultSize, style | wxBORDER_NONE | wxTE_PROCESS_ENTER, wxTextValidator(wxFILTER_NUMERIC));
#ifdef __WXOSX__
text_ctrl->OSXDisableAllSmartSubstitutions();
Expand Down
6 changes: 6 additions & 0 deletions src/slic3r/GUI/Widgets/TextInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <wx/panel.h>

#include "slic3r/GUI/GUI_App.hpp"
#include "slic3r/GUI/Accessibility.hpp"

BEGIN_EVENT_TABLE(TextInput, wxPanel)

Expand Down Expand Up @@ -56,6 +57,11 @@ void TextInput::Create(wxWindow * parent,
state_handler.attach({&label_color, &text_color});
state_handler.update_binds();

if(Slic3r::GUI::Accessibility::IsLabelAvailable())
wxStaticText *virtualLabel = new wxStaticText(
this, wxID_ANY, Slic3r::GUI::Accessibility::GetLastLabelString(), wxDefaultPosition, wxSize(0, 0), wxST_NO_AUTORESIZE
);

text_ctrl = new wxTextCtrl(this, wxID_ANY, text, {4, 4}, size, style | wxBORDER_NONE);
#ifdef __WXOSX__
text_ctrl->OSXDisableAllSmartSubstitutions();
Expand Down