diff --git a/common/draw_panel_gal.cpp b/common/draw_panel_gal.cpp index 7ba5d854b5..941effbc30 100644 --- a/common/draw_panel_gal.cpp +++ b/common/draw_panel_gal.cpp @@ -184,7 +184,8 @@ void EDA_DRAW_PANEL_GAL::onPaint( wxPaintEvent& WXUNUSED( aEvent ) ) m_gal->BeginDrawing(); m_gal->SetClearColor( settings->GetBackgroundColor() ); - m_gal->SetCursorColor( settings->GetLayerColor( LAYER_CURSOR ) ); + m_gal->SetGridColor( settings->GetGridColor() ); + m_gal->SetCursorColor( settings->GetCursorColor() ); // TODO: find why ClearScreen() must be called here in opengl mode // and only if m_view->IsDirty() in Cairo mode to avoid distaly artifacts diff --git a/common/legacy_gal/eda_draw_frame.cpp b/common/legacy_gal/eda_draw_frame.cpp index 093cc0b5a5..0df3d7107f 100644 --- a/common/legacy_gal/eda_draw_frame.cpp +++ b/common/legacy_gal/eda_draw_frame.cpp @@ -593,17 +593,9 @@ void EDA_DRAW_FRAME::DisplayUnitsMsg() switch( m_UserUnits ) { - case INCHES: - msg = _( "Inches" ); - break; - - case MILLIMETRES: - msg = _( "mm" ); - break; - - default: - msg = _( "Units" ); - break; + case INCHES: msg = _( "Inches" ); break; + case MILLIMETRES: msg = _( "mm" ); break; + default: msg = _( "Units" ); break; } SetStatusText( msg, 4 ); @@ -776,7 +768,7 @@ const wxString EDA_DRAW_FRAME::GetZoomLevelIndicator() const } else if( BASE_SCREEN* screen = GetScreen() ) { - level = m_zoomLevelCoeff / (double) screen->GetZoom(); + level = m_zoomLevelCoeff / screen->GetZoom(); } // returns a human readable value which can be displayed as zoom @@ -807,12 +799,6 @@ void EDA_DRAW_FRAME::LoadSettings( wxConfigBase* aCfg ) if( aCfg->Read( baseCfgName + ShowGridEntryKeyword, &btmp ) ) SetGridVisibility( btmp ); - // Read grid color: - COLOR4D wtmp = COLOR4D::UNSPECIFIED; - - if( wtmp.SetFromWxString( aCfg->Read( baseCfgName + GridColorEntryKeyword, wxT( "NONE" ) ) ) ) - SetGridColor( wtmp ); - aCfg->Read( baseCfgName + LastGridSizeIdKeyword, &m_LastGridSizeId, 0L ); // m_LastGridSizeId is an offset, expected to be >= 0 @@ -841,8 +827,6 @@ void EDA_DRAW_FRAME::SaveSettings( wxConfigBase* aCfg ) aCfg->Write( baseCfgName + UserUnitsEntryKeyword, (int) m_UserUnits ); aCfg->Write( baseCfgName + ShowGridEntryKeyword, IsGridVisible() ); - aCfg->Write( baseCfgName + GridColorEntryKeyword, - GetGridColor().ToColour().GetAsString( wxC2S_CSS_SYNTAX ) ); aCfg->Write( baseCfgName + LastGridSizeIdKeyword, ( long ) m_LastGridSizeId ); aCfg->Write( baseCfgName + FirstRunShownKeyword, m_firstRunDialogSetting ); @@ -1020,11 +1004,6 @@ void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable ) view->SetCenter( VECTOR2D( m_canvas->GetScreenCenterLogicalPosition() ) ); } - // fixme-gal - gal->SetGridVisibility( true ); - gal->SetGridColor( COLOR4D(0.0,0.0,0.0,1.0)); - - // Transfer EDA_DRAW_PANEL settings GetGalCanvas()->GetViewControls()->EnableCursorWarping( !m_canvas->GetEnableZoomNoCenter() ); GetGalCanvas()->GetViewControls()->EnableMousewheelPan( m_canvas->GetEnableMousewheelPan() ); @@ -1033,7 +1012,6 @@ void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable ) GetGalCanvas()->SetEvtHandlerEnabled( aEnable ); - // Reset current tool on switch(); SetNoToolSelected(); diff --git a/eeschema/eeschema.cpp b/eeschema/eeschema.cpp index 2d9f06677c..185f33e654 100644 --- a/eeschema/eeschema.cpp +++ b/eeschema/eeschema.cpp @@ -230,6 +230,7 @@ static PARAM_CFG_ARRAY& cfg_params() CLR( "Color4DErcEEx", LAYER_ERC_ERR, COLOR4D( RED ).WithAlpha(0.8 ) ) CLR( "Color4DGridEx", LAYER_SCHEMATIC_GRID, COLOR4D( DARKGRAY ) ) CLR( "Color4DBgCanvasEx", LAYER_SCHEMATIC_BACKGROUND, COLOR4D( WHITE ) ) + CLR( "Color4DCursorEx", LAYER_SCHEMATIC_CURSOR, COLOR4D( BLACK ) ) CLR( "Color4DBrightenedEx", LAYER_BRIGHTENED, COLOR4D( PUREMAGENTA ) ) CLR( "Color4DHiddenEx", LAYER_HIDDEN, COLOR4D( LIGHTGRAY ) ) CLR( "Color4DWorksheetEx", LAYER_WORKSHEET, COLOR4D( RED ) ) @@ -253,6 +254,7 @@ bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits ) SetLayerColor( COLOR4D( DARKGRAY ), ii ); SetLayerColor( COLOR4D::WHITE, LAYER_SCHEMATIC_BACKGROUND ); + SetLayerColor( COLOR4D::BLACK, LAYER_SCHEMATIC_CURSOR ); // Must be called before creating the main frame in order to // display the real hotkeys in menus or tool tips diff --git a/eeschema/eeschema_config.cpp b/eeschema/eeschema_config.cpp index 420a6ff317..b40013260e 100644 --- a/eeschema/eeschema_config.cpp +++ b/eeschema/eeschema_config.cpp @@ -391,10 +391,6 @@ void SCH_EDIT_FRAME::LoadSettings( wxConfigBase* aCfg ) ReadHotkeyConfig( SCH_EDIT_FRAME_NAME, g_Schematic_Hokeys_Descr ); wxConfigLoadSetups( aCfg, GetConfigurationSettings() ); - SetGridColor( GetLayerColor( LAYER_SCHEMATIC_GRID ) ); - GetGalCanvas()->GetView()->GetGAL()->SetGridColor( GetGridColor() ); - SetDrawBgColor( GetLayerColor( LAYER_SCHEMATIC_BACKGROUND ) ); - SetDefaultBusThickness( (int) aCfg->Read( DefaultBusWidthEntry, DEFAULTBUSTHICKNESS ) ); SetDefaultLineThickness( (int) aCfg->Read( DefaultDrawLineWidthEntry, DEFAULTDRAWLINETHICKNESS ) ); SCH_JUNCTION::SetSymbolSize( (int) aCfg->Read( DefaultJctSizeEntry, SCH_JUNCTION::GetSymbolSize() ) ); @@ -521,9 +517,6 @@ void LIB_EDIT_FRAME::LoadSettings( wxConfigBase* aCfg ) ReadHotkeyConfig( LIB_EDIT_FRAME_NAME, g_Libedit_Hokeys_Descr ); - SetGridColor( GetLayerColor( LAYER_SCHEMATIC_GRID ) ); - SetDrawBgColor( GetLayerColor( LAYER_SCHEMATIC_BACKGROUND ) ); - SetDefaultLineThickness( (int) aCfg->Read( DefaultDrawLineWidthEntry, DEFAULTDRAWLINETHICKNESS ) ); SetDefaultPinLength( (int) aCfg->Read( DefaultPinLengthEntry, DEFAULTPINLENGTH ) ); m_textPinNumDefaultSize = (int) aCfg->Read( defaultPinNumSizeEntry, DEFAULTPINNUMSIZE ); diff --git a/eeschema/sch_base_frame.cpp b/eeschema/sch_base_frame.cpp index 86a63fbf43..589e0a60c3 100644 --- a/eeschema/sch_base_frame.cpp +++ b/eeschema/sch_base_frame.cpp @@ -163,23 +163,6 @@ void SCH_BASE_FRAME::OnOpenLibraryViewer( wxCommandEvent& event ) } -// Virtual from EDA_DRAW_FRAME -COLOR4D SCH_BASE_FRAME::GetDrawBgColor() const -{ - return GetLayerColor( LAYER_SCHEMATIC_BACKGROUND ); -} - - -void SCH_BASE_FRAME::SetDrawBgColor( COLOR4D aColor ) -{ - m_drawBgColor= aColor; - SetLayerColor( aColor, LAYER_SCHEMATIC_BACKGROUND ); - - if( m_auimgr.GetManagedWindow() ) - m_auimgr.Update(); -} - - SCH_SCREEN* SCH_BASE_FRAME::GetScreen() const { return (SCH_SCREEN*) EDA_DRAW_FRAME::GetScreen(); diff --git a/eeschema/sch_base_frame.h b/eeschema/sch_base_frame.h index ceba7b5efc..87c024af3f 100644 --- a/eeschema/sch_base_frame.h +++ b/eeschema/sch_base_frame.h @@ -170,11 +170,6 @@ public: void OnGridSettings( wxCommandEvent& aEvent ); - // Virtual from EDA_DRAW_FRAME - // the background color of the draw canvas: - COLOR4D GetDrawBgColor() const override; - void SetDrawBgColor( COLOR4D aColor) override; - const TITLE_BLOCK& GetTitleBlock() const override; void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) override; @@ -282,11 +277,10 @@ public: * @param aConvert preselected deMorgan conversion * @return the selected component */ - COMPONENT_SELECTION SelectComponentFromLibBrowser( - wxTopLevelWindow* aParent, - const SCHLIB_FILTER* aFilter, - const LIB_ID& aPreselectedLibid, - int aUnit, int aConvert ); + COMPONENT_SELECTION SelectComponentFromLibBrowser( wxTopLevelWindow* aParent, + const SCHLIB_FILTER* aFilter, + const LIB_ID& aPreselectedLibid, + int aUnit, int aConvert ); virtual void Zoom_Automatique( bool aWarpPointer ) override; diff --git a/eeschema/sch_draw_panel.cpp b/eeschema/sch_draw_panel.cpp index 69b8a4a656..cd35047e6d 100644 --- a/eeschema/sch_draw_panel.cpp +++ b/eeschema/sch_draw_panel.cpp @@ -135,9 +135,6 @@ SCH_DRAW_PANEL::SCH_DRAW_PANEL( wxWindow* aParentWindow, wxWindowID aWindowId, m_doubleClickInterval = 250; - m_gal->SetGridColor( GetLayerColor( LAYER_SCHEMATIC_GRID ) ); - m_gal->SetCursorColor( COLOR4D(0.0, 0.0, 0.0, 1.0) ); - m_viewControls->SetSnapping( true ); SetEvtHandlerEnabled( true ); @@ -201,7 +198,6 @@ bool SCH_DRAW_PANEL::SwitchBackend( GAL_TYPE aGalType ) setDefaultLayerDeps(); m_gal->SetWorldUnitLength( IU_2_GAL_WORLD_UNIT ); m_gal->SetGridSize( grid_size ); - m_gal->SetGridColor( GetLayerColor( LAYER_SCHEMATIC_GRID ) ); return rv; } diff --git a/eeschema/sch_painter.cpp b/eeschema/sch_painter.cpp index c1ba3cf4b8..c36765a7d3 100644 --- a/eeschema/sch_painter.cpp +++ b/eeschema/sch_painter.cpp @@ -949,7 +949,8 @@ void SCH_PAINTER::draw( SCH_TEXT *aText, int aLayer ) switch( aText->Type() ) { - case SCH_HIERARCHICAL_LABEL_T: color = m_schSettings.GetLayerColor( LAYER_SHEETLABEL ); break; + case SCH_SHEET_PIN_T: color = m_schSettings.GetLayerColor( LAYER_SHEETLABEL ); break; + case SCH_HIERARCHICAL_LABEL_T: color = m_schSettings.GetLayerColor( LAYER_HIERLABEL ); break; case SCH_GLOBAL_LABEL_T: color = m_schSettings.GetLayerColor( LAYER_GLOBLABEL ); break; case SCH_LABEL_T: color = m_schSettings.GetLayerColor( LAYER_LOCLABEL ); break; default: color = m_schSettings.GetLayerColor( LAYER_NOTES ); break; diff --git a/eeschema/sch_painter.h b/eeschema/sch_painter.h index f6bc42ec9f..4e77e8cb0c 100644 --- a/eeschema/sch_painter.h +++ b/eeschema/sch_painter.h @@ -83,6 +83,12 @@ public: return luma < 0.5; } + const COLOR4D& GetBackgroundColor() override { return m_layerColors[ LAYER_SCHEMATIC_BACKGROUND ]; } + + const COLOR4D& GetGridColor() override { return m_layerColors[ LAYER_SCHEMATIC_GRID ]; } + + const COLOR4D& GetCursorColor() override { return m_layerColors[ LAYER_SCHEMATIC_CURSOR ]; } + int m_ShowUnit; // Show all units if 0 int m_ShowConvert; // Show all conversions if 0 diff --git a/eeschema/sch_preview_panel.cpp b/eeschema/sch_preview_panel.cpp index 0d9b46b796..f18016018a 100644 --- a/eeschema/sch_preview_panel.cpp +++ b/eeschema/sch_preview_panel.cpp @@ -69,8 +69,8 @@ SCH_PREVIEW_PANEL::SCH_PREVIEW_PANEL( wxWindow* aParentWindow, wxWindowID aWindo // on updated viewport data. m_viewControls = new KIGFX::WX_VIEW_CONTROLS( m_view, this ); - m_gal->SetGridColor( COLOR4D(0.0, 0.0, 0.0, 1.0) ); - m_gal->SetCursorColor( COLOR4D(0.0, 0.0, 0.0, 1.0) ); + m_gal->SetGridColor( GetLayerColor( LAYER_SCHEMATIC_GRID ) ); + m_gal->SetCursorColor( GetLayerColor( LAYER_SCHEMATIC_CURSOR ) ); m_gal->SetGridSize( VECTOR2D( 50.0, 50.0 ) ); m_viewControls->SetSnapping( true ); diff --git a/eeschema/viewlib_frame.cpp b/eeschema/viewlib_frame.cpp index 4c3d357719..4496393aa6 100644 --- a/eeschema/viewlib_frame.cpp +++ b/eeschema/viewlib_frame.cpp @@ -670,19 +670,11 @@ void LIB_VIEW_FRAME::ExportToSchematicLibraryPart( wxCommandEvent& event ) #define CMPLIST_WIDTH_KEY "ViewCmplistWidth" #define CMPVIEW_SHOW_PINELECTRICALTYPE_KEY "ViewCmpShowPinElectricalType" -// Currently, the library viewer has no dialog to change the background color -// of the draw canvas. Therefore the background color is here just -// in case of this option is added to some library viewer config dialog -#define LIBVIEW_BGCOLOR "LibviewBgColor" - void LIB_VIEW_FRAME::LoadSettings( wxConfigBase* aCfg ) { EDA_DRAW_FRAME::LoadSettings( aCfg ); - SetGridColor( GetLayerColor( LAYER_SCHEMATIC_GRID ) ); - SetDrawBgColor( GetLayerColor( LAYER_SCHEMATIC_BACKGROUND ) ); - aCfg->Read( LIBLIST_WIDTH_KEY, &m_libListWidth, 150 ); aCfg->Read( CMPLIST_WIDTH_KEY, &m_cmpListWidth, 150 ); aCfg->Read( CMPLIST_WIDTH_KEY, &m_cmpListWidth, 150 ); diff --git a/eeschema/widgets/widget_eeschema_color_config.cpp b/eeschema/widgets/widget_eeschema_color_config.cpp index af1283a098..5a3c85eeea 100644 --- a/eeschema/widgets/widget_eeschema_color_config.cpp +++ b/eeschema/widgets/widget_eeschema_color_config.cpp @@ -90,9 +90,11 @@ static COLORBUTTON sheetColorButtons[] = { static COLORBUTTON miscColorButtons[] = { { _( "ERC warning" ), LAYER_ERC_WARN }, { _( "ERC error" ), LAYER_ERC_ERR }, + { _( "Cursor" ), LAYER_SCHEMATIC_CURSOR }, { _( "Grid" ), LAYER_SCHEMATIC_GRID }, { _( "Brightened" ), LAYER_BRIGHTENED }, { _( "Hidden items" ), LAYER_HIDDEN }, + { _( "Background" ), LAYER_SCHEMATIC_BACKGROUND }, { wxT( "" ), -1 } // Sentinel marking end of list. }; @@ -186,42 +188,7 @@ void WIDGET_EESCHEMA_COLOR_CONFIG::CreateControls() groups++; } - COLOR4D bgColor = GetDrawFrame()->GetDrawBgColor(); - wxMemoryDC iconDC; - wxBitmap bitmap( m_butt_size_pix ); - - iconDC.SelectObject( bitmap ); - iconDC.SetPen( *wxBLACK_PEN ); - - wxBrush brush; - brush.SetColour( bgColor.ToColour() ); - brush.SetStyle( wxBRUSHSTYLE_SOLID ); - iconDC.SetBrush( brush ); - iconDC.DrawRectangle( 0, 0, m_butt_size_pix.x, m_butt_size_pix.y ); - - buttonId++; - wxBitmapButton* selBgColorBtn = new wxBitmapButton( - this, buttonId, bitmap, wxDefaultPosition, - m_butt_size_pix + m_butt_border_pix + wxSize( 1, 1 ) ); - selBgColorBtn->SetClientData( (void*) &bgColorButton ); - - Connect( 1800, buttonId, wxEVT_COMMAND_BUTTON_CLICKED, - wxCommandEventHandler( WIDGET_EESCHEMA_COLOR_CONFIG::SetColor ) ); - - wxStaticText* bgColorLabel = new wxStaticText( this, wxID_ANY, _( "Background Color" ) ); - wxFont font( bgColorLabel->GetFont() ); - font.SetWeight( wxFONTWEIGHT_BOLD ); - bgColorLabel->SetFont( font ); - - if( columnBoxSizer ) - { - // Add a spacer to improve appearance. - columnBoxSizer->AddSpacer( 5 ); - columnBoxSizer->Add( bgColorLabel, 1, wxALL, 5 ); - columnBoxSizer->Add( selBgColorBtn, 1, wxRIGHT | wxBOTTOM, 5 ); - } - - currentColors[ LAYER_SCHEMATIC_BACKGROUND ] = bgColor; + Connect( 1800, buttonId, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WIDGET_EESCHEMA_COLOR_CONFIG::SetColor ) ); // Dialog now needs to be resized, but the associated command is found elsewhere. } @@ -291,17 +258,9 @@ bool WIDGET_EESCHEMA_COLOR_CONFIG::TransferDataFromControl() } } - // Update color of background - GetDrawFrame()->SetDrawBgColor( bgcolor ); - currentColors[ LAYER_SCHEMATIC_BACKGROUND ] = bgcolor; - for( SCH_LAYER_ID clyr = SCH_LAYER_ID_START; clyr < SCH_LAYER_ID_END; ++clyr ) SetLayerColor( currentColors[ clyr ], clyr ); - m_drawFrame->SetGridColor( GetLayerColor( LAYER_SCHEMATIC_GRID ) ); - m_drawFrame->GetGalCanvas()->GetView()->GetGAL()->SetGridColor( m_drawFrame->GetGridColor() ); - m_drawFrame->GetGalCanvas()->Refresh(); - return true; } diff --git a/gerbview/gerbview_painter.cpp b/gerbview/gerbview_painter.cpp index d3ce818a0f..f5e15ae8a8 100644 --- a/gerbview/gerbview_painter.cpp +++ b/gerbview/gerbview_painter.cpp @@ -72,8 +72,6 @@ void GERBVIEW_RENDER_SETTINGS::ImportLegacyColors( const COLORS_DESIGN_SETTINGS* for( int i = GAL_LAYER_ID_START; i < GAL_LAYER_ID_END; i++ ) m_layerColors[i] = aSettings->GetLayerColor( i ); - SetBackgroundColor( aSettings->GetItemColor( LAYER_PCB_BACKGROUND ) ); - update(); } diff --git a/gerbview/gerbview_painter.h b/gerbview/gerbview_painter.h index 167d8c0f8d..2f07353c46 100644 --- a/gerbview/gerbview_painter.h +++ b/gerbview/gerbview_painter.h @@ -87,6 +87,12 @@ public: update(); // recompute other shades of the color } + const COLOR4D& GetBackgroundColor() override { return m_layerColors[ LAYER_PCB_BACKGROUND ]; } + + const COLOR4D& GetGridColor() override { return m_layerColors[ LAYER_GRID ]; } + + const COLOR4D& GetCursorColor() override { return m_layerColors[ LAYER_CURSOR ]; } + inline bool IsSpotFill() const { return m_spotFill; diff --git a/include/layers_id_colors_and_visibility.h b/include/layers_id_colors_and_visibility.h index 0fdc5b03bc..22733a4719 100644 --- a/include/layers_id_colors_and_visibility.h +++ b/include/layers_id_colors_and_visibility.h @@ -254,6 +254,7 @@ enum SCH_LAYER_ID: int LAYER_DEVICE_BACKGROUND, LAYER_SCHEMATIC_GRID, LAYER_SCHEMATIC_BACKGROUND, + LAYER_SCHEMATIC_CURSOR, LAYER_BRIGHTENED, LAYER_HIDDEN, diff --git a/include/painter.h b/include/painter.h index 1025876494..3206d1a8c5 100644 --- a/include/painter.h +++ b/include/painter.h @@ -191,22 +191,20 @@ public: /** * Function GetBackgroundColor * Returns current background color settings. - * @return Background color. */ - inline const COLOR4D& GetBackgroundColor() const - { - return m_backgroundColor; - } + virtual const COLOR4D& GetBackgroundColor() = 0; /** - * Function SetBackgroundColor - * Sets new color for background. - * @param aColor is the new background color. + * Function GetGridColor + * Returns current grid color settings. */ - inline void SetBackgroundColor( const COLOR4D& aColor ) - { - m_backgroundColor = aColor; - } + virtual const COLOR4D& GetGridColor() = 0; + + /** + * Function GetCursorColor + * Returns current cursor color settings. + */ + virtual const COLOR4D& GetCursorColor() = 0; /** * Function GetLayerColor diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index 74b0163c14..b8dafb8c91 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -118,8 +118,6 @@ void PCB_RENDER_SETTINGS::ImportLegacyColors( const COLORS_DESIGN_SETTINGS* aSet m_layerColors[GetNetnameLayer( layer )] = lightLabel; } - SetBackgroundColor ( aSettings->GetItemColor( LAYER_PCB_BACKGROUND ) ); - update(); } diff --git a/pcbnew/pcb_painter.h b/pcbnew/pcb_painter.h index 48ad17ebaa..f9835fc82d 100644 --- a/pcbnew/pcb_painter.h +++ b/pcbnew/pcb_painter.h @@ -143,6 +143,12 @@ public: return luma < 0.5; } + const COLOR4D& GetBackgroundColor() override { return m_layerColors[ LAYER_PCB_BACKGROUND ]; } + + const COLOR4D& GetGridColor() override { return m_layerColors[ LAYER_GRID ]; } + + const COLOR4D& GetCursorColor() override { return m_layerColors[ LAYER_CURSOR ]; } + protected: ///> Flag determining if items on a given layer should be drawn as an outline or a filled item bool m_sketchMode[GAL_LAYER_ID_END];