Don't feed wxWidgets negative column widths.

This commit is contained in:
Jeff Young 2022-11-16 12:35:21 +00:00
parent b9ac486000
commit 1b3f03a800
12 changed files with 22 additions and 34 deletions

View File

@ -343,9 +343,9 @@ void DIALOG_CONFIGURE_PATHS::OnUpdateUI( wxUpdateUIEvent& event )
int width = m_EnvVars->GetClientRect().GetWidth();
m_EnvVars->AutoSizeColumn( TV_NAME_COL );
m_EnvVars->SetColSize( TV_NAME_COL, std::max( m_EnvVars->GetColSize( TV_NAME_COL ), 120 ) );
m_EnvVars->SetColSize( TV_NAME_COL, std::max( 72, m_EnvVars->GetColSize( TV_NAME_COL ) ) );
m_EnvVars->SetColSize( TV_VALUE_COL, width - m_EnvVars->GetColSize( TV_NAME_COL ) );
m_EnvVars->SetColSize( TV_VALUE_COL, std::max( 120, width - m_EnvVars->GetColSize( TV_NAME_COL ) ) );
m_gridWidth = m_EnvVars->GetSize().GetX();
m_gridWidthsDirty = false;

View File

@ -200,10 +200,9 @@ void PANEL_TEXT_VARIABLES::OnUpdateUI( wxUpdateUIEvent& event )
int width = m_TextVars->GetClientRect().GetWidth();
m_TextVars->AutoSizeColumn( TV_NAME_COL );
m_TextVars->SetColSize( TV_NAME_COL, std::max( m_TextVars->GetColSize( TV_NAME_COL ),
120 ) );
m_TextVars->SetColSize( TV_NAME_COL, std::max( 72, m_TextVars->GetColSize( TV_NAME_COL ) ) );
m_TextVars->SetColSize( TV_VALUE_COL, width - m_TextVars->GetColSize( TV_NAME_COL ) );
m_TextVars->SetColSize( TV_VALUE_COL, std::max( 120, width - m_TextVars->GetColSize( TV_NAME_COL ) ) );
m_gridWidthsDirty = false;
}

View File

@ -717,14 +717,14 @@ void DIALOG_LABEL_PROPERTIES::AdjustGridColumns( int aWidth )
aWidth -= ( m_grid->GetSize().x - m_grid->GetClientSize().x );
m_grid->AutoSizeColumn( 0 );
m_grid->SetColSize( 0, std::max( m_grid->GetColSize( 0 ), 72 ) );
m_grid->SetColSize( 0, std::max( 72, m_grid->GetColSize( 0 ) ) );
int fixedColsWidth = m_grid->GetColSize( 0 );
for( int i = 2; i < m_grid->GetNumberCols(); i++ )
fixedColsWidth += m_grid->GetColSize( i );
m_grid->SetColSize( 1, std::max( aWidth - fixedColsWidth, 120 ) );
m_grid->SetColSize( 1, std::max( 120, aWidth - fixedColsWidth ) );
}

View File

@ -716,13 +716,14 @@ void DIALOG_LIB_SYMBOL_PROPERTIES::adjustGridColumns()
int width = KIPLATFORM::UI::GetUnobscuredSize( m_grid ).x;
m_grid->AutoSizeColumn( FDC_NAME );
m_grid->SetColSize( FDC_NAME, std::max( 72, m_grid->GetColSize( FDC_NAME ) ) );
int fixedColsWidth = m_grid->GetColSize( FDC_NAME );
for( int i = 2; i < m_grid->GetNumberCols(); i++ )
fixedColsWidth += m_grid->GetColSize( i );
m_grid->SetColSize( FDC_VALUE, width - fixedColsWidth );
m_grid->SetColSize( FDC_VALUE, std::max( 120, width - fixedColsWidth ) );
}

View File

@ -821,16 +821,14 @@ void DIALOG_SHEET_PROPERTIES::AdjustGridColumns()
int width = KIPLATFORM::UI::GetUnobscuredSize( m_grid ).x;
m_grid->AutoSizeColumn( 0 );
m_grid->SetColSize( 0, std::max( 72, m_grid->GetColSize( 0 ) ) );
int fixedColsWidth = m_grid->GetColSize( 0 );
for( int i = 2; i < m_grid->GetNumberCols(); i++ )
fixedColsWidth += m_grid->GetColSize( i );
int colSize = std::max( width - fixedColsWidth, -1 );
colSize = ( colSize == 0 ) ? -1 : colSize; // don't hide the column!
m_grid->SetColSize( 1, colSize );
m_grid->SetColSize( 1, std::max( 120, width - fixedColsWidth ) );
}

View File

@ -1064,16 +1064,14 @@ void DIALOG_SYMBOL_PROPERTIES::AdjustFieldsGridColumns()
int fieldsWidth = KIPLATFORM::UI::GetUnobscuredSize( m_fieldsGrid ).x;
m_fieldsGrid->AutoSizeColumn( 0 );
m_fieldsGrid->SetColSize( 0, std::max( 72, m_fieldsGrid->GetColSize( 0 ) ) );
int fixedColsWidth = m_fieldsGrid->GetColSize( 0 );
for( int i = 2; i < m_fieldsGrid->GetNumberCols(); i++ )
fixedColsWidth += m_fieldsGrid->GetColSize( i );
int colSize = std::max( fieldsWidth - fixedColsWidth, -1 );
colSize = ( colSize == 0 ) ? -1 : colSize; // don't hide the column!
m_fieldsGrid->SetColSize( 1, colSize );
m_fieldsGrid->SetColSize( 1, std::max( 120, fieldsWidth - fixedColsWidth ) );
}

View File

@ -972,13 +972,8 @@ void PANEL_SYM_LIB_TABLE::adjustPathSubsGridColumns( int aWidth )
aWidth -= ( m_path_subs_grid->GetSize().x - m_path_subs_grid->GetClientSize().x );
m_path_subs_grid->AutoSizeColumn( 0 );
int remaining_width = aWidth - m_path_subs_grid->GetColSize( 0 );
if( remaining_width < 0 )
m_path_subs_grid->SetColSize( 1, -1 );
else
m_path_subs_grid->SetColSize( 1, remaining_width );
m_path_subs_grid->SetColSize( 0, std::max( 72, m_path_subs_grid->GetColSize( 0 ) ) );
m_path_subs_grid->SetColSize( 1, std::max( 120, aWidth - m_path_subs_grid->GetColSize( 0 ) ) );
}

View File

@ -233,7 +233,7 @@ void PANEL_TEMPLATE_FIELDNAMES::AdjustGridColumns( int aWidth )
// Account for scroll bars
aWidth -= ( m_grid->GetSize().x - m_grid->GetClientSize().x );
m_grid->SetColSize( 0, std::max( 40, aWidth - 2 * m_checkboxColWidth ) );
m_grid->SetColSize( 0, std::max( 72, aWidth - 2 * m_checkboxColWidth ) );
m_grid->SetColSize( 1, m_checkboxColWidth );
m_grid->SetColSize( 2, m_checkboxColWidth );
}

View File

@ -276,9 +276,9 @@ private:
int width = m_grid->GetClientRect().GetWidth();
m_grid->AutoSizeColumn( 0 );
m_grid->SetColSize( 0, std::max( 120, m_grid->GetColSize( 0 ) ) );
m_grid->SetColSize( 0, std::max( 72, m_grid->GetColSize( 0 ) ) );
m_grid->SetColSize( 1, width - m_grid->GetColSize( 0 ) );
m_grid->SetColSize( 1, std::max( 120, width - m_grid->GetColSize( 0 ) ) );
m_grid_widths_dirty = false;
}

View File

@ -452,7 +452,7 @@ void DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::AdjustNetclassGridColumns( int aWidth )
aWidth -= m_originalColWidths[ i ];
}
m_netclassGrid->SetColSize( 0, aWidth );
m_netclassGrid->SetColSize( 0, std::max( 72, aWidth ) );
}

View File

@ -146,8 +146,8 @@ void DIALOG_SWAP_LAYERS::adjustGridColumns()
// Account for scroll bars
int width = KIPLATFORM::UI::GetUnobscuredSize( m_grid ).x;
m_grid->SetColSize( 0, width / 2 );
m_grid->SetColSize( 1, width - m_grid->GetColSize( 0 ) );
m_grid->SetColSize( 0, std::max( 40, width / 2 ) );
m_grid->SetColSize( 1, std::max( 40, width - m_grid->GetColSize( 0 ) ) );
}

View File

@ -954,11 +954,8 @@ void PANEL_FP_LIB_TABLE::adjustPathSubsGridColumns( int aWidth )
aWidth -= ( m_path_subs_grid->GetSize().x - m_path_subs_grid->GetClientSize().x );
m_path_subs_grid->AutoSizeColumn( 0 );
if( aWidth - m_path_subs_grid->GetColSize( 0 ) < 60 )
m_path_subs_grid->SetColSize( 0, aWidth / 2 );
m_path_subs_grid->SetColSize( 1, aWidth - m_path_subs_grid->GetColSize( 0 ) );
m_path_subs_grid->SetColSize( 0, std::max( 72, m_path_subs_grid->GetColSize( 0 ) ) );
m_path_subs_grid->SetColSize( 1, std::max( 120, aWidth - m_path_subs_grid->GetColSize( 0 ) ) );
}