Make KIGFX::GRID_STYLE an enum class

This provides stronger typing to these values.
This commit is contained in:
John Beard 2017-02-16 10:50:34 +08:00 committed by Maciej Suminski
parent 7ad30b7167
commit ff3bfaf82b
5 changed files with 13 additions and 13 deletions

View File

@ -35,7 +35,7 @@ static const wxString GalGridStyleConfig( "GridStyle" );
GAL_DISPLAY_OPTIONS::GAL_DISPLAY_OPTIONS() GAL_DISPLAY_OPTIONS::GAL_DISPLAY_OPTIONS()
: gl_antialiasing_mode( OPENGL_ANTIALIASING_MODE::NONE ), : gl_antialiasing_mode( OPENGL_ANTIALIASING_MODE::NONE ),
m_gridStyle( GRID_STYLE_DOTS ) m_gridStyle( GRID_STYLE::DOTS )
{} {}
@ -47,7 +47,7 @@ void GAL_DISPLAY_OPTIONS::ReadConfig( wxConfigBase* aCfg, wxString aBaseName )
aCfg->Read( aBaseName + GalGridStyleConfig, aCfg->Read( aBaseName + GalGridStyleConfig,
reinterpret_cast<long*>( &m_gridStyle ), reinterpret_cast<long*>( &m_gridStyle ),
static_cast<long>( KIGFX::GRID_STYLE::GRID_STYLE_DOTS ) ); static_cast<long>( KIGFX::GRID_STYLE::DOTS ) );
NotifyChanged(); NotifyChanged();
} }

View File

@ -61,7 +61,7 @@ GAL::GAL( GAL_DISPLAY_OPTIONS& aDisplayOptions ) :
SetGridDrawThreshold( 10 ); SetGridDrawThreshold( 10 );
SetCoarseGrid( 10 ); SetCoarseGrid( 10 );
SetGridLineWidth( 0.5 ); SetGridLineWidth( 0.5 );
gridStyle = GRID_STYLE_LINES; gridStyle = GRID_STYLE::LINES;
// Initialize the cursor shape // Initialize the cursor shape
SetCursorColor( COLOR4D( 1.0, 1.0, 1.0, 1.0 ) ); SetCursorColor( COLOR4D( 1.0, 1.0, 1.0, 1.0 ) );
@ -202,7 +202,7 @@ void GAL::DrawGrid()
// Draw the grid behind all other layers // Draw the grid behind all other layers
SetLayerDepth( depthRange.y * 0.75 ); SetLayerDepth( depthRange.y * 0.75 );
if( gridStyle == GRID_STYLE_LINES ) if( gridStyle == GRID_STYLE::LINES )
{ {
SetIsFill( false ); SetIsFill( false );
SetIsStroke( true ); SetIsStroke( true );

View File

@ -888,7 +888,7 @@ void OPENGL_GAL::DrawGrid()
glDisable( GL_DEPTH_TEST ); glDisable( GL_DEPTH_TEST );
glDisable( GL_TEXTURE_2D ); glDisable( GL_TEXTURE_2D );
if( gridStyle == GRID_STYLE_DOTS ) if( gridStyle == GRID_STYLE::DOTS )
{ {
glEnable( GL_STENCIL_TEST ); glEnable( GL_STENCIL_TEST );
glStencilFunc( GL_ALWAYS, 1, 1 ); glStencilFunc( GL_ALWAYS, 1, 1 );
@ -918,7 +918,7 @@ void OPENGL_GAL::DrawGrid()
} }
} }
if( gridStyle == GRID_STYLE_DOTS ) if( gridStyle == GRID_STYLE::DOTS )
{ {
glStencilFunc( GL_NOTEQUAL, 0, 1 ); glStencilFunc( GL_NOTEQUAL, 0, 1 );
glColor4d( gridColor.r, gridColor.g, gridColor.b, 1.0 ); glColor4d( gridColor.r, gridColor.g, gridColor.b, 1.0 );
@ -942,7 +942,7 @@ void OPENGL_GAL::DrawGrid()
} }
} }
if( gridStyle == GRID_STYLE_DOTS ) if( gridStyle == GRID_STYLE::DOTS )
glDisable( GL_STENCIL_TEST ); glDisable( GL_STENCIL_TEST );
glEnable( GL_DEPTH_TEST ); glEnable( GL_DEPTH_TEST );

View File

@ -32,12 +32,12 @@ class wxString;
namespace KIGFX namespace KIGFX
{ {
/** /**
* GridStyle: Type definition of the grid style * GRID_STYLE: Type definition of the grid style
*/ */
enum GRID_STYLE enum class GRID_STYLE
{ {
GRID_STYLE_LINES, ///< Use lines for the grid LINES, ///< Use lines for the grid
GRID_STYLE_DOTS ///< Use dots for the grid DOTS ///< Use dots for the grid
}; };
enum class OPENGL_ANTIALIASING_MODE : long enum class OPENGL_ANTIALIASING_MODE : long

View File

@ -47,13 +47,13 @@
static void setRadioFromGridStyle( wxRadioBox& aRBox, static void setRadioFromGridStyle( wxRadioBox& aRBox,
KIGFX::GRID_STYLE aStyle ) KIGFX::GRID_STYLE aStyle )
{ {
aRBox.SetSelection( aStyle != KIGFX::GRID_STYLE_DOTS ); aRBox.SetSelection( aStyle != KIGFX::GRID_STYLE::DOTS );
} }
static KIGFX::GRID_STYLE getGridStyleFromRadio( const wxRadioBox& aRBox ) static KIGFX::GRID_STYLE getGridStyleFromRadio( const wxRadioBox& aRBox )
{ {
return aRBox.GetSelection() == 0 ? KIGFX::GRID_STYLE_DOTS : KIGFX::GRID_STYLE_LINES; return aRBox.GetSelection() == 0 ? KIGFX::GRID_STYLE::DOTS : KIGFX::GRID_STYLE::LINES;
} }