GL Studio C++ Runtime API
gls_button.h
Go to the documentation of this file.
1/// \file gls_button.h
2/// \brief The GlsPushButton runtime 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 INCLUDED_GLS_BUTTON_H
40#define INCLUDED_GLS_BUTTON_H
41
43#include "group.h"
44
45/// Provides support for creating DLLs.
46#if( defined( GLSGEN_EXPORT_GlsPushButton ) || defined( GLSGEN_IMPORT_GlsPushButton ) || defined( GLS_EXPORT_GENERATED ) || defined( GLS_IMPORT_GENERATED ) ) \
47 && defined( _MSC_VER )
48# if defined( GLSGEN_EXPORT_GlsPushButton ) || defined( GLS_EXPORT_GENERATED )
49# define GLSGEN_GlsPushButton_EXPORT __declspec( dllexport )
50# else
51# define GLSGEN_GlsPushButton_EXPORT __declspec( dllimport )
52# endif
53#else
54# define GLSGEN_GlsPushButton_EXPORT
55#endif
56///////////////////////////////////////////////////////////////////////////////
57
58/// Automatically link the runtime library plugin (on Windows).
59#define LIB_BASE_NAME "gls_push_button"
60#include "gls_auto_lib.h"
61#undef LIB_BASE_NAME
62
63namespace disti
64{
65enum
66{
67 GLS_GLSBUTTON_CHANGE_CALLBACK = GLS_LAST_INITIALIZER + 1,
68 GLS_GLSBUTTON_TOGGLE,
69 GLS_GLSBUTTON_WHICH_OBJ_POS_UP,
70 GLS_GLSBUTTON_WHICH_OBJ_POS_DOWN,
71 GLS_GLSBUTTON_STATE,
72 GLS_GLSBUTTON_EMIT_STATE_CHANGE_EVENT
73};
74
75/** Runtime implementation of a push button */
76class GlsPushButton : public Group
77{
78private:
81
82public:
83 DISTI_DEPRECATED( "This identifier is forbidden by the C++ standard. Use BaseClass instead." )
84 typedef Group _BaseClass; ///< Deprecated typedef for the base class.
85 typedef Group BaseClass; ///< Typedef for the base class.
86
88
89 bool _toggle; ///< The push button behavior (true=toggle, false=momentary).
90 int _whichObjectPosUp; ///< The object index to be the button up position.
91 int _whichObjectPosDown; ///< The object index to be the button down position.
92 int _state; ///< The button state: 0=up, 1=down.
93 bool _emitStateChangeEvent; ///< If true "StateChange" events will be emitted when this button changes state.
94
95 bool _mouseIsDown; ///< True when the mouse has been pushed down on this button.
96 unsigned int _currentCursor; ///< The current cursor used for interaction. Any other cursors are ignored while interacting.
97
98 friend class GlsPushButtonEditor;
99
100 /// Create a new GlsPushButton.
101 /// \param generateInstance Whether or not to generate an instance name for this object.
102 GLSGEN_GlsPushButton_EXPORT GlsPushButton( bool generateInstance = false );
103
104 /// Create a new GlsPushButton.
105 /// \param that The object to copy from.
106 /// \param generateNames Whether or not to generate an instance name for this object.
107 GLSGEN_GlsPushButton_EXPORT GlsPushButton( const GlsPushButton& that, const bool generateNames );
108
109 /** Destroy a GlsPushButton object */
111
112 /// \return A pointer to a new GlsPushButton object.
114
120
121 /** Sets the child index that represents the up state of the button
122 * \param which New child index for the up state
123 */
125
126 /** Returns the child index that represents the up state of the button
127 * \return Current child index for the up state
128 */
130
131 /// Sets the child index that represents the down state of the button.
132 /// \param which The new child index for the down state.
134
135 /// Returns the index that represents the down state of the button.
136 /// \return The current child index for the down state.
138
139 /// Sets if the object should hold its state(true) or return to the up state(false).
140 /// \param toggle The new behavior of if the object should hold its state(true) or return to the up state(false).
141 virtual GLSGEN_GlsPushButton_EXPORT void Toggle( bool toggle );
142
143 /// Returns if the object should hold its state(true) or return to the up state(false).
144 /// \return The current behavior of if the object should hold its state(true) or return to the up state(false).
146
148 const Vector& logicalCoords,
149 float scale,
150 const Vector& directionVector,
151 Vector& collisionWinLoc /*Returned*/,
152 const OpenGLMatrices& drawnMatrices ) DISTI_METHOD_OVERRIDE;
153
154#ifndef GLES
157#endif
158
160
161 //////////////////////////////////////////////////
162 // Push Button specific operations
163 //////////////////////////////////////////////////
165
166 /** Sets the push button state (0=up, 1=down)
167 * \param state New button state (0=up, 1=down)
168 */
169 virtual GLSGEN_GlsPushButton_EXPORT void State( const int& state );
170
171 /** Returns the current push button state (0=up, 1=down)
172 * \return Current push button state (0=up, 1=down)
173 */
175
176 /** Returns the current push button state (0=up, 1=down)
177 * \deprecated this method is not const correct, use const version instead
178 * \return Current push button state (0=up, 1=down)
179 */
180 DISTI_DEPRECATED( "Use the const version instead." )
181 virtual int State() DISTI_FINAL
182 {
183 return const_cast<const GlsPushButton*>( this )->State();
184 }
185
186private:
187 DisplayObject* GetPickedObject( bool firstPick,
188 const Vector& winLoc,
189 const Vector& logicalCoords,
190 float scale, const Vector& directionVector,
191 Vector& collisionWinLoc /*Returned*/,
192 const OpenGLMatrices& drawnMatrices );
193 bool _forceDrawDownState; // Flag control for when the button is visually down (the actual state may vary)
194
195protected:
196#ifdef GLES
197 /** Set a single attribute from the GLO file.
198 * \param data The attribute to set and its associated data.
199 */
200 GLS_EXPORT void SetFromGloData( GlsGloFileAttribute& data ) DISTI_METHOD_OVERRIDE;
201#endif
202};
203
204} // namespace disti
205
206#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_button.h:77
unsigned int _currentCursor
The current cursor used for interaction. Any other cursors are ignored while interacting.
Definition: gls_button.h:96
void SetValue(int spec, va_list &args) DISTI_METHOD_OVERRIDE
void CopyProperties(DisplayObject *src) DISTI_METHOD_OVERRIDE
virtual void State(const int &state)
int _state
The button state: 0=up, 1=down.
Definition: gls_button.h:92
void SetAvailableAttributes(unsigned int value) DISTI_METHOD_OVERRIDE
void GetCppInterfaceDescriptionFree(InterfaceListType *array) DISTI_METHOD_OVERRIDE
DisplayObject * handle(DisplayEvent *ev) DISTI_METHOD_OVERRIDE
int _whichObjectPosUp
The object index to be the button up position.
Definition: gls_button.h:90
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
virtual int State() const
bool _emitStateChangeEvent
If true "StateChange" events will be emitted when this button changes state.
Definition: gls_button.h:93
virtual int WhichObjectPosDown() const
virtual DisplayObject * Pick3D(const Vector &winLoc, const Vector &logicalCoords, float scale, const Vector &directionVector, Vector &collisionWinLoc, const OpenGLMatrices &drawnMatrices) DISTI_METHOD_OVERRIDE
bool _mouseIsDown
True when the mouse has been pushed down on this button.
Definition: gls_button.h:95
virtual int WhichObjectPosUp() const
int _whichObjectPosDown
The object index to be the button down position.
Definition: gls_button.h:91
DisplayObject * CloneObject(bool generateNames=false) DISTI_METHOD_OVERRIDE
InterfaceListType * GetCppInterfaceDescription(InterfaceListType *addToThisList=NULL) DISTI_METHOD_OVERRIDE
virtual bool Toggle() const
bool _toggle
The push button behavior (true=toggle, false=momentary).
Definition: gls_button.h:89
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.
#define GLSGEN_GlsPushButton_EXPORT
Provides support for creating DLLs.
Definition: gls_button.h:54
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 GLS_EXPORT
Macro denoting which functions should be visible from the runtime library.
Definition: gls_include.h:50
The disti::Group class. Implements groups of objects.
Definition: bmpimage.h:46