| 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
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*/
40
41#ifndef INCLUDED_GLS_BUTTON_H
42#define INCLUDED_GLS_BUTTON_H
43
44#include "gls_cpp_lang_support.h"
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
65 namespace disti
66{
67 enum
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 */
78 class GlsPushButton : public Group
79{
80 private:
81 GlsPushButton& operator=( const GlsPushButton& ) DISTI_SPECIAL_MEM_FUN_DELETE;
82 GlsPushButton( const GlsPushButton& ) DISTI_SPECIAL_MEM_FUN_DELETE;
83
84 public:
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
89 GLSGEN_GlsPushButton_EXPORT void SetValue( int spec, va_list& args ) DISTI_METHOD_OVERRIDE;
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 */
112 virtual GLSGEN_GlsPushButton_EXPORT ~GlsPushButton();
113
114 /// \return A pointer to a new GlsPushButton object.
115 static GLSGEN_GlsPushButton_EXPORT DisplayObject* CreateInstance();
116
117 virtual GLSGEN_GlsPushButton_EXPORT void SetAvailableAttributes( unsigned int value ) DISTI_METHOD_OVERRIDE;
118 virtual GLSGEN_GlsPushButton_EXPORT DisplayObject* CloneObject( bool generateNames = false ) DISTI_METHOD_OVERRIDE;
119 virtual GLSGEN_GlsPushButton_EXPORT void PreDraw( const OpenGLMatrices& parentMatrices, Culler& culler ) DISTI_METHOD_OVERRIDE;
120 virtual GLSGEN_GlsPushButton_EXPORT void Draw() DISTI_METHOD_OVERRIDE;
121 virtual GLSGEN_GlsPushButton_EXPORT void CopyProperties( DisplayObject* src ) 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 */
126 virtual GLSGEN_GlsPushButton_EXPORT void WhichObjectPosUp( int which );
127
128 /** Returns the child index that represents the up state of the button
129 * \return Current child index for the up state
130 */
131 virtual GLSGEN_GlsPushButton_EXPORT int WhichObjectPosUp() const;
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.
135 virtual GLSGEN_GlsPushButton_EXPORT void WhichObjectPosDown( int which );
136
137 /// Returns the index that represents the down state of the button.
138 /// \return The current child index for the down state.
139 virtual GLSGEN_GlsPushButton_EXPORT int WhichObjectPosDown() const;
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).
147 virtual GLSGEN_GlsPushButton_EXPORT bool Toggle() const;
148
149 virtual GLSGEN_GlsPushButton_EXPORT DisplayObject* Pick3D( const Vector& winLoc,
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
157 virtual GLSGEN_GlsPushButton_EXPORT InterfaceListType* GetCppInterfaceDescription( InterfaceListType* addToThisList = NULL ) DISTI_METHOD_OVERRIDE;
158 virtual GLSGEN_GlsPushButton_EXPORT void GetCppInterfaceDescriptionFree( InterfaceListType* array ) DISTI_METHOD_OVERRIDE;
159#endif
160
161 GLSGEN_GlsPushButton_EXPORT bool IsVisibleInScene( const DisplayObject* obj = NULL ) const DISTI_METHOD_OVERRIDE;
162
163 //////////////////////////////////////////////////
164 // Push Button specific operations
165 //////////////////////////////////////////////////
166 GLSGEN_GlsPushButton_EXPORT DisplayObject* handle( DisplayEvent* ev ) DISTI_METHOD_OVERRIDE;
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 */
176 virtual GLSGEN_GlsPushButton_EXPORT int State() const;
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
188 private:
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
196 protected:
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
disti::Culler
Definition: cull.h:50
disti::DisplayEvent
Definition: events.h:113
disti::DisplayObject
Definition: display.h:96
disti::DynamicArray
Definition: dynamic_array.h:79
disti::GlsGloFileAttribute
Definition: gls_glo_file.h:1243
disti::GlsPushButton
Definition: gls_button.h:79
disti::GlsPushButton::SetAvailableAttributes
virtual void SetAvailableAttributes(unsigned int value) DISTI_METHOD_OVERRIDE
disti::GlsPushButton::Draw
virtual void Draw() DISTI_METHOD_OVERRIDE
disti::GlsPushButton::_currentCursor
unsigned int _currentCursor
The current cursor used for interaction. Any other cursors are ignored while interacting.
Definition: gls_button.h:98
disti::GlsPushButton::SetValue
void SetValue(int spec, va_list &args) DISTI_METHOD_OVERRIDE
disti::GlsPushButton::CloneObject
virtual DisplayObject * CloneObject(bool generateNames=false) DISTI_METHOD_OVERRIDE
disti::GlsPushButton::SetFromGloData
virtual GLS_EXPORT void SetFromGloData(GlsGloFileAttribute &data) DISTI_METHOD_OVERRIDE
disti::GlsPushButton::State
virtual void State(const int &state)
disti::GlsPushButton::_state
int _state
The button state: 0=up, 1=down.
Definition: gls_button.h:94
disti::GlsPushButton::PreDraw
virtual void PreDraw(const OpenGLMatrices &parentMatrices, Culler &culler) DISTI_METHOD_OVERRIDE
disti::GlsPushButton::handle
DisplayObject * handle(DisplayEvent *ev) DISTI_METHOD_OVERRIDE
disti::GlsPushButton::_whichObjectPosUp
int _whichObjectPosUp
The object index to be the button up position.
Definition: gls_button.h:92
disti::GlsPushButton::CreateInstance
static DisplayObject * CreateInstance()
disti::GlsPushButton::IsVisibleInScene
bool IsVisibleInScene(const DisplayObject *obj=NULL) const DISTI_METHOD_OVERRIDE
disti::GlsPushButton::State
virtual int State() const
disti::GlsPushButton::_emitStateChangeEvent
bool _emitStateChangeEvent
If true "StateChange" events will be emitted when this button changes state.
Definition: gls_button.h:95
disti::GlsPushButton::WhichObjectPosDown
virtual int WhichObjectPosDown() const
disti::GlsPushButton::Pick3D
virtual DisplayObject * Pick3D(const Vector &winLoc, const Vector &logicalCoords, float scale, const Vector &directionVector, Vector &collisionWinLoc, const OpenGLMatrices &drawnMatrices) DISTI_METHOD_OVERRIDE
disti::GlsPushButton::CopyProperties
virtual void CopyProperties(DisplayObject *src) DISTI_METHOD_OVERRIDE
disti::GlsPushButton::_mouseIsDown
bool _mouseIsDown
True when the mouse has been pushed down on this button.
Definition: gls_button.h:97
disti::GlsPushButton::WhichObjectPosUp
virtual int WhichObjectPosUp() const
disti::GlsPushButton::_whichObjectPosDown
int _whichObjectPosDown
The object index to be the button down position.
Definition: gls_button.h:93
disti::GlsPushButton::Toggle
virtual bool Toggle() const
disti::GlsPushButton::_toggle
bool _toggle
The push button behavior (true=toggle, false=momentary).
Definition: gls_button.h:91
disti::Group
Definition: group.h:53
disti::OpenGLMatrices
Class to contain current OpenGL view, projection and draw matrices.
Definition: util.h:544
disti::VertexNoColor
Definition: vertex.h:85
gls_auto_lib.h
The gls_auto_lib.
GLSGEN_GlsPushButton_EXPORT
#define GLSGEN_GlsPushButton_EXPORT
Provides support for creating DLLs.
Definition: gls_button.h:56
gls_cpp_lang_support.h
Macros and helper code to determine what subset of C++11/14/17 is available.
DISTI_SPECIAL_MEM_FUN_DELETE
#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:246
DISTI_DEPRECATED
#define DISTI_DEPRECATED(msg)
Defines whether this compiler supports the C++14 deprecated attribute.
Definition: gls_cpp_lang_support.h:488
DISTI_FINAL
#define DISTI_FINAL
Macro to wrap the final keyword, removed on compilers that don't support it.
Definition: gls_cpp_lang_support.h:224
DISTI_METHOD_OVERRIDE
#define DISTI_METHOD_OVERRIDE
Macro to wrap the override keyword, removed on compilers that don't support it.
Definition: gls_cpp_lang_support.h:222
GLS_EXPORT
#define GLS_EXPORT
Macro denoting which functions should be visible from the runtime library.
Definition: gls_include.h:52
group.h
The disti::Group class. Implements groups of objects.
disti
Definition: bmpimage.h:47