Improve color theme support in the footprint preview widget
This ensures the colors used by the status text pane in the preview widget are the same as the canvas, so there is a seemless transition between the two. Additionally, remove the scrollbars from the symbol preview widget in the place symbol dialog - they are pointless.
This commit is contained in:
parent
63f777b620
commit
265c6fa3b7
|
@ -28,38 +28,46 @@ FOOTPRINT_PREVIEW_WIDGET::FOOTPRINT_PREVIEW_WIDGET( wxWindow* aParent, KIWAY& aK
|
|||
wxPanel( aParent, wxID_ANY, wxDefaultPosition, wxDefaultSize,
|
||||
wxFULL_REPAINT_ON_RESIZE | wxTAB_TRAVERSAL ),
|
||||
m_prev_panel( nullptr ),
|
||||
m_status_label( nullptr ),
|
||||
m_sizer( nullptr )
|
||||
m_status( nullptr ),
|
||||
m_statusPanel( nullptr ),
|
||||
m_statusSizer( nullptr ),
|
||||
m_outerSizer( nullptr )
|
||||
{
|
||||
m_prev_panel = FOOTPRINT_PREVIEW_PANEL_BASE::Create( this, aKiway );
|
||||
|
||||
if( !m_prev_panel )
|
||||
return;
|
||||
|
||||
SetBackgroundColour( *wxBLACK );
|
||||
SetForegroundColour( *wxWHITE );
|
||||
m_statusPanel = new wxPanel( this );
|
||||
m_status = new wxStaticText( m_statusPanel, wxID_ANY, wxEmptyString );
|
||||
m_statusSizer = new wxBoxSizer( wxVERTICAL );
|
||||
m_statusSizer->Add( 0, 0, 1 ); // add a spacer
|
||||
m_statusSizer->Add( m_status, 0, wxALIGN_CENTER );
|
||||
m_statusSizer->Add( 0, 0, 1 ); // add a spacer
|
||||
m_statusPanel->SetSizer( m_statusSizer );
|
||||
|
||||
m_status_label = new wxStaticText( this, -1, wxEmptyString );
|
||||
m_sizer = new wxBoxSizer( wxVERTICAL );
|
||||
m_sizer->Add( 0, 0, 1 );
|
||||
m_sizer->Add( m_status_label, 0, wxALL | wxALIGN_CENTER, 0 );
|
||||
m_sizer->Add( 0, 0, 1 );
|
||||
// Give the status panel the same color scheme as the canvas so it isn't jarring when switched to
|
||||
m_statusPanel->SetBackgroundColour( m_prev_panel->GetBackgroundColor().ToColour() );
|
||||
m_statusPanel->SetForegroundColour( m_prev_panel->GetForegroundColor().ToColour() );
|
||||
|
||||
auto outer_sizer = new wxBoxSizer( wxVERTICAL );
|
||||
outer_sizer->Add( m_prev_panel->GetWindow(), 1, wxALL | wxEXPAND, 0 );
|
||||
outer_sizer->Add( m_sizer, 1, wxALL | wxALIGN_CENTER, 0 );
|
||||
m_outerSizer = new wxBoxSizer( wxVERTICAL );
|
||||
m_outerSizer->Add( m_prev_panel->GetWindow(), 1, wxALL | wxEXPAND, 0 );
|
||||
m_outerSizer->Add( m_statusPanel, 1, wxALL | wxEXPAND, 0 );
|
||||
|
||||
// Hide the status panel to start
|
||||
m_statusPanel->Hide();
|
||||
|
||||
m_sizer->ShowItems( false );
|
||||
m_prev_panel->SetStatusHandler( [this]( FOOTPRINT_STATUS s ){ this->OnStatusChange( s ); } );
|
||||
|
||||
SetSizer( outer_sizer );
|
||||
SetSizer( m_outerSizer );
|
||||
Layout();
|
||||
}
|
||||
|
||||
|
||||
void FOOTPRINT_PREVIEW_WIDGET::SetStatusText( wxString const& aText )
|
||||
{
|
||||
m_status_label->SetLabel( aText );
|
||||
m_sizer->ShowItems( true );
|
||||
m_status->SetLabel( aText );
|
||||
m_statusPanel->Show();
|
||||
m_prev_panel->GetWindow()->Hide();
|
||||
Layout();
|
||||
}
|
||||
|
@ -67,9 +75,9 @@ void FOOTPRINT_PREVIEW_WIDGET::SetStatusText( wxString const& aText )
|
|||
|
||||
void FOOTPRINT_PREVIEW_WIDGET::ClearStatus()
|
||||
{
|
||||
m_status_label->SetLabel( wxEmptyString );
|
||||
m_status->SetLabel( wxEmptyString );
|
||||
m_statusPanel->Hide();
|
||||
m_prev_panel->GetWindow()->Show();
|
||||
m_sizer->ShowItems( false );
|
||||
Layout();
|
||||
}
|
||||
|
||||
|
|
|
@ -55,6 +55,8 @@ SYMBOL_PREVIEW_WIDGET::SYMBOL_PREVIEW_WIDGET( wxWindow* aParent, KIWAY& aKiway,
|
|||
m_preview = new SCH_PREVIEW_PANEL( aParent, wxID_ANY, wxDefaultPosition, wxSize( -1, -1 ),
|
||||
m_galDisplayOptions, canvasType );
|
||||
m_preview->SetStealsFocus( false );
|
||||
m_preview->ShowScrollbars( wxSHOW_SB_NEVER, wxSHOW_SB_NEVER );
|
||||
m_preview->GetGAL()->SetAxesEnabled( false );
|
||||
|
||||
// Do not display the grid: the look is not good for a small canvas area.
|
||||
// But mainly, due to some strange bug I (JPC) was unable to fix, the grid creates
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
#include <functional>
|
||||
#include <import_export.h>
|
||||
|
||||
#include <gal/color4d.h>
|
||||
|
||||
class FOOTPRINT_LOAD_EVENT;
|
||||
class FOOTPRINT_PREVIEW_PANEL_BASE;
|
||||
class LIB_ID;
|
||||
|
@ -89,8 +91,12 @@ private:
|
|||
void OnStatusChange( FOOTPRINT_STATUS aStatus );
|
||||
|
||||
FOOTPRINT_PREVIEW_PANEL_BASE* m_prev_panel;
|
||||
wxStaticText* m_status_label;
|
||||
wxSizer* m_sizer;
|
||||
|
||||
wxStaticText* m_status;
|
||||
wxPanel* m_statusPanel;
|
||||
wxSizer* m_statusSizer;
|
||||
wxSizer* m_outerSizer;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -128,6 +134,12 @@ public:
|
|||
*/
|
||||
virtual wxWindow* GetWindow() = 0;
|
||||
|
||||
/**
|
||||
* Get the colors to use in a preview widget to match the preview panel.
|
||||
*/
|
||||
virtual const KIGFX::COLOR4D& GetBackgroundColor() = 0;
|
||||
virtual const KIGFX::COLOR4D& GetForegroundColor() = 0;
|
||||
|
||||
/**
|
||||
* Return a footprint preview panel instance via Kiface. May return null
|
||||
* if Kiway is not available or there is any error on load.
|
||||
|
|
|
@ -291,6 +291,24 @@ FOOTPRINT_PREVIEW_PANEL::~FOOTPRINT_PREVIEW_PANEL( )
|
|||
}
|
||||
|
||||
|
||||
const COLOR4D& FOOTPRINT_PREVIEW_PANEL::GetBackgroundColor()
|
||||
{
|
||||
KIGFX::PAINTER* painter = GetView()->GetPainter();
|
||||
auto settings = static_cast<KIGFX::PCB_RENDER_SETTINGS*>( painter->GetSettings() );
|
||||
|
||||
return settings->GetBackgroundColor();
|
||||
}
|
||||
|
||||
|
||||
const COLOR4D& FOOTPRINT_PREVIEW_PANEL::GetForegroundColor()
|
||||
{
|
||||
KIGFX::PAINTER* painter = GetView()->GetPainter();
|
||||
auto settings = static_cast<KIGFX::PCB_RENDER_SETTINGS*>( painter->GetSettings() );
|
||||
|
||||
return settings->GetCursorColor();
|
||||
}
|
||||
|
||||
|
||||
FOOTPRINT_PREVIEW_PANEL::CACHE_ENTRY FOOTPRINT_PREVIEW_PANEL::CacheAndReturn( const LIB_ID& aFPID )
|
||||
{
|
||||
auto opt_ent = m_iface->GetFromCache( aFPID );
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include <functional>
|
||||
|
||||
#include <pcb_draw_panel_gal.h>
|
||||
#include <gal/color4d.h>
|
||||
#include <gal/gal_display_options.h>
|
||||
#include <lib_id.h>
|
||||
#include <kiway_player.h>
|
||||
|
@ -64,6 +65,9 @@ public:
|
|||
|
||||
virtual void SetStatusHandler( FOOTPRINT_STATUS_HANDLER aHandler ) override;
|
||||
|
||||
virtual const KIGFX::COLOR4D& GetBackgroundColor() override;
|
||||
virtual const KIGFX::COLOR4D& GetForegroundColor() override;
|
||||
|
||||
virtual wxWindow* GetWindow() override;
|
||||
BOARD* GetBoard() { return m_dummyBoard.get(); }
|
||||
|
||||
|
|
Loading…
Reference in New Issue