mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
ide: IconDes now can reorganize order by d&d
git-svn-id: svn://ultimatepp.org/upp/trunk@9263 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
1b18bfd501
commit
79f59ad163
5 changed files with 60 additions and 55 deletions
|
|
@ -299,6 +299,9 @@ IconDes::IconDes()
|
|||
ilist.WhenCursor = THISBACK(ListCursor);
|
||||
ilist.WhenLeftDouble = THISBACK(EditImage);
|
||||
ilist.NoWantFocus();
|
||||
|
||||
ilist.WhenDrag = THISBACK(Drag);
|
||||
ilist.WhenDropInsert = THISBACK(DnDInsert);
|
||||
|
||||
search <<= THISBACK(Search);
|
||||
search.SetFilter(CharFilterToUpper);
|
||||
|
|
|
|||
|
|
@ -333,6 +333,8 @@ private:
|
|||
void InsertIml();
|
||||
void MoveSlot(int d);
|
||||
void ChangeSlot(int d);
|
||||
void DnDInsert(int line, PasteClip& d);
|
||||
void Drag();
|
||||
|
||||
static FileSel& ImgFile();
|
||||
|
||||
|
|
|
|||
|
|
@ -365,20 +365,6 @@ void IconDes::RemoveImage()
|
|||
ilist.GoEnd();
|
||||
}
|
||||
|
||||
void IconDes::MoveSlot(int d)
|
||||
{
|
||||
if(!IsCurrent())
|
||||
return;
|
||||
int c = ilist.GetKey();
|
||||
d = c + d;
|
||||
if(d >= 0 && d < slot.GetCount()) {
|
||||
slot.Swap(c, d);
|
||||
search <<= Null;
|
||||
SyncList();
|
||||
GoTo(d);
|
||||
}
|
||||
}
|
||||
|
||||
void IconDes::ChangeSlot(int d)
|
||||
{
|
||||
if(!IsCurrent())
|
||||
|
|
@ -483,4 +469,37 @@ bool IconDes::GetExport(int ii) const
|
|||
return slot[ii].exp;
|
||||
}
|
||||
|
||||
void IconDes::MoveSlot(int d)
|
||||
{
|
||||
if(!IsCurrent())
|
||||
return;
|
||||
int c = ilist.GetKey();
|
||||
d = c + d;
|
||||
if(d >= 0 && d < slot.GetCount()) {
|
||||
slot.Swap(c, d);
|
||||
search <<= Null;
|
||||
SyncList();
|
||||
GoTo(d);
|
||||
}
|
||||
}
|
||||
|
||||
void IconDes::DnDInsert(int line, PasteClip& d)
|
||||
{
|
||||
if(GetInternalPtr<ArrayCtrl>(d, "icondes-icon") == &ilist && IsCurrent() &&
|
||||
line >= 0 && line <= slot.GetCount() && d.Accept()) {
|
||||
int c = ilist.GetKey();
|
||||
slot.Move(c, line);
|
||||
if(c <= line)
|
||||
line--;
|
||||
search <<= Null;
|
||||
SyncList();
|
||||
GoTo(line);
|
||||
}
|
||||
}
|
||||
|
||||
void IconDes::Drag()
|
||||
{
|
||||
ilist.DoDragAndDrop(InternalClip(ilist, "icondes-icon"), ilist.GetDragSample(), DND_MOVE);
|
||||
}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -337,8 +337,8 @@ struct WorkspaceWork {
|
|||
void SaveLoadPackageNS(bool sel = true);
|
||||
void TouchFile(const String& path);
|
||||
|
||||
void DoMove(int b, bool drag);
|
||||
void MoveFile(int d);
|
||||
void Move(Vector<String>& v, FileList& ta, int d);
|
||||
|
||||
void DnDInsert(int line, PasteClip& d);
|
||||
void Drag();
|
||||
|
|
|
|||
|
|
@ -959,15 +959,6 @@ void WorkspaceWork::AddNormalUses()
|
|||
SaveLoadPackage();
|
||||
}
|
||||
|
||||
void WorkspaceWork::Move(Vector<String>& v, FileList& ta, int d)
|
||||
{
|
||||
int i = ta.GetCursor();
|
||||
if(i < 0 || i + d < 0 || i + d > v.GetCount() - 1) return;
|
||||
Swap(v[i], v[i + d]);
|
||||
SaveLoadPackage();
|
||||
ta.SetCursor(i + d);
|
||||
}
|
||||
|
||||
void WorkspaceWork::RemovePackageMenu(Bar& bar)
|
||||
{
|
||||
if(bar.IsScanKeys() || bar.IsScanHelp() || !bar.IsMenuBar())
|
||||
|
|
@ -1093,19 +1084,25 @@ void WorkspaceWork::PackageMenu(Bar& menu)
|
|||
}
|
||||
}
|
||||
|
||||
void WorkspaceWork::MoveFile(int d)
|
||||
void WorkspaceWork::DoMove(int b, bool drag)
|
||||
{
|
||||
int fi = filelist.GetCursor();
|
||||
int s = filelist.GetSbPos();
|
||||
if(fi < 0 || fi >= fileindex.GetCount())
|
||||
return;
|
||||
int a = fileindex[fi];
|
||||
int b = fileindex[fi + d];
|
||||
if(a < 0 || a >= actual.file.GetCount() || b < 0 || b >= actual.file.GetCount())
|
||||
if(a < 0 || b < 0 || a >= actual.file.GetCount() ||
|
||||
(drag ? b > actual.file.GetCount() : b >= actual.file.GetCount()))
|
||||
return;
|
||||
int s = filelist.GetSbPos();
|
||||
ShowFile(a);
|
||||
ShowFile(b);
|
||||
Swap(actual.file[a], actual.file[b]);
|
||||
if(drag) {
|
||||
actual.file.Move(a, b);
|
||||
if(b >= a)
|
||||
b--;
|
||||
}
|
||||
else
|
||||
Swap(actual.file[a], actual.file[b]);
|
||||
ShowFile(a);
|
||||
ShowFile(b);
|
||||
SavePackage();
|
||||
|
|
@ -1119,36 +1116,20 @@ void WorkspaceWork::MoveFile(int d)
|
|||
filelist.Sync();
|
||||
}
|
||||
|
||||
void WorkspaceWork::MoveFile(int d)
|
||||
{
|
||||
int bi = filelist.GetCursor() + d;
|
||||
if(bi < 0 || bi >= fileindex.GetCount())
|
||||
return;
|
||||
DoMove(fileindex[bi], false);
|
||||
}
|
||||
|
||||
void WorkspaceWork::DnDInsert(int line, PasteClip& d)
|
||||
{
|
||||
if(GetActivePackage() == METAPACKAGE)
|
||||
return;
|
||||
if(GetInternalPtr<UppList>(d, "package-file") == &filelist && d.Accept()) {
|
||||
int fi = filelist.GetCursor();
|
||||
int s = filelist.GetSbPos();
|
||||
if(fi < 0 || fi > fileindex.GetCount() || line < 0 || line > fileindex.GetCount())
|
||||
return;
|
||||
int a = fileindex[fi];
|
||||
int b = line < fileindex.GetCount() ? fileindex[line] : actual.file.GetCount();
|
||||
if(a < 0 || a > actual.file.GetCount() || b < 0 || b > actual.file.GetCount() || a == b)
|
||||
return;
|
||||
ShowFile(a);
|
||||
ShowFile(b);
|
||||
actual.file.Move(a, b);
|
||||
if(b >= a)
|
||||
b--;
|
||||
ShowFile(a);
|
||||
ShowFile(b);
|
||||
SavePackage();
|
||||
LoadActualPackage();
|
||||
filelist.SetSbPos(s);
|
||||
for(int i = 0; i < fileindex.GetCount(); i++)
|
||||
if(fileindex[i] == b) {
|
||||
filelist.SetCursor(i);
|
||||
break;
|
||||
}
|
||||
filelist.Sync();
|
||||
}
|
||||
if(GetInternalPtr<UppList>(d, "package-file") == &filelist && d.Accept())
|
||||
DoMove(line < fileindex.GetCount() ? fileindex[line] : actual.file.GetCount(), true);
|
||||
}
|
||||
|
||||
void WorkspaceWork::Drag()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue