[Plib-cvs] plib/src/puAux puAuxChooser.cxx,NONE,1.1 Makefile.am,1.2,1.3 puAux.h,1.1,1.2 puAuxCompass
Brought to you by:
sjbaker
From: James J. <pu...@us...> - 2004-08-05 01:04:08
|
Update of /cvsroot/plib/plib/src/puAux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18925 Modified Files: Makefile.am puAux.h puAuxCompass.cxx Added Files: puAuxChooser.cxx Log Message: Adds puAuxChooser and some changes to puAuxCompass (John Fay) --- NEW FILE: puAuxChooser.cxx --- /* PUI Auxiliary Widget Library Derived from PLIB, the Portable Game Library by Steve Baker. Copyright (C) 1998,2002,2004 Steve Baker This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA [...65 lines suppressed...] void puaChooser::menuCleanup ( puObject *ob ) { puObject *p = ob -> getParent () ; ((puaChooser*)( p -> getUserData () )) -> menuCleanup ( ob -> getLegend () ) ; } void puaChooser::static_popup_cb ( puObject *ob ) { ((puaChooser*)( ob -> getUserData () )) -> popup_cb () ; } void puaChooser::static_menu_cb ( puObject *ob ) { ((puaChooser*)( ob -> getUserData () )) -> menuCleanup ( (const char *)NULL ) ; } Index: Makefile.am =================================================================== RCS file: /cvsroot/plib/plib/src/puAux/Makefile.am,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Makefile.am 21 Mar 2004 19:49:48 -0000 1.2 +++ Makefile.am 5 Aug 2004 01:03:49 -0000 1.3 @@ -16,7 +16,8 @@ puAuxSliderWithInput.cxx \ puAuxSpinBox.cxx \ puAuxTriSlider.cxx \ - puAuxVerticalMenu.cxx + puAuxVerticalMenu.cxx \ + puAuxChooser.cxx INCLUDES = -I$(top_srcdir)/src/sg \ -I$(top_srcdir)/src/pui \ Index: puAux.h =================================================================== RCS file: /cvsroot/plib/plib/src/puAux/puAux.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- puAux.h 28 Feb 2004 00:54:03 -0000 1.1 +++ puAux.h 5 Aug 2004 01:03:49 -0000 1.2 @@ -41,6 +41,7 @@ #define PUCLASS_BISLIDERWITHENDS 0x02000000 #define PUCLASS_SLIDERWITHINPUT 0x04000000 #define PUCLASS_COMPASS 0x08000000 +#define PUCLASS_CHOOSER 0x10000000 // Widget Declarations @@ -56,6 +57,7 @@ class puaBiSliderWithEnds ; class puaCompass ; class puaSliderWithInput ; +class puaChooser ; // A File selector widget @@ -743,7 +745,11 @@ { setValue ( PUACOMPASS_INACTIVE ) ; - sgSetQuat ( rotation, 1.0f, 0.0f, 0.0f, 0.0f ) ; +// sgSetQuat ( rotation, 1.0f, 0.0f, 0.0f, 0.0f ) ; +// sgSetQuat ( rotation, 0.707107f, 0.707107f, 0.0f, 0.0f ) ; +// sgSetQuat ( rotation, 0.5f, -0.5f, 0.5f, 0.5f ) ; +// sgSetQuat ( rotation, 0.866025f, -0.166667f, 0.166667f, 0.166667f ) ; + sgSetQuat ( rotation, 0.866025f, -0.408248f, 0.288675f, 0.0f ) ; sgSetVec3 ( translation, 0.0f, 0.0f, 0.0f ) ; point_size = 10.0f ; @@ -764,9 +770,20 @@ // Accessors and mutators void getRotation ( sgQuat q ) const { memcpy ( q, rotation, 4 * sizeof(sgFloat) ) ; } void setRotation ( sgQuat q ) { memcpy ( rotation, q, 4 * sizeof(sgFloat) ) ; } + void setRotation ( sgFloat t, sgFloat x, sgFloat y, sgFloat z ) + { + sgFloat sinth = sgSin ( t / 2.0f ) ; + sgFloat norm = sgSqrt ( x * x + y * y + z * z ) ; + if ( norm == 0.0 ) norm = 1.0 ; + rotation[SG_W] = sgCos ( t / 2.0f ) ; + rotation[SG_X] = sinth * x / norm ; + rotation[SG_Y] = sinth * y / norm ; + rotation[SG_Z] = sinth * z / norm ; + } void getTranslation ( sgVec3 t ) const { memcpy ( t, translation, 3 * sizeof(sgFloat) ) ; } void setTranslation ( sgVec3 t ) { memcpy ( translation, t, 3 * sizeof(sgFloat) ) ; } + void setTranslation ( sgFloat x, sgFloat y, sgFloat z ) { translation[SG_X] = x ; translation[SG_Y] = y ; translation[SG_Z] = z ; } float getPointSize () const { return point_size ; } void setPointSize ( float p ) { point_size = p ; } @@ -779,5 +796,41 @@ } ; +class puaChooser +{ + UL_TYPE_DATA + + puButton *chooser_button ; + puPopupMenu *popup_menu ; + + int x1, y1, x2, y2 ; + + static void static_popup_cb ( puObject * ) ; + static void static_menu_cb ( puObject * ) ; + +public: + + ~puaChooser () + { + delete chooser_button ; + delete popup_menu ; + } + + puaChooser ( int _x1, int _y1, int _x2, int _y2, char *legend ) ; + + void add_item ( char *str, puCallback _cb, void *_user_data = NULL ) ; + void close () ; + + void popup_cb () ; + + void menuCleanup ( const char *s ) ; + + void hide () { chooser_button -> hide () ; popup_menu -> hide () ; } + void reveal () { chooser_button -> reveal () ; popup_menu -> hide () ; } + + static void menuCleanup ( puObject * ) ; +} ; + + #endif Index: puAuxCompass.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/puAux/puAuxCompass.cxx,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- puAuxCompass.cxx 21 Mar 2004 19:03:23 -0000 1.4 +++ puAuxCompass.cxx 5 Aug 2004 01:03:49 -0000 1.5 @@ -37,19 +37,19 @@ if ( getIntegerValue () == value ) \ glColor4fv ( colour [ PUCOL_LEGEND ] ) ; \ else \ - glColor4f ( 1.0, 1.0, 1.0, 1.0 ) + glColor4fv ( colour [ PUCOL_FOREGROUND ] ) #define SET_ARC_COLOUR2(value1,value2) \ if ( ( getIntegerValue () == value1 ) || ( getIntegerValue () == value2 ) ) \ glColor4fv ( colour [ PUCOL_LEGEND ] ) ; \ else \ - glColor4f ( 1.0, 1.0, 1.0, 1.0 ) + glColor4fv ( colour [ PUCOL_FOREGROUND ] ) #define SET_ARC_COLOUR3(value1,value2,value3) \ if ( ( getIntegerValue () == value1 ) || ( getIntegerValue () == value2 ) || ( getIntegerValue () == value3 ) ) \ glColor4fv ( colour [ PUCOL_LEGEND ] ) ; \ else \ - glColor4f ( 1.0, 1.0, 1.0, 1.0 ) + glColor4fv ( colour [ PUCOL_FOREGROUND ] ) void puaCompass::draw ( int dx, int dy ) { @@ -69,8 +69,8 @@ { float xsize = float(abox.max[0] - abox.min[0]) ; float ysize = float(abox.max[1] - abox.min[1]) ; - float xcenter = float(dx) + xsize / 2.0f ; - float ycenter = float(dy) + ysize / 2.0f ; + float xcenter = float(dx + abox.min[0]) + xsize / 2.0f ; + float ycenter = float(dy + abox.min[1]) + ysize / 2.0f ; float size = ( ( xsize > ysize ) ? ysize : xsize ) / 2.5f ; glMatrixMode ( GL_MODELVIEW ) ; @@ -217,8 +217,8 @@ mouse_click_line.direction_vector[1] = 2.0f * ( prev_rotation[SG_W] * prev_rotation[SG_X] + prev_rotation[SG_Y] * prev_rotation[SG_Z] ) ; mouse_click_line.direction_vector[2] = prev_rotation[SG_W] * prev_rotation[SG_W] + prev_rotation[SG_Z] * prev_rotation[SG_Z] - prev_rotation[SG_X] * prev_rotation[SG_X] - prev_rotation[SG_Y] * prev_rotation[SG_Y] ; - float xm = float(x) - xsize / 2.0f ; - float ym = float(y) - ysize / 2.0f ; + float xm = float(x - abox.min[0]) - xsize / 2.0f ; + float ym = float(y - abox.min[1]) - ysize / 2.0f ; sgSetVec3 ( mouse_click_line.point_on_line, xm, ym, 0.0f ) ; sgRotateCoordQuat ( mouse_click_line.point_on_line, prev_rotation ) ; |