mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-04 14:39:08 +02:00
Make RuleTable scrollable & DnD move instead of copy
Having lots of rules in RuleTable may lead to an assertion failure on opening preferences dialog: > assert "sz.x <= 1000 && sz.y <= 750" failed in > PrefsDialog::PrefsDialog(): Preferences dialog exceeds max size This change will make the RuleTable scrollable (as it is/was when creating many rules) instead of expanding the dialog size. Further I had to fix the calculation of the clicked row from the given coords. Even without this proposed change for scrolling, the calculated row has always been the one above the clicked row - maybe this changed in wxWidgets 3.0. Now it uses CalcUnscrolledPosition() which seems to work fine even without scrolling. Last change is for drag and drop mode: rules are not being copied, but moved on dnd - I changed this to reflect this mode on the cursor while dragging an item.
This commit is contained in:
parent
df2de94f6b
commit
ce09f4b883
@ -113,7 +113,9 @@ void ExtImportPrefs::PopulateOrExchange(ShuttleGui & S)
|
|||||||
#endif
|
#endif
|
||||||
RuleTable->SetRowLabelSize (0);
|
RuleTable->SetRowLabelSize (0);
|
||||||
RuleTable->SetSelectionMode (wxGrid::wxGridSelectRows);
|
RuleTable->SetSelectionMode (wxGrid::wxGridSelectRows);
|
||||||
RuleTable->AutoSizeColumns ();
|
// call SetMinSize to enable scrolling on large content
|
||||||
|
RuleTable->Fit();
|
||||||
|
RuleTable->SetMinSize(RuleTable->GetSize());
|
||||||
|
|
||||||
ExtImportPrefsDropTarget *dragtarget1 {};
|
ExtImportPrefsDropTarget *dragtarget1 {};
|
||||||
RuleTable->SetDropTarget (
|
RuleTable->SetDropTarget (
|
||||||
@ -330,7 +332,7 @@ void ExtImportPrefs::OnPluginBeginDrag(wxListEvent& WXUNUSED(event))
|
|||||||
dragtext2->SetText(wxT(""));
|
dragtext2->SetText(wxT(""));
|
||||||
dragSource.SetData(*dragtext2);
|
dragSource.SetData(*dragtext2);
|
||||||
mDragFocus = PluginList;
|
mDragFocus = PluginList;
|
||||||
wxDragResult result = dragSource.DoDragDrop(TRUE);
|
wxDragResult result = dragSource.DoDragDrop(wxDrag_DefaultMove);
|
||||||
mDragFocus = NULL;
|
mDragFocus = NULL;
|
||||||
switch (result)
|
switch (result)
|
||||||
{
|
{
|
||||||
@ -644,7 +646,7 @@ void ExtImportPrefs::OnRuleTableCellClick (wxGridEvent& event)
|
|||||||
dragtext1->SetText(wxT(""));
|
dragtext1->SetText(wxT(""));
|
||||||
dragSource.SetData(*dragtext1);
|
dragSource.SetData(*dragtext1);
|
||||||
mDragFocus = RuleTable;
|
mDragFocus = RuleTable;
|
||||||
wxDragResult result = dragSource.DoDragDrop(TRUE);
|
wxDragResult result = dragSource.DoDragDrop(wxDrag_DefaultMove);
|
||||||
mDragFocus = NULL;
|
mDragFocus = NULL;
|
||||||
switch (result)
|
switch (result)
|
||||||
{
|
{
|
||||||
@ -711,8 +713,8 @@ bool ExtImportPrefsDropTarget::OnDrop(wxCoord x, wxCoord y)
|
|||||||
Grid *RuleTable = mPrefs->GetRuleTable();
|
Grid *RuleTable = mPrefs->GetRuleTable();
|
||||||
if (mPrefs->GetDragFocus() == RuleTable)
|
if (mPrefs->GetDragFocus() == RuleTable)
|
||||||
{
|
{
|
||||||
if (RuleTable->YToRow (y -
|
if (RuleTable->YToRow(
|
||||||
RuleTable->GetColLabelSize ()) == wxNOT_FOUND)
|
RuleTable->CalcUnscrolledPosition(wxPoint(x, y)).y) == wxNOT_FOUND)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (mPrefs->GetDragFocus() == PluginList)
|
else if (mPrefs->GetDragFocus() == PluginList)
|
||||||
@ -746,8 +748,7 @@ wxDragResult ExtImportPrefsDropTarget::OnDragOver(wxCoord x, wxCoord y,
|
|||||||
if (mPrefs->GetDragFocus() == RuleTable)
|
if (mPrefs->GetDragFocus() == RuleTable)
|
||||||
{
|
{
|
||||||
int row;
|
int row;
|
||||||
row = RuleTable->YToRow (y -
|
row = RuleTable->YToRow(RuleTable->CalcUnscrolledPosition(wxPoint(x, y)).y);
|
||||||
RuleTable->GetColLabelSize ());
|
|
||||||
if (row == wxNOT_FOUND)
|
if (row == wxNOT_FOUND)
|
||||||
return wxDragNone;
|
return wxDragNone;
|
||||||
|
|
||||||
@ -785,7 +786,7 @@ wxDragResult ExtImportPrefsDropTarget::OnDragOver(wxCoord x, wxCoord y,
|
|||||||
wxLIST_STATE_SELECTED);
|
wxLIST_STATE_SELECTED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return wxDragCopy;
|
return wxDragMove;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExtImportPrefsDropTarget::OnLeave()
|
void ExtImportPrefsDropTarget::OnLeave()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user