@@ -108,7 +108,7 @@ struct MyClickHandler : public ControlEventHandler
108
108
{
109
109
void onClick ( Control* control, int mouseButtonMask )
110
110
{
111
- OE_NOTICE << " Thank you for clicking on " << typeid (control).name ()
111
+ OE_NOTICE << " Thank you for clicking on " << typeid (control).name () << mouseButtonMask
112
112
<< std::endl;
113
113
}
114
114
};
@@ -262,30 +262,66 @@ void GlobePlugin::setupMap()
262
262
263
263
void GlobePlugin::setupControls ()
264
264
{
265
- // a centered hbox container along the bottom on the screen.
266
- HBox* bottom = new HBox ();
267
- bottom->setFrame ( new RoundedFrame () );
268
- bottom->getFrame ()->setBackColor (0 ,0 ,0 ,0.5 );
269
- bottom->setMargin ( 10 );
270
- bottom->setSpacing ( 145 );
271
- bottom->setVertAlign ( Control::ALIGN_BOTTOM );
272
- bottom->setHorizAlign ( Control::ALIGN_CENTER );
273
-
274
- for ( int i=0 ; i<4 ; ++i )
275
- {
276
- LabelControl* label = new LabelControl ();
277
- std::stringstream buf;
278
- buf << " Label_" << i;
279
- label->setText ( buf.str () );
280
- label->setMargin ( 10 );
281
- label->setBackColor ( 1 ,1 ,1 ,0.4 );
282
- bottom->addControl ( label );
283
-
284
- label->setActiveColor (1 ,.3 ,.3 ,1 );
285
- label->addEventHandler ( new MyClickHandler );
286
- }
287
-
288
- mControlCanvas ->addControl ( bottom );
265
+
266
+ std::string imgDir = QDir::cleanPath ( QgsApplication::pkgDataPath () + " /globe/gui" ).toStdString ();
267
+
268
+ // MOVE CONTROLS
269
+ // Horizontal container
270
+ HBox* moveHControls = new HBox ();
271
+ moveHControls->setFrame ( new RoundedFrame () );
272
+ // moveHControls->getFrame()->setBackColor(0.5,0.5,0.5,0.1);
273
+ // moveHControls->setMargin( 10 );
274
+ moveHControls->setSpacing ( 15 );
275
+ moveHControls->setVertAlign ( Control::ALIGN_CENTER );
276
+ moveHControls->setHorizAlign ( Control::ALIGN_CENTER );
277
+ moveHControls->setPosition ( 20 , 40 );
278
+
279
+ // Move Left
280
+ osg::Image* moveLeftImg = osgDB::readImageFile ( imgDir + " /move-left.png" );
281
+ ImageControl* moveLeft = new ImageControl (moveLeftImg);
282
+ // moveLeft->setPosition( 0, 5 );
283
+ moveLeft->addEventHandler ( new MyClickHandler );
284
+
285
+ // Move Right
286
+ osg::Image* moveRightImg = osgDB::readImageFile ( imgDir + " /move-right.png" );
287
+ ImageControl* moveRight = new ImageControl (moveRightImg);
288
+ // moveRight->setPosition( 10, 5 );
289
+ moveRight->addEventHandler ( new MyClickHandler );
290
+
291
+
292
+ // Vertical container
293
+ VBox* moveVControls = new VBox ();
294
+ moveVControls->setFrame ( new RoundedFrame () );
295
+ // moveControls->getFrame()->setBackColor(0.5,0.5,0.5,0.1);
296
+ // moveControls->setMargin( 10 );
297
+ moveVControls->setSpacing ( 15 );
298
+ moveVControls->setVertAlign ( Control::ALIGN_CENTER );
299
+ moveVControls->setHorizAlign ( Control::ALIGN_CENTER );
300
+ moveVControls->setPosition ( 40 , 20 );
301
+
302
+ // Move Up
303
+ osg::Image* moveUpImg = osgDB::readImageFile ( imgDir + " /move-up.png" );
304
+ ImageControl* moveUp = new ImageControl (moveUpImg);
305
+ // moveUp->setPosition( 5, 10 );
306
+ moveUp->addEventHandler ( new MyClickHandler );
307
+
308
+ // Move Down
309
+ osg::Image* moveDownImg = osgDB::readImageFile ( imgDir + " /move-down.png" );
310
+ ImageControl* moveDown = new ImageControl (moveDownImg);
311
+ // moveDown->setPosition( 5, 0 );
312
+ moveDown->addEventHandler ( new MyClickHandler );
313
+ // END MOVE CONTROLS
314
+
315
+ // add controls to moveControls group
316
+ moveHControls->addControl ( moveLeft );
317
+ moveHControls->addControl ( moveRight );
318
+ moveVControls->addControl ( moveUp );
319
+ moveVControls->addControl ( moveDown );
320
+
321
+ // add controls groups to canavas
322
+ mControlCanvas ->addControl ( moveHControls );
323
+ mControlCanvas ->addControl ( moveVControls );
324
+
289
325
}
290
326
291
327
void GlobePlugin::setupProxy ()
0 commit comments