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
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 const EESCHEMA_SETTINGS* settings = mgr.GetAppSettings<EESCHEMA_SETTINGS>();
109 return true;
110}
111
112
114{
116}
117
118
120{
122}
123
124
127{
128 switch( aSelection )
129 {
130 case 0: return SIM_MOUSE_WHEEL_ACTION::NONE;
131 case 1: return SIM_MOUSE_WHEEL_ACTION::PAN_LEFT_RIGHT;
132 case 2: return SIM_MOUSE_WHEEL_ACTION::ZOOM_HORIZONTALLY;
133 default: break;
134 }
135
136 return SIM_MOUSE_WHEEL_ACTION::NONE;
137}
138
140{
141 switch( a )
142 {
143 case SIM_MOUSE_WHEEL_ACTION::NONE: return 0;
144 case SIM_MOUSE_WHEEL_ACTION::PAN_LEFT_RIGHT: return 1;
145 case SIM_MOUSE_WHEEL_ACTION::ZOOM_HORIZONTALLY: return 2;
146 default: break;
147 }
148
149 return 0;
150}
151
152
154 const SIM_MOUSE_WHEEL_ACTION_SET& anActionSet )
155{
156 static constexpr auto setSelection =
157 []( wxChoice* aChoice, auto action )
158 {
159 aChoice->SetSelection( static_cast<int>( action ) );
160 };
161
162 setSelection( m_choiceVScrollUnmodified, anActionSet.vertical_unmodified );
163 setSelection( m_choiceVScrollCtrl, anActionSet.vertical_with_ctrl );
164 setSelection( m_choiceVScrollShift, anActionSet.vertical_with_shift );
165 setSelection( m_choiceVScrollAlt, anActionSet.vertical_with_alt );
166
167 m_choiceHScroll->SetSelection( actionToHorizontalScrollSelection( anActionSet.horizontal ) );
168}
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()
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