Implement a more flexible layout for the objects tab of appearances.
This commit is contained in:
parent
54682d39ff
commit
15edac4738
|
@ -532,7 +532,7 @@ void APPEARANCE_CONTROLS::rebuildLayers()
|
|||
ROW_ICON_PROVIDER::STATE::OFF, layer );
|
||||
|
||||
COLOR_SWATCH* swatch = new COLOR_SWATCH( panel, COLOR4D::UNSPECIFIED, layer,
|
||||
bgColor, theme->GetColor( layer ), false );
|
||||
bgColor, theme->GetColor( layer ), false );
|
||||
swatch->SetToolTip( _( "Left double click or middle click for color change, "
|
||||
"right click for menu" ) );
|
||||
|
||||
|
@ -549,13 +549,13 @@ void APPEARANCE_CONTROLS::rebuildLayers()
|
|||
firstLayer = false;
|
||||
|
||||
sizer->AddSpacer( 1 );
|
||||
sizer->Add( indicator, 0, wxALIGN_CENTER_VERTICAL | wxTOP, topMargin );
|
||||
sizer->Add( indicator, 0, wxALIGN_CENTER_VERTICAL | wxTOP, topMargin );
|
||||
sizer->AddSpacer( 5 );
|
||||
sizer->Add( swatch, 0, wxALIGN_CENTER_VERTICAL | wxTOP, topMargin );
|
||||
sizer->Add( swatch, 0, wxALIGN_CENTER_VERTICAL | wxTOP, topMargin );
|
||||
sizer->AddSpacer( 6 );
|
||||
sizer->Add( btn_visible, 0, wxALIGN_CENTER_VERTICAL | wxTOP, topMargin );
|
||||
sizer->AddSpacer( 5 );
|
||||
sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxTOP, topMargin );
|
||||
sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxTOP, topMargin );
|
||||
|
||||
m_layers_outer_sizer->Add( panel, 0, wxEXPAND, 0 );
|
||||
|
||||
|
@ -974,35 +974,18 @@ void APPEARANCE_CONTROLS::rebuildObjects()
|
|||
COLOR_SETTINGS* theme = m_frame->GetColorSettings();
|
||||
COLOR4D bgColor = theme->GetColor( LAYER_PCB_BACKGROUND );
|
||||
GAL_SET visible = board->GetVisibleElements();
|
||||
bool firstSlider = true;
|
||||
int sliderAlignment = wxALIGN_CENTER_VERTICAL;
|
||||
int sliderLableAlignment = wxALIGN_CENTER_VERTICAL;
|
||||
|
||||
#ifdef __WXMAC__
|
||||
sliderAlignment = wxALIGN_BOTTOM;
|
||||
sliderLableAlignment = wxALIGN_TOP;
|
||||
#endif
|
||||
int swatchWidth = m_windowObjects->ConvertDialogToPixels( wxSize( 8, 0 ) ).x;
|
||||
int labelWidth = 0;
|
||||
|
||||
m_objectSettings.clear();
|
||||
m_objectsSizer->Clear( true );
|
||||
m_objectsSizer->AddSpacer( 5 );
|
||||
|
||||
auto appendObject =
|
||||
[&]( int aRow, std::unique_ptr<APPEARANCE_SETTING>& aSetting )
|
||||
[&]( const std::unique_ptr<APPEARANCE_SETTING>& aSetting )
|
||||
{
|
||||
int layer = aSetting->id;
|
||||
int topMargin = 0;
|
||||
|
||||
if( aSetting->can_control_opacity )
|
||||
{
|
||||
if( firstSlider )
|
||||
topMargin = wxTOP;
|
||||
|
||||
firstSlider = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
topMargin = wxTOP;
|
||||
}
|
||||
wxBoxSizer* sizer = new wxBoxSizer( wxHORIZONTAL );
|
||||
int layer = aSetting->id;
|
||||
|
||||
aSetting->visible = visible.Contains( ToGalLayer( layer ) );
|
||||
COLOR4D color = theme->GetColor( layer );
|
||||
|
@ -1010,18 +993,21 @@ void APPEARANCE_CONTROLS::rebuildObjects()
|
|||
|
||||
if( color != COLOR4D::UNSPECIFIED )
|
||||
{
|
||||
COLOR_SWATCH* swatch = new COLOR_SWATCH( m_windowObjects, color, layer, bgColor,
|
||||
defColor, false );
|
||||
COLOR_SWATCH* swatch = new COLOR_SWATCH( m_windowObjects, color, layer,
|
||||
bgColor, defColor, false );
|
||||
swatch->SetToolTip( _( "Left double click or middle click for color change, "
|
||||
"right click for menu" ) );
|
||||
|
||||
m_objectsSizer->Add( swatch, wxGBPosition( aRow, 0 ), wxDefaultSpan,
|
||||
wxALIGN_CENTER_VERTICAL | topMargin | wxLEFT | wxRIGHT, 1 );
|
||||
sizer->Add( swatch, 0, wxALIGN_CENTER_VERTICAL, 0 );
|
||||
aSetting->ctl_color = swatch;
|
||||
|
||||
swatch->Bind( COLOR_SWATCH_CHANGED,
|
||||
&APPEARANCE_CONTROLS::OnColorSwatchChanged, this );
|
||||
}
|
||||
else
|
||||
{
|
||||
sizer->AddSpacer( swatchWidth );
|
||||
}
|
||||
|
||||
BITMAP_TOGGLE* btn_visible = new BITMAP_TOGGLE( m_windowObjects, layer,
|
||||
KiBitmap( visibility_xpm ),
|
||||
|
@ -1032,10 +1018,10 @@ void APPEARANCE_CONTROLS::rebuildObjects()
|
|||
tip.Printf( _( "Show or hide %s" ), aSetting->label.Lower() );
|
||||
btn_visible->SetToolTip( tip );
|
||||
|
||||
m_objectsSizer->Add( btn_visible, wxGBPosition( aRow, 1 ), wxDefaultSpan,
|
||||
sliderLableAlignment | topMargin | wxLEFT, 1 );
|
||||
aSetting->ctl_visibility = btn_visible;
|
||||
|
||||
sizer->AddSpacer( 5 );
|
||||
|
||||
btn_visible->Bind( TOGGLE_CHANGED,
|
||||
[&]( wxCommandEvent& aEvent )
|
||||
{
|
||||
|
@ -1048,13 +1034,19 @@ void APPEARANCE_CONTROLS::rebuildObjects()
|
|||
label->Wrap( -1 );
|
||||
label->SetToolTip( aSetting->tooltip );
|
||||
|
||||
wxGBSpan labelSpan( 1, aSetting->can_control_opacity ? 1 : 2 );
|
||||
|
||||
m_objectsSizer->Add( label, wxGBPosition( aRow, 2 ), labelSpan,
|
||||
sliderLableAlignment | topMargin | wxLEFT | wxRIGHT, 1 );
|
||||
|
||||
if( aSetting->can_control_opacity )
|
||||
{
|
||||
label->SetMinSize( wxSize( labelWidth, -1 ) );
|
||||
#ifdef __WXMAC__
|
||||
sizer->Add( btn_visible, 0, wxALIGN_CENTER_VERTICAL | wxBOTTOM, 10 );
|
||||
sizer->AddSpacer( 5 );
|
||||
sizer->Add( label, 0, wxALIGN_CENTER_VERTICAL | wxBOTTOM, 10 );
|
||||
#else
|
||||
sizer->Add( btn_visible, 0, wxALIGN_CENTER_VERTICAL, 0 );
|
||||
sizer->AddSpacer( 5 );
|
||||
sizer->Add( label, 0, wxALIGN_CENTER_VERTICAL, 0 );
|
||||
#endif
|
||||
|
||||
wxSlider* slider = new wxSlider( m_windowObjects, wxID_ANY, 100, 0, 100,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxSL_HORIZONTAL );
|
||||
|
@ -1067,8 +1059,7 @@ void APPEARANCE_CONTROLS::rebuildObjects()
|
|||
tip.Printf( _( "Set opacity of %s" ), aSetting->label.Lower() );
|
||||
slider->SetToolTip( tip );
|
||||
|
||||
m_objectsSizer->Add( slider, wxGBPosition( aRow, 3 ), wxDefaultSpan,
|
||||
sliderAlignment | topMargin | wxLEFT | wxRIGHT, 1 );
|
||||
sizer->Add( slider, 1, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, 5 );
|
||||
aSetting->ctl_opacity = slider;
|
||||
|
||||
auto opacitySliderHandler =
|
||||
|
@ -1082,15 +1073,19 @@ void APPEARANCE_CONTROLS::rebuildObjects()
|
|||
slider->Bind( wxEVT_SCROLL_CHANGED, opacitySliderHandler );
|
||||
slider->Bind( wxEVT_SCROLL_THUMBTRACK, opacitySliderHandler );
|
||||
}
|
||||
else
|
||||
{
|
||||
sizer->Add( btn_visible, 0, wxALIGN_CENTER_VERTICAL, 0 );
|
||||
sizer->AddSpacer( 5 );
|
||||
sizer->Add( label, 0, wxALIGN_CENTER_VERTICAL, 0 );
|
||||
}
|
||||
|
||||
aSetting->ctl_text = label;
|
||||
m_objectsSizer->Add( sizer, 0, wxEXPAND | wxLEFT | wxRIGHT, 5 );
|
||||
m_objectsSizer->AddSpacer( 1 );
|
||||
};
|
||||
|
||||
m_objectsSizer->SetEmptyCellSize( wxSize( m_pointSize, m_pointSize * 2 / 3 ) );
|
||||
|
||||
int gridRow = 0;
|
||||
|
||||
for( unsigned row = 0; row < arrayDim( s_objectSettings ); ++row )
|
||||
for( const APPEARANCE_SETTING& s_setting : s_objectSettings )
|
||||
{
|
||||
// TODO(JE)
|
||||
#ifdef NOTYET
|
||||
|
@ -1098,28 +1093,36 @@ void APPEARANCE_CONTROLS::rebuildObjects()
|
|||
continue;
|
||||
#endif
|
||||
|
||||
if( !s_objectSettings[row].spacer )
|
||||
if( !s_setting.spacer )
|
||||
{
|
||||
m_objectSettings.emplace_back(
|
||||
std::make_unique<APPEARANCE_SETTING>( s_objectSettings[row] ) );
|
||||
m_objectSettings.emplace_back( std::make_unique<APPEARANCE_SETTING>( s_setting ) );
|
||||
|
||||
std::unique_ptr<APPEARANCE_SETTING>& setting = m_objectSettings.back();
|
||||
|
||||
// Because s_render_rows is created static, we must explicitly call
|
||||
// wxGetTranslation for texts which are internationalized (tool tips
|
||||
// and item names)
|
||||
setting->tooltip = wxGetTranslation( s_objectSettings[row].tooltip );
|
||||
setting->label = wxGetTranslation( s_objectSettings[row].label );
|
||||
setting->tooltip = wxGetTranslation( s_setting.tooltip );
|
||||
setting->label = wxGetTranslation( s_setting.label );
|
||||
|
||||
appendObject( gridRow, setting );
|
||||
if( setting->can_control_opacity )
|
||||
{
|
||||
int width = m_windowObjects->GetTextExtent( setting->label ).x;
|
||||
labelWidth = std::max( labelWidth, width );
|
||||
}
|
||||
|
||||
m_objectSettingsMap[ToGalLayer( setting->id )] = setting.get();
|
||||
}
|
||||
|
||||
gridRow++;
|
||||
}
|
||||
|
||||
m_objectsSizer->AddGrowableCol( 3, 1 );
|
||||
for( const std::unique_ptr<APPEARANCE_SETTING>& setting : m_objectSettings )
|
||||
{
|
||||
if( setting->spacer )
|
||||
m_objectsSizer->AddSpacer( m_pointSize );
|
||||
else
|
||||
appendObject( setting );
|
||||
}
|
||||
|
||||
m_objectsSizer->Layout();
|
||||
}
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ APPEARANCE_CONTROLS_BASE::APPEARANCE_CONTROLS_BASE( wxWindow* parent, wxWindowID
|
|||
m_panelLayers->SetSizer( m_panelLayersSizer );
|
||||
m_panelLayers->Layout();
|
||||
m_panelLayersSizer->Fit( m_panelLayers );
|
||||
m_notebook->AddPage( m_panelLayers, wxT("Layers"), true );
|
||||
m_notebook->AddPage( m_panelLayers, wxT("Layers"), false );
|
||||
m_panelObjects = new wxPanel( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
|
||||
m_panelObjects->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) );
|
||||
|
||||
|
@ -90,20 +90,12 @@ APPEARANCE_CONTROLS_BASE::APPEARANCE_CONTROLS_BASE( wxWindow* parent, wxWindowID
|
|||
m_windowObjects->SetScrollRate( 0, 5 );
|
||||
m_windowObjects->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) );
|
||||
|
||||
wxBoxSizer* bSizer161;
|
||||
bSizer161 = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
m_objectsSizer = new wxGridBagSizer( 0, 4 );
|
||||
m_objectsSizer->SetFlexibleDirection( wxBOTH );
|
||||
m_objectsSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
|
||||
m_objectsSizer = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
|
||||
bSizer161->Add( m_objectsSizer, 1, wxEXPAND|wxALL, 5 );
|
||||
|
||||
|
||||
m_windowObjects->SetSizer( bSizer161 );
|
||||
m_windowObjects->SetSizer( m_objectsSizer );
|
||||
m_windowObjects->Layout();
|
||||
bSizer161->Fit( m_windowObjects );
|
||||
m_objectsSizer->Fit( m_windowObjects );
|
||||
m_objectsPanelSizer->Add( m_windowObjects, 1, wxEXPAND, 5 );
|
||||
|
||||
|
||||
|
@ -213,7 +205,7 @@ APPEARANCE_CONTROLS_BASE::APPEARANCE_CONTROLS_BASE( wxWindow* parent, wxWindowID
|
|||
wxBoxSizer* bSizer191;
|
||||
bSizer191 = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
m_rbNetColorAll = new wxRadioButton( m_paneNetDisplay->GetPane(), wxID_ANY, wxT("All"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
|
||||
m_rbNetColorAll = new wxRadioButton( m_paneNetDisplay->GetPane(), wxID_ANY, wxT("All"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_rbNetColorAll->SetToolTip( wxT("Net and netclass colors are shown on all copper items") );
|
||||
|
||||
bSizer191->Add( m_rbNetColorAll, 1, wxRIGHT|wxLEFT, 5 );
|
||||
|
@ -224,7 +216,7 @@ APPEARANCE_CONTROLS_BASE::APPEARANCE_CONTROLS_BASE( wxWindow* parent, wxWindowID
|
|||
|
||||
bSizer191->Add( m_rbNetColorRatsnest, 1, wxLEFT, 5 );
|
||||
|
||||
m_rbNetColorOff = new wxRadioButton( m_paneNetDisplay->GetPane(), wxID_ANY, wxT("None"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_rbNetColorOff = new wxRadioButton( m_paneNetDisplay->GetPane(), wxID_ANY, wxT("None"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
|
||||
m_rbNetColorOff->SetToolTip( wxT("Net and netclass colors are not shown") );
|
||||
|
||||
bSizer191->Add( m_rbNetColorOff, 1, wxLEFT, 5 );
|
||||
|
@ -242,7 +234,7 @@ APPEARANCE_CONTROLS_BASE::APPEARANCE_CONTROLS_BASE( wxWindow* parent, wxWindowID
|
|||
m_panelNetsAndClasses->SetSizer( bSizer16 );
|
||||
m_panelNetsAndClasses->Layout();
|
||||
bSizer16->Fit( m_panelNetsAndClasses );
|
||||
m_notebook->AddPage( m_panelNetsAndClasses, wxT("Nets"), false );
|
||||
m_notebook->AddPage( m_panelNetsAndClasses, wxT("Nets"), true );
|
||||
|
||||
m_sizerOuter->Add( m_notebook, 1, wxEXPAND, 5 );
|
||||
|
||||
|
@ -253,6 +245,8 @@ APPEARANCE_CONTROLS_BASE::APPEARANCE_CONTROLS_BASE( wxWindow* parent, wxWindowID
|
|||
int m_cbLayerPresetsNChoices = sizeof( m_cbLayerPresetsChoices ) / sizeof( wxString );
|
||||
m_cbLayerPresets = new wxChoice( presetsSizer->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_cbLayerPresetsNChoices, m_cbLayerPresetsChoices, 0 );
|
||||
m_cbLayerPresets->SetSelection( 1 );
|
||||
m_cbLayerPresets->SetToolTip( wxT("Layer presets") );
|
||||
|
||||
presetsSizer->Add( m_cbLayerPresets, 1, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
|
||||
|
||||
m_btnDeletePreset = new wxBitmapButton( presetsSizer->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 );
|
||||
|
|
|
@ -115,7 +115,7 @@
|
|||
<object class="notebookpage" expanded="1">
|
||||
<property name="bitmap"></property>
|
||||
<property name="label">Layers</property>
|
||||
<property name="select">1</property>
|
||||
<property name="select">0</property>
|
||||
<object class="wxPanel" expanded="1">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
|
@ -817,26 +817,9 @@
|
|||
<property name="window_style">wxHSCROLL|wxVSCROLL</property>
|
||||
<object class="wxBoxSizer" expanded="1">
|
||||
<property name="minimum_size"></property>
|
||||
<property name="name">bSizer161</property>
|
||||
<property name="name">m_objectsSizer</property>
|
||||
<property name="orient">wxVERTICAL</property>
|
||||
<property name="permission">none</property>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxEXPAND|wxALL</property>
|
||||
<property name="proportion">1</property>
|
||||
<object class="wxGridBagSizer" expanded="0">
|
||||
<property name="empty_cell_size"></property>
|
||||
<property name="flexible_direction">wxBOTH</property>
|
||||
<property name="growablecols"></property>
|
||||
<property name="growablerows"></property>
|
||||
<property name="hgap">4</property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="name">m_objectsSizer</property>
|
||||
<property name="non_flexible_grow_mode">wxFLEX_GROWMODE_SPECIFIED</property>
|
||||
<property name="permission">protected</property>
|
||||
<property name="vgap">0</property>
|
||||
</object>
|
||||
</object>
|
||||
<property name="permission">protected</property>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
|
@ -846,7 +829,7 @@
|
|||
<object class="notebookpage" expanded="1">
|
||||
<property name="bitmap"></property>
|
||||
<property name="label">Nets</property>
|
||||
<property name="select">0</property>
|
||||
<property name="select">1</property>
|
||||
<object class="wxPanel" expanded="1">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
|
@ -1631,7 +1614,7 @@
|
|||
<property name="window_name"></property>
|
||||
<property name="window_style"></property>
|
||||
<event name="OnCollapsiblePaneChanged">OnNetDisplayPaneChanged</event>
|
||||
<object class="wxBoxSizer" expanded="1">
|
||||
<object class="wxBoxSizer" expanded="0">
|
||||
<property name="minimum_size"></property>
|
||||
<property name="name">bSizer1211</property>
|
||||
<property name="orient">wxVERTICAL</property>
|
||||
|
@ -1697,11 +1680,11 @@
|
|||
<property name="wrap">-1</property>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<object class="sizeritem" expanded="0">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxEXPAND</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxBoxSizer" expanded="1">
|
||||
<object class="wxBoxSizer" expanded="0">
|
||||
<property name="minimum_size"></property>
|
||||
<property name="name">bSizer191</property>
|
||||
<property name="orient">wxHORIZONTAL</property>
|
||||
|
@ -1756,7 +1739,7 @@
|
|||
<property name="resize">Resizable</property>
|
||||
<property name="show">1</property>
|
||||
<property name="size"></property>
|
||||
<property name="style">wxRB_GROUP</property>
|
||||
<property name="style"></property>
|
||||
<property name="subclass">; ; forward_declare</property>
|
||||
<property name="toolbar_pane">0</property>
|
||||
<property name="tooltip">Net and netclass colors are shown on all copper items</property>
|
||||
|
@ -1884,7 +1867,7 @@
|
|||
<property name="resize">Resizable</property>
|
||||
<property name="show">1</property>
|
||||
<property name="size"></property>
|
||||
<property name="style"></property>
|
||||
<property name="style">wxRB_GROUP</property>
|
||||
<property name="subclass">; ; forward_declare</property>
|
||||
<property name="toolbar_pane">0</property>
|
||||
<property name="tooltip">Net and netclass colors are not shown</property>
|
||||
|
@ -1974,7 +1957,7 @@
|
|||
<property name="style"></property>
|
||||
<property name="subclass">; ; forward_declare</property>
|
||||
<property name="toolbar_pane">0</property>
|
||||
<property name="tooltip"></property>
|
||||
<property name="tooltip">Layer presets</property>
|
||||
<property name="validator_data_type"></property>
|
||||
<property name="validator_style">wxFILTER_NONE</property>
|
||||
<property name="validator_type">wxDefaultValidator</property>
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#include <wx/bitmap.h>
|
||||
#include <wx/image.h>
|
||||
#include <wx/icon.h>
|
||||
#include <wx/gbsizer.h>
|
||||
#include <wx/textctrl.h>
|
||||
#include <wx/bmpbuttn.h>
|
||||
#include <wx/button.h>
|
||||
|
@ -61,7 +60,7 @@ class APPEARANCE_CONTROLS_BASE : public wxPanel
|
|||
wxPanel* m_panelObjects;
|
||||
wxBoxSizer* m_objectsPanelSizer;
|
||||
wxScrolledWindow* m_windowObjects;
|
||||
wxGridBagSizer* m_objectsSizer;
|
||||
wxBoxSizer* m_objectsSizer;
|
||||
wxPanel* m_panelNetsAndClasses;
|
||||
wxSplitterWindow* m_netsTabSplitter;
|
||||
wxPanel* m_panelNets;
|
||||
|
|
Loading…
Reference in New Issue