Very minimum accessibility of PrusaSlicer

This commit is contained in:
dawidpieper 2023-11-13 00:33:38 +01:00 committed by YuSanka
parent 5f9f5be614
commit 3e399a3977
9 changed files with 84 additions and 2 deletions

View File

@ -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

View File

@ -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

View File

@ -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 */

View File

@ -18,6 +18,7 @@
#include "OG_CustomCtrl.hpp"
#include "MsgDialog.hpp"
#include "format.hpp"
#include "Accessibility.hpp"
#include <utility>
#include <wx/bookctrl.h>
@ -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;
}
@ -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;

View File

@ -6,7 +6,7 @@ BitmapToggleButton::BitmapToggleButton(wxWindow* parent, const wxString& label,
{
const long style = wxBORDER_NONE | wxBU_EXACTFIT | wxBU_LEFT;
if (label.IsEmpty())
wxBitmapToggleButton::Create(parent, id, wxNullBitmap, wxDefaultPosition, wxDefaultSize, style);
wxBitmapToggleButton::Create(parent, id, wxNullBitmap, wxDefaultPosition, wxDefaultSize, style | wxBU_NOTEXT);
else {
#ifdef __WXGTK3__
wxSize label_size = parent->GetTextExtent(label);
@ -15,7 +15,7 @@ BitmapToggleButton::BitmapToggleButton(wxWindow* parent, const wxString& label,
wxSize def_size = wxDefaultSize;
#endif
// Call Create() from wxToggleButton instead of wxBitmapToggleButton to allow add Label text under Linux
wxToggleButton::Create(parent, id, label, wxDefaultPosition, def_size, style);
wxToggleButton::Create(parent, id, label, wxDefaultPosition, def_size, style | wxBU_NOTEXT);
}
#ifdef __WXMSW__

View File

@ -1,4 +1,5 @@
#include "CheckBox.hpp"
#include "slic3r/GUI/Accessibility.hpp"
//#include "../wxExtensions.hpp"
@ -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);
@ -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__

View File

@ -40,6 +40,8 @@ private:
ScalableBitmap m_off_disabled;
ScalableBitmap m_on_focused;
ScalableBitmap m_off_focused;
wxString m_accessibility_label;
};
#endif // !slic3r_GUI_CheckBox_hpp_

View File

@ -4,6 +4,7 @@
#include "UIColors.hpp"
#include "../GUI_App.hpp"
#include "../Accessibility.hpp"
#include <wx/dcgraph.h>
#include <wx/panel.h>
@ -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();

View File

@ -5,6 +5,7 @@
#include <wx/panel.h>
#include "slic3r/GUI/GUI_App.hpp"
#include "slic3r/GUI/Accessibility.hpp"
BEGIN_EVENT_TABLE(TextInput, wxPanel)
@ -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();