484_uppsrc2_r6303.diff

The diff file to apply for uppsrc directory (second version for r6303) - Sender Ghost, 09/04/2013 02:57 AM

Download (3.22 KB)

View differences:

uppsrc/ide/LayDes/laydes.cpp 2013-09-04 04:38:44 +0400
1297 1297
	ReloadItems();
1298 1298
}
1299 1299

  
1300
bool RectTopLeftLess(const Rect& a, const Rect& b)
1301
{
1302
	if(a.top < b.top)
1303
		return true;
1304
	if(a.top == b.top)
1305
		return a.left < b.left;
1306
	return false;
1307
}
1308

  
1309
void LayDes::SortTopLeftItems()
1310
{
1311
	SaveState();
1312
	int count = cursor.GetCount();
1313
	if(currentlayout < 0 || count < 2)
1314
		return;
1315
	LayoutData& l = CurrentLayout();
1316
	Array<LayoutItem> item;
1317
	item.SetCount(count);
1318
	Vector<Rect> rect;
1319
	rect.SetCount(count);
1320
	Vector<int> order;
1321
	order <<= cursor;
1322
	for(int i = 0; i < count; ++i) {
1323
		rect[i] = CtrlRect(l.item[cursor[i]].pos, l.size);
1324
		item[i] = l.item[cursor[i]];
1325
	}
1326
	IndexSort2(rect, order, item, &RectTopLeftLess);
1327
	int q = FindIndex(order, cursor.Top());
1328
	Sort(cursor);
1329
	l.item.Remove(cursor);
1330
	int ii = cursor[0];
1331
	l.item.InsertPick(ii, item);
1332
	cursor.Clear();
1333
	for(int i = 0; i < count; ++i)
1334
		cursor.Add(i + ii);
1335
	if(q >= 0 && q != count - 1)
1336
		Swap(cursor.Top(), cursor[q]);
1337
	ReloadItems();
1338
}
1339

  
1300 1340
void LayDes::Flush()
1301 1341
{
1302 1342
	currentlayout = -1;
......
1489 1529
		}
1490 1530
	}
1491 1531
	else if(item.IsCursor()) {
1492
		if(!GetCtrl())
1532
		int c = item.GetCursor();
1533
		if(!GetCtrl()) {
1493 1534
			cursor.Clear();
1494
		cursor.Add(item.GetCursor());
1535
			cursor.Add(c);
1536
		}
1537
		else {
1538
			int q = FindIndex(cursor, c);
1539
			if(q >= 0)
1540
				cursor.Remove(q);
1541
			else
1542
				cursor.Add(c);
1543
		}
1495 1544
	}
1496 1545
	SetFocus();
1497 1546
	SyncItems();
uppsrc/ide/LayDes/LayDes.h 2013-09-04 04:36:31 +0400
385 385
	void        MoveUp();
386 386
	void        MoveDown();
387 387
	void        SortItems();
388
	void        SortTopLeftItems();
388 389
	void        SelectAll();
389 390

  
390 391
	void        Matrix();
uppsrc/ide/LayDes/laydes.key 2013-09-04 04:33:39 +0400
3 3
KEY(MOVEUP, "Move Up", K_CTRL_UP)
4 4
KEY(MOVEDOWN, "Move Down", K_CTRL_DOWN)
5 5
KEY(SORTITEMS, "Sort by position", 0)
6
KEY(SORTTOPLEFTITEMS, "Sort by top-left position", 0)
6 7
KEY(LAYOUTS, "Layouts..", 0)
7 8
KEY(PREVLAYOUT, "Previous layout", K_ALT_PAGEUP)
8 9
KEY(NEXTLAYOUT, "Next layout", K_ALT_PAGEDOWN)
uppsrc/ide/LayDes/laywin.cpp 2013-09-04 04:43:05 +0400
48 48
	bool iscursor = currentlayout >= 0 && cursor.GetCount();
49 49
	bar.Add(iscursor, AK_MOVEUP, LayImg::MoveUp(), THISBACK(MoveUp));
50 50
	bar.Add(iscursor, AK_MOVEDOWN, LayImg::MoveDown(), THISBACK(MoveDown));
51
	bar.Add(cursor.GetCount() >= 2, AK_SORTITEMS, LayImg::SortItems(), THISBACK(SortItems));
51
	bar.Separator();
52
	bool sortable = cursor.GetCount() >= 2;
53
	bar.Add(sortable, AK_SORTITEMS, LayImg::SortItems(), THISBACK(SortItems));
54
	bar.Add(sortable, AK_SORTTOPLEFTITEMS, LayImg::SortItems(), THISBACK(SortTopLeftItems));
52 55
}
53 56

  
54 57
void LayDes::AlignBar(Bar& bar)