1
/****************************************************************************
3
GLUI User Interface Toolkit
4
---------------------------
9
--------------------------------------------------
11
Copyright (c) 1998 Paul Rademacher
13
This program is freely distributable without licensing fees and is
14
provided without guarantee or warrantee expressed or implied. This
15
program is -not- in the public domain.
17
*****************************************************************************/
24
/*** This object must be used to create a GLUI ***/
26
GLUI_Master_Object GLUI_Master;
29
/************************************ finish_drawing() ************/
31
void finish_drawing( void )
36
/************************************************ GLUI::GLUI() **********/
38
int GLUI::init( char *text, long flags, int x, int y, int parent_window )
44
strncpy( window_name.string, text, sizeof(GLUI_String));
46
/*** We copy over the current window callthroughs ***/
47
/*** (I think this might actually only be needed for subwindows) ***/
48
/* glut_keyboard_CB = GLUI_Master.glut_keyboard_CB;
49
glut_reshape_CB = GLUI_Master.glut_reshape_CB;
50
glut_special_CB = GLUI_Master.glut_special_CB;
51
glut_mouse_CB = GLUI_Master.glut_mouse_CB;*/
54
if ( (flags & GLUI_SUBWINDOW) != GLUI_SUBWINDOW ) {
55
old_glut_window = glutGetWindow();
57
create_standalone_window( window_name, x, y );
58
setup_default_glut_callbacks();
60
if ( old_glut_window > 0 )
61
glutSetWindow( old_glut_window );
63
top_level_glut_window_id = glut_window_id;
66
old_glut_window = glutGetWindow();
68
create_subwindow( parent_window, flags );
69
setup_default_glut_callbacks();
71
if ( old_glut_window > 0 )
72
glutSetWindow( old_glut_window );
74
top_level_glut_window_id = parent_window;
77
glutReshapeFunc( glui_parent_window_reshape_func );
78
glutSpecialFunc( glui_parent_window_special_func );
79
glutKeyboardFunc( glui_parent_window_keyboard_func );
80
glutMouseFunc( glui_parent_window_mouse_func );
89
/**************************** GLUI_Main::create_standalone_window() ********/
91
void GLUI_Main::create_standalone_window( char *name, int x, int y )
93
glutInitWindowSize( 100, 100 );
94
if ( x >= 0 OR y >= 0 )
95
glutInitWindowPosition( x, y );
96
glutInitDisplayMode( GLUT_RGB | GLUT_SINGLE ); /* | GLUT_DOUBLE ); */
97
glut_window_id = glutCreateWindow( name );
98
glDisable( GL_DEPTH_TEST );
99
glCullFace( GL_BACK );
100
glDisable( GL_CULL_FACE );
101
glDisable( GL_LIGHTING );
102
glDrawBuffer( GL_FRONT );
106
/******************************** GLUI_Main::create_subwindow() **********/
108
void GLUI_Main::create_subwindow( int parent_window, int window_alignment )
110
glut_window_id = glutCreateSubWindow( parent_window, 0,0, 100, 100 );
111
glDisable( GL_DEPTH_TEST );
112
glCullFace( GL_BACK );
113
glDisable( GL_CULL_FACE );
114
glDisable( GL_LIGHTING );
115
glDrawBuffer( GL_FRONT );
117
this->parent_window = parent_window;
121
/**************************** GLUI_Main::setup_default_glut_callbacks() *****/
123
void GLUI_Main::setup_default_glut_callbacks( void )
125
glutDisplayFunc( glui_display_func );
126
glutReshapeFunc( glui_reshape_func );
127
glutKeyboardFunc( glui_keyboard_func );
128
glutSpecialFunc( glui_special_func );
129
glutMouseFunc( glui_mouse_func );
130
glutMotionFunc( glui_motion_func );
131
glutPassiveMotionFunc( glui_passive_motion_func );
132
glutEntryFunc( glui_entry_func );
133
glutVisibilityFunc( glui_visibility_func );
134
/* glutIdleFunc( glui_idle_func ); */
138
/********************************************** glui_display_func() ********/
140
void glui_display_func( void )
144
/* printf( "display func\n" ); */
146
glui = GLUI_Master.find_glui_by_window_id( glutGetWindow() );
151
Do not do anything after the above line, b/c the GLUI
152
window might have just closed itself
158
/********************************************** glui_reshape_func() ********/
160
void glui_reshape_func( int w, int h )
163
GLUI_Glut_Window *glut_window;
166
/*printf( "glui_reshape_func(): %d w/h: %d/%d\n", glutGetWindow(), w, h ); */
168
current_window = glutGetWindow();
170
/*** First check if this is main glut window ***/
171
glut_window = GLUI_Master.find_glut_window( current_window );
173
glut_window->glut_reshape_CB(w,h);
175
/*** Now send reshape events to all subwindows ***/
176
glui = (GLUI*) GLUI_Master.gluis.first_child();
178
if ( TEST_AND( glui->flags, GLUI_SUBWINDOW) AND
179
glui->parent_window == current_window ) {
180
glutSetWindow( glui->get_glut_window_id());
182
/* glui->check_subwindow_position(); */
184
glui = (GLUI*) glui->next();
188
/*** A standalone GLUI window ***/
190
glui = GLUI_Master.find_glui_by_window_id( current_window );
198
/********************************************** glui_keyboard_func() ********/
200
void glui_keyboard_func(unsigned char key, int x, int y)
204
GLUI_Glut_Window *glut_window;
206
current_window = glutGetWindow();
207
glut_window = GLUI_Master.find_glut_window( current_window );
209
/*printf( "key: %d\n", current_window ); */
211
if ( glut_window ) { /** Was event in a GLUT window? **/
212
if ( GLUI_Master.active_control_glui AND GLUI_Master.active_control ) {
213
glutSetWindow( GLUI_Master.active_control_glui->get_glut_window_id() );
215
GLUI_Master.active_control_glui->keyboard(key,x,y);
218
glutSetWindow( current_window );
221
glut_window->glut_keyboard_CB( key, x, y );
224
else { /*** Nope, event was in a standalone GLUI window **/
225
glui = GLUI_Master.find_glui_by_window_id( glutGetWindow() );
228
glui->keyboard(key,x,y);
235
/************************************************ glui_special_func() ********/
237
void glui_special_func(int key, int x, int y)
241
GLUI_Glut_Window *glut_window;
243
current_window = glutGetWindow();
244
glut_window = GLUI_Master.find_glut_window( current_window );
246
if ( glut_window ) { /** Was event in a GLUT window? **/
247
if ( GLUI_Master.active_control_glui AND GLUI_Master.active_control ) {
248
glutSetWindow( GLUI_Master.active_control_glui->get_glut_window_id() );
250
GLUI_Master.active_control_glui->special(key,x,y);
253
glutSetWindow( current_window );
256
glut_window->glut_special_CB( key, x, y );
259
else { /*** Nope, event was in a standalone GLUI window **/
260
glui = GLUI_Master.find_glui_by_window_id( glutGetWindow() );
263
glui->special(key,x,y);
271
/********************************************** glui_mouse_func() ********/
273
void glui_mouse_func(int button, int state, int x, int y)
277
GLUI_Glut_Window *glut_window;
279
current_window = glutGetWindow();
280
glut_window = GLUI_Master.find_glut_window( current_window );
282
if ( glut_window ) { /** Was event in a GLUT window? **/
283
if ( GLUI_Master.active_control_glui != NULL )
284
GLUI_Master.active_control_glui->disactivate_current_control();
286
glut_window->glut_mouse_CB( button, state, x, y );
289
else { /** Nope - event was in a GLUI standalone window **/
290
glui = GLUI_Master.find_glui_by_window_id( glutGetWindow() );
292
glui->passive_motion( 0,0 );
293
glui->mouse( button, state, x, y );
300
/********************************************** glui_motion_func() ********/
302
void glui_motion_func(int x, int y)
306
glui = GLUI_Master.find_glui_by_window_id( glutGetWindow() );
316
/**************************************** glui_passive_motion_func() ********/
318
void glui_passive_motion_func(int x, int y)
322
glui = GLUI_Master.find_glui_by_window_id( glutGetWindow() );
325
glui->passive_motion(x,y);
331
/********************************************** glui_entry_func() ********/
333
void glui_entry_func(int state)
337
glui = GLUI_Master.find_glui_by_window_id( glutGetWindow() );
345
/******************************************** glui_visibility_func() ********/
347
void glui_visibility_func(int state)
351
/* printf( "IN GLUI VISIBILITY()\n" ); */
352
/* fflush( stdout ); */
354
glui = GLUI_Master.find_glui_by_window_id( glutGetWindow() );
357
glui->visibility(state);
362
/********************************************** glui_idle_func() ********/
363
/* Send idle event to each glui, then to the main window */
365
void glui_idle_func(void)
369
glui = (GLUI*) GLUI_Master.gluis.first_child();
374
glui = (GLUI*) glui->next();
377
if ( GLUI_Master.glut_idle_CB ) {
378
/*** We set the current glut window before calling the user's
379
idle function, even though glut explicitly says the window id is
380
undefined in an idle callback. ***/
382
/** Check what the current window is first ***/
384
/*** Arbitrarily set the window id to the main gfx window of the
385
first glui window ***/
386
/* int current_window, new_window; */
387
/* current_window = glutGetWindow(); */
388
/* if (GLUI_Master.gluis.first_child() != NULL ) { */
389
/* new_window = ((GLUI_Main*)GLUI_Master.gluis.first_child())-> */
390
/* main_gfx_window_id; */
391
/* if ( new_window > 0 AND new_window != old_window ) { */
392
/* --- Window is changed only if its not already the current window ---*/
393
/* glutSetWindow( new_window ); */
397
GLUI_Master.glut_idle_CB();
402
/*********************************** GLUI_Master_Object::create_glui() ******/
404
GLUI *GLUI_Master_Object::create_glui( char *name, long flags,int x,int y )
411
new_glui->init( name, flags, x, y, -1 );
412
new_glui->link_this_to_parent_last( &this->gluis );
421
/************************** GLUI_Master_Object::create_glui_subwindow() ******/
423
GLUI *GLUI_Master_Object::create_glui_subwindow( int parent_window,
432
sprintf( new_name, "subwin_%p", this );
434
new_glui->init( new_name, flags | GLUI_SUBWINDOW, 0,0,
436
new_glui->main_panel->set_int_val( GLUI_PANEL_EMBOSSED );
437
new_glui->link_this_to_parent_last( &this->gluis );
447
/********************** GLUI_Master_Object::find_glui_by_window_id() ********/
449
GLUI *GLUI_Master_Object::find_glui_by_window_id( int window_id )
453
node = gluis.first_child();
455
if ( ((GLUI*)node)->get_glut_window_id() == window_id )
464
/******************************************** GLUI_Main::display() **********/
466
void GLUI_Main::display( void )
470
/*glutSetWindow(1);///WOW WHAT A HACK */
472
/**** This function is used as a special place to do 'safe' processing,
473
e.g., handling window close requests.
474
That is, we can't close the window directly in the callback, so
475
we set a flag, post a redisplay message (which eventually calls
476
this function), then close the window safely in here. ****/
477
if ( closing == true ) {
482
/* if ( TEST_AND( this->flags, GLUI_SUBWINDOW ))
483
check_subwindow_position();
486
/******* Draw GLUI window ******/
488
glClearColor( (float) bkgd_color.r / 255.0,
489
(float) bkgd_color.g / 255.0,
490
(float) bkgd_color.b / 255.0,
492
glClear( GL_COLOR_BUFFER_BIT ); /* | GL_DEPTH_BUFFER_BIT ); */
494
/* glutSwapBuffers(); //performs flush also // %%%%%%%%%% */
497
win_w = glutGet( GLUT_WINDOW_WIDTH );
498
win_h = glutGet( GLUT_WINDOW_HEIGHT );
500
/*** Check here if the window needs resizing ***/
501
if ( win_w != main_panel->w OR win_h != main_panel->h ) {
502
glutReshapeWindow( main_panel->w, main_panel->h );
506
set_ortho_projection();
508
glMatrixMode( GL_MODELVIEW );
511
/*** Rotate image so y increases upwards, contrary to OpenGL axes ***/
512
glTranslatef( (float) win_w/2.0, (float) win_h/2.0, 0.0 );
513
glRotatef( 180.0, 0.0, 1.0, 0.0 );
514
glRotatef( 180.0, 0.0, 0.0, 1.0 );
515
glTranslatef( (float) -win_w/2.0, (float) -win_h/2.0, 0.0 );
517
/* glDrawBuffer( GL_BACK ); // Is there ever a need to draw to back buffer?? */
519
// main_panel->draw_bkgd_box( 0, 0, win_w, win_h );
520
main_panel->draw_recursive( 0, 0 );
522
/*glutSwapBuffers(); //performs flush also */
529
/*************************************** _glutBitmapWidthString() **********/
531
int _glutBitmapWidthString( void *font, char *s )
536
while( *p != '\0' ) {
537
width += glutBitmapWidth( font, *p );
544
/************************************ _glutBitmapString *********************/
545
/* Displays the contents of a string using GLUT's bitmap character function */
546
/* Does not handle newlines */
548
void _glutBitmapString( void *font, char *s )
552
while( *p != '\0' ) {
553
glutBitmapCharacter( font, *p );
560
/****************************** GLUI_Main::reshape() **************/
562
void GLUI_Main::reshape( int reshape_w, int reshape_h )
568
new_w = main_panel->w;/* + 1; */
569
new_h = main_panel->h;/* + 1; */
571
if ( reshape_w != new_w OR reshape_h != new_h ) {
575
glutReshapeWindow( new_w, new_h );
580
if ( TEST_AND( this->flags, GLUI_SUBWINDOW ) ) {
581
check_subwindow_position();
583
/***** if ( TEST_AND(this->flags,GLUI_SUBWINDOW_LEFT )) {
585
else if ( TEST_AND(this->flags,GLUI_SUBWINDOW_LEFT )) {
587
else if ( TEST_AND(this->flags,GLUI_SUBWINDOW_LEFT )) {
589
else if ( TEST_AND(this->flags,GLUI_SUBWINDOW_RIGHT )) {
594
glViewport( 0, 0, new_w, new_h );
596
/* printf( "%d: %d\n", glutGetWindow(), this->flags ); */
598
/* glutPostRedisplay(); */
602
/****************************** GLUI_Main::keyboard() **************/
604
void GLUI_Main::keyboard(unsigned char key, int x, int y)
606
GLUI_Control *new_control;
608
curr_modifiers = glutGetModifiers();
610
/*** If it's a tab or shift tab, we don't pass it on to the controls.
611
Instead, we use it to cycle through active controls ***/
612
if ( key == '\t' AND mouse_button_down == false ) {
613
if ( curr_modifiers & GLUT_ACTIVE_SHIFT ) {
614
new_control = find_prev_control( active_control );
617
new_control = find_next_control( active_control );
620
/* if ( new_control )
621
printf( "new_control: %s\n", new_control->name );
624
disactivate_current_control();
625
activate_control( new_control, GLUI_ACTIVATE_TAB );
627
else if ( key == ' ' AND active_control
628
AND active_control->spacebar_mouse_click == true ) {
629
/*** If the user presses the spacebar, and a non-edittext control
630
is active, we send it a mouse down event followed by a mouse up
631
event (simulated mouse-click) ***/
633
active_control->mouse_down_handler( 0, 0 );
634
active_control->mouse_up_handler( 0, 0, true );
636
/*** Pass the keystroke onto the active control, if any ***/
637
if ( active_control != NULL )
638
active_control->key_handler( key, curr_modifiers );
643
/****************************** GLUI_Main::special() **************/
645
void GLUI_Main::special(int key, int x, int y)
647
curr_modifiers = glutGetModifiers();
649
/*** Pass the keystroke onto the active control, if any ***/
650
if ( active_control != NULL )
651
active_control->special_handler( key, glutGetModifiers() );
656
/****************************** GLUI_Main::mouse() **************/
658
void GLUI_Main::mouse(int button, int state, int x, int y)
661
GLUI_Control *control;
663
/* printf( "MOUSE: %d %d\n", button, state ); */
667
curr_modifiers = glutGetModifiers();
669
if ( button == GLUT_LEFT ) {
670
control = find_control( x, y );
672
/*if ( control ) printf( "control: %s\n", control->name.string ); */
674
if ( mouse_button_down AND active_control != NULL AND
676
/** We just released the mouse, which was depressed at some
679
callthrough = active_control->
680
mouse_up_handler( x, y, control==active_control);
681
glutSetCursor( GLUT_CURSOR_LEFT_ARROW );
683
if ( active_control AND
684
active_control->active_type ==
685
GLUI_CONTROL_ACTIVE_MOUSEDOWN AND 0){
686
/*** This is a control that needs to be disactivated when the
687
mouse button is released ****/
688
disactivate_current_control();
693
if ( NOT mouse_button_down AND state == GLUT_DOWN ) {
694
/*** We just pressed the mouse down at some control ***/
696
if ( active_control != control ) {
697
if ( active_control != NULL ) {
698
/** There is an active control still - disactivate it ***/
699
disactivate_current_control();
703
if ( control->enabled ) {
704
activate_control( control, GLUI_ACTIVATE_MOUSE );
705
callthrough = control->mouse_down_handler( x, y );
711
if ( state == GLUT_DOWN )
712
mouse_button_down = true;
713
else if ( state == GLUT_UP )
714
mouse_button_down = false;
718
NO CALLTHROUGH NEEDED FOR MOUSE EVENTS
719
if ( callthrough AND glut_mouse_CB )
720
glut_mouse_CB( button, state, x, y );
723
callthrough=callthrough; /* To get rid of compiler warnings */
727
/****************************** GLUI_Main::motion() **************/
729
void GLUI_Main::motion(int x, int y)
732
GLUI_Control *control;
734
/* printf( "MOTION: %d %d\n", x, y ); */
738
control = find_control(x,y);
740
if ( mouse_button_down AND active_control != NULL ) {
742
active_control->mouse_held_down_handler(x,y,control==active_control);
746
NO CALLTHROUGH NEEDED FOR MOUSE EVENTS
748
if ( callthrough AND glut_motion_CB )
752
callthrough=callthrough; /* To get rid of compiler warnings */
756
/*********************** GLUI_Main::passive_motion() **************/
758
void GLUI_Main::passive_motion(int x, int y)
760
GLUI_Control *control;
762
control = find_control( x, y );
764
/* printf( "%p %p\n", control, mouse_over_control ); */
766
if ( control != mouse_over_control ) {
767
if ( mouse_over_control ) {
768
mouse_over_control->mouse_over( false, x, y );
772
control->mouse_over( true, x, y );
773
mouse_over_control = control;
778
if ( curr_cursor != GLUT_CURSOR_INHERIT ) {
779
curr_cursor = GLUT_CURSOR_INHERIT;
780
glutSetCursor( GLUT_CURSOR_INHERIT );
786
/****************************** GLUI_Main::entry() **************/
788
void GLUI_Main::entry(int state)
790
/*if ( NOT active_control OR ( active_control AND ( active_control->type == GLUI_CONTROL_EDITTEXT
791
OR active_control->type == GLUI_CONTROL_SPINNER) ) )*/
792
glutSetCursor( GLUT_CURSOR_LEFT_ARROW );
796
/****************************** GLUI_Main::visibility() **************/
798
void GLUI_Main::visibility(int state)
803
/****************************** GLUI_Main::idle() **************/
805
void GLUI_Main::idle(void)
807
/*** Pass the idle event onto the active control, if any ***/
809
/* printf( "IDLE \t" ); */
811
if ( active_control != NULL ) {
812
/* First we check if the control actually needs the idle right now.
813
Otherwise, let's avoid wasting cycles and OpenGL context switching */
815
if ( active_control->needs_idle() ) {
816
/*** Set the current glut window to the glui window */
817
/*** But don't change the window if we're already at that window ***/
819
if ( glut_window_id > 0 AND glutGetWindow() != glut_window_id ) {
820
glutSetWindow( glut_window_id );
823
active_control->idle();
829
/******************************************* GLUI_Main::find_control() ******/
831
GLUI_Control *GLUI_Main::find_control( int x, int y )
833
GLUI_Control *node, *last_container;
835
last_container = NULL;
838
while( node != NULL ) {
839
if ( node->type != GLUI_CONTROL_COLUMN AND
841
node->x_abs, node->x_abs + node->w,
842
node->y_abs, node->y_abs + node->h ) ) {
843
/*** Point is inside current node ***/
845
if ( node->first_child() == NULL ) {
846
/*** SPECIAL CASE: for edittext boxes, we make sure click is
847
in box, and not on name string. This should be generalized
848
for all controls later... ***/
849
if ( node->type == GLUI_CONTROL_EDITTEXT ) {
850
if ( x < node->x_abs + ((GLUI_EditText*)node)->text_x_offset )
851
return (GLUI_Control*) node->parent();
854
return node; /* point is inside this node, and node has no children,
855
so return this node as the selected node */
858
/*** This is a container class ***/
859
last_container = node;
860
node = (GLUI_Control*) node->first_child(); /* Descend into child */
865
node = (GLUI_Control*) node->next();
869
/** No leaf-level nodes found to accept the mouse click, so
870
return the last container control found which DOES accept the click **/
872
if ( last_container ) {
873
/* printf( "ctrl: '%s'\n", last_container->name ); */
875
return last_container;
883
/************************************* GLUI_Main::pack_controls() ***********/
885
void GLUI_Main::pack_controls( void )
887
main_panel->pack(0,0);
889
/**** Now align controls within their bounds ****/
890
align_controls( main_panel );
892
/*** If this is a subwindow, expand panel to fit parent window ***/
893
if ( TEST_AND( this->flags, GLUI_SUBWINDOW ) ) {
894
int parent_h, parent_w;
897
orig_window = glutGetWindow();
898
glutSetWindow( this->top_level_glut_window_id );
899
parent_h = glutGet( GLUT_WINDOW_HEIGHT );
900
parent_w = glutGet( GLUT_WINDOW_WIDTH );
902
glutSetWindow( orig_window );
904
/* printf( "%d %d\n", parent_h, parent_w ); */
907
if ( TEST_AND(this->flags,GLUI_SUBWINDOW_TOP )) {
908
main_panel->w = MAX( main_panel->w, parent_w );
910
else if ( TEST_AND(this->flags,GLUI_SUBWINDOW_LEFT )) {
911
main_panel->h = MAX( main_panel->h, parent_h );
913
else if ( TEST_AND(this->flags,GLUI_SUBWINDOW_BOTTOM )) {
914
main_panel->w = MAX( main_panel->w, parent_w );
916
else if ( TEST_AND(this->flags,GLUI_SUBWINDOW_RIGHT )) {
917
main_panel->h = MAX( main_panel->h, parent_h );
922
this->w = main_panel->w;
923
this->h = main_panel->h;
927
/************************************ GLUI_Main::align_controls() **********/
929
void GLUI_Main::align_controls( GLUI_Control *control )
935
child = (GLUI_Control*) control->first_child();
937
while( child != NULL ) {
938
align_controls( child );
940
child = (GLUI_Control*)child->next();
946
/*********************************** GLUI::set_main_gfx_window() ************/
948
void GLUI::set_main_gfx_window( int window_id )
950
main_gfx_window_id = window_id;
954
/********************************* GLUI_Main::post_update_main_gfx() ********/
956
void GLUI_Main::post_update_main_gfx( void )
960
if ( main_gfx_window_id > 0 ) {
961
old_window = glutGetWindow();
962
glutSetWindow( main_gfx_window_id );
965
glutSetWindow( old_window );
970
/********************************* GLUI_Main::set_front_draw_buffer() ********/
972
int GLUI_Main::set_front_draw_buffer( void )
976
glGetIntegerv( GL_DRAW_BUFFER, &state );
978
glDrawBuffer( GL_FRONT );
984
/********************************* GLUI_Main::restore_draw_buffer() **********/
986
void GLUI_Main::restore_draw_buffer( int buffer_state )
988
glDrawBuffer( buffer_state );
992
/******************************************** GLUI_Main::GLUI_Main() ********/
994
GLUI_Main::GLUI_Main( void )
996
mouse_button_down = false;
999
active_control = NULL;
1000
mouse_over_control = NULL;
1001
main_gfx_window_id = -1;
1002
glut_window_id = -1;
1006
glui_id = GLUI_Master.glui_id_counter;
1007
GLUI_Master.glui_id_counter++;
1009
font = GLUT_BITMAP_HELVETICA_12;
1010
curr_cursor = GLUT_CURSOR_LEFT_ARROW;
1012
bkgd_color.set( 200, 200, 200 );
1013
bkgd_color_f[0] = 200.0 / 255.0;
1014
bkgd_color_f[1] = 200.0 / 255.0;
1015
bkgd_color_f[2] = 200.0 / 255.0;
1017
/*** Create the main panel ***/
1018
main_panel = new GLUI_Panel;
1019
main_panel->set_int_val( GLUI_PANEL_NONE );
1020
main_panel->glui = (GLUI*) this;
1021
main_panel->name = "\0";
1024
/************************************ GLUI_Main::draw_raised_box() **********/
1026
void GLUI_Main::draw_raised_box( int x, int y, int w, int h )
1031
glColor3ub( bkgd_color.r, bkgd_color.g, bkgd_color.b );
1032
glBegin( GL_LINE_LOOP );
1033
glVertex2i( x+1, y+1 ); glVertex2i( w-1, y+1 );
1034
glVertex2i( w-1, h-1 ); glVertex2i( x+1, h-1 );
1037
glColor3d( 1.0, 1.0, 1.0 );
1038
glBegin( GL_LINE_STRIP );
1039
glVertex2i( x, h ); glVertex2i( x, y ); glVertex2i( w, y );
1042
glColor3d( 0.0, 0.0, 0.0 );
1043
glBegin( GL_LINE_STRIP );
1044
glVertex2i( w, y ); glVertex2i( w, h ); glVertex2i( x, h );
1047
glColor3d( .5, .5, .5 );
1048
glBegin( GL_LINE_STRIP );
1049
glVertex2i( w-1, y+1 ); glVertex2i( w-1, h-1 ); glVertex2i( x+1, h-1 );
1054
/************************************ GLUI_Main::draw_lowered_box() **********/
1055
/* Not quite perfect... **/
1057
void GLUI_Main::draw_lowered_box( int x, int y, int w, int h )
1062
glColor3ub( bkgd_color.r, bkgd_color.g, bkgd_color.b );
1063
glBegin( GL_LINE_LOOP );
1064
glVertex2i( x+1, y+1 ); glVertex2i( w-1, y+1 );
1065
glVertex2i( w-1, h-1 ); glVertex2i( x+1, h-1 );
1068
glColor3d( 0.0, 0.0, 0.0 );
1069
glBegin( GL_LINE_STRIP );
1070
glVertex2i( x, h ); glVertex2i( x, y ); glVertex2i( w, y );
1073
glColor3d( 1.0, 1.0, 1.0 );
1074
glBegin( GL_LINE_STRIP );
1075
glVertex2i( w, y ); glVertex2i( w, h ); glVertex2i( x, h );
1078
glColor3d( .5, .5, .5 );
1079
glBegin( GL_LINE_STRIP );
1080
glVertex2i( w-1, y+1 ); glVertex2i( w-1, h-1 ); glVertex2i( x+1, h-1 );
1085
/************************************* GLUI_Main::activate_control() *********/
1087
void GLUI_Main::activate_control( GLUI_Control *control, int how )
1089
/** Are we not activating a control in the same window as the
1090
previous active control? */
1091
if ( GLUI_Master.active_control_glui AND
1092
this != (GLUI_Main*) GLUI_Master.active_control_glui ) {
1093
GLUI_Master.active_control_glui->disactivate_current_control();
1096
/******* Now activate it *****/
1097
if ( control != NULL AND control->can_activate AND control->enabled ) {
1098
active_control = control;
1100
control->activate(how);
1102
/*if ( NOT active_control->is_container OR */
1103
/* active_control->type == GLUI_CONTROL_ROLLOUT) { */
1104
active_control->translate_and_draw_front();
1108
active_control = NULL;
1111
/* printf( "activate: %d\n", glutGetWindow() ); */
1112
GLUI_Master.active_control = active_control;
1113
GLUI_Master.active_control_glui = (GLUI*) this;
1117
/************************* GLUI_Main::disactivate_current_control() **********/
1119
void GLUI_Main::disactivate_current_control( void )
1123
if ( active_control != NULL ) {
1124
orig = active_control->set_to_glut_window();
1126
active_control->disactivate();
1128
/** If this isn't a container control, then redraw it in its
1129
disactivated state. Container controls, such as panels, look
1130
the same activated or not **/
1132
/*if ( NOT active_control->is_container OR */
1133
/* active_control->type == GLUI_CONTROL_ROLLOUT ) { */
1134
active_control->translate_and_draw_front();
1137
active_control->restore_window( orig );
1139
active_control = NULL;
1142
/* printf( "disactivate: %d\n", glutGetWindow() ); */
1143
GLUI_Master.active_control = NULL;
1144
GLUI_Master.active_control_glui = NULL;
1148
/****************************** GLUI_Main::find_next_control() **************/
1150
GLUI_Control *GLUI_Main::find_next_control_( GLUI_Control *control )
1152
/*** THIS IS NOT find_next_control()! This is an unused older
1153
version (look at the underscore at the end) ***/
1155
if ( control == NULL )
1156
return find_next_control_rec( main_panel );
1158
return find_next_control_rec( control );
1161
/****************************** GLUI_Main::find_next_control() **************/
1163
GLUI_Control *GLUI_Main::find_next_control_rec( GLUI_Control *control )
1165
GLUI_Control *child = NULL, *rec_control, *sibling;
1167
/*** Recursively investigate children ***/
1168
child = (GLUI_Control*) control->first_child();
1170
/*** If we can activate the first child, then do so ***/
1171
if ( child->can_activate AND child->enabled )
1173
else /*** Recurse into first child ***/
1174
rec_control = find_next_control_rec( child );
1180
/*** At this point, either we don't have children, or the child cannot
1181
be activated. So let's try the next sibling ***/
1183
sibling = (GLUI_Control*) control->next();
1185
if ( sibling->can_activate AND sibling->enabled )
1187
else /*** Recurse into sibling ***/
1188
rec_control = find_next_control_rec( sibling );
1198
/****************************** GLUI_Main::find_next_control() **************/
1200
GLUI_Control *GLUI_Main::find_next_control( GLUI_Control *control )
1202
GLUI_Control *tmp_control = NULL;
1205
if ( control == NULL )
1206
control = main_panel;
1208
while( control != NULL ) {
1209
/** see if this control has a child **/
1210
tmp_control = (GLUI_Control*) control->first_child();
1212
if ( tmp_control != NULL ) {
1213
if ( tmp_control->can_activate AND tmp_control->enabled )
1216
control = tmp_control; /* Descend into child */
1220
/*** At this point, control has no children ***/
1222
/** see if this control has a next sibling **/
1223
tmp_control = (GLUI_Control*) control->next();
1225
if ( tmp_control != NULL ) {
1226
if ( tmp_control->can_activate AND tmp_control->enabled )
1229
control = tmp_control;
1233
/** back up until we find a sibling of an ancestor **/
1235
while ( control->parent() AND back_up ) {
1236
control = (GLUI_Control*) control->parent();
1238
if ( control->next() ) {
1239
control = (GLUI_Control*) control->next();
1240
if ( control->can_activate AND control->enabled )
1245
/*** if ( control->is_container ) {
1246
tmp_control = control;
1257
/** Check if we've cycled back to the top... if so, return NULL **/
1258
if ( control == main_panel ) {
1263
if ( tmp_control != NULL AND tmp_control->can_activate AND
1264
tmp_control->enabled ) {
1272
/****************************** GLUI_Main::find_prev_control() **************/
1274
GLUI_Control *GLUI_Main::find_prev_control( GLUI_Control *control )
1276
GLUI_Control *tmp_control, *next_control;
1278
if ( control == NULL ) { /* here we find the last valid control */
1279
next_control = main_panel;
1282
tmp_control = next_control;
1283
next_control = find_next_control( tmp_control );
1284
} while( next_control != NULL );
1288
else { /* here we find the actual previous control */
1289
next_control = main_panel;
1292
tmp_control = next_control;
1293
next_control = find_next_control( tmp_control );
1294
} while( next_control != NULL AND next_control != control );
1296
if ( next_control == NULL OR tmp_control == main_panel )
1303
/************************* GLUI_Master_Object::set_glutIdleFunc() ***********/
1305
void GLUI_Master_Object::set_glutIdleFunc(void (*f)(void))
1308
glutIdleFunc( glui_idle_func );
1312
/**************************************** GLUI::disable() ********************/
1314
void GLUI::disable( void )
1316
disactivate_current_control();
1317
main_panel->disable();
1321
/******************************************** GLUI::sync_live() **************/
1323
void GLUI::sync_live( void )
1325
main_panel->sync_live(true, true);
1329
/********************************* GLUI_Master_Object::sync_live_all() *****/
1331
void GLUI_Master_Object::sync_live_all( void )
1335
glui = (GLUI*) GLUI_Master.gluis.first_child();
1338
glui->sync_live(); /** sync it **/
1340
glui = (GLUI*) glui->next();
1345
/************************************* GLUI_Master_Object::close() **********/
1347
void GLUI_Master_Object::close_all( void )
1351
glui = (GLUI*) GLUI_Master.gluis.first_child();
1354
glui->close(); /** Set flag to close **/
1356
glui = (GLUI*) glui->next();
1361
/************************************* GLUI_Main::close_internal() **********/
1363
void GLUI_Main::close_internal( void )
1365
glutDestroyWindow(glutGetWindow()); /** Close this window **/
1369
if ( GLUI_Master.active_control_glui == this ) {
1370
GLUI_Master.active_control = NULL;
1371
GLUI_Master.active_control_glui = NULL;
1374
if ( parent_window != -1 ) {
1375
glutSetWindow( parent_window );
1376
int win_w = glutGet( GLUT_WINDOW_WIDTH );
1377
int win_h = glutGet( GLUT_WINDOW_HEIGHT );
1378
glutReshapeWindow(win_w+1, win_h);
1379
glutReshapeWindow(win_w-1, win_h);
1382
delete this->main_panel;
1388
/************************************************** GLUI::close() **********/
1390
void GLUI::close( void )
1392
int old_glut_window;
1396
old_glut_window = glutGetWindow();
1397
glutSetWindow( get_glut_window_id() );
1398
glutPostRedisplay();
1400
glutSetWindow( old_glut_window );
1404
/************************** GLUI_Main::check_subwindow_position() **********/
1406
void GLUI_Main::check_subwindow_position( void )
1408
/*** Reposition this window if subwindow ***/
1409
if ( TEST_AND( this->flags, GLUI_SUBWINDOW ) ) {
1411
int parent_w, parent_h, new_x, new_y;
1412
int old_window = glutGetWindow();
1414
glutSetWindow( glut_window_id );
1416
glutSetWindow( glutGet( GLUT_WINDOW_PARENT ));
1417
parent_w = glutGet( GLUT_WINDOW_WIDTH );
1418
parent_h = glutGet( GLUT_WINDOW_HEIGHT );
1420
glutSetWindow( glut_window_id );
1422
if ( TEST_AND(this->flags,GLUI_SUBWINDOW_RIGHT )) {
1423
new_x = parent_w - this->w;
1426
else if ( TEST_AND(this->flags,GLUI_SUBWINDOW_LEFT )) {
1430
else if ( TEST_AND(this->flags,GLUI_SUBWINDOW_BOTTOM )) {
1432
new_y = parent_h - this->h;
1434
else { /*** GLUI_SUBWINDOW_TOP ***/
1439
/** Now make adjustments based on presence of other subwindows **/
1441
curr_glui = (GLUI*) GLUI_Master.gluis.first_child();
1442
while( curr_glui ) {
1443
if ( TEST_AND( curr_glui->flags, GLUI_SUBWINDOW) AND
1444
curr_glui->parent_window == this->parent_window ) {
1446
if ( TEST_AND( curr_glui->flags,GLUI_SUBWINDOW_LEFT ) ) {
1448
else if ( TEST_AND( curr_glui->flags,GLUI_SUBWINDOW_BOTTOM ) ) {
1450
else if ( TEST_AND( curr_glui->flags,GLUI_SUBWINDOW_RIGHT ) ) {
1452
else if ( TEST_AND( curr_glui->flags,GLUI_SUBWINDOW_TOP ) AND
1453
( TEST_AND( this->flags,GLUI_SUBWINDOW_LEFT ) OR
1454
TEST_AND( this->flags,GLUI_SUBWINDOW_RIGHT ) ) ) {
1455
/** If we are a RIGHT or LEFT subwindow, and there exists some
1456
TOP subwindow, bump our position down **/
1458
new_y += curr_glui->h;
1461
/** CHeck multiple subwins at same position **/
1462
/** We check the glui_id's: only the glui with the higher
1463
ID number (meaning it was created later) gets bumped over **/
1464
if ( curr_glui != this AND this->glui_id > curr_glui->glui_id ) {
1465
if ( TEST_AND( this->flags,GLUI_SUBWINDOW_LEFT ) AND
1466
TEST_AND( curr_glui->flags,GLUI_SUBWINDOW_LEFT ) ) {
1467
new_x += curr_glui->w;
1469
else if ( TEST_AND( this->flags,GLUI_SUBWINDOW_TOP ) AND
1470
TEST_AND( curr_glui->flags,GLUI_SUBWINDOW_TOP ) ) {
1471
new_y += curr_glui->h;
1473
else if ( TEST_AND( this->flags,GLUI_SUBWINDOW_BOTTOM ) AND
1474
TEST_AND( curr_glui->flags,GLUI_SUBWINDOW_BOTTOM ) ) {
1475
new_y -= curr_glui->h;
1477
else if ( TEST_AND( this->flags,GLUI_SUBWINDOW_RIGHT ) AND
1478
TEST_AND( curr_glui->flags,GLUI_SUBWINDOW_RIGHT ) ) {
1479
new_x -= curr_glui->w;
1485
curr_glui = (GLUI*) curr_glui->next();
1490
CLAMP( new_x, 0, new_x );
1491
CLAMP( new_y, 0, new_y );
1493
glutPositionWindow( new_x, new_y );
1494
/* glutPostRedisplay(); */
1496
glutSetWindow( old_window );
1501
/********************************* GLUI_Master_Object::reshape() **********/
1502
/* This gets called by the user from a GLUT reshape callback. So we look */
1503
/* for subwindows that belong to the current window */
1505
void GLUI_Master_Object::reshape( void )
1510
current_window = glutGetWindow();
1512
glui = (GLUI*) GLUI_Master.gluis.first_child();
1514
if ( TEST_AND( glui->flags, GLUI_SUBWINDOW) AND
1515
glui->parent_window == current_window ) {
1516
glutSetWindow( glui->get_glut_window_id());
1517
glui->check_subwindow_position();
1520
glui = (GLUI*) glui->next();
1523
glutSetWindow(current_window);
1527
/**************************** GLUI_Master_Object::set_glutReshapeFunc() *****/
1529
void GLUI_Master_Object::set_glutReshapeFunc(void (*f)(int width, int height))
1531
glutReshapeFunc( glui_reshape_func );
1532
add_cb_to_glut_window( glutGetWindow(), GLUI_GLUT_RESHAPE, (void*) f);
1536
/**************************** GLUI_Master_Object::set_glutKeyboardFunc() ****/
1538
void GLUI_Master_Object::set_glutKeyboardFunc(void (*f)(unsigned char key,
1541
glutKeyboardFunc( glui_keyboard_func );
1542
add_cb_to_glut_window( glutGetWindow(), GLUI_GLUT_KEYBOARD, (void*) f);
1546
/*********************** GLUI_Master_Object::set_glutSpecialFunc() **********/
1548
void GLUI_Master_Object::set_glutSpecialFunc(void (*f)(int key,
1551
glutSpecialFunc( glui_special_func );
1552
add_cb_to_glut_window( glutGetWindow(), GLUI_GLUT_SPECIAL, (void*) f);
1556
/*********************** GLUI_Master_Object::set_glutMouseFunc() **********/
1558
void GLUI_Master_Object::set_glutMouseFunc(void (*f)(int button, int state,
1561
glutMouseFunc( glui_mouse_func );
1562
add_cb_to_glut_window( glutGetWindow(), GLUI_GLUT_MOUSE, (void*) f);
1566
/****************************** glui_parent_window_reshape_func() **********/
1567
/* This is the reshape callback for a window that contains subwindows */
1569
void glui_parent_window_reshape_func( int w, int h )
1575
/* printf( "glui_parent_window_reshape_func: %d\n", glutGetWindow() ); */
1577
current_window = glutGetWindow();
1579
glui = (GLUI*) GLUI_Master.gluis.first_child();
1581
if ( TEST_AND( glui->flags, GLUI_SUBWINDOW) AND
1582
glui->parent_window == current_window ) {
1583
glutSetWindow( glui->get_glut_window_id());
1584
glui->check_subwindow_position();
1585
glutSetWindow( current_window );
1588
glui->glut_reshape_CB( w, h );
1594
glui = (GLUI*) glui->next();
1599
/****************************** glui_parent_window_keyboard_func() **********/
1601
void glui_parent_window_keyboard_func(unsigned char key, int x, int y)
1603
/* printf( "glui_parent_window_keyboard_func: %d\n", glutGetWindow() ); */
1608
current_window = glutGetWindow();
1610
if ( GLUI_Master.active_control_glui AND GLUI_Master.active_control ) {
1611
glutSetWindow( GLUI_Master.active_control_glui->get_glut_window_id() );
1613
GLUI_Master.active_control_glui->keyboard(key,x,y);
1615
glutSetWindow( current_window );
1618
glui = (GLUI*) GLUI_Master.gluis.first_child();
1620
if ( TEST_AND( glui->flags, GLUI_SUBWINDOW) AND
1621
glui->parent_window == current_window ) {
1622
glui->glut_keyboard_CB( key, x, y );
1626
glui = (GLUI*) glui->next();
1632
/****************************** glui_parent_window_special_func() **********/
1634
void glui_parent_window_special_func(int key, int x, int y)
1636
/*printf( "glui_parent_window_special_func: %d\n", glutGetWindow() ); */
1641
/** If clicking in the main area of a window w/subwindows,
1642
disactivate any current control **/
1643
if ( GLUI_Master.active_control_glui != NULL )
1644
GLUI_Master.active_control_glui->disactivate_current_control();
1646
/*** Now pass on the mouse event ***/
1648
current_window = glutGetWindow();
1650
glui = (GLUI*) GLUI_Master.gluis.first_child();
1652
if ( TEST_AND( glui->flags, GLUI_SUBWINDOW) AND
1653
glui->parent_window == current_window ) {
1654
glutSetWindow( glui->get_glut_window_id());
1655
glui->glut_special_CB( key, x, y );
1659
glui = (GLUI*) glui->next();
1664
/****************************** glui_parent_window_mouse_func() **********/
1666
void glui_parent_window_mouse_func(int button, int state, int x, int y)
1671
/** If clicking in the main area of a window w/subwindows,
1672
disactivate any current control **/
1673
if ( GLUI_Master.active_control_glui != NULL )
1674
GLUI_Master.active_control_glui->disactivate_current_control();
1677
/*** Now pass on the mouse event ***/
1679
current_window = glutGetWindow();
1681
glui = (GLUI*) GLUI_Master.gluis.first_child();
1683
if ( TEST_AND( glui->flags, GLUI_SUBWINDOW) AND
1684
glui->parent_window == current_window ) {
1685
glutSetWindow( glui->get_glut_window_id());
1686
glui->glut_mouse_CB( button, state, x, y );
1690
glui = (GLUI*) glui->next();
1696
/************************** GLUI_Master_Object::find_glut_window() **********/
1698
GLUI_Glut_Window *GLUI_Master_Object::find_glut_window( int window_id )
1700
GLUI_Glut_Window *window;
1702
window = (GLUI_Glut_Window*) glut_windows.first_child();
1704
if ( window->glut_window_id == window_id )
1707
window = (GLUI_Glut_Window*) window->next();
1710
/*** Window not found - return NULL ***/
1715
/******************** GLUI_Master_Object::add_cb_to_glut_window() **********/
1717
void GLUI_Master_Object::add_cb_to_glut_window(int window_id,
1718
int cb_type,void *cb)
1720
GLUI_Glut_Window *window;
1722
window = find_glut_window( window_id );
1724
/*** Allocate new window structure ***/
1726
window = new GLUI_Glut_Window;
1727
window->glut_window_id = window_id;
1728
window->link_this_to_parent_last( (GLUI_Node*) &this->glut_windows );
1732
case GLUI_GLUT_RESHAPE:
1733
window->glut_reshape_CB = (void(*)(int,int)) cb;
1735
case GLUI_GLUT_DISPLAY:
1736
window->glut_display_CB = (void(*)()) cb;
1738
case GLUI_GLUT_KEYBOARD:
1739
window->glut_keyboard_CB = (void(*)(unsigned char,int,int)) cb;
1741
case GLUI_GLUT_SPECIAL:
1742
window->glut_special_CB = (void(*)(int,int,int)) cb;
1744
case GLUI_GLUT_MOUSE:
1745
window->glut_mouse_CB = (void(*)(int,int,int,int)) cb;
1747
case GLUI_GLUT_MOTION:
1748
window->glut_motion_CB = (void(*)(int,int)) cb;
1750
case GLUI_GLUT_PASSIVE_MOTION:
1751
window->glut_passive_motion_CB = (void(*)(int,int)) cb;
1753
case GLUI_GLUT_ENTRY:
1754
window->glut_entry_CB = (void(*)(int)) cb;
1756
case GLUI_GLUT_VISIBILITY:
1757
window->glut_visibility_CB= (void(*)(int)) cb;
1763
/************* GLUI_Master_Object::set_left_button_glut_menu_control() *****/
1765
void GLUI_Master_Object::set_left_button_glut_menu_control(
1766
GLUI_Control *control )
1768
curr_left_button_glut_menu = control;
1772
/******************************* GLUI_Main::set_ortho_projection() **********/
1774
void GLUI_Main::set_ortho_projection( void )
1778
win_w = glutGet( GLUT_WINDOW_WIDTH );
1779
win_h = glutGet( GLUT_WINDOW_HEIGHT );
1781
glMatrixMode( GL_PROJECTION );
1783
/* gluOrtho2D( 0.0, (float) win_w, 0.0, (float) win_h ); */
1784
glOrtho( 0.0, (float)win_w, 0.0, (float) win_h, -1000.0, 1000.0 );
1786
glMatrixMode( GL_MODELVIEW );
1788
return; /****-----------------------------------------------***/
1790
glMatrixMode( GL_MODELVIEW );
1793
/*** Rotate image so y increases upwards, contrary to OpenGL axes ***/
1794
glTranslatef( (float) win_w/2.0, (float) win_h/2.0, 0.0 );
1795
glRotatef( 180.0, 0.0, 1.0, 0.0 );
1796
glRotatef( 180.0, 0.0, 0.0, 1.0 );
1797
glTranslatef( (float) -win_w/2.0, (float) -win_h/2.0, 0.0 );
1801
/******************************* GLUI_Main::set_viewport() **********/
1803
void GLUI_Main::set_viewport( void )
1805
glViewport( 0, 0, main_panel->w, main_panel->h );
1809
/****************************** GLUI_Main::refresh() ****************/
1811
void GLUI_Main::refresh( void )
1816
/****** GLUI_Glut_Window *glut_window;
1818
current_window = glutGetWindow();
1819
glut_window = GLUI_Master.find_glut_window( current_window );
1820
if ( glut_window ) {
1821
glut_window->glut_reshape_CB(w,h);
1824
orig = glutGetWindow();
1828
if ( TEST_AND( this->flags, GLUI_SUBWINDOW ) ) {
1829
/*** GLUI subwindow ***/
1831
check_subwindow_position();
1833
if ( glut_window_id > 0 )
1834
glutSetWindow( glut_window_id );
1835
glutPostRedisplay();
1837
/* printf( "top_level: %d\n", top_level_glut_window_id );*/
1838
glutSetWindow( top_level_glut_window_id );
1841
/*** Standalone GLUI window ***/
1843
if ( glut_window_id > 0 )
1844
glutSetWindow( glut_window_id );
1846
new_h = glutGet( GLUT_WINDOW_HEIGHT );
1847
new_w = glutGet( GLUT_WINDOW_WIDTH );
1852
glutReshapeWindow( new_w, new_h );
1854
glutPostRedisplay();
1857
glutSetWindow( orig);
1862
/***************** GLUI_Master_Object::get_main_gfx_viewport() ***********/
1864
void GLUI_Master_Object::get_viewport_area( int *x, int *y,
1868
int curr_x, curr_y, curr_w, curr_h;
1871
curr_window = glutGetWindow();
1874
curr_w = glutGet( GLUT_WINDOW_WIDTH );
1875
curr_h = glutGet( GLUT_WINDOW_HEIGHT );
1877
curr_glui = (GLUI*) gluis.first_child();
1878
while( curr_glui ) {
1879
if ( TEST_AND( curr_glui->flags, GLUI_SUBWINDOW) AND
1880
curr_glui->parent_window == curr_window ) {
1882
/* printf( "%s -> %d %d %d\n", curr_glui->window_name.string, curr_glui->flags,
1883
curr_glui->w, curr_glui->h );*/
1885
if ( TEST_AND( curr_glui->flags,GLUI_SUBWINDOW_LEFT ) ) {
1886
curr_x += curr_glui->w;
1887
curr_w -= curr_glui->w;
1889
else if ( TEST_AND( curr_glui->flags,GLUI_SUBWINDOW_BOTTOM ) ) {
1890
curr_y += curr_glui->h;
1891
curr_h -= curr_glui->h;
1893
else if ( TEST_AND( curr_glui->flags,GLUI_SUBWINDOW_RIGHT ) ) {
1894
curr_w -= curr_glui->w;
1896
else if ( TEST_AND( curr_glui->flags,GLUI_SUBWINDOW_TOP ) ) {
1897
curr_h -= curr_glui->h;
1901
curr_glui = (GLUI*) curr_glui->next();
1904
curr_x = MAX( 0, curr_x );
1905
curr_y = MAX( 0, curr_y );
1906
curr_w = MAX( 0, curr_w );
1907
curr_h = MAX( 0, curr_h );
1916
/*****************GLUI_Master_Object::auto_set_main_gfx_viewport() **********/
1918
void GLUI_Master_Object::auto_set_viewport( void )
1922
get_viewport_area( &x, &y, &w, &h );
1923
glViewport( MAX(x,0), MAX(y,0), MAX(w,0), MAX(h,0) );
1928
/***************************************** GLUI::show() **********************/
1930
void GLUI::show( void )
1934
orig_window = main_panel->set_to_glut_window();
1938
main_panel->restore_window(orig_window);
1943
/***************************************** GLUI::hide() **********************/
1945
void GLUI::hide( void )
1949
this->disactivate_current_control();
1951
orig_window = main_panel->set_to_glut_window();
1955
main_panel->restore_window(orig_window);