From ded21fe5d2c4a3bd7351f65daabffda52a73e7b2 Mon Sep 17 00:00:00 2001 From: cxl Date: Mon, 2 Sep 2013 13:05:51 +0000 Subject: [PATCH] ide: Layout Designer sorting of items improved #484 git-svn-id: svn://ultimatepp.org/upp/trunk@6303 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/ide/LayDes/laydes.cpp | 41 +++++++++++++++++++++++------------ uppsrc/ide/icon.ico | Bin 2862 -> 2862 bytes 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/uppsrc/ide/LayDes/laydes.cpp b/uppsrc/ide/LayDes/laydes.cpp index 3834b66c9..6b7b465c0 100644 --- a/uppsrc/ide/LayDes/laydes.cpp +++ b/uppsrc/ide/LayDes/laydes.cpp @@ -1263,23 +1263,36 @@ void LayDes::SortItems() if(currentlayout < 0 || cursor.GetCount() < 2) return; LayoutData& l = CurrentLayout(); - Vector sc(cursor, 1); - Sort(sc); - int count = sc.GetCount(); + Sort(cursor); + int count = cursor.GetCount(); + + Array item; Vector rect; - for(int i = 0; i < count; ++i) - rect.Add(CtrlRect(l.item[sc[i]].pos, l.size)); - - // Use selection sort as RectLess is not transitive - for(int i = 0; i < count - 1; i++) { - int ii = i; - for(int j = i + 1; j < count; j++) - if(RectLess(rect[j], rect[ii])) - ii = j; - Swap(rect[i], rect[ii]); - Swap(l.item[sc[i]], l.item[sc[ii]]); + for(int i = 0; i < count; ++i) { + rect.Add(CtrlRect(l.item[cursor[i]].pos, l.size)); + item.Add() = l.item[cursor[i]]; } + l.item.Remove(cursor); + + bool swap = false; + do { + swap = false; + for(int i = 0; i < count - 1; i++) + if(RectLess(rect[i + 1], rect[i])) { + Swap(rect[i], rect[i + 1]); + Swap(item[i], item[i + 1]); + swap = true; + } + } + while(swap); + + int ii = cursor[0]; + l.item.InsertPick(ii, item); + + cursor.Clear(); + for(int i = 0; i < count; i++) + cursor.Add(i + ii); ReloadItems(); } diff --git a/uppsrc/ide/icon.ico b/uppsrc/ide/icon.ico index ed674dab4681e8f6a8a54a9f03063eb6fa681734..4cff9502574c41f1a9581c6a4b36e1faac662d5c 100644 GIT binary patch literal 2862 zcmeHJF;2uV5ZuJEV^P5iKr~#5bcmV)cmUG90D-6}pgoBKI)1=gQqa)z93(Tdj-8yj zLnnbK(5?kwy51SBF9+e+={%Qmhwp@;(h0t}K`Wjk_o6qNgPCWTZgZa3(WRO4uBRaWU^%}ZADoMNG>wby>KEB1#TZX8^Os;o zBXG`qV!ck0qrc+(sk5BVpOCtI-!=Fu(&OVfkQ@2z<+B-29@qWM@vOKXv4h4?*IB;u z%gPtM67U;2-|S;oq%(uhafg&X?sH8Jxr_IV*O5-ZFU{ADJU={&4~@LPzKO4cv=9iW z2h@1v=eJiI-<-kbKkyI#1Lb|NB6kLNOK+yC#5p4fYTjCDofA8{UfR}WxB<6rTVaGD zAg>p5Ti2`r* literal 2862 zcmcguy^hmB5FVe6&r5ZbRGhBi%1A*-bS~fpkW!{XLOcPqktm=;5ONncJc|n&dL9SK z%r~>MyIv(Ax_gv?&&u`C@p-JWu9xe$V{Dvm1|32wvRx2)vN^dYuEXibpQYChc7JzGs~k&O>eF zh;ivrj znzMnq@~@I5GgoKHByJ@fk-2k@3l=3x}0T#}c*!0~^0%p>-E z==`)U?roltBjzN=Zjj0R{pirX?}J}6|7`;*Zcc*Nr%%t*IbyFqa>;Dt$+{cOibLU> z7#^`i6}5MD$4On5p|C6pSJ$OuBhs|3Th_H}y^r8>S!>d{lEuxIOKcERe>V2p+062S zYulOO9r!C&;}^e5{HAebRk1F-*I2iU?+etkeI@qu`sMZoGV5npGr8-W F{sOt@+Oq%v