Properties: improve handling of column splitter
This commit is contained in:
parent
8c7691fbc3
commit
696a1cd39d
|
@ -33,8 +33,10 @@
|
||||||
|
|
||||||
extern APIIMPORT wxPGGlobalVarsClass* wxPGGlobalVars;
|
extern APIIMPORT wxPGGlobalVarsClass* wxPGGlobalVars;
|
||||||
|
|
||||||
PROPERTIES_PANEL::PROPERTIES_PANEL( wxWindow* aParent, EDA_BASE_FRAME* aFrame )
|
PROPERTIES_PANEL::PROPERTIES_PANEL( wxWindow* aParent, EDA_BASE_FRAME* aFrame ) :
|
||||||
: wxPanel( aParent ), m_frame( aFrame )
|
wxPanel( aParent ),
|
||||||
|
m_frame( aFrame ),
|
||||||
|
m_splitter_key_proportion( -1 )
|
||||||
{
|
{
|
||||||
wxBoxSizer* mainSizer = new wxBoxSizer( wxVERTICAL );
|
wxBoxSizer* mainSizer = new wxBoxSizer( wxVERTICAL );
|
||||||
|
|
||||||
|
@ -62,6 +64,20 @@ PROPERTIES_PANEL::PROPERTIES_PANEL( wxWindow* aParent, EDA_BASE_FRAME* aFrame )
|
||||||
Connect( wxEVT_PG_CHANGED, wxPropertyGridEventHandler( PROPERTIES_PANEL::valueChanged ), NULL, this );
|
Connect( wxEVT_PG_CHANGED, wxPropertyGridEventHandler( PROPERTIES_PANEL::valueChanged ), NULL, this );
|
||||||
Connect( wxEVT_PG_CHANGING, wxPropertyGridEventHandler( PROPERTIES_PANEL::valueChanging ), NULL, this );
|
Connect( wxEVT_PG_CHANGING, wxPropertyGridEventHandler( PROPERTIES_PANEL::valueChanging ), NULL, this );
|
||||||
Connect( wxEVT_SHOW, wxShowEventHandler( PROPERTIES_PANEL::onShow ), NULL, this );
|
Connect( wxEVT_SHOW, wxShowEventHandler( PROPERTIES_PANEL::onShow ), NULL, this );
|
||||||
|
|
||||||
|
Bind( wxEVT_PG_COL_END_DRAG,
|
||||||
|
[&]( wxPropertyGridEvent& )
|
||||||
|
{
|
||||||
|
m_splitter_key_proportion =
|
||||||
|
static_cast<float>( m_grid->GetSplitterPosition() ) / m_grid->GetSize().x;
|
||||||
|
} );
|
||||||
|
|
||||||
|
Bind( wxEVT_SIZE,
|
||||||
|
[&]( wxSizeEvent& aEvent )
|
||||||
|
{
|
||||||
|
RecalculateSplitterPos();
|
||||||
|
aEvent.Skip();
|
||||||
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -174,7 +190,7 @@ void PROPERTIES_PANEL::update( const SELECTION& aSelection )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_grid->FitColumns();
|
RecalculateSplitterPos();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -183,3 +199,12 @@ void PROPERTIES_PANEL::onShow( wxShowEvent& aEvent )
|
||||||
if( aEvent.IsShown() )
|
if( aEvent.IsShown() )
|
||||||
UpdateData();
|
UpdateData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PROPERTIES_PANEL::RecalculateSplitterPos()
|
||||||
|
{
|
||||||
|
if( m_splitter_key_proportion < 0 )
|
||||||
|
m_grid->CenterSplitter();
|
||||||
|
else
|
||||||
|
m_grid->SetSplitterPosition( m_splitter_key_proportion * m_grid->GetSize().x );
|
||||||
|
}
|
||||||
|
|
|
@ -60,6 +60,8 @@ public:
|
||||||
return m_displayed;
|
return m_displayed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RecalculateSplitterPos();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void update( const SELECTION& aSelection );
|
virtual void update( const SELECTION& aSelection );
|
||||||
virtual wxPGProperty* createPGProperty( const PROPERTY_BASE* aProperty ) const = 0;
|
virtual wxPGProperty* createPGProperty( const PROPERTY_BASE* aProperty ) const = 0;
|
||||||
|
@ -73,6 +75,9 @@ protected:
|
||||||
wxPropertyGrid* m_grid;
|
wxPropertyGrid* m_grid;
|
||||||
EDA_BASE_FRAME* m_frame;
|
EDA_BASE_FRAME* m_frame;
|
||||||
wxStaticText* m_caption;
|
wxStaticText* m_caption;
|
||||||
|
|
||||||
|
/// Proportion of the grid column splitter that is used for the key column (0.0 - 1.0)
|
||||||
|
float m_splitter_key_proportion;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* PROPERTIES_PANEL_H */
|
#endif /* PROPERTIES_PANEL_H */
|
||||||
|
|
Loading…
Reference in New Issue