KiCad PCB EDA Suite
Loading...
Searching...
No Matches
panel_simulator_preferences.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2024 KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include <type_traits>
21#include <wx/defs.h>
22#include <pgm_base.h>
25#include "../eeschema_settings.h"
26
27
30{
31#ifdef __WXOSX_MAC__
32 m_lblVScrollCtrl->SetLabel( _( "Cmd" ) );
33 m_lblVScrollAlt->SetLabel( _( "Option" ) );
34#endif
35
36 // Populate the wxChoice items programmatically here instead of via the form builder
37 // to ease maintenance.
38
39 static const wxString verticalChoiceItems[] =
40 {
41 _("No action"),
42 _("Pan left/right"),
43 _("Pan right/left"),
44 _("Pan up/down"),
45 _("Zoom"),
46 _("Zoom horizontally"),
47 _("Zoom vertically")
48 };
49
50 static constexpr auto ACTION_COUNT = static_cast<unsigned>( SIM_MOUSE_WHEEL_ACTION::COUNT );
51
52 static_assert( std::extent<decltype(verticalChoiceItems)>::value == ACTION_COUNT,
53 "verticalChoiceItems size does not match VERTICAL_SCROLL_ACTION::COUNT" );
54
55 m_choiceVScrollUnmodified->Set( ACTION_COUNT, verticalChoiceItems );
56 m_choiceVScrollCtrl ->Set( ACTION_COUNT, verticalChoiceItems );
57 m_choiceVScrollShift ->Set( ACTION_COUNT, verticalChoiceItems );
58 m_choiceVScrollAlt ->Set( ACTION_COUNT, verticalChoiceItems );
59
60 static const wxString horizontalChoiceItems[] =
61 {
62 _("No action"),
63 _("Pan left/right"),
64 _("Zoom horizontally")
65 };
66
67 m_choiceHScroll->Set( std::extent<decltype(horizontalChoiceItems)>::value,
68 horizontalChoiceItems );
69}
70
71
73
74
76{
78}
79
80
82{
83 static constexpr auto toAction =
84 []( const wxChoice* aChoice )
85 {
86 return static_cast<SIM_MOUSE_WHEEL_ACTION>( aChoice->GetSelection() );
87 };
88
90 EESCHEMA_SETTINGS* cfg = mgr.GetAppSettings<EESCHEMA_SETTINGS>( "eeschema" );
92
94 actions.vertical_with_ctrl = toAction( m_choiceVScrollCtrl );
95 actions.vertical_with_shift = toAction( m_choiceVScrollShift );
96 actions.vertical_with_alt = toAction( m_choiceVScrollAlt );
97
98 actions.horizontal = horizontalScrollSelectionToAction( m_choiceHScroll->GetSelection() );
99
100 return true;
101}
102
103
105{
107 EESCHEMA_SETTINGS* cfg = mgr.GetAppSettings<EESCHEMA_SETTINGS>( "eeschema" );
108
110 return true;
111}
112
113
115{
117}
118
119
121{
123}
124
125
128{
129 switch( aSelection )
130 {
131 case 0: return SIM_MOUSE_WHEEL_ACTION::NONE;
132 case 1: return SIM_MOUSE_WHEEL_ACTION::PAN_LEFT_RIGHT;
133 case 2: return SIM_MOUSE_WHEEL_ACTION::ZOOM_HORIZONTALLY;
134 default: break;
135 }
136
137 return SIM_MOUSE_WHEEL_ACTION::NONE;
138}
139
141{
142 switch( a )
143 {
144 case SIM_MOUSE_WHEEL_ACTION::NONE: return 0;
145 case SIM_MOUSE_WHEEL_ACTION::PAN_LEFT_RIGHT: return 1;
146 case SIM_MOUSE_WHEEL_ACTION::ZOOM_HORIZONTALLY: return 2;
147 default: break;
148 }
149
150 return 0;
151}
152
153
155 const SIM_MOUSE_WHEEL_ACTION_SET& anActionSet )
156{
157 static constexpr auto setSelection =
158 []( wxChoice* aChoice, auto action )
159 {
160 aChoice->SetSelection( static_cast<int>( action ) );
161 };
162
163 setSelection( m_choiceVScrollUnmodified, anActionSet.vertical_unmodified );
164 setSelection( m_choiceVScrollCtrl, anActionSet.vertical_with_ctrl );
165 setSelection( m_choiceVScrollShift, anActionSet.vertical_with_shift );
166 setSelection( m_choiceVScrollAlt, anActionSet.vertical_with_alt );
167
168 m_choiceHScroll->SetSelection( actionToHorizontalScrollSelection( anActionSet.horizontal ) );
169}
Class PANEL_SIMULATOR_PREFERENCES_BASE.
void onMouseDefaults(wxCommandEvent &) override
void applyMouseScrollActionsToPanel(const SIM_MOUSE_WHEEL_ACTION_SET &anActionSet)
static int actionToHorizontalScrollSelection(SIM_MOUSE_WHEEL_ACTION anAction)
void ResetPanel() override
Reset the contents of this panel.
static SIM_MOUSE_WHEEL_ACTION horizontalScrollSelectionToAction(int aSelection)
void onTrackpadDefaults(wxCommandEvent &) override
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition: pgm_base.h:142
T * GetAppSettings(const wxString &aFilename)
Returns a handle to the a given settings by type If the settings have already been loaded,...
#define _(s)
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: pgm_base.cpp:1060
see class PGM_BASE
SIM_MOUSE_WHEEL_ACTION
Enumerates the possible mouse wheel actions that can be performed on simulator plots.
Contains the set of modified mouse wheel actions that can be performed on a simulator plot.
static SIM_MOUSE_WHEEL_ACTION_SET GetMouseDefaults()
SIM_MOUSE_WHEEL_ACTION vertical_unmodified
SIM_MOUSE_WHEEL_ACTION vertical_with_alt
SIM_MOUSE_WHEEL_ACTION horizontal
SIM_MOUSE_WHEEL_ACTION vertical_with_ctrl
SIM_MOUSE_WHEEL_ACTION vertical_with_shift
static SIM_MOUSE_WHEEL_ACTION_SET GetTrackpadDefaults()
SIM_MOUSE_WHEEL_ACTION_SET mouse_wheel_actions