Thread: [Plib-cvs] plib/src/pui pu.h,1.114,1.115 puGroup.cxx,1.19,1.20 puMenuBar.cxx,1.14,1.15 puObject.cxx,
Brought to you by:
sjbaker
From: James J. <pu...@us...> - 2002-07-12 03:23:36
|
Update of /cvsroot/plib/plib/src/pui In directory usw-pr-cvs1:/tmp/cvs-serv17087 Modified Files: pu.h puGroup.cxx puMenuBar.cxx puObject.cxx puPopupMenu.cxx puVerticalMenu.cxx Log Message: Added "vStatus" and related functions to puGroup to facilitate allowing Menubars and Vertical Menus to (optionally) lock themselves in the corner of the window, no matter what window reshapes take place. Index: pu.h =================================================================== RCS file: /cvsroot/plib/plib/src/pui/pu.h,v retrieving revision 1.114 retrieving revision 1.115 diff -u -d -r1.114 -r1.115 --- pu.h 12 Jul 2002 02:57:19 -0000 1.114 +++ pu.h 12 Jul 2002 03:23:33 -0000 1.115 @@ -625,6 +625,7 @@ int highlighted ; int am_default ; int window ; /* Which window does the object appear in? */ + int v_status ; /* 1 if the Object should lock in the top left corner, 0 if not */ const char *label ; puFont labelFont ; int labelPlace ; const char *legend ; puFont legendFont ; int legendPlace ; @@ -862,6 +863,9 @@ int getDefaultIntegerValue ( void ) { return default_value.getIntegerValue () ; } float getDefaultFloatValue ( void ) { return default_value.getFloatValue () ; } char *getDefaultStringValue ( void ) { return default_value.getStringValue () ; } + + int getVStatus ( void ) const { return v_status ; } /* JCJ 6 Jun 2002 */ + void setVStatus ( int vstat ) { v_status = vstat ; } } ; /* @@ -1434,6 +1438,7 @@ { type |= PUCLASS_VERTMENU ; floating = TRUE ; + if ( y < 0 ) { setVStatus( TRUE ) ; } /* It is now supposed to stick to the top left - JCJ*/ } void add_submenu ( const char *str, char *items[], puCallback _cb[] ) ; Index: puGroup.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/pui/puGroup.cxx,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- puGroup.cxx 19 Dec 2001 19:30:41 -0000 1.19 +++ puGroup.cxx 12 Jul 2002 03:23:33 -0000 1.20 @@ -255,16 +255,40 @@ * correctly. */ - if ( ( bo -> getType () & PUCLASS_MENUBAR ) && - ( bo -> getWindow () == puGetWindow () ) ) + int x, y ; + int xdraw = dx + abox.min[0] ; + int ydraw = dy + abox.min[1] ; + bo -> getPosition (&x, &y) ; + /* Introduced PUCLASS_VERTMENU into the club of widgets being automatically moved */ + /* to the top-left corner of the screen. This eliminates all Vertmenu-resize and */ + /* window-jumping problems. - JCJ 31 May 2002 */ + + /* If the object is a menubar or a vertmenu and supposed to be locked to the top, */ + /* then move it there. - JCJ 6 June 2002 */ + if ( ( ( bo -> getType () & PUCLASS_MENUBAR ) || + ( ( bo -> getType () & PUCLASS_VERTMENU ) && + ( bo -> getVStatus () == 1 ) ) ) && + ( bo -> getWindow () == puGetWindow () ) ) { int obWidth, obHeight ; bo -> getSize ( &obWidth, &obHeight ) ; bo -> setPosition ( 0, puGetWindowHeight() - obHeight ) ; + } + else + { + if ( ( y < 0 ) && ( bo->getType () & PUCLASS_POPUPMENU ) ) + { + /* IF the object's bottom left corner lies outside the window, THEN */ + /* move the object to the top left - JCJ and Fay 5 Jun 2002 */ + int absx, absy ; + bo -> getAbsolutePosition (&absx, &absy) ; + if ( absy < 0 ) + ydraw -= absy ; + } } - bo -> draw ( dx + abox.min[0], dy + abox.min[1] ) ; + bo -> draw ( xdraw, ydraw ) ; } } Index: puMenuBar.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/pui/puMenuBar.cxx,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- puMenuBar.cxx 10 Nov 2001 13:37:38 -0000 1.14 +++ puMenuBar.cxx 12 Jul 2002 03:23:33 -0000 1.15 @@ -1,21 +1,21 @@ /* PLIB - A Suite of Portable Game Libraries Copyright (C) 2001 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 - + For further information visit http://plib.sourceforge.net $Id$ @@ -64,16 +64,19 @@ if ( x_siz < (x_max - x_min) ) x_siz = x_max - x_min ; // Adjust the present size if ( y_siz < (y_max - y_min) ) y_siz = y_max - y_min ; - int x_pos = glutGet ( (GLenum)GLUT_WINDOW_X ) ; - int y_pos = glutGet ( (GLenum)GLUT_WINDOW_Y ) ; + //int x_pos = glutGet ( (GLenum)GLUT_WINDOW_X ) ; + //int y_pos = glutGet ( (GLenum)GLUT_WINDOW_Y ) ; glutReshapeWindow ( x_siz, y_siz ) ; - glutPositionWindow ( x_pos + x_min, y_pos ) ; + //glutPositionWindow ( x_pos + x_min, y_pos ) ; // Unneccessary - JCJ 6 Jun 2002 x_min = par_box->min[0] - x_min ; y_min = y_siz - ( par_box->max[1] - par_box->min[1] ) ; - parent -> setPosition ( x_min, y_min ) ; + /* If the parent window is SUPPOSED to be stuck at the top of the screen, move it. + - JCJ 6 June 2002 */ + if (parent -> getVStatus () == 1) + parent -> setPosition ( x_min, y_min ) ; glutSetWindow ( temp_window ) ; } Index: puObject.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/pui/puObject.cxx,v retrieving revision 1.43 retrieving revision 1.44 diff -u -d -r1.43 -r1.44 --- puObject.cxx 12 Jul 2002 01:01:24 -0000 1.43 +++ puObject.cxx 12 Jul 2002 03:23:33 -0000 1.44 @@ -139,6 +139,7 @@ highlighted = FALSE ; am_default = FALSE ; window = puGetWindow () ; + v_status = 0 ; cb = NULL ; active_cb = NULL ; Index: puPopupMenu.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/pui/puPopupMenu.cxx,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- puPopupMenu.cxx 7 Nov 2001 23:51:09 -0000 1.11 +++ puPopupMenu.cxx 12 Jul 2002 03:23:33 -0000 1.12 @@ -1,26 +1,27 @@ /* PLIB - A Suite of Portable Game Libraries Copyright (C) 2001 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 - + For further information visit http://plib.sourceforge.net $Id$ */ + #include "puLocal.h" puObject *puPopupMenu::add_item ( const char *str, puCallback _cb ) @@ -121,9 +122,16 @@ if ( dlist == NULL || ! isVisible () || ! isActive () || ( window != puGetWindow () ) ) return FALSE ; - /* Must test 'isHit' before making the menu invisible! */ + /* If an item is going to fall out the bottom of the window and puGroup will */ + /* move it upward (around line 303 of puGroup.cxx), then make sure checkhit */ + /* realizes the thing has moved -- JCJ and Fay 5 June 2002 */ - int hit = isHit ( x, y ) ; + int absx, absy ; + getAbsolutePosition (&absx, &absy) ; + if ( absy < 0 ) + y += absy ; + + /* Must test 'isHit' before making the menu invisible! */ /* * June 17th, 1998, Shammi : @@ -136,6 +144,12 @@ track of changing abox sizes when daughter objects are changing sizes. */ + + int hit = isHit ( x, y ) ; + + /* If the mouse is clicked on another widget, hide the window - JCJ 18 Jun 2002 */ + if ( updown != PU_DRAG && !hit ) + hide () ; recalc_bbox(); x -= abox.min[0] ; Index: puVerticalMenu.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/pui/puVerticalMenu.cxx,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- puVerticalMenu.cxx 7 Nov 2001 23:51:09 -0000 1.6 +++ puVerticalMenu.cxx 12 Jul 2002 03:23:33 -0000 1.7 @@ -26,6 +26,7 @@ extern void puMenuBar_drop_down_the_menu ( puObject *b ); +/* If there is only one entry in a vmenu, just act as if clicking the menu clicks the oneshot underneath it. */ void puVerticalMenu::add_submenu ( const char *str, char *items[], puCallback _cb[] ) { int w, h ; |