Merge branch 'dvd-revert-performance-breaking-commits' of https://github.com/vslavik/wxWidgets
Revert recent changes to wxDataViewCtrl which resulted in unacceptable performance regressions. See https://github.com/wxWidgets/wxWidgets/pull/2461 See #14939, #19003.
This commit is contained in:
@@ -86,7 +86,7 @@ class wxCocoaDataViewControl;
|
|||||||
class wxDataViewColumnNativeData
|
class wxDataViewColumnNativeData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxDataViewColumnNativeData() : m_NativeColumnPtr(NULL), m_isLast(false), m_prevWidth(0)
|
wxDataViewColumnNativeData() : m_NativeColumnPtr(NULL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,32 +105,9 @@ public:
|
|||||||
m_NativeColumnPtr = newNativeColumnPtr;
|
m_NativeColumnPtr = newNativeColumnPtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GetIsLast() const
|
|
||||||
{
|
|
||||||
return m_isLast;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetIsLast(bool isLast)
|
|
||||||
{
|
|
||||||
m_isLast = isLast;
|
|
||||||
}
|
|
||||||
|
|
||||||
int GetPrevWidth() const
|
|
||||||
{
|
|
||||||
return m_prevWidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetPrevWidth(int prevWidth)
|
|
||||||
{
|
|
||||||
m_prevWidth = prevWidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// not owned by us
|
// not owned by us
|
||||||
NSTableColumn* m_NativeColumnPtr;
|
NSTableColumn* m_NativeColumnPtr;
|
||||||
|
|
||||||
bool m_isLast;
|
|
||||||
int m_prevWidth;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
@@ -2092,7 +2092,7 @@ wxCocoaDataViewControl::wxCocoaDataViewControl(wxWindow* peer,
|
|||||||
),
|
),
|
||||||
m_DataSource(NULL),
|
m_DataSource(NULL),
|
||||||
m_OutlineView([[wxCocoaOutlineView alloc] init]),
|
m_OutlineView([[wxCocoaOutlineView alloc] init]),
|
||||||
m_expanderWidth(0)
|
m_expanderWidth(-1)
|
||||||
{
|
{
|
||||||
// initialize scrollview (the outline view is part of a scrollview):
|
// initialize scrollview (the outline view is part of a scrollview):
|
||||||
NSScrollView* scrollview = (NSScrollView*) GetWXWidget();
|
NSScrollView* scrollview = (NSScrollView*) GetWXWidget();
|
||||||
@@ -2243,9 +2243,7 @@ bool wxCocoaDataViewControl::InsertColumn(unsigned int pos, wxDataViewColumn* co
|
|||||||
void wxCocoaDataViewControl::FitColumnWidthToContent(unsigned int pos)
|
void wxCocoaDataViewControl::FitColumnWidthToContent(unsigned int pos)
|
||||||
{
|
{
|
||||||
const int count = GetCount();
|
const int count = GetCount();
|
||||||
wxDataViewColumnNativeData *nativeData = GetColumn(pos)->GetNativeData();
|
NSTableColumn *column = GetColumn(pos)->GetNativeData()->GetNativeColumnPtr();
|
||||||
NSTableColumn *column = nativeData->GetNativeColumnPtr();
|
|
||||||
UInt32 const noOfColumns = [[m_OutlineView tableColumns] count];
|
|
||||||
|
|
||||||
class MaxWidthCalculator
|
class MaxWidthCalculator
|
||||||
{
|
{
|
||||||
@@ -2253,11 +2251,10 @@ void wxCocoaDataViewControl::FitColumnWidthToContent(unsigned int pos)
|
|||||||
MaxWidthCalculator(wxCocoaOutlineView *view,
|
MaxWidthCalculator(wxCocoaOutlineView *view,
|
||||||
NSTableColumn *column, unsigned columnIndex)
|
NSTableColumn *column, unsigned columnIndex)
|
||||||
: m_width(0),
|
: m_width(0),
|
||||||
m_height(0),
|
|
||||||
m_view(view),
|
m_view(view),
|
||||||
m_column(columnIndex),
|
m_column(columnIndex),
|
||||||
m_indent(0),
|
m_indent(0),
|
||||||
m_expander(0),
|
m_expander(-1),
|
||||||
m_tableColumn(column)
|
m_tableColumn(column)
|
||||||
{
|
{
|
||||||
// account for indentation in the column with expander
|
// account for indentation in the column with expander
|
||||||
@@ -2274,28 +2271,24 @@ void wxCocoaDataViewControl::FitColumnWidthToContent(unsigned int pos)
|
|||||||
{
|
{
|
||||||
NSCell *cell = [m_view preparedCellAtColumn:m_column row:row];
|
NSCell *cell = [m_view preparedCellAtColumn:m_column row:row];
|
||||||
unsigned cellWidth = ceil([cell cellSize].width);
|
unsigned cellWidth = ceil([cell cellSize].width);
|
||||||
unsigned cellHeight = ceil([cell cellSize].height);
|
|
||||||
|
|
||||||
if ( m_indent )
|
if ( m_indent )
|
||||||
cellWidth += m_indent * [m_view levelForRow:row];
|
cellWidth += m_indent * [m_view levelForRow:row];
|
||||||
|
|
||||||
if ( m_expander == 0 && m_tableColumn == [m_view outlineTableColumn] )
|
if ( m_expander == -1 && m_tableColumn == [m_view outlineTableColumn] )
|
||||||
{
|
{
|
||||||
NSRect rc = [m_view frameOfOutlineCellAtRow:row];
|
NSRect rc = [m_view frameOfOutlineCellAtRow:row];
|
||||||
m_expander = ceil(rc.origin.x + rc.size.width);
|
m_expander = ceil(rc.origin.x + rc.size.width);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_width = wxMax(m_width, cellWidth);
|
m_width = wxMax(m_width, cellWidth);
|
||||||
m_height = wxMax(m_height, cellHeight);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetMaxWidth() const { return m_width; }
|
int GetMaxWidth() const { return m_width; }
|
||||||
int GetMaxHeight() const { return m_height; }
|
|
||||||
int GetExpanderWidth() const { return m_expander; }
|
int GetExpanderWidth() const { return m_expander; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_width;
|
int m_width;
|
||||||
int m_height;
|
|
||||||
wxCocoaOutlineView *m_view;
|
wxCocoaOutlineView *m_view;
|
||||||
unsigned m_column;
|
unsigned m_column;
|
||||||
int m_indent;
|
int m_indent;
|
||||||
@@ -2373,42 +2366,10 @@ void wxCocoaDataViewControl::FitColumnWidthToContent(unsigned int pos)
|
|||||||
|
|
||||||
// there might not necessarily be an expander in the rows we've examined above so let's
|
// there might not necessarily be an expander in the rows we've examined above so let's
|
||||||
// globally store the expander width for re-use because it should always be the same
|
// globally store the expander width for re-use because it should always be the same
|
||||||
if ( m_expanderWidth == 0 )
|
if ( m_expanderWidth == -1 )
|
||||||
m_expanderWidth = calculator.GetExpanderWidth();
|
m_expanderWidth = calculator.GetExpanderWidth();
|
||||||
|
|
||||||
const bool isLast = pos == noOfColumns - 1;
|
[column setWidth:calculator.GetMaxWidth() + wxMax(0, m_expanderWidth)];
|
||||||
|
|
||||||
if ( isLast )
|
|
||||||
{
|
|
||||||
// Note that FitColumnWidthToContent() is called whenever a column is
|
|
||||||
// added, so we might also just temporarily become the last column;
|
|
||||||
// since we cannot know at this time whether we will just temporarily
|
|
||||||
// be the last column, we store our current column width in order to
|
|
||||||
// restore it later in case we suddenly are no longer the last column
|
|
||||||
// because new columns have been added --> we need to restore our
|
|
||||||
// previous width in that case because it must not get lost.
|
|
||||||
nativeData->SetPrevWidth(GetColumn(pos)->GetWidth());
|
|
||||||
|
|
||||||
[m_OutlineView sizeLastColumnToFit];
|
|
||||||
}
|
|
||||||
else if ( GetColumn(pos)->GetWidthVariable() == wxCOL_WIDTH_AUTOSIZE )
|
|
||||||
{
|
|
||||||
[column setWidth:calculator.GetMaxWidth() + m_expanderWidth];
|
|
||||||
}
|
|
||||||
else if ( nativeData->GetIsLast() )
|
|
||||||
{
|
|
||||||
[column setWidth:nativeData->GetPrevWidth()];
|
|
||||||
}
|
|
||||||
|
|
||||||
nativeData->SetIsLast(isLast);
|
|
||||||
|
|
||||||
if ( !(GetDataViewCtrl()->GetWindowStyle() & wxDV_VARIABLE_LINE_HEIGHT) )
|
|
||||||
{
|
|
||||||
int curHeight = ceil([m_OutlineView rowHeight]);
|
|
||||||
int rowHeight = calculator.GetMaxHeight();
|
|
||||||
if ( rowHeight > curHeight )
|
|
||||||
SetRowHeight(rowHeight);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@@ -302,7 +302,10 @@ void wxOSXDataViewModelNotifier::AdjustAutosizedColumns()
|
|||||||
unsigned count = m_DataViewCtrlPtr->GetColumnCount();
|
unsigned count = m_DataViewCtrlPtr->GetColumnCount();
|
||||||
for ( unsigned col = 0; col < count; col++ )
|
for ( unsigned col = 0; col < count; col++ )
|
||||||
{
|
{
|
||||||
m_DataViewCtrlPtr->GetDataViewPeer()->FitColumnWidthToContent(col);
|
wxDataViewColumn *column = m_DataViewCtrlPtr->GetColumnPtr(col);
|
||||||
|
|
||||||
|
if ( column->GetWidthVariable() == wxCOL_WIDTH_AUTOSIZE )
|
||||||
|
m_DataViewCtrlPtr->GetDataViewPeer()->FitColumnWidthToContent(col);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -438,9 +441,6 @@ bool wxDataViewCtrl::InsertColumn(unsigned int pos, wxDataViewColumn* columnPtr)
|
|||||||
// otherwise ask the control to 'update' the data in the newly appended column:
|
// otherwise ask the control to 'update' the data in the newly appended column:
|
||||||
if (GetColumnCount() == 1)
|
if (GetColumnCount() == 1)
|
||||||
SetExpanderColumn(columnPtr);
|
SetExpanderColumn(columnPtr);
|
||||||
|
|
||||||
AdjustAutosizedColumns();
|
|
||||||
|
|
||||||
// done:
|
// done:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -482,8 +482,6 @@ bool wxDataViewCtrl::DeleteColumn(wxDataViewColumn* columnPtr)
|
|||||||
{
|
{
|
||||||
m_ColumnPtrs.Remove(columnPtr);
|
m_ColumnPtrs.Remove(columnPtr);
|
||||||
delete columnPtr;
|
delete columnPtr;
|
||||||
|
|
||||||
AdjustAutosizedColumns();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Reference in New Issue
Block a user