Commit 1d98f1f1 authored by dickelbeck's avatar dickelbeck

more layer_widget work

parent e7a49c83
......@@ -21,7 +21,7 @@ LAYER_PANEL_BASE::LAYER_PANEL_BASE( wxWindow* parent, wxWindowID id, const wxPoi
wxBoxSizer* bSizer3;
bSizer3 = new wxBoxSizer( wxVERTICAL );
m_LayerScrolledWindow = new wxScrolledWindow( m_LayerPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxVSCROLL );
m_LayerScrolledWindow = new wxScrolledWindow( m_LayerPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNO_BORDER|wxVSCROLL );
m_LayerScrolledWindow->SetScrollRate( 5, 5 );
m_LayersFlexGridSizer = new wxFlexGridSizer( 0, 4, 1, 3 );
m_LayersFlexGridSizer->SetFlexibleDirection( wxHORIZONTAL );
......@@ -37,16 +37,14 @@ LAYER_PANEL_BASE::LAYER_PANEL_BASE( wxWindow* parent, wxWindowID id, const wxPoi
bSizer3->Fit( m_LayerPanel );
m_notebook->AddPage( m_LayerPanel, _("Layers"), true );
m_RenderingPanel = new wxPanel( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
m_RenderingPanel->SetToolTip( _("Part depiction and visibility") );
wxBoxSizer* bSizer4;
bSizer4 = new wxBoxSizer( wxVERTICAL );
m_RenderScrolledWindow = new wxScrolledWindow( m_RenderingPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxVSCROLL );
m_RenderScrolledWindow = new wxScrolledWindow( m_RenderingPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNO_BORDER|wxVSCROLL );
m_RenderScrolledWindow->SetScrollRate( 5, 5 );
m_RenderFlexGridSizer = new wxFlexGridSizer( 0, 2, 1, 3 );
m_RenderFlexGridSizer = new wxFlexGridSizer( 0, 3, 1, 3 );
m_RenderFlexGridSizer->SetFlexibleDirection( wxHORIZONTAL );
m_RenderFlexGridSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_RenderFlexGridSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_NONE );
m_RenderScrolledWindow->SetSizer( m_RenderFlexGridSizer );
m_RenderScrolledWindow->Layout();
......
......@@ -52,7 +52,7 @@
#define LYR_COLUMN_COUNT 4 ///< Layer tab column count
#define RND_COLUMN_COUNT 2 ///< Rendering tab column count
#define RND_COLUMN_COUNT 3 ///< Rendering tab column count
#define ID_SHOW_ALL_COPPERS wxID_HIGHEST
#define ID_SHOW_NO_COPPERS (wxID_HIGHEST+1)
......@@ -500,26 +500,27 @@ protected:
bmb->SetToolTip( _("Middle click for color change" ) );
m_RenderFlexGridSizer->Insert( index+col, new wxSizerItem( bmb, flags ) );
#if 1
#if 0
// column 1
col = 1;
wxCheckBox* cb = new wxCheckBox( m_RenderScrolledWindow, encodeId( col, aSpec.id ), aSpec.rowName );
wxCheckBox* cb = new wxCheckBox( m_RenderScrolledWindow, encodeId( col, aSpec.id ), aSpec.rowName,
wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT );
cb->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( LAYER_WIDGET::OnRenderCheckBox ), NULL, this );
// cb->SetToolTip( _( "Enable this for visibility" ) );
m_RenderFlexGridSizer->Insert( index+col, new wxSizerItem( cb, flags ) );
#else
// column 1
col = 1;
wxStaticText* st = new wxStaticText( m_RenderScrolledWindow, encodeId( col, aSpec.id ), aSpec.rowName );
m_RenderFlexGridSizer->Insert( index+col,
new wxSizerItem( st, wxSizerFlags().Align( wxALIGN_CENTER_VERTICAL )) );
// column 2
col = 2;
wxCheckBox* cb = new wxCheckBox( m_RenderScrolledWindow, encodeId( col, aSpec.id ), wxEmptyString );
cb->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( LAYER_WIDGET::OnRenderCheckBox ), NULL, this );
// cb->SetToolTip( _( "Enable this for visibility" ) );
m_RenderFlexGridSizer->Insert( index+col, new wxSizerItem( cb, flags ) );
// column 2
col = 2;
wxStaticText* st = new wxStaticText( m_RenderScrolledWindow, encodeId( col, aSpec.id ), aSpec.rowName );
m_RenderFlexGridSizer->Insert( index+col,
new wxSizerItem( st, wxSizerFlags().Align( wxALIGN_CENTER_VERTICAL )) );
#endif
}
......@@ -541,7 +542,7 @@ public:
m_LayerScrolledWindow->Connect( wxEVT_RIGHT_DOWN,
wxMouseEventHandler( LAYER_WIDGET::OnRightDownLayers ), NULL, this );
// since Popupmenu() call this->ProcessEvent() we must call this->Connect()
// since Popupmenu() calls this->ProcessEvent() we must call this->Connect()
// and not m_LayerScrolledWindow->Connect()
Connect( ID_SHOW_ALL_COPPERS, ID_SHOW_NO_COPPERS,
wxEVT_COMMAND_MENU_SELECTED,
......@@ -550,44 +551,69 @@ public:
/**
* Function GetPreferredSize
* Function GetBestSize
* returns the preferred minimum size, taking into consideration the
* dynamic content. Nothing in wxWidgets was reliable enough.
*/
wxSize GetPreferredSize()
wxSize GetBestSize() const
{
FitInside();
// size of m_LayerScrolledWindow --------------
wxArrayInt widths = m_LayersFlexGridSizer->GetColWidths();
int totWidth = 0;
for( int i=0; i<LYR_COLUMN_COUNT; ++i )
for( int i=0; i<LYR_COLUMN_COUNT && i<(int)widths.GetCount(); ++i )
{
totWidth += widths[i] + m_LayersFlexGridSizer->GetHGap();
// printf("widths[%d]:%d\n", i, widths[i] );
}
wxArrayInt heights = m_LayersFlexGridSizer->GetRowHeights();
int totHeight = 2 * heights[0]; // use 2 row heights to approximate tab height
int totHeight = 0;
int rowCount = GetLayerRowCount();
for( int i=0; i<rowCount; ++i )
for( int i=0; i<rowCount && i<(int)heights.GetCount(); ++i )
{
totHeight += heights[i] + m_LayersFlexGridSizer->GetVGap();
// printf("heights[%d]:%d\n", i, heights[i] );
}
// on linux: trial and error min until horizontal scroll bar goes away.
// I think this is to account for the top most window's frame:
// Account for the parent's frame:
totWidth += 10;
wxSize layerWindowSize( totWidth, totHeight );
if( heights.GetCount() )
totHeight += 2 * heights[0]; // use 2 row heights to approximate tab height
else
totHeight += 20; // not used except before adding rows.
return layerWindowSize;
}
wxSize layerz( totWidth, totHeight );
void SetPreferredSize()
{
SetMinSize( GetPreferredSize() );
// size of m_RenderScrolledWindow --------------
widths = m_RenderFlexGridSizer->GetColWidths();
totWidth = 0;
for( int i=0; i<RND_COLUMN_COUNT && i<(int)widths.GetCount(); ++i )
{
totWidth += widths[i] + m_RenderFlexGridSizer->GetHGap();
// printf("widths[%d]:%d\n", i, widths[i] );
}
heights = m_RenderFlexGridSizer->GetRowHeights();
totHeight = 0;
rowCount = GetRenderRowCount();
for( int i=0; i<rowCount && i<(int)heights.GetCount(); ++i )
{
totHeight += heights[i] + m_RenderFlexGridSizer->GetVGap();
// printf("heights[%d]:%d\n", i, heights[i] );
}
// account for the parent's frame, this one void space of 10 PLUS a border:
totWidth += 20;
if( heights.GetCount() )
totHeight += 2 * heights[0]; // use 2 row heights to approximate tab height
else
totHeight += 20; // not used except before adding rows
wxSize renderz( totWidth, totHeight );
return wxSize( max(renderz.x,layerz.x), max(renderz.y,layerz.y) );
}
......@@ -620,6 +646,7 @@ public:
{
int nextRow = GetLayerRowCount();
insertLayerRow( nextRow, aRow );
FitInside();
}
/**
......@@ -640,6 +667,7 @@ public:
{
int nextRow = GetRenderRowCount();
insertRenderRow( nextRow, aRow );
FitInside();
}
/**
......@@ -852,16 +880,14 @@ public:
lw->AppendLayerRow( LAYER_WIDGET::ROW( wxT("brown_layer"), 2, BROWN ) );
lw->AppendLayerRow( LAYER_WIDGET::ROW( wxT("layer_4_you"), 3, BLUE, false ) );
lw->AppendRenderRow( LAYER_WIDGET::ROW( wxT("With Ears"), 0, GREEN ) );
lw->AppendRenderRow( LAYER_WIDGET::ROW( wxT("With Very Large Ears"), 0, GREEN ) );
lw->AppendRenderRow( LAYER_WIDGET::ROW( wxT("With Legs"), 1, YELLOW ) );
lw->SetPreferredSize();
lw->SelectLayerRow( 1 );
wxAuiPaneInfo li;
li.MinSize( lw->GetPreferredSize() );
li.BestSize( lw->GetPreferredSize() );
li.MinSize( lw->GetBestSize() );
li.BestSize( lw->GetBestSize() );
li.Left();
// li.MaximizeButton( true );
// li.MinimizeButton( true );
......
......@@ -190,7 +190,7 @@
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style">wxVSCROLL</property>
<property name="window_style">wxNO_BORDER|wxVSCROLL</property>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
......@@ -233,7 +233,7 @@
</object>
</object>
<object class="notebookpage" expanded="1">
<property name="bitmap">depiction; </property>
<property name="bitmap">; Load From File</property>
<property name="label">Rendering</property>
<property name="select">0</property>
<object class="wxPanel" expanded="1">
......@@ -251,7 +251,7 @@
<property name="pos"></property>
<property name="size"></property>
<property name="subclass"></property>
<property name="tooltip">Part depiction and visibility</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style">wxTAB_TRAVERSAL</property>
......@@ -307,7 +307,7 @@
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style">wxVSCROLL</property>
<property name="window_style">wxNO_BORDER|wxVSCROLL</property>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
......@@ -332,14 +332,14 @@
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
<object class="wxFlexGridSizer" expanded="1">
<property name="cols">2</property>
<property name="cols">3</property>
<property name="flexible_direction">wxHORIZONTAL</property>
<property name="growablecols"></property>
<property name="growablerows"></property>
<property name="hgap">3</property>
<property name="minimum_size"></property>
<property name="name">m_RenderFlexGridSizer</property>
<property name="non_flexible_grow_mode">wxFLEX_GROWMODE_SPECIFIED</property>
<property name="non_flexible_grow_mode">wxFLEX_GROWMODE_NONE</property>
<property name="permission">protected</property>
<property name="rows">0</property>
<property name="vgap">1</property>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment