1 /*
2  Copyright (C) 2010-2014 Kristian Duske
3 
4  This file is part of TrenchBroom.
5 
6  TrenchBroom is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  TrenchBroom is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with TrenchBroom.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #include "MousePreferencePane.h"
21 
22 #include "StringUtils.h"
23 #include "PreferenceManager.h"
24 #include "Preferences.h"
25 #include "View/BorderLine.h"
26 #include "View/KeyboardShortcutEditor.h"
27 #include "View/KeyboardShortcutEvent.h"
28 #include "View/ViewConstants.h"
29 
30 #include <wx/checkbox.h>
31 #include <wx/gbsizer.h>
32 #include <wx/sizer.h>
33 #include <wx/slider.h>
34 #include <wx/stattext.h>
35 
36 namespace TrenchBroom {
37     namespace View {
MousePreferencePane(wxWindow * parent)38         MousePreferencePane::MousePreferencePane(wxWindow* parent) :
39         PreferencePane(parent) {
40             createGui();
41             bindEvents();
42         }
43 
OnLookSpeedChanged(wxScrollEvent & event)44         void MousePreferencePane::OnLookSpeedChanged(wxScrollEvent& event) {
45             if (IsBeingDeleted()) return;
46 
47             const float value = m_lookSpeedSlider->GetValue() / 100.0f;
48 
49             PreferenceManager& prefs = PreferenceManager::instance();
50             prefs.set(Preferences::CameraLookSpeed, value);
51         }
52 
OnInvertLookHAxisChanged(wxCommandEvent & event)53         void MousePreferencePane::OnInvertLookHAxisChanged(wxCommandEvent& event) {
54             if (IsBeingDeleted()) return;
55 
56             const bool value = event.GetInt() != 0;
57 
58             PreferenceManager& prefs = PreferenceManager::instance();
59             prefs.set(Preferences::CameraLookInvertH, value);
60         }
61 
OnInvertLookVAxisChanged(wxCommandEvent & event)62         void MousePreferencePane::OnInvertLookVAxisChanged(wxCommandEvent& event) {
63             if (IsBeingDeleted()) return;
64 
65             const bool value = event.GetInt() != 0;
66 
67             PreferenceManager& prefs = PreferenceManager::instance();
68             prefs.set(Preferences::CameraLookInvertV, value);
69         }
70 
OnPanSpeedChanged(wxScrollEvent & event)71         void MousePreferencePane::OnPanSpeedChanged(wxScrollEvent& event) {
72             if (IsBeingDeleted()) return;
73 
74             const float value = m_panSpeedSlider->GetValue() / 100.0f;
75 
76             PreferenceManager& prefs = PreferenceManager::instance();
77             prefs.set(Preferences::CameraPanSpeed, value);
78         }
79 
OnInvertPanHAxisChanged(wxCommandEvent & event)80         void MousePreferencePane::OnInvertPanHAxisChanged(wxCommandEvent& event) {
81             if (IsBeingDeleted()) return;
82 
83             const bool value = event.GetInt() != 0;
84 
85             PreferenceManager& prefs = PreferenceManager::instance();
86             prefs.set(Preferences::CameraPanInvertH, value);
87         }
88 
OnInvertPanVAxisChanged(wxCommandEvent & event)89         void MousePreferencePane::OnInvertPanVAxisChanged(wxCommandEvent& event) {
90             if (IsBeingDeleted()) return;
91 
92             const bool value = event.GetInt() != 0;
93 
94             PreferenceManager& prefs = PreferenceManager::instance();
95             prefs.set(Preferences::CameraPanInvertV, value);
96         }
97 
OnMoveSpeedChanged(wxScrollEvent & event)98         void MousePreferencePane::OnMoveSpeedChanged(wxScrollEvent& event) {
99             if (IsBeingDeleted()) return;
100 
101             const float value = m_moveSpeedSlider->GetValue() / 100.0f;
102 
103             PreferenceManager& prefs = PreferenceManager::instance();
104             prefs.set(Preferences::CameraMoveSpeed, value);
105         }
106 
OnInvertMouseWheelChanged(wxCommandEvent & event)107         void MousePreferencePane::OnInvertMouseWheelChanged(wxCommandEvent& event) {
108             if (IsBeingDeleted()) return;
109 
110             const bool value = event.GetInt() != 0;
111 
112             PreferenceManager& prefs = PreferenceManager::instance();
113             prefs.set(Preferences::CameraMouseWheelInvert, value);
114         }
115 
OnEnableAltMoveChanged(wxCommandEvent & event)116         void MousePreferencePane::OnEnableAltMoveChanged(wxCommandEvent& event) {
117             if (IsBeingDeleted()) return;
118 
119             const bool value = event.GetInt() != 0;
120 
121             PreferenceManager& prefs = PreferenceManager::instance();
122             prefs.set(Preferences::CameraEnableAltMove, value);
123         }
124 
OnInvertAltMoveAxisChanged(wxCommandEvent & event)125         void MousePreferencePane::OnInvertAltMoveAxisChanged(wxCommandEvent& event) {
126             if (IsBeingDeleted()) return;
127 
128             const bool value = event.GetInt() != 0;
129 
130             PreferenceManager& prefs = PreferenceManager::instance();
131             prefs.set(Preferences::CameraAltMoveInvert, value);
132         }
133 
OnMoveCameraInCursorDirChanged(wxCommandEvent & event)134         void MousePreferencePane::OnMoveCameraInCursorDirChanged(wxCommandEvent& event) {
135             if (IsBeingDeleted()) return;
136 
137             const bool value = event.GetInt() != 0;
138 
139             PreferenceManager& prefs = PreferenceManager::instance();
140             prefs.set(Preferences::CameraMoveInCursorDir, value);
141         }
142 
OnFlySpeedChanged(wxScrollEvent & event)143         void MousePreferencePane::OnFlySpeedChanged(wxScrollEvent& event) {
144             if (IsBeingDeleted()) return;
145 
146             const float value = m_flySpeedSlider->GetValue() / 100.0f;
147 
148             PreferenceManager& prefs = PreferenceManager::instance();
149             prefs.set(Preferences::CameraFlySpeed, value);
150         }
151 
OnInvertFlyVAxisChanged(wxCommandEvent & event)152         void MousePreferencePane::OnInvertFlyVAxisChanged(wxCommandEvent& event) {
153             if (IsBeingDeleted()) return;
154 
155             const bool value = event.GetInt() != 0;
156 
157             PreferenceManager& prefs = PreferenceManager::instance();
158             prefs.set(Preferences::CameraFlyInvertV, value);
159         }
160 
OnForwardKeyChanged(KeyboardShortcutEvent & event)161         void MousePreferencePane::OnForwardKeyChanged(KeyboardShortcutEvent& event) {
162             if (IsBeingDeleted()) return;
163 
164             PreferenceManager& prefs = PreferenceManager::instance();
165 
166             const KeyboardShortcut shortcut(event.key(), event.modifier1(), event.modifier2(), event.modifier3());
167             if (prefs.get(Preferences::CameraFlyBackward).hasKey() && prefs.get(Preferences::CameraFlyBackward) == shortcut)
168                 event.Veto();
169             else if (prefs.get(Preferences::CameraFlyLeft).hasKey() && prefs.get(Preferences::CameraFlyLeft) == shortcut)
170                 event.Veto();
171             else if (prefs.get(Preferences::CameraFlyRight).hasKey() && prefs.get(Preferences::CameraFlyRight) == shortcut)
172                 event.Veto();
173             else
174                 prefs.set(Preferences::CameraFlyForward, shortcut);
175         }
176 
OnBackwardKeyChanged(KeyboardShortcutEvent & event)177         void MousePreferencePane::OnBackwardKeyChanged(KeyboardShortcutEvent& event) {
178             if (IsBeingDeleted()) return;
179 
180             PreferenceManager& prefs = PreferenceManager::instance();
181 
182             const KeyboardShortcut shortcut(event.key(), event.modifier1(), event.modifier2(), event.modifier3());
183             if (prefs.get(Preferences::CameraFlyForward).hasKey() && prefs.get(Preferences::CameraFlyForward) == shortcut)
184                 event.Veto();
185             else if (prefs.get(Preferences::CameraFlyLeft).hasKey() && prefs.get(Preferences::CameraFlyLeft) == shortcut)
186                 event.Veto();
187             else if (prefs.get(Preferences::CameraFlyRight).hasKey() && prefs.get(Preferences::CameraFlyRight) == shortcut)
188                 event.Veto();
189             else
190                 prefs.set(Preferences::CameraFlyBackward, shortcut);
191         }
192 
OnLeftKeyChanged(KeyboardShortcutEvent & event)193         void MousePreferencePane::OnLeftKeyChanged(KeyboardShortcutEvent& event) {
194             if (IsBeingDeleted()) return;
195 
196             PreferenceManager& prefs = PreferenceManager::instance();
197 
198             const KeyboardShortcut shortcut(event.key(), event.modifier1(), event.modifier2(), event.modifier3());
199             if (prefs.get(Preferences::CameraFlyForward).hasKey() && prefs.get(Preferences::CameraFlyForward) == shortcut)
200                 event.Veto();
201             else if (prefs.get(Preferences::CameraFlyBackward).hasKey() && prefs.get(Preferences::CameraFlyBackward) == shortcut)
202                 event.Veto();
203             else if (prefs.get(Preferences::CameraFlyRight).hasKey() && prefs.get(Preferences::CameraFlyRight) == shortcut)
204                 event.Veto();
205             else
206                 prefs.set(Preferences::CameraFlyLeft, shortcut);
207         }
208 
OnRightKeyChanged(KeyboardShortcutEvent & event)209         void MousePreferencePane::OnRightKeyChanged(KeyboardShortcutEvent& event) {
210             if (IsBeingDeleted()) return;
211 
212             PreferenceManager& prefs = PreferenceManager::instance();
213 
214             const KeyboardShortcut shortcut(event.key(), event.modifier1(), event.modifier2(), event.modifier3());
215             if (prefs.get(Preferences::CameraFlyForward).hasKey() && prefs.get(Preferences::CameraFlyForward) == shortcut)
216                 event.Veto();
217             else if (prefs.get(Preferences::CameraFlyBackward).hasKey() && prefs.get(Preferences::CameraFlyBackward) == shortcut)
218                 event.Veto();
219             else if (prefs.get(Preferences::CameraFlyLeft).hasKey() && prefs.get(Preferences::CameraFlyLeft) == shortcut)
220                 event.Veto();
221             else
222                 prefs.set(Preferences::CameraFlyRight, shortcut);
223         }
224 
createGui()225         void MousePreferencePane::createGui() {
226             wxWindow* mousePreferences = createCameraPreferences();
227 
228             wxSizer* sizer = new wxBoxSizer(wxVERTICAL);
229             sizer->AddSpacer(LayoutConstants::NarrowVMargin);
230             sizer->Add(mousePreferences, 1, wxEXPAND);
231             sizer->AddSpacer(LayoutConstants::WideVMargin);
232 
233             SetMinSize(sizer->GetMinSize());
234             SetSizer(sizer);
235 
236             SetBackgroundColour(*wxWHITE);
237         }
238 
createCameraPreferences()239         wxWindow* MousePreferencePane::createCameraPreferences() {
240             wxPanel* box = new wxPanel(this);
241             box->SetBackgroundColour(*wxWHITE);
242 
243             wxStaticText* lookPrefsHeader = new wxStaticText(box, wxID_ANY, "Mouse Look");
244             lookPrefsHeader->SetFont(lookPrefsHeader->GetFont().Bold());
245             wxStaticText* lookSpeedLabel = new wxStaticText(box, wxID_ANY, "Sensitivity");
246             m_lookSpeedSlider = new wxSlider(box, wxID_ANY, 50, 1, 100, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_BOTTOM);
247             m_invertLookHAxisCheckBox = new wxCheckBox(box, wxID_ANY, "Invert X Axis");
248             m_invertLookVAxisCheckBox = new wxCheckBox(box, wxID_ANY, "Invert Y Axis");
249 
250             wxStaticText* panPrefsHeader = new wxStaticText(box, wxID_ANY, "Mouse Pan");
251             panPrefsHeader->SetFont(panPrefsHeader->GetFont().Bold());
252             wxStaticText* panSpeedLabel = new wxStaticText(box, wxID_ANY, "Sensitivity");
253             m_panSpeedSlider = new wxSlider(box, wxID_ANY, 50, 1, 100, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_BOTTOM);
254 
255             m_invertPanHAxisCheckBox = new wxCheckBox(box, wxID_ANY, "Invert X Axis");
256             m_invertPanVAxisCheckBox = new wxCheckBox(box, wxID_ANY, "Invert Y Axis");
257             wxStaticText* movePrefsHeader = new wxStaticText(box, wxID_ANY, "Mouse Move");
258             movePrefsHeader->SetFont(movePrefsHeader->GetFont().Bold());
259 
260             wxStaticText* moveSpeedLabel = new wxStaticText(box, wxID_ANY, "Sensitivity");
261             m_moveSpeedSlider = new wxSlider(box, wxID_ANY, 50, 1, 100, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_BOTTOM);
262             m_invertMouseWheelCheckBox = new wxCheckBox(box, wxID_ANY, "Invert mouse wheel");
263             m_enableAltMoveCheckBox = new wxCheckBox(box, wxID_ANY, "Alt+MMB drag to move camera");
264             m_invertAltMoveAxisCheckBox = new wxCheckBox(box, wxID_ANY, "Invert Z axis in Alt+MMB drag");
265             m_moveInCursorDirCheckBox = new wxCheckBox(box, wxID_ANY, "Move camera towards cursor");
266 
267             wxStaticText* flyPrefsHeader = new wxStaticText(box, wxID_ANY, "Fly Mode");
268             flyPrefsHeader->SetFont(lookPrefsHeader->GetFont().Bold());
269             wxStaticText* flySpeedLabel = new wxStaticText(box, wxID_ANY, "Sensitivity");
270             m_flySpeedSlider = new wxSlider(box, wxID_ANY, 50, 1, 100, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_BOTTOM);
271             m_invertFlyVAxisCheckBox = new wxCheckBox(box, wxID_ANY, "Invert Y Axis");
272 
273             wxStaticText* forwardKeyLabel = new wxStaticText(box, wxID_ANY, "Forward");
274             m_forwardKeyEditor = new KeyboardShortcutEditor(box, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_THEME);
275             m_forwardKeyEditor->SetMinSize(wxSize(80, wxDefaultCoord));
276             wxStaticText* backwardKeyLabel = new wxStaticText(box, wxID_ANY, "Backward");
277             m_backwardKeyEditor = new KeyboardShortcutEditor(box, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_THEME);
278             m_backwardKeyEditor->SetMinSize(wxSize(80, wxDefaultCoord));
279             wxStaticText* leftKeyLabel = new wxStaticText(box, wxID_ANY, "Left");
280             m_leftKeyEditor = new KeyboardShortcutEditor(box, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_THEME);
281             m_leftKeyEditor->SetMinSize(wxSize(80, wxDefaultCoord));
282             wxStaticText* rightKeyLabel = new wxStaticText(box, wxID_ANY, "Right");
283             m_rightKeyEditor = new KeyboardShortcutEditor(box, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_THEME);
284             m_rightKeyEditor->SetMinSize(wxSize(80, wxDefaultCoord));
285 
286             const int HMargin           = LayoutConstants::WideHMargin;
287             const int LMargin           = LayoutConstants::WideVMargin;
288             const int HeaderFlags       = wxLEFT;
289             const int LabelFlags        = wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL | wxLEFT;
290             const int SliderFlags       = wxEXPAND | wxRIGHT;
291             const int CheckBoxFlags     = wxRIGHT;
292             const int KeyEditorFlags    = wxRIGHT;
293             const int LineFlags         = wxEXPAND | wxTOP;
294 
295             wxGridBagSizer* sizer = new wxGridBagSizer(LayoutConstants::NarrowVMargin, LayoutConstants::WideHMargin);
296             sizer->Add(lookPrefsHeader,             wxGBPosition( 0, 0), wxGBSpan(1,2), HeaderFlags, HMargin);
297             sizer->Add(lookSpeedLabel,              wxGBPosition( 1, 0), wxDefaultSpan, LabelFlags, HMargin);
298             sizer->Add(m_lookSpeedSlider,           wxGBPosition( 1, 1), wxDefaultSpan, SliderFlags, HMargin);
299             sizer->Add(m_invertLookHAxisCheckBox,   wxGBPosition( 2, 1), wxDefaultSpan, CheckBoxFlags, HMargin);
300             sizer->Add(m_invertLookVAxisCheckBox,   wxGBPosition( 3, 1), wxDefaultSpan, CheckBoxFlags, HMargin);
301             sizer->Add(new BorderLine(box),         wxGBPosition( 4, 0), wxGBSpan(1,2), LineFlags, LMargin);
302 
303             sizer->Add(panPrefsHeader,              wxGBPosition( 5, 0), wxGBSpan(1,2), HeaderFlags, HMargin);
304             sizer->Add(panSpeedLabel,               wxGBPosition( 6, 0), wxDefaultSpan, LabelFlags, HMargin);
305             sizer->Add(m_panSpeedSlider,            wxGBPosition( 6, 1), wxDefaultSpan, SliderFlags, HMargin);
306             sizer->Add(m_invertPanHAxisCheckBox,    wxGBPosition( 7, 1), wxDefaultSpan, CheckBoxFlags, HMargin);
307             sizer->Add(m_invertPanVAxisCheckBox,    wxGBPosition( 8, 1), wxDefaultSpan, CheckBoxFlags, HMargin);
308             sizer->Add(new BorderLine(box),         wxGBPosition( 9, 0), wxGBSpan(1,2), LineFlags, LMargin);
309 
310             sizer->Add(movePrefsHeader,             wxGBPosition(10, 0), wxGBSpan(1,2), HeaderFlags, HMargin);
311             sizer->Add(moveSpeedLabel,              wxGBPosition(11, 0), wxDefaultSpan, LabelFlags, HMargin);
312             sizer->Add(m_moveSpeedSlider,           wxGBPosition(11, 1), wxDefaultSpan, SliderFlags, HMargin);
313             sizer->Add(m_invertMouseWheelCheckBox,  wxGBPosition(12, 1), wxDefaultSpan, CheckBoxFlags, HMargin);
314             sizer->Add(m_enableAltMoveCheckBox,     wxGBPosition(13, 1), wxDefaultSpan, CheckBoxFlags, HMargin);
315             sizer->Add(m_invertAltMoveAxisCheckBox, wxGBPosition(14, 1), wxDefaultSpan, CheckBoxFlags, HMargin);
316             sizer->Add(m_moveInCursorDirCheckBox,   wxGBPosition(15, 1), wxDefaultSpan, CheckBoxFlags, HMargin);
317             sizer->Add(new BorderLine(box),         wxGBPosition(16, 0), wxGBSpan(1,2), LineFlags, LMargin);
318 
319             sizer->Add(flyPrefsHeader,              wxGBPosition(17, 0), wxGBSpan(1,2), HeaderFlags, HMargin);
320             sizer->Add(flySpeedLabel,               wxGBPosition(18, 0), wxDefaultSpan, LabelFlags, HMargin);
321             sizer->Add(m_flySpeedSlider,            wxGBPosition(18, 1), wxDefaultSpan, SliderFlags, HMargin);
322             sizer->Add(m_invertFlyVAxisCheckBox,    wxGBPosition(19, 1), wxDefaultSpan, CheckBoxFlags, HMargin);
323 
324             sizer->Add(forwardKeyLabel,             wxGBPosition(20, 0), wxDefaultSpan, LabelFlags, HMargin);
325             sizer->Add(m_forwardKeyEditor,          wxGBPosition(20, 1), wxDefaultSpan, KeyEditorFlags, HMargin);
326             sizer->Add(backwardKeyLabel,            wxGBPosition(21, 0), wxDefaultSpan, LabelFlags, HMargin);
327             sizer->Add(m_backwardKeyEditor,         wxGBPosition(21, 1), wxDefaultSpan, KeyEditorFlags, HMargin);
328             sizer->Add(leftKeyLabel,                wxGBPosition(22, 0), wxDefaultSpan, LabelFlags, HMargin);
329             sizer->Add(m_leftKeyEditor,             wxGBPosition(22, 1), wxDefaultSpan, KeyEditorFlags, HMargin);
330             sizer->Add(rightKeyLabel,               wxGBPosition(23, 0), wxDefaultSpan, LabelFlags, HMargin);
331             sizer->Add(m_rightKeyEditor,            wxGBPosition(23, 1), wxDefaultSpan, KeyEditorFlags, HMargin);
332 
333             sizer->AddGrowableCol(1);
334             sizer->SetMinSize(500, wxDefaultCoord);
335             box->SetSizer(sizer);
336             return box;
337         }
338 
bindEvents()339         void MousePreferencePane::bindEvents() {
340             m_invertLookHAxisCheckBox->Bind(wxEVT_CHECKBOX, &MousePreferencePane::OnInvertLookHAxisChanged, this);
341             m_invertLookVAxisCheckBox->Bind(wxEVT_CHECKBOX, &MousePreferencePane::OnInvertLookVAxisChanged, this);
342             m_invertPanHAxisCheckBox->Bind(wxEVT_CHECKBOX, &MousePreferencePane::OnInvertPanHAxisChanged, this);
343             m_invertPanVAxisCheckBox->Bind(wxEVT_CHECKBOX, &MousePreferencePane::OnInvertPanVAxisChanged, this);
344             m_invertMouseWheelCheckBox->Bind(wxEVT_CHECKBOX, &MousePreferencePane::OnInvertMouseWheelChanged, this);
345             m_enableAltMoveCheckBox->Bind(wxEVT_CHECKBOX, &MousePreferencePane::OnEnableAltMoveChanged, this);
346             m_moveInCursorDirCheckBox->Bind(wxEVT_CHECKBOX, &MousePreferencePane::OnMoveCameraInCursorDirChanged, this);
347             m_invertFlyVAxisCheckBox->Bind(wxEVT_CHECKBOX, &MousePreferencePane::OnInvertFlyVAxisChanged, this);
348 
349             bindSliderEvents(m_lookSpeedSlider, &MousePreferencePane::OnLookSpeedChanged, this);
350             bindSliderEvents(m_panSpeedSlider, &MousePreferencePane::OnPanSpeedChanged, this);
351             bindSliderEvents(m_moveSpeedSlider, &MousePreferencePane::OnMoveSpeedChanged, this);
352             bindSliderEvents(m_flySpeedSlider, &MousePreferencePane::OnFlySpeedChanged, this);
353 
354             m_forwardKeyEditor->Bind(KEYBOARD_SHORTCUT_EVENT, &MousePreferencePane::OnForwardKeyChanged, this);
355             m_backwardKeyEditor->Bind(KEYBOARD_SHORTCUT_EVENT, &MousePreferencePane::OnBackwardKeyChanged, this);
356             m_leftKeyEditor->Bind(KEYBOARD_SHORTCUT_EVENT, &MousePreferencePane::OnLeftKeyChanged, this);
357             m_rightKeyEditor->Bind(KEYBOARD_SHORTCUT_EVENT, &MousePreferencePane::OnRightKeyChanged, this);
358         }
359 
doCanResetToDefaults()360         bool MousePreferencePane::doCanResetToDefaults() {
361             return true;
362         }
363 
doResetToDefaults()364         void MousePreferencePane::doResetToDefaults() {
365             PreferenceManager& prefs = PreferenceManager::instance();
366             prefs.resetToDefault(Preferences::CameraLookSpeed);
367             prefs.resetToDefault(Preferences::CameraLookInvertH);
368             prefs.resetToDefault(Preferences::CameraLookInvertV);
369 
370             prefs.resetToDefault(Preferences::CameraPanSpeed);
371             prefs.resetToDefault(Preferences::CameraPanInvertH);
372             prefs.resetToDefault(Preferences::CameraPanInvertV);
373 
374             prefs.resetToDefault(Preferences::CameraMoveSpeed);
375             prefs.resetToDefault(Preferences::CameraMouseWheelInvert);
376             prefs.resetToDefault(Preferences::CameraEnableAltMove);
377             prefs.resetToDefault(Preferences::CameraAltMoveInvert);
378             prefs.resetToDefault(Preferences::CameraMoveInCursorDir);
379 
380             prefs.resetToDefault(Preferences::CameraFlySpeed);
381             prefs.resetToDefault(Preferences::CameraFlyInvertV);
382 
383             prefs.resetToDefault(Preferences::CameraFlyForward);
384             prefs.resetToDefault(Preferences::CameraFlyBackward);
385             prefs.resetToDefault(Preferences::CameraFlyLeft);
386             prefs.resetToDefault(Preferences::CameraLookSpeed);
387             prefs.resetToDefault(Preferences::CameraFlyRight);
388         }
389 
doUpdateControls()390         void MousePreferencePane::doUpdateControls() {
391             PreferenceManager& prefs = PreferenceManager::instance();
392 
393             m_lookSpeedSlider->SetValue(static_cast<int>(prefs.get(Preferences::CameraLookSpeed) * m_lookSpeedSlider->GetMax()));
394             m_invertLookHAxisCheckBox->SetValue(prefs.get(Preferences::CameraLookInvertH));
395             m_invertLookVAxisCheckBox->SetValue(prefs.get(Preferences::CameraLookInvertV));
396 
397             m_panSpeedSlider->SetValue(static_cast<int>(prefs.get(Preferences::CameraPanSpeed) * m_panSpeedSlider->GetMax()));
398             m_invertPanHAxisCheckBox->SetValue(prefs.get(Preferences::CameraPanInvertH));
399             m_invertPanVAxisCheckBox->SetValue(prefs.get(Preferences::CameraPanInvertV));
400 
401             m_moveSpeedSlider->SetValue(static_cast<int>(prefs.get(Preferences::CameraMoveSpeed) * m_moveSpeedSlider->GetMax()));
402             m_invertMouseWheelCheckBox->SetValue(prefs.get(Preferences::CameraMouseWheelInvert));
403             m_enableAltMoveCheckBox->SetValue(prefs.get(Preferences::CameraEnableAltMove));
404             m_invertAltMoveAxisCheckBox->SetValue(prefs.get(Preferences::CameraAltMoveInvert));
405             m_moveInCursorDirCheckBox->SetValue(prefs.get(Preferences::CameraMoveInCursorDir));
406 
407             m_flySpeedSlider->SetValue(static_cast<int>(prefs.get(Preferences::CameraFlySpeed) * m_flySpeedSlider->GetMax()));
408             m_invertFlyVAxisCheckBox->SetValue(prefs.get(Preferences::CameraFlyInvertV));
409 
410             m_forwardKeyEditor->SetShortcut(prefs.get(Preferences::CameraFlyForward));
411             m_backwardKeyEditor->SetShortcut(prefs.get(Preferences::CameraFlyBackward));
412             m_leftKeyEditor->SetShortcut(prefs.get(Preferences::CameraFlyLeft));
413             m_rightKeyEditor->SetShortcut(prefs.get(Preferences::CameraFlyRight));
414         }
415 
doValidate()416         bool MousePreferencePane::doValidate() {
417             return true;
418         }
419 	}
420 }
421