Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 85 lines (71 sloc) 1.784 kB
25074b9 extended option class to manage menus nicely, plus revised visualizat…
rtv authored
1
ec56d04 header clean up
rtv authored
2 #include "stage.hh"
3 #include "worldfile.hh"
4 #include "option.hh"
5 #include "canvas.hh"
25074b9 extended option class to manage menus nicely, plus revised visualizat…
rtv authored
6 using namespace Stg;
7
e02c2f6 Warning cleanup
jeremy_asher authored
8
55b9c56 @rtv simplified bitmap rendering (back to the old days) for speed and to a…
authored
9 Option::Option( const std::string& n,
10 const std::string& tok,
11 const std::string& key,
1fdc189 fixed gripper bug reported by Pante a
rtv authored
12 bool v,
13 World* world ) :
14 optName( n ),
15 value( v ),
16 wf_token( tok ),
17 shortcut( key ),
18 menu( NULL ),
19 menuCb( NULL ),
20 _world( world ),
55b9c56 @rtv simplified bitmap rendering (back to the old days) for speed and to a…
authored
21 htname( n )
1fdc189 fixed gripper bug reported by Pante a
rtv authored
22 {
23 /* do nothing */
24 }
e02c2f6 Warning cleanup
jeremy_asher authored
25
1fdc189 fixed gripper bug reported by Pante a
rtv authored
26 Fl_Menu_Item* getMenuItem( Fl_Menu_* menu, int i )
27 {
28 const Fl_Menu_Item* mArr = menu->menu();
29 return const_cast<Fl_Menu_Item*>( &mArr[ i ] );
51a42c8 Extended Option class to allow custom callbacks on menu option select…
jeremy_asher authored
30 }
e02c2f6 Warning cleanup
jeremy_asher authored
31
32
25074b9 extended option class to manage menus nicely, plus revised visualizat…
rtv authored
33 void Option::Load( Worldfile* wf, int section )
34 {
7655f7b bugfixes
rtv authored
35 //printf( "loading wf key %s\n", wf_token.c_str() );
379cfd6 @rtv added support for load/save of visualization options
authored
36 set( (bool)wf->ReadInt( section, wf_token.c_str(), value ));
25074b9 extended option class to manage menus nicely, plus revised visualizat…
rtv authored
37 }
38
39 void Option::Save( Worldfile* wf, int section )
40 {
41 wf->WriteInt(section, wf_token.c_str(), value );
42 }
43
51a42c8 Extended Option class to allow custom callbacks on menu option select…
jeremy_asher authored
44 void Option::toggleCb( Fl_Widget* w, void* p )
25074b9 extended option class to manage menus nicely, plus revised visualizat…
rtv authored
45 {
86c7a93 Fixed Option loading not updating menu
jeremy_asher authored
46 //Fl_Menu_* menu = static_cast<Fl_Menu_*>( w );
47 Option* opt = static_cast<Option*>( p );
48 opt->invert();
51a42c8 Extended Option class to allow custom callbacks on menu option select…
jeremy_asher authored
49 if ( opt->menuCb )
f1e3f66 Added saving of perspective cam mode, fixed camera pointer not changi…
jeremy_asher authored
50 opt->menuCb( opt->menuCbWidget, opt );
51a42c8 Extended Option class to allow custom callbacks on menu option select…
jeremy_asher authored
51 }
52
f1e3f66 Added saving of perspective cam mode, fixed camera pointer not changi…
jeremy_asher authored
53 void Option::menuCallback( Fl_Callback* cb, Fl_Widget* w ) {
51a42c8 Extended Option class to allow custom callbacks on menu option select…
jeremy_asher authored
54 menuCb = cb;
f1e3f66 Added saving of perspective cam mode, fixed camera pointer not changi…
jeremy_asher authored
55 menuCbWidget = w;
25074b9 extended option class to manage menus nicely, plus revised visualizat…
rtv authored
56 }
57
86c7a93 Fixed Option loading not updating menu
jeremy_asher authored
58 void Option::createMenuItem( Fl_Menu_Bar* m, std::string path )
25074b9 extended option class to manage menus nicely, plus revised visualizat…
rtv authored
59 {
86c7a93 Fixed Option loading not updating menu
jeremy_asher authored
60 menu = m;
61 path = path + "/" + optName;
62 // create a menu item and save its index
63 menuIndex = menu->add( path.c_str(), shortcut.c_str(),
64 toggleCb, this,
65 FL_MENU_TOGGLE | (value ? FL_MENU_VALUE : 0 ) );
51a42c8 Extended Option class to allow custom callbacks on menu option select…
jeremy_asher authored
66 }
25074b9 extended option class to manage menus nicely, plus revised visualizat…
rtv authored
67
86c7a93 Fixed Option loading not updating menu
jeremy_asher authored
68 void Option::set( bool val )
25074b9 extended option class to manage menus nicely, plus revised visualizat…
rtv authored
69 {
86c7a93 Fixed Option loading not updating menu
jeremy_asher authored
70 value = val;
25074b9 extended option class to manage menus nicely, plus revised visualizat…
rtv authored
71
86c7a93 Fixed Option loading not updating menu
jeremy_asher authored
72 if( menu ) {
51a42c8 Extended Option class to allow custom callbacks on menu option select…
jeremy_asher authored
73 Fl_Menu_Item* item = getMenuItem( menu, menuIndex );
86c7a93 Fixed Option loading not updating menu
jeremy_asher authored
74 value ? item->set() : item->clear();
75 }
e2df9ad started to fix bug when changes to data filter doesnt redraw screen -…
alexcb authored
76
77 if( _world ) {
78 WorldGui* wg = dynamic_cast< WorldGui* >( _world );
79 if( wg == NULL ) return;
80 Canvas* canvas = wg->GetCanvas();
81 canvas->invalidate();
82 canvas->redraw();
83 }
25074b9 extended option class to manage menus nicely, plus revised visualizat…
rtv authored
84 }
Something went wrong with that request. Please try again.