NDEVR
API Documentation
KeyController.h
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Design
28File: KeyController
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/Event.h>
35#include <NDEVR/SoftwareService.h>
36#include <NDEVR/Dictionary.h>
37#include <NDEVR/INIInterface.h>
38#include <NDEVR/TranslatedString.h>
39#include <NDEVR/UUID.h>
40#include <functional>
41namespace NDEVR
42{
43 class DesignObjectLookup;
44 class Camera;
45
51 {
52 public:
60 virtual bool processKeyEvent(const KeyEvent& key_event, DesignObjectLookup* lookup, Camera* camera) = 0;
61 };
62
73
78 {
79 public:
84 NDEVR_BASE_API BasicKeyController(const TranslatedString& key_controller_title);
92 NDEVR_BASE_API bool processKeyEvent(const KeyEvent& key_event, DesignObjectLookup* lookup, Camera* camera) final override;
101 NDEVR_BASE_API virtual bool processKeyEvent(const StringView& id, const KeyEvent& key_event, DesignObjectLookup* lookup, Camera* camera) = 0;
105 NDEVR_BASE_API virtual void resetKeyControllerToDefaults() = 0;
110 NDEVR_BASE_API const TranslatedString& keyControllerTitle() const { return m_key_controller_title; };
115 NDEVR_BASE_API const Buffer<KeyOption>& currentKeyMaps() const { return m_key_options; };
120 NDEVR_BASE_API virtual void setKeyOption(const KeyOption& option);
125 NDEVR_BASE_API virtual void getINI(INIFactory& factory) override;
130 NDEVR_BASE_API virtual void addKeyOption(const KeyOption& option);
131 protected:
135 };
136
143 {
144 public:
148 NDEVR_BASE_API KeyController();
152 NDEVR_BASE_API virtual ~KeyController(){}
158 NDEVR_BASE_API void addController(UUID id, KeyControllerBase* controller);
163 NDEVR_BASE_API void removeController(UUID id);
174 NDEVR_BASE_API bool hasController(UUID id) const;
182 NDEVR_BASE_API bool processKeyEvent(const KeyEvent& event, DesignObjectLookup* lookup, Camera* camera) override;
183 //void addHotKey(KeyEvent key, std::function<bool(const KeyEvent& key_event, DesignObjectLookup* lookup, Camera* camera)> action);
184 //void addRemoveHotKey(const KeyEvent& key);
189 NDEVR_BASE_API static KeyController& DefaultKeyController();
190 private:
191 Buffer<KeyControllerBase*> m_controllers;
192 Dictionary<UUID, KeyControllerBase*> m_controller_lookup;
193 };
194};//End namespace NDEVR
Buffer< KeyOption > m_key_options
The collection of registered key option mappings.
const Buffer< KeyOption > & currentKeyMaps() const
Returns the current set of key option mappings.
TranslatedString m_key_controller_title
The display title for this key controller.
bool m_save_ini_on_change_key_option_change
Whether to automatically save INI settings when a key option changes.
bool processKeyEvent(const KeyEvent &key_event, DesignObjectLookup *lookup, Camera *camera) final override
Processes a key event by matching it against registered key options.
BasicKeyController(const TranslatedString &key_controller_title)
Constructs a BasicKeyController with the given title.
const TranslatedString & keyControllerTitle() const
Returns the display title of this key controller.
virtual void resetKeyControllerToDefaults()=0
Resets all key mappings to their default values.
virtual bool processKeyEvent(const StringView &id, const KeyEvent &key_event, DesignObjectLookup *lookup, Camera *camera)=0
Processes a key event identified by its string ID.
virtual void addKeyOption(const KeyOption &option)
Adds a new key option mapping to this controller.
virtual void setKeyOption(const KeyOption &option)
Sets or updates an existing key option mapping.
virtual void getINI(INIFactory &factory) override
Serializes or deserializes key controller settings to/from an INI file.
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
A core object representing a user view as well as convenience functions for moving this view through ...
Definition Camera.h:95
A core class where all Design Objects including models, materials, and geometries are stored.
A hash-based key-value store, useful for quick associative lookups.
Definition Dictionary.h:64
Contains methods for easily reading and writing to an INI file including efficient casting,...
Definition INIReader.h:107
INIInterface()
Constructs an INIInterface with no default INI file.
Forward declaration for the camera class.
virtual bool processKeyEvent(const KeyEvent &key_event, DesignObjectLookup *lookup, Camera *camera)=0
Processes a key event and performs the associated action.
void removeController(UUID id)
Removes a sub-controller identified by a UUID.
static KeyController & DefaultKeyController()
Returns the application-wide default KeyController singleton.
bool processKeyEvent(const KeyEvent &event, DesignObjectLookup *lookup, Camera *camera) override
Dispatches a key event to all registered sub-controllers.
Buffer< KeyControllerBase * > controllers() const
Returns all registered sub-controllers.
void addController(UUID id, KeyControllerBase *controller)
Adds a sub-controller identified by a UUID.
virtual ~KeyController()
Destructor.
bool hasController(UUID id) const
Checks whether a sub-controller with the given UUID is registered.
KeyController()
Constructs the KeyController.
Describes a user key press event used to trigger behavior in the NDEVR API.
Definition Event.h:49
Software Service Managers take a Software service to modify the behavior of the software.
Base interface for services that extend or modify software behavior through modules.
The core String View class for the NDEVR API.
Definition StringView.h:58
The core String class for the NDEVR API.
Definition String.h:95
Any text displayed to the user should be defined as a TranslatedString which allows the program to lo...
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
Definition UUID.h:61
The primary namespace for the NDEVR SDK.
An action that can be tied to a specific KeyPress within the software.
String id
Unique identifier for this key option.
TranslatedString display_name
User-facing display name for this key option.
KeyEvent key_event
The key event associated with this option.