GL Studio C++ Runtime API
gls_button.h
Go to the documentation of this file.
1/*! \file
2 \brief The GlsPushButton runtime class.
3
4 \par Copyright Information
5
6 Copyright (c) 2017 by The DiSTI Corporation.<br>
7 11301 Corporate Blvd; Suite 100<br>
8 Orlando, Florida 32817<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
14reproduced, in whole or part, in any form, or by any means of electronic,
15mechanical, or otherwise, without the written permission of DiSTI. Said
16permission may be derived through the purchase of applicable DiSTI product
17licenses which detail the distribution rights of this content and any
18Derivative Works based on this or other copyrighted DiSTI Software.
19
20 NO WARRANTY. THE SOFTWARE IS PROVIDED "AS-IS," WITHOUT WARRANTY OF ANY KIND,
21AND ANY USE OF THIS SOFTWARE PRODUCT IS AT YOUR OWN RISK. TO THE MAXIMUM EXTENT
22PERMITTED BY APPLICABLE LAW, DISTI AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES
23AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
24IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND/OR FITNESS FOR A
25PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, WITH REGARD TO THE SOFTWARE.
26
27 LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,
28IN NO EVENT SHALL DISTI OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
29INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
30DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
31INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
32INABILITY TO USE THE SOFTWARE, EVEN IF DISTI HAS BEEN ADVISED OF THE POSSIBILITY
33OF SUCH DAMAGES. DISTI'S ENTIRE LIABILITY AND YOUR EXCLUSIVE REMEDY SHALL NOT
34EXCEED FIVE DOLLARS (US$5.00).
35
36 The aforementioned terms and restrictions are governed by the laws of the
37State of Florida and the United States of America.
38
39*/
40
41#ifndef INCLUDED_GLS_BUTTON_H
42#define INCLUDED_GLS_BUTTON_H
43
45#include "group.h"
46
47/// Provides support for creating DLLs.
48#if( defined( GLSGEN_EXPORT_GlsPushButton ) || defined( GLSGEN_IMPORT_GlsPushButton ) || defined( GLS_EXPORT_GENERATED ) || defined( GLS_IMPORT_GENERATED ) ) \
49 && defined( _MSC_VER )
50# if defined( GLSGEN_EXPORT_GlsPushButton ) || defined( GLS_EXPORT_GENERATED )
51# define GLSGEN_GlsPushButton_EXPORT __declspec( dllexport )
52# else
53# define GLSGEN_GlsPushButton_EXPORT __declspec( dllimport )
54# endif
55#else
56# define GLSGEN_GlsPushButton_EXPORT
57#endif
58///////////////////////////////////////////////////////////////////////////////
59
60/// Automatically link the runtime library plugin (on Windows).
61#define LIB_BASE_NAME "gls_push_button"
62#include "gls_auto_lib.h"
63#undef LIB_BASE_NAME
64
65namespace disti
66{
67enum
68{
69 GLS_GLSBUTTON_CHANGE_CALLBACK = GLS_LAST_INITIALIZER + 1,
70 GLS_GLSBUTTON_TOGGLE,
71 GLS_GLSBUTTON_WHICH_OBJ_POS_UP,
72 GLS_GLSBUTTON_WHICH_OBJ_POS_DOWN,
73 GLS_GLSBUTTON_STATE,
74 GLS_GLSBUTTON_EMIT_STATE_CHANGE_EVENT
75};
76
77/** Runtime implementation of a push button */
78class GlsPushButton : public Group
79{
80private:
83
84public:
85 DISTI_DEPRECATED( "This identifier is forbidden by the C++ standard. Use BaseClass instead." )
86 typedef Group _BaseClass; ///< Deprecated typedef for the base class.
87 typedef Group BaseClass; ///< Typedef for the base class.
88
90
91 bool _toggle; ///< The push button behavior (true=toggle, false=momentary).
92 int _whichObjectPosUp; ///< The object index to be the button up position.
93 int _whichObjectPosDown; ///< The object index to be the button down position.
94 int _state; ///< The button state: 0=up, 1=down.
95 bool _emitStateChangeEvent; ///< If true "StateChange" events will be emitted when this button changes state.
96
97 bool _mouseIsDown; ///< True when the mouse has been pushed down on this button.
98 unsigned int _currentCursor; ///< The current cursor used for interaction. Any other cursors are ignored while interacting.
99
100 friend class GlsPushButtonEditor;
101
102 /// Create a new GlsPushButton.
103 /// \param generateInstance Whether or not to generate an instance name for this object.
104 GLSGEN_GlsPushButton_EXPORT GlsPushButton( bool generateInstance = false );
105
106 /// Create a new GlsPushButton.
107 /// \param that The object to copy from.
108 /// \param generateNames Whether or not to generate an instance name for this object.
109 GLSGEN_GlsPushButton_EXPORT GlsPushButton( const GlsPushButton& that, const bool generateNames );
110
111 /** Destroy a GlsPushButton object */
113
114 /// \return A pointer to a new GlsPushButton object.
116
119 virtual GLSGEN_GlsPushButton_EXPORT void PreDraw( const OpenGLMatrices& parentMatrices, Culler& culler ) DISTI_METHOD_OVERRIDE;
122
123 /** Sets the child index that represents the up state of the button
124 * \param which New child index for the up state
125 */
127
128 /** Returns the child index that represents the up state of the button
129 * \return Current child index for the up state
130 */
132
133 /// Sets the child index that represents the down state of the button.
134 /// \param which The new child index for the down state.
136
137 /// Returns the index that represents the down state of the button.
138 /// \return The current child index for the down state.
140
141 /// Sets if the object should hold its state(true) or return to the up state(false).
142 /// \param toggle The new behavior of if the object should hold its state(true) or return to the up state(false).
143 virtual GLSGEN_GlsPushButton_EXPORT void Toggle( bool toggle );
144
145 /// Returns if the object should hold its state(true) or return to the up state(false).
146 /// \return The current behavior of if the object should hold its state(true) or return to the up state(false).
148
150 const Vector& logicalCoords,
151 float scale,
152 const Vector& directionVector,
153 Vector& collisionWinLoc /*Returned*/,
154 const OpenGLMatrices& drawnMatrices ) DISTI_METHOD_OVERRIDE;
155
156#ifndef GLES
159#endif
160
162
163 //////////////////////////////////////////////////
164 // Push Button specific operations
165 //////////////////////////////////////////////////
167
168 /** Sets the push button state (0=up, 1=down)
169 * \param state New button state (0=up, 1=down)
170 */
171 virtual GLSGEN_GlsPushButton_EXPORT void State( const int& state );
172
173 /** Returns the current push button state (0=up, 1=down)
174 * \return Current push button state (0=up, 1=down)
175 */
177
178 /** Returns the current push button state (0=up, 1=down)
179 * \deprecated this method is not const correct, use const version instead
180 * \return Current push button state (0=up, 1=down)
181 */
182 DISTI_DEPRECATED( "Use the const version instead." )
183 virtual int State() DISTI_FINAL
184 {
185 return const_cast<const GlsPushButton*>( this )->State();
186 }
187
188private:
189 DisplayObject* GetPickedObject( bool firstPick,
190 const Vector& winLoc,
191 const Vector& logicalCoords,
192 float scale, const Vector& directionVector,
193 Vector& collisionWinLoc /*Returned*/,
194 const OpenGLMatrices& drawnMatrices );
195
196protected:
197#ifdef GLES
198 /** Set a single attribute from the GLO file.
199 * \param data The attribute to set and its associated data.
200 */
201 virtual GLS_EXPORT void SetFromGloData( GlsGloFileAttribute& data ) DISTI_METHOD_OVERRIDE;
202#endif
203};
204
205} // namespace disti
206
207#endif
Definition: cull.h:50
Definition: events.h:113
Definition: display.h:96
Definition: dynamic_array.h:79
Definition: gls_glo_file.h:1243
Definition: gls_button.h:79
virtual InterfaceListType * GetCppInterfaceDescription(InterfaceListType *addToThisList=NULL) DISTI_METHOD_OVERRIDE
virtual void SetAvailableAttributes(unsigned int value) DISTI_METHOD_OVERRIDE
virtual void Draw() DISTI_METHOD_OVERRIDE
virtual void GetCppInterfaceDescriptionFree(InterfaceListType *array) DISTI_METHOD_OVERRIDE
unsigned int _currentCursor
The current cursor used for interaction. Any other cursors are ignored while interacting.
Definition: gls_button.h:98
void SetValue(int spec, va_list &args) DISTI_METHOD_OVERRIDE
virtual DisplayObject * CloneObject(bool generateNames=false) DISTI_METHOD_OVERRIDE
virtual void State(const int &state)
int _state
The button state: 0=up, 1=down.
Definition: gls_button.h:94
virtual void PreDraw(const OpenGLMatrices &parentMatrices, Culler &culler) 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:92
static DisplayObject * CreateInstance()
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:95
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
virtual void CopyProperties(DisplayObject *src) DISTI_METHOD_OVERRIDE
bool _mouseIsDown
True when the mouse has been pushed down on this button.
Definition: gls_button.h:97
virtual int WhichObjectPosUp() const
int _whichObjectPosDown
The object index to be the button down position.
Definition: gls_button.h:93
virtual bool Toggle() const
bool _toggle
The push button behavior (true=toggle, false=momentary).
Definition: gls_button.h:91
Definition: group.h:53
Class to contain current OpenGL view, projection and draw matrices.
Definition: util.h:544
Definition: vertex.h:85
The gls_auto_lib.
#define GLSGEN_GlsPushButton_EXPORT
Provides support for creating DLLs.
Definition: gls_button.h:56
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:235
#define DISTI_DEPRECATED(msg)
Defines whether this compiler supports the C++14 deprecated attribute.
Definition: gls_cpp_lang_support.h:457
#define DISTI_FINAL
Macro to wrap the final keyword, removed on compilers that don't support it.
Definition: gls_cpp_lang_support.h:216
#define DISTI_METHOD_OVERRIDE
Macro to wrap the override keyword, removed on compilers that don't support it.
Definition: gls_cpp_lang_support.h:214
#define GLS_EXPORT
Macro denoting which functions should be visible from the runtime library.
Definition: gls_include.h:52
The disti::Group class. Implements groups of objects.
Force inclusion of the DirectShow library.
Definition: bmpimage.h:47