mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-03 17:10:41 +08:00
Very minimum accessibility of PrusaSlicer
This commit is contained in:
parent
5f9f5be614
commit
3e399a3977
@ -31,6 +31,7 @@ set(SLIC3R_GUI_SOURCES
|
|||||||
GUI/ConfigSnapshotDialog.hpp
|
GUI/ConfigSnapshotDialog.hpp
|
||||||
GUI/3DScene.cpp
|
GUI/3DScene.cpp
|
||||||
GUI/3DScene.hpp
|
GUI/3DScene.hpp
|
||||||
|
GUI/Accessibility.cpp
|
||||||
GUI/format.hpp
|
GUI/format.hpp
|
||||||
GUI/GLShadersManager.hpp
|
GUI/GLShadersManager.hpp
|
||||||
GUI/GLShadersManager.cpp
|
GUI/GLShadersManager.cpp
|
||||||
|
27
src/slic3r/GUI/Accessibility.cpp
Normal file
27
src/slic3r/GUI/Accessibility.cpp
Normal 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
|
29
src/slic3r/GUI/Accessibility.hpp
Normal file
29
src/slic3r/GUI/Accessibility.hpp
Normal 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 */
|
@ -18,6 +18,7 @@
|
|||||||
#include "OG_CustomCtrl.hpp"
|
#include "OG_CustomCtrl.hpp"
|
||||||
#include "MsgDialog.hpp"
|
#include "MsgDialog.hpp"
|
||||||
#include "format.hpp"
|
#include "format.hpp"
|
||||||
|
#include "Accessibility.hpp"
|
||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <wx/bookctrl.h>
|
#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);
|
this->back_to_sys_value(opt_id);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Accessibility::ClearLabelString();
|
||||||
|
|
||||||
// assign function objects for callbacks, etc.
|
// assign function objects for callbacks, etc.
|
||||||
return field;
|
return field;
|
||||||
}
|
}
|
||||||
@ -256,6 +259,7 @@ void OptionsGroup::append_separator()
|
|||||||
|
|
||||||
void OptionsGroup::activate_line(Line& line)
|
void OptionsGroup::activate_line(Line& line)
|
||||||
{
|
{
|
||||||
|
if(!line.label.IsEmpty()) Accessibility::SetNextLabelString(line.label);
|
||||||
if (line.is_separator())
|
if (line.is_separator())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ BitmapToggleButton::BitmapToggleButton(wxWindow* parent, const wxString& label,
|
|||||||
{
|
{
|
||||||
const long style = wxBORDER_NONE | wxBU_EXACTFIT | wxBU_LEFT;
|
const long style = wxBORDER_NONE | wxBU_EXACTFIT | wxBU_LEFT;
|
||||||
if (label.IsEmpty())
|
if (label.IsEmpty())
|
||||||
wxBitmapToggleButton::Create(parent, id, wxNullBitmap, wxDefaultPosition, wxDefaultSize, style);
|
wxBitmapToggleButton::Create(parent, id, wxNullBitmap, wxDefaultPosition, wxDefaultSize, style | wxBU_NOTEXT);
|
||||||
else {
|
else {
|
||||||
#ifdef __WXGTK3__
|
#ifdef __WXGTK3__
|
||||||
wxSize label_size = parent->GetTextExtent(label);
|
wxSize label_size = parent->GetTextExtent(label);
|
||||||
@ -15,7 +15,7 @@ BitmapToggleButton::BitmapToggleButton(wxWindow* parent, const wxString& label,
|
|||||||
wxSize def_size = wxDefaultSize;
|
wxSize def_size = wxDefaultSize;
|
||||||
#endif
|
#endif
|
||||||
// Call Create() from wxToggleButton instead of wxBitmapToggleButton to allow add Label text under Linux
|
// 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__
|
#ifdef __WXMSW__
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include "CheckBox.hpp"
|
#include "CheckBox.hpp"
|
||||||
|
#include "slic3r/GUI/Accessibility.hpp"
|
||||||
|
|
||||||
//#include "../wxExtensions.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_on_focused(this, "check_on_focused", px_cnt)
|
||||||
, m_off_focused(this, "check_off_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
|
#ifdef __WXOSX__ // State not fully implement on MacOS
|
||||||
Bind(wxEVT_SET_FOCUS, &CheckBox::updateBitmap, this);
|
Bind(wxEVT_SET_FOCUS, &CheckBox::updateBitmap, this);
|
||||||
Bind(wxEVT_KILL_FOCUS, &CheckBox::updateBitmap, this);
|
Bind(wxEVT_KILL_FOCUS, &CheckBox::updateBitmap, this);
|
||||||
@ -57,6 +63,8 @@ void CheckBox::update()
|
|||||||
if (GetBitmapMargins().GetWidth() == 0 && !GetLabelText().IsEmpty())
|
if (GetBitmapMargins().GetWidth() == 0 && !GetLabelText().IsEmpty())
|
||||||
SetBitmapMargins(4, 0);
|
SetBitmapMargins(4, 0);
|
||||||
update_size();
|
update_size();
|
||||||
|
|
||||||
|
this->SetLabel(m_accessibility_label+((val)?(" X"):("")));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
|
@ -40,6 +40,8 @@ private:
|
|||||||
ScalableBitmap m_off_disabled;
|
ScalableBitmap m_off_disabled;
|
||||||
ScalableBitmap m_on_focused;
|
ScalableBitmap m_on_focused;
|
||||||
ScalableBitmap m_off_focused;
|
ScalableBitmap m_off_focused;
|
||||||
|
|
||||||
|
wxString m_accessibility_label;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // !slic3r_GUI_CheckBox_hpp_
|
#endif // !slic3r_GUI_CheckBox_hpp_
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "UIColors.hpp"
|
#include "UIColors.hpp"
|
||||||
|
|
||||||
#include "../GUI_App.hpp"
|
#include "../GUI_App.hpp"
|
||||||
|
#include "../Accessibility.hpp"
|
||||||
|
|
||||||
#include <wx/dcgraph.h>
|
#include <wx/dcgraph.h>
|
||||||
#include <wx/panel.h>
|
#include <wx/panel.h>
|
||||||
@ -286,6 +287,10 @@ void SpinInput::Create(wxWindow *parent,
|
|||||||
state_handler.attach({&label_color, &text_color});
|
state_handler.attach({&label_color, &text_color});
|
||||||
state_handler.update_binds();
|
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));
|
text_ctrl = new wxTextCtrl(this, wxID_ANY, text, {20, 4}, wxDefaultSize, style | wxBORDER_NONE | wxTE_PROCESS_ENTER, wxTextValidator(wxFILTER_NUMERIC));
|
||||||
#ifdef __WXOSX__
|
#ifdef __WXOSX__
|
||||||
text_ctrl->OSXDisableAllSmartSubstitutions();
|
text_ctrl->OSXDisableAllSmartSubstitutions();
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include <wx/panel.h>
|
#include <wx/panel.h>
|
||||||
|
|
||||||
#include "slic3r/GUI/GUI_App.hpp"
|
#include "slic3r/GUI/GUI_App.hpp"
|
||||||
|
#include "slic3r/GUI/Accessibility.hpp"
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(TextInput, wxPanel)
|
BEGIN_EVENT_TABLE(TextInput, wxPanel)
|
||||||
|
|
||||||
@ -56,6 +57,11 @@ void TextInput::Create(wxWindow * parent,
|
|||||||
state_handler.attach({&label_color, &text_color});
|
state_handler.attach({&label_color, &text_color});
|
||||||
state_handler.update_binds();
|
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);
|
text_ctrl = new wxTextCtrl(this, wxID_ANY, text, {4, 4}, size, style | wxBORDER_NONE);
|
||||||
#ifdef __WXOSX__
|
#ifdef __WXOSX__
|
||||||
text_ctrl->OSXDisableAllSmartSubstitutions();
|
text_ctrl->OSXDisableAllSmartSubstitutions();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user