GL Studio C++ Runtime API
gls_switch.h
Go to the documentation of this file.
1/// \file gls_switch.h
2/// \brief The disti::GlsSwitch class.
3///
4/// \par Copyright Information
5///
6/// Copyright (c) 2017 by The DiSTI Corporation.<br>
7/// 12249 Science Drive; Suite 300<br>
8/// Orlando, Florida 32826<br>
9/// USA<br>
10/// <br>
11/// All rights reserved.<br>
12///
13/// This Software contains proprietary trade secrets of DiSTI and may not be
14/// reproduced, in whole or part, in any form, or by any means of electronic,
15/// mechanical, or otherwise, without the written permission of DiSTI. Said
16/// permission may be derived through the purchase of applicable DiSTI product
17/// licenses which detail the distribution rights of this content and any
18/// Derivative Works based on this or other copyrighted DiSTI Software.
19///
20/// NO WARRANTY. THE SOFTWARE IS PROVIDED "AS-IS," WITHOUT WARRANTY OF ANY KIND,
21/// AND ANY USE OF THIS SOFTWARE PRODUCT IS AT YOUR OWN RISK. TO THE MAXIMUM EXTENT
22/// PERMITTED BY APPLICABLE LAW, DISTI AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES
23/// AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
24/// IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND/OR FITNESS FOR A
25/// PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, WITH REGARD TO THE SOFTWARE.
26///
27/// LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,
28/// IN NO EVENT SHALL DISTI OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
29/// INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
30/// DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
31/// INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
32/// INABILITY TO USE THE SOFTWARE, EVEN IF DISTI HAS BEEN ADVISED OF THE POSSIBILITY
33/// OF SUCH DAMAGES. DISTI'S ENTIRE LIABILITY AND YOUR EXCLUSIVE REMEDY SHALL NOT
34/// EXCEED FIVE DOLLARS (US$5.00).
35///
36/// The aforementioned terms and restrictions are governed by the laws of the
37/// State of Florida and the United States of America.
38
39#ifndef DISTI_INCLUDED_GLS_SWITCH_H
40#define DISTI_INCLUDED_GLS_SWITCH_H
41
43#include "glsutil.h"
44#include "group.h"
45
46/// Provides support for creating DLLs.
47#if( defined( GLSGEN_EXPORT_GlsSwitch ) || defined( GLSGEN_IMPORT_GlsSwitch ) || defined( GLS_EXPORT_GENERATED ) || defined( GLS_IMPORT_GENERATED ) ) \
48 && defined( _MSC_VER )
49# if defined( GLSGEN_EXPORT_GlsSwitch ) || defined( GLS_EXPORT_GENERATED )
50# define GLSGEN_GlsSwitch_EXPORT __declspec( dllexport )
51# else
52# define GLSGEN_GlsSwitch_EXPORT __declspec( dllimport )
53# endif
54#else
55# define GLSGEN_GlsSwitch_EXPORT
56#endif
57///////////////////////////////////////////////////////////////////////////////
58
59/// Automatically link the runtime library plugin (on Windows).
60#define LIB_BASE_NAME "gls_switch"
61#include "gls_auto_lib.h"
62#undef LIB_BASE_NAME
63
64namespace disti
65{
66enum
67{
68 GLS_GLSSWITCH_INITIAL_DETENT_VAL = GLS_LAST_INITIALIZER + 1,
69 GLS_GLSSWITCH_WHICH_OBJECT_BACKGROUND,
70 GLS_GLSSWITCH_FIRST_DETENT_SNAPBACK, // for normal or snapback behavior
71 GLS_GLSSWITCH_LAST_DETENT_SNAPBACK, // for normal or snapback behavior
72 GLS_GLSSWITCH_EMIT_DETENT_VAL_EVENT,
73 GLS_GLSSWITCH_EMIT_LIMIT_EVENT,
74 GLS_GLSSWITCH_EMIT_RELEASE_EVENT
75};
76
77/** Runtime implementation of a switch */
78class GlsSwitch : public Group
79{
80private:
83
84public:
85 friend class GlsSwitchEditor;
86 DISTI_DEPRECATED( "This identifier is forbidden by the C++ standard. Use BaseClass instead." )
87 typedef Group _BaseClass; ///< Deprecated typedef for the base class.
88 typedef Group BaseClass; ///< Typedef for the base class.
89
90 int _detentVal; ///< CurrentPosition
91 bool _firstDetentSnapback; ///< If true, the position will snap from the first detent back to the second detent when released.
92 bool _lastDetentSnapback; ///< If true, the position will snap from the last detent back to the second to last detent when released.
93 int _whichObjectBackground; ///< the geometry index (plus 1) to serve as the switch background. 0 is no background object.
94 bool _emitDetentValEvent; ///< If true, events will be emitted whenever the detent value changes.
95
96 /// Set if a DetentVal event should be emitted.
97 /// \param value The new emit event flag to set.
98 void EmitDetentValEvent( const bool& value );
99
100 /// \return Whether or not a DetentVal event should be emitted.
102
103 /// Set if a Limit event should be emitted.
104 /// \param value The new emit event flag to set.
105 void EmitLimitEvent( const bool& value );
106
107 /// \return Whether or not a Limit event should be emitted.
109
110 /// Set if a Release event should be emitted.
111 /// \param value The new emit event flag to set.
112 void EmitReleaseEvent( const bool& value );
113
114 /// \return Whether or not a Release event should be emitted.
116
117 /// \return The number of detents on this switch.
119
120 /// \returns The geometry associated with the detent.
121 /// \param detent The index of the detent whose geometry is to be returned.
123
124 /// \return The geometry specified as the background, NULL is returned if none.
126
127 /// Create a new GlsSwitch.
128 /// \param generateInstance Whether or not to generate an instance name for this object.
129 GLSGEN_GlsSwitch_EXPORT GlsSwitch( bool generateInstance = false );
130
131 /// Copy constructor
132 /// \param that The object to copy from.
133 /// \param generateNames Whether or not to generate an instance name for this object.
134 GLSGEN_GlsSwitch_EXPORT GlsSwitch( const GlsSwitch& that, const bool generateNames );
135
136 /** Destroy a GlsSwitch object */
138
139 /// \return A pointer to a new GlsSwitch object.
141
143
145
147
149
151
152#ifndef GLES
155#endif
156
157 /// \return Whether or not this switch is horizontal or vertical relative to the y axis.
159
161
163
165
166 //////////////////////////////////////////////////
167 // Switch specific operations
168 //////////////////////////////////////////////////
169
170 /** Sets current detent of the switch
171 * \param val New detent of the switch
172 */
173 virtual GLSGEN_GlsSwitch_EXPORT void DetentVal( const int& val );
174
175 /** Returns the current detent of the switch
176 * \return Current switch detent
177 */
179
180 /** Sets current background geometry index value of the switch
181 * \param val New switch background geometry index value
182 */
183 virtual GLSGEN_GlsSwitch_EXPORT void WhichObjectBackground( const int& val );
184
185 /** Returns the current background geometry index value of the switch
186 * \return Current switch background geometry index value
187 */
189
190 /** Returns the current background geometry index value of the switch
191 * \deprecated this method is not const correct, use const version instead
192 * \return Current switch background geometry index value
193 */
194 DISTI_DEPRECATED( "Use the const version instead." )
196 {
197 return const_cast<const GlsSwitch*>( this )->WhichObjectBackground();
198 }
199
200protected:
201 bool _emitLimitEvent; ///< If true, an event will be emitted when the switch hits its maximum or minimum state.
202 bool _emitReleaseEvent; ///< If true, an event will be emitted when the switch is released.
203
204 Vector _mouseDownOCoords; ///< Stores the object coordinates of the last mouse down on this object.
205
206 bool _mouseWasDown; ///< Whether or not the mouse is down on this object.
207 unsigned int _currentCursor; ///< The current cursor used for interaction. Any other cursors are ignored while interacting.
208
209 /// Uses event data to calculate a new switch position based on the DCS of the object.
210 /// \note This is not intended to be called directly.
211 /// \param self This object.
212 /// \param ev The input event.
213 /// \param inputType The input type of this switch.
214 /// \param numPositions The number of positions in this switch.
215 /// \param scale Additional scale to be applied.
216 /// \return The new position of the switch.
218 InputOrientationEnum inputType, int numPositions,
219 float scale = 1.0f );
220
221#ifdef GLES
222 /** Set a single attribute from the GLO file.
223 * \param data The attribute to set and its associated data.
224 */
226#endif
227};
228
229} // namespace disti
230
231#endif
Definition: cull.h:49
Definition: events.h:111
Definition: display.h:95
Definition: dynamic_array.h:79
Definition: gls_glo_file.h:1241
Definition: gls_switch.h:79
int _detentVal
CurrentPosition.
Definition: gls_switch.h:90
bool _emitDetentValEvent
If true, events will be emitted whenever the detent value changes.
Definition: gls_switch.h:94
bool _firstDetentSnapback
If true, the position will snap from the first detent back to the second detent when released.
Definition: gls_switch.h:91
unsigned int _currentCursor
The current cursor used for interaction. Any other cursors are ignored while interacting.
Definition: gls_switch.h:207
GlsSwitch(bool generateInstance=false)
GlsSwitch(const GlsSwitch &that, const bool generateNames)
void SetValue(int spec, va_list &args) DISTI_METHOD_OVERRIDE
void CopyProperties(DisplayObject *src) DISTI_METHOD_OVERRIDE
void SetAvailableAttributes(unsigned int value) DISTI_METHOD_OVERRIDE
void GetCppInterfaceDescriptionFree(InterfaceListType *array) DISTI_METHOD_OVERRIDE
virtual int DetentVal()
virtual void DetentVal(const int &val)
virtual ~GlsSwitch()
bool _mouseWasDown
Whether or not the mouse is down on this object.
Definition: gls_switch.h:206
DisplayObject * handle(DisplayEvent *ev) DISTI_METHOD_OVERRIDE
void PreDraw(const OpenGLMatrices &parentMatrices, Culler &culler) DISTI_METHOD_OVERRIDE
static DisplayObject * CreateInstance()
void Draw() DISTI_METHOD_OVERRIDE
bool IsVisibleInScene(const DisplayObject *obj=NULL) const DISTI_METHOD_OVERRIDE
bool _emitReleaseEvent
If true, an event will be emitted when the switch is released.
Definition: gls_switch.h:202
InputOrientationEnum InputType()
void EmitLimitEvent(const bool &value)
Vector _mouseDownOCoords
Stores the object coordinates of the last mouse down on this object.
Definition: gls_switch.h:204
DisplayObject * BackgroundGeometry() const
virtual void WhichObjectBackground(const int &val)
int _whichObjectBackground
the geometry index (plus 1) to serve as the switch background. 0 is no background object.
Definition: gls_switch.h:93
bool EmitDetentValEvent()
Definition: gls_switch.h:101
void EmitReleaseEvent(const bool &value)
virtual int WhichObjectBackground() const
DisplayObject * CloneObject(bool generateNames=false) DISTI_METHOD_OVERRIDE
bool _emitLimitEvent
If true, an event will be emitted when the switch hits its maximum or minimum state.
Definition: gls_switch.h:201
bool EmitReleaseEvent()
Definition: gls_switch.h:115
bool _lastDetentSnapback
If true, the position will snap from the last detent back to the second to last detent when released.
Definition: gls_switch.h:92
int CalcSwitchPosDCS(DisplayObject *self, DisplayEvent *ev, InputOrientationEnum inputType, int numPositions, float scale=1.0f)
bool EmitLimitEvent()
Definition: gls_switch.h:108
InterfaceListType * GetCppInterfaceDescription(InterfaceListType *addToThisList=NULL) DISTI_METHOD_OVERRIDE
DisplayObject * DetentGeometry(int detent) const
Definition: group.h:52
Class to contain current OpenGL view, projection and draw matrices.
Definition: util.h:540
Definition: vertex.h:84
The gls_auto_lib.
Macros and helper code to determine what subset of C++11/14/17 is available.
#define DISTI_SPECIAL_MEM_FUN_DELETE
Macro to wrap function deletion, removed on compilers that don't support it.
Definition: gls_cpp_lang_support.h:245
#define DISTI_DEPRECATED(msg)
Defines whether this compiler supports the C++14 deprecated attribute.
Definition: gls_cpp_lang_support.h:487
#define DISTI_FINAL
Macro to wrap the final keyword, removed on compilers that don't support it.
Definition: gls_cpp_lang_support.h:223
#define DISTI_METHOD_OVERRIDE
Macro to wrap the override keyword, removed on compilers that don't support it.
Definition: gls_cpp_lang_support.h:221
#define GLSGEN_GlsSwitch_EXPORT
Provides support for creating DLLs.
Definition: gls_switch.h:55
GL Studio helper functions.
The disti::Group class. Implements groups of objects.
Definition: bmpimage.h:46
InputOrientationEnum
Enumeration for Input Operators.
Definition: glsutil.h:270