From 11438eb0ec7702b31564978c18648ec350b79272 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Fri, 28 May 2021 11:49:34 -0700 Subject: [PATCH] Add standard wire orange and correct color init Initialized COLOR4D takes an EDA_COLOR_T enum but then referenced it as an index to the color table. This uses the enum as comparison against the table-stored enum. Adds standard orange to picker swatches --- common/dialogs/dialog_color_picker.cpp | 8 ++++---- common/gal/color4d.cpp | 25 ++++++++++++++++++++++--- include/gal/color4d.h | 5 +++++ 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/common/dialogs/dialog_color_picker.cpp b/common/dialogs/dialog_color_picker.cpp index ea6d567ce0..2a31857ee6 100644 --- a/common/dialogs/dialog_color_picker.cpp +++ b/common/dialogs/dialog_color_picker.cpp @@ -154,13 +154,13 @@ void DIALOG_COLOR_PICKER::initDefinedColors( CUSTOM_COLORS_LIST* aPredefinedColo // Colors are built from the colorRefs() table (size NBCOLORS). // The look is better when colorRefs() order is displayed in a grid matrix - // of 6 row and 5 columns, first filling a row, and after the next column. + // of 7 row and 5 columns, first filling a row, and after the next column. // But the wxFlexGrid used here must be filled by columns, then next row // the best interval colorRefs() from a matrix row to the next row is 6 // So when have to reorder the index used to explore colorRefs() int grid_col = 0; int grid_row = 0; - int table_row_count = 6; + int table_row_count = 7; wxSize swatchSize = ConvertDialogToPixels( SWATCH_SIZE_LARGE_DU ); wxSize checkerboardSize = ConvertDialogToPixels( CHECKERBOARD_SIZE_DU ); @@ -204,13 +204,13 @@ void DIALOG_COLOR_PICKER::initDefinedColors( CUSTOM_COLORS_LIST* aPredefinedColo for( int jj = 0; jj < NBCOLORS; ++jj, grid_col++ ) { - if( grid_col*table_row_count >= NBCOLORS ) + if( grid_col * table_row_count >= NBCOLORS ) { // the current grid row is filled, and we must fill the next grid row grid_col = 0; grid_row++; } - int ii = grid_row + (grid_col*table_row_count); // The index in colorRefs() + int ii = grid_row + ( grid_col * table_row_count ); // The index in colorRefs() int butt_ID = ID_COLOR_BLACK + ii; COLOR4D buttcolor = COLOR4D( colorRefs()[ii].m_Numcolor ); diff --git a/common/gal/color4d.cpp b/common/gal/color4d.cpp index f673f5eceb..771d1a537c 100644 --- a/common/gal/color4d.cpp +++ b/common/gal/color4d.cpp @@ -44,30 +44,35 @@ const StructColors* colorRefs() { 194, 194, 194, LIGHTGRAY, TS( "Gray 3" ), WHITE }, { 255, 255, 255, WHITE, TS( "White" ), WHITE }, { 194, 255, 255, LIGHTYELLOW, TS( "L.Yellow" ), WHITE }, + { 191, 229, 255, LIGHTERORANGE, TS( "L.Orange" ), WHITE }, { 72, 0, 0, DARKBLUE, TS( "Blue 1" ), BLUE }, { 0, 72, 0, DARKGREEN, TS( "Green 1" ), GREEN }, { 72, 72, 0, DARKCYAN, TS( "Cyan 1" ), CYAN }, { 0, 0, 72, DARKRED, TS( "Red 1" ), RED }, { 72, 0, 72, DARKMAGENTA, TS( "Magenta 1" ), MAGENTA }, { 0, 72, 72, DARKBROWN, TS( "Brown 1" ), BROWN }, + { 0, 77, 128, DARKORANGE, TS( "Orange 1" ), ORANGE }, { 132, 0, 0, BLUE, TS( "Blue 2" ), LIGHTBLUE }, { 0, 132, 0, GREEN, TS( "Green 2" ), LIGHTGREEN }, { 132, 132, 0, CYAN, TS( "Cyan 2" ), LIGHTCYAN }, { 0, 0, 132, RED, TS( "Red 2" ), LIGHTRED }, { 132, 0, 132, MAGENTA, TS( "Magenta 2" ), LIGHTMAGENTA }, { 0, 132, 132, BROWN, TS( "Brown 2" ), YELLOW }, + { 0, 102, 204, ORANGE, TS( "Orange 2" ), LIGHTORANGE }, { 194, 0, 0, LIGHTBLUE, TS( "Blue 3" ), PUREBLUE, }, { 0, 194, 0, LIGHTGREEN, TS( "Green 3" ), PUREGREEN }, { 194, 194, 0, LIGHTCYAN, TS( "Cyan 3" ), PURECYAN }, { 0, 0, 194, LIGHTRED, TS( "Red 3" ), PURERED }, { 194, 0, 194, LIGHTMAGENTA, TS( "Magenta 3" ), PUREMAGENTA }, { 0, 194, 194, YELLOW, TS( "Yellow 3" ), PUREYELLOW }, + { 0, 133, 221, LIGHTORANGE, TS( "Orange 3" ), PUREORANGE }, { 255, 0, 0, PUREBLUE, TS( "Blue 4" ), WHITE }, { 0, 255, 0, PUREGREEN, TS( "Green 4" ), WHITE }, { 255, 255, 0, PURECYAN, TS( "Cyan 4" ), WHITE }, { 0, 0, 255, PURERED, TS( "Red 4" ), WHITE }, { 255, 0, 255, PUREMAGENTA, TS( "Magenta 4" ), WHITE }, { 0, 255, 255, PUREYELLOW, TS( "Yellow 4" ), WHITE }, + { 0, 153, 255, PUREORANGE, TS( "Orange 4" ), WHITE }, }; return s_ColorRefs; } @@ -81,9 +86,23 @@ COLOR4D::COLOR4D( EDA_COLOR_T aColor ) return; } - r = colorRefs()[aColor].m_Red / 255.0; - g = colorRefs()[aColor].m_Green / 255.0; - b = colorRefs()[aColor].m_Blue / 255.0; + int candidate = 0; + + for( ; candidate < NBCOLORS; ++candidate ) + { + if( colorRefs()[candidate].m_Numcolor == aColor ) + break; + } + + if( candidate >= NBCOLORS ) + { + *this = COLOR4D::UNSPECIFIED; + return; + } + + r = colorRefs()[candidate].m_Red / 255.0; + g = colorRefs()[candidate].m_Green / 255.0; + b = colorRefs()[candidate].m_Blue / 255.0; a = 1.0; } diff --git a/include/gal/color4d.h b/include/gal/color4d.h index 47da07adff..1b5a50d581 100644 --- a/include/gal/color4d.h +++ b/include/gal/color4d.h @@ -71,6 +71,11 @@ enum EDA_COLOR_T PURERED, PUREMAGENTA, PUREYELLOW, + LIGHTERORANGE, + DARKORANGE, + ORANGE, + LIGHTORANGE, + PUREORANGE, NBCOLORS, ///< Number of colors HIGHLIGHT_FLAG = ( 1<<19 ), MASKCOLOR = 31 ///< mask for color index into colorRefs()[]