From 23194dbe54c639a2dd841e522de5a00a2f77b008 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 5 Nov 2021 23:35:10 +0000 Subject: [PATCH] User-settable high-contrast dimming factor. ADDED user-settable high-contrast dimming factor. Fixes https://gitlab.com/kicad/code/kicad/issues/6922 --- common/dialogs/panel_common_settings.cpp | 7 + common/dialogs/panel_common_settings_base.cpp | 24 +- common/dialogs/panel_common_settings_base.fbp | 216 +++++++++++++++++- common/dialogs/panel_common_settings_base.h | 8 +- common/render_settings.cpp | 2 +- common/settings/app_settings.cpp | 11 +- common/settings/common_settings.cpp | 3 + include/render_settings.h | 1 - include/settings/app_settings.h | 1 - include/settings/common_settings.h | 1 + pcbnew/pcb_base_frame.cpp | 1 - pcbnew/pcb_painter.cpp | 4 + 12 files changed, 256 insertions(+), 23 deletions(-) diff --git a/common/dialogs/panel_common_settings.cpp b/common/dialogs/panel_common_settings.cpp index 30f532ea53..470625bcb2 100644 --- a/common/dialogs/panel_common_settings.cpp +++ b/common/dialogs/panel_common_settings.cpp @@ -279,6 +279,10 @@ bool PANEL_COMMON_SETTINGS::TransferDataFromWindow() commonSettings->m_Appearance.use_icons_in_menus = m_checkBoxIconsInMenus->GetValue(); commonSettings->m_Appearance.apply_icon_scale_to_fonts = m_scaleFonts->GetValue(); + double dimmingPercent = 80; + m_highContrastCtrl->GetValue().ToDouble( &dimmingPercent ); + commonSettings->m_Appearance.hicontrast_dimming_factor = dimmingPercent / 100.0f; + commonSettings->m_Input.immediate_actions = !m_NonImmediateActions->GetValue(); commonSettings->m_Input.warp_mouse_on_move = m_warpMouseOnMove->GetValue(); @@ -367,6 +371,9 @@ void PANEL_COMMON_SETTINGS::applySettingsToPanel( COMMON_SETTINGS& aSettings ) m_checkBoxIconsInMenus->SetValue( aSettings.m_Appearance.use_icons_in_menus ); m_scaleFonts->SetValue( aSettings.m_Appearance.apply_icon_scale_to_fonts ); + double dimmingPercent = aSettings.m_Appearance.hicontrast_dimming_factor * 100.0f; + m_highContrastCtrl->SetValue( wxString::Format( "%.0f", dimmingPercent ) ); + m_warpMouseOnMove->SetValue( aSettings.m_Input.warp_mouse_on_move ); m_NonImmediateActions->SetValue( !aSettings.m_Input.immediate_actions ); diff --git a/common/dialogs/panel_common_settings_base.cpp b/common/dialogs/panel_common_settings_base.cpp index 2790bd3d8f..9e7af0a304 100644 --- a/common/dialogs/panel_common_settings_base.cpp +++ b/common/dialogs/panel_common_settings_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 3.10.0-4761b0c5) +// C++ code generated with wxFormBuilder (version Oct 26 2018) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -163,6 +163,26 @@ PANEL_COMMON_SETTINGS_BASE::PANEL_COMMON_SETTINGS_BASE( wxWindow* parent, wxWind m_sbUserInterface->Add( m_fontScalingHelp, 0, wxLEFT, 8 ); + m_sbUserInterface->Add( 0, 0, 1, wxEXPAND, 5 ); + + wxBoxSizer* bSizerHighContrast; + bSizerHighContrast = new wxBoxSizer( wxHORIZONTAL ); + + m_highContrastLabel = new wxStaticText( m_sbUserInterface->GetStaticBox(), wxID_ANY, _("High-contrast mode dimming factor:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_highContrastLabel->Wrap( -1 ); + bSizerHighContrast->Add( m_highContrastLabel, 1, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); + + m_highContrastCtrl = new wxTextCtrl( m_sbUserInterface->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + bSizerHighContrast->Add( m_highContrastCtrl, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + m_highContrastUnits = new wxStaticText( m_sbUserInterface->GetStaticBox(), wxID_ANY, _("%"), wxDefaultPosition, wxDefaultSize, 0 ); + m_highContrastUnits->Wrap( -1 ); + bSizerHighContrast->Add( m_highContrastUnits, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); + + + m_sbUserInterface->Add( bSizerHighContrast, 1, wxEXPAND, 5 ); + + bLeftSizer->Add( m_sbUserInterface, 1, wxEXPAND|wxALL, 5 ); @@ -317,7 +337,7 @@ PANEL_COMMON_SETTINGS_BASE::PANEL_COMMON_SETTINGS_BASE( wxWindow* parent, wxWind rightSizer->Add( sbSizer41, 1, wxALL|wxEXPAND, 5 ); - bPanelSizer->Add( rightSizer, 0, wxALL|wxEXPAND, 5 ); + bPanelSizer->Add( rightSizer, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); this->SetSizer( bPanelSizer ); diff --git a/common/dialogs/panel_common_settings_base.fbp b/common/dialogs/panel_common_settings_base.fbp index f8fe78e651..c4b81192f1 100644 --- a/common/dialogs/panel_common_settings_base.fbp +++ b/common/dialogs/panel_common_settings_base.fbp @@ -1,6 +1,6 @@ - + C++ @@ -14,7 +14,6 @@ panel_common_settings_base 1000 none - 1 PanelCommonSettings @@ -26,7 +25,6 @@ 1 1 UI - 0 1 0 @@ -48,7 +46,6 @@ -1,-1 RESETTABLE_PANEL; widgets/resettable_panel.h; Not forward_declare - 0 wxTAB_TRAVERSAL @@ -518,7 +515,6 @@ - 0 @@ -817,7 +813,6 @@ - 0 @@ -1578,13 +1573,220 @@ -1 + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + + + 5 + wxEXPAND + 1 + + + bSizerHighContrast + wxHORIZONTAL + none + + 5 + wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + High-contrast mode dimming factor: + 0 + + 0 + + + 0 + + 1 + m_highContrastLabel + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + + 0 + + 1 + m_highContrastCtrl + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + % + 0 + + 0 + + + 0 + + 1 + m_highContrastUnits + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 - wxALL|wxEXPAND + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT 0 diff --git a/common/dialogs/panel_common_settings_base.h b/common/dialogs/panel_common_settings_base.h index 467d44abf3..a7a8ebc509 100644 --- a/common/dialogs/panel_common_settings_base.h +++ b/common/dialogs/panel_common_settings_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 3.10.0-4761b0c5) +// C++ code generated with wxFormBuilder (version Oct 26 2018) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -63,6 +63,9 @@ class PANEL_COMMON_SETTINGS_BASE : public RESETTABLE_PANEL wxCheckBox* m_canvasScaleAuto; wxCheckBox* m_scaleFonts; wxStaticText* m_fontScalingHelp; + wxStaticText* m_highContrastLabel; + wxTextCtrl* m_highContrastCtrl; + wxStaticText* m_highContrastUnits; wxCheckBox* m_warpMouseOnMove; wxCheckBox* m_NonImmediateActions; wxCheckBox* m_cbRememberOpenFiles; @@ -86,7 +89,7 @@ class PANEL_COMMON_SETTINGS_BASE : public RESETTABLE_PANEL wxSpinCtrl* m_backupLimitTotalSize; wxStaticText* m_staticText17; - // Virtual event handlers, override them in your derived class + // Virtual event handlers, overide them in your derived class virtual void OnTextEditorClick( wxCommandEvent& event ) { event.Skip(); } virtual void onUpdateUIPdfPath( wxUpdateUIEvent& event ) { event.Skip(); } virtual void OnPDFViewerClick( wxCommandEvent& event ) { event.Skip(); } @@ -96,7 +99,6 @@ class PANEL_COMMON_SETTINGS_BASE : public RESETTABLE_PANEL public: PANEL_COMMON_SETTINGS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString ); - ~PANEL_COMMON_SETTINGS_BASE(); }; diff --git a/common/render_settings.cpp b/common/render_settings.cpp index 15430f74b3..ad4c876749 100644 --- a/common/render_settings.cpp +++ b/common/render_settings.cpp @@ -36,7 +36,7 @@ RENDER_SETTINGS::RENDER_SETTINGS() : m_selectFactor = 0.5f; m_highlightEnabled = false; m_hiContrastEnabled = false; - m_hiContrastFactor = 0.2f; //TODO: Make this user-configurable + m_hiContrastFactor = 0.2f; m_outlineWidth = 1; m_drawingSheetLineWidth = 100000; m_defaultPenWidth = 0; diff --git a/common/settings/app_settings.cpp b/common/settings/app_settings.cpp index 968b140b9b..94394cfe8c 100644 --- a/common/settings/app_settings.cpp +++ b/common/settings/app_settings.cpp @@ -66,14 +66,11 @@ APP_SETTINGS_BASE::APP_SETTINGS_BASE( const std::string& aFilename, int aSchemaV m_params.emplace_back( new PARAM( "graphics.canvas_type", &m_Graphics.canvas_type, EDA_DRAW_PANEL_GAL::GAL_FALLBACK ) ); - m_params.emplace_back( new PARAM( - "graphics.highlight_factor", &m_Graphics.highlight_factor, 0.5f, 0.0, 1.0f ) ); + m_params.emplace_back( new PARAM( "graphics.highlight_factor", + &m_Graphics.highlight_factor, 0.5f, 0.0, 1.0f ) ); - m_params.emplace_back( new PARAM( - "graphics.select_factor", &m_Graphics.select_factor, 0.75f, 0.0, 1.0f ) ); - - m_params.emplace_back( new PARAM( - "graphics.high_contrast_factor", &m_Graphics.high_contrast_factor, 0.35f, 0.0, 1.0f ) ); + m_params.emplace_back( new PARAM( "graphics.select_factor", + &m_Graphics.select_factor, 0.75f, 0.0, 1.0f ) ); m_params.emplace_back( new PARAM( "color_picker.default_tab", &m_ColorPicker.default_tab, 0 ) ); diff --git a/common/settings/common_settings.cpp b/common/settings/common_settings.cpp index 2df21f51f8..2454f334c0 100644 --- a/common/settings/common_settings.cpp +++ b/common/settings/common_settings.cpp @@ -103,6 +103,9 @@ COMMON_SETTINGS::COMMON_SETTINGS() : m_Appearance.apply_icon_scale_to_fonts = false; #endif + m_params.emplace_back( new PARAM( "appearance.hicontrast_dimming_factor", + &m_Appearance.hicontrast_dimming_factor, 0.8f ) ); + m_params.emplace_back( new PARAM( "auto_backup.enabled", &m_Backup.enabled, true ) ); m_params.emplace_back( new PARAM( "auto_backup.backup_on_autosave", diff --git a/include/render_settings.h b/include/render_settings.h index 2a405f445c..f92a156a0b 100644 --- a/include/render_settings.h +++ b/include/render_settings.h @@ -277,7 +277,6 @@ public: void SetHighlightFactor( float aFactor ) { m_highlightFactor = aFactor; } void SetSelectFactor( float aFactor ) { m_selectFactor = aFactor; } - void SetHighContrastFactor( float aFactor ) { m_hiContrastFactor = aFactor; } // TODO: these can go away once the drawing sheet is moved to Cairo-based printing wxDC* GetPrintDC() const { return m_printDC; } diff --git a/include/settings/app_settings.h b/include/settings/app_settings.h index 96baafe213..f5eee63526 100644 --- a/include/settings/app_settings.h +++ b/include/settings/app_settings.h @@ -115,7 +115,6 @@ public: int canvas_type; float highlight_factor; ///< How much to brighten highlighted objects by float select_factor; ///< How much to brighten selected objects by - float high_contrast_factor; ///< How much to darken inactive layers by }; struct COLOR_PICKER diff --git a/include/settings/common_settings.h b/include/settings/common_settings.h index 491461df91..7559a2fc8d 100644 --- a/include/settings/common_settings.h +++ b/include/settings/common_settings.h @@ -54,6 +54,7 @@ public: ICON_THEME icon_theme; bool use_icons_in_menus; bool apply_icon_scale_to_fonts; + double hicontrast_dimming_factor; }; struct AUTO_BACKUP diff --git a/pcbnew/pcb_base_frame.cpp b/pcbnew/pcb_base_frame.cpp index 12c026a95f..906634ba31 100644 --- a/pcbnew/pcb_base_frame.cpp +++ b/pcbnew/pcb_base_frame.cpp @@ -789,7 +789,6 @@ void PCB_BASE_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg ) { rs->SetHighlightFactor( aCfg->m_Graphics.highlight_factor ); rs->SetSelectFactor( aCfg->m_Graphics.select_factor ); - rs->SetHighContrastFactor( aCfg->m_Graphics.high_contrast_factor ); } } } diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index becb8a33cc..a94345dd30 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -46,6 +46,7 @@ #include #include #include +#include #include #include @@ -57,6 +58,7 @@ #include #include #include +#include #include "pcbnew_settings.h" using namespace KIGFX; @@ -127,6 +129,8 @@ void PCB_RENDER_SETTINGS::LoadColors( const COLOR_SETTINGS* aSettings ) m_layerColors[GetNetnameLayer( layer )] = lightLabel; } + m_hiContrastFactor = 1.0f - Pgm().GetCommonSettings()->m_Appearance.hicontrast_dimming_factor; + update(); }