// scenerytools.cpp -- the toolbar for scenery operations // // Written by Frederic Bouvier, started March 2003. // // Copyright (C) 2003 Frederic Bouvier - fredb@users.sourceforge.net // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 2 of the // License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // // $Id: scenerytools.cpp,v 1.9 2005/05/09 07:02:13 fredb Exp $ #ifdef _MSC_VER # pragma warning( disable: 4800 4503 ) #endif #include "scenerytools.hpp" #include "mainwin.hpp" #include "shadows.xpm" extern FGSD_Preferences generalPreferences; FGSD_SceneryToolbar::FGSD_SceneryToolbar( int x, int y, int w, int h, FGSD_MainWindow *mw ) : Fl_Group( x, y, w, h ) , _shadowImage( shadows_xpm ) { begin(); int posx = 5; _showScenery = new Fl_Button( x+posx, y+5, 30, 30, "S" ); _showScenery->type( FL_TOGGLE_BUTTON ); _showScenery->tooltip( "Hide/Show FGFS scenery tiles" ); _showScenery->callback( &FGSD_MainWindow::tileButton_cb, mw ); _showScenery->value( generalPreferences.showTiles() ); posx += 30; _showStatic = new Fl_Button( x+posx, y+5, 30, 30, "St" ); _showStatic->type( FL_TOGGLE_BUTTON ); _showStatic->tooltip( "Hide/Show FGFS static objects" ); _showStatic->callback( &FGSD_MainWindow::staticButton_cb, mw ); _showStatic->value( generalPreferences.showStatic() ); posx += 30; _showFrame = new Fl_Button( x+posx, y+5, 30, 30, "T" ); _showFrame->type( FL_TOGGLE_BUTTON ); _showFrame->tooltip( "Hide/Show FGFS scenery tile frames" ); _showFrame->callback( &FGSD_MainWindow::tileFrameButton_cb, mw ); _showFrame->value( generalPreferences.showTileFrames() ); posx += 30; _editVertex = new Fl_Button( x+posx, y+5, 30, 30, "V" ); _editVertex->type( FL_TOGGLE_BUTTON ); _editVertex->tooltip( "Edit vertices mode" ); _editVertex->callback( &FGSD_MainWindow::vertexMode_cb, mw ); posx += 40; _alphaTile = new Fl_Value_Slider( x+posx, y+5, 100, 30 ); _alphaTile->type( FL_HORIZONTAL ); _alphaTile->step( 0.01 ); _alphaTile->range( 0.0, 1.0 ); _alphaTile->tooltip( "Transparency value for tiles" ); _alphaTile->callback( &FGSD_MainWindow::alpha_cb, (void *)mw ); _alphaTile->value( generalPreferences.alphaValue() ); posx += 110; _viewType = new Fl_Choice( x+posx, y+5, 150, 30 ); _viewType->tooltip( "Drawing mode" ); _viewType->callback( &FGSD_SceneryToolbar::drawType_cb, (void *)mw ); _viewType->add( "Normal" ); _viewType->add( "Shadowed" ); _viewType->add( "Slope Gradient" ); _viewType->value( 0 ); posx += 160; _hentry = new FGSD_FloatInput( mw, x+posx, y+5, 100, 30 ); _hentry->tooltip( "Height for next change" ); posx += 110; end(); resizable( 0 ); box( FL_THIN_UP_BOX ); } void FGSD_SceneryToolbar::show( bool yes ) { yes ? Fl_Group::show() : Fl_Group::hide(); if ( !yes ) _editVertex->value( 0 ); // parent()->relayout(); } void FGSD_SceneryToolbar::noFragmentPresent() { _showScenery->value( 1 ); _showScenery->deactivate(); _alphaTile->value( 1.0 ); drawTiles( true ); } void FGSD_SceneryToolbar::fragmentPresent() { drawTiles( _showScenery->value() ); _alphaTile->activate(); _showScenery->activate(); } const char *FGSD_SceneryToolbar::heightValue() const { return _hentry->value(); } void FGSD_SceneryToolbar::heightValue( const char *v ) { _hentry->value( v ); } bool FGSD_SceneryToolbar::drawShadows() const { bool ret = false; /* Fl_Widget *w = _viewType->child( _viewType->value() ); if ( w ) ret = strcmp( w->label(), "Shadowed" ) == 0; */ return ret; } void FGSD_SceneryToolbar::drawType_cb( Fl_Widget *w, void *v ) { int x = static_cast( w )->value(); static_cast( v )->setDrawType( static_cast( x ) ); } void FGSD_SceneryToolbar::drawTiles( bool d ) { if ( d != ( _showScenery->value() ? true : false ) ) { _showScenery->value( d ); } if ( d ) { _showStatic->show(); _showFrame->show(); _viewType->show(); _editVertex->show(); _alphaTile->show(); } else { _showStatic->hide(); _showFrame->hide(); _viewType->hide(); _editVertex->hide(); _alphaTile->hide(); } }