1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
|
/**
* @file llfolderview.cpp
* @brief Implementation of the folder view collection of classes.
*
* $LicenseInfo:firstyear=2001&license=viewergpl$
*
* Copyright (c) 2001-2009, Linden Research, Inc.
*
* Second Life Viewer Source Code
* The source code in this file ("Source Code") is provided by Linden Lab
* to you under the terms of the GNU General Public License, version 2.0
* ("GPL"), unless you have obtained a separate licensing agreement
* ("Other License"), formally executed by you and Linden Lab. Terms of
* the GPL can be found in doc/GPL-license.txt in this distribution, or
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
*
* There are special exceptions to the terms and conditions of the GPL as
* it is applied to this Source Code. View the full text of the exception
* in the file doc/FLOSS-exception.txt in this software distribution, or
* online at
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
*
* By copying, modifying or distributing this software, you acknowledge
* that you have read and understood your obligations described above,
* and agree to abide by those obligations.
*
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
* COMPLETENESS OR PERFORMANCE.
* $/LicenseInfo$
*/
#include "llviewerprecompiledheaders.h"
#include "llfolderview.h"
#include "llcallbacklist.h"
#include "llinventorybridge.h"
#include "llinventoryclipboard.h" // *TODO: remove this once hack below gone.
#include "llinventoryfilter.h"
#include "llfoldertype.h"
#include "llfloaterinventory.h"// hacked in for the bonus context menu items.
#include "llkeyboard.h"
#include "lllineeditor.h"
#include "llmenugl.h"
#include "llpreview.h"
#include "llscrollcontainer.h" // hack to allow scrolling
#include "lltooldraganddrop.h"
#include "lltrans.h"
#include "llui.h"
#include "llviewertexture.h"
#include "llviewertexturelist.h"
#include "llviewerjointattachment.h"
#include "llviewermenu.h"
#include "lluictrlfactory.h"
#include "llviewercontrol.h"
#include "llviewerwindow.h"
#include "llvoavatar.h"
#include "llfloaterproperties.h"
// Linden library includes
#include "lldbstrings.h"
#include "llfocusmgr.h"
#include "llfontgl.h"
#include "llgl.h"
#include "llrender.h"
#include "llinventory.h"
// Third-party library includes
#include <algorithm>
///----------------------------------------------------------------------------
/// Local function declarations, constants, enums, and typedefs
///----------------------------------------------------------------------------
const S32 RENAME_WIDTH_PAD = 4;
const S32 RENAME_HEIGHT_PAD = 2;
const S32 AUTO_OPEN_STACK_DEPTH = 16;
const S32 MIN_ITEM_WIDTH_VISIBLE = LLFolderViewItem::ICON_WIDTH
+ LLFolderViewItem::ICON_PAD
+ LLFolderViewItem::ARROW_SIZE
+ LLFolderViewItem::TEXT_PAD
+ /*first few characters*/ 40;
const S32 MINIMUM_RENAMER_WIDTH = 80;
enum {
SIGNAL_NO_KEYBOARD_FOCUS = 1,
SIGNAL_KEYBOARD_FOCUS = 2
};
F32 LLFolderView::sAutoOpenTime = 1.f;
void delete_selected_item(void* user_data);
void copy_selected_item(void* user_data);
void open_selected_items(void* user_data);
void properties_selected_items(void* user_data);
void paste_items(void* user_data);
void renamer_focus_lost( LLFocusableElement* handler, void* user_data );
//---------------------------------------------------------------------------
// Tells all folders in a folderview to sort their items
// (and only their items, not folders) by a certain function.
class LLSetItemSortFunction : public LLFolderViewFunctor
{
public:
LLSetItemSortFunction(U32 ordering)
: mSortOrder(ordering) {}
virtual ~LLSetItemSortFunction() {}
virtual void doFolder(LLFolderViewFolder* folder);
virtual void doItem(LLFolderViewItem* item);
U32 mSortOrder;
};
// Set the sort order.
void LLSetItemSortFunction::doFolder(LLFolderViewFolder* folder)
{
folder->setItemSortOrder(mSortOrder);
}
// Do nothing.
void LLSetItemSortFunction::doItem(LLFolderViewItem* item)
{
return;
}
//---------------------------------------------------------------------------
// Tells all folders in a folderview to close themselves
// For efficiency, calls setOpenArrangeRecursively().
// The calling function must then call:
// LLFolderView* root = getRoot();
// if( root )
// {
// root->arrange( NULL, NULL );
// root->scrollToShowSelection();
// }
// to patch things up.
class LLCloseAllFoldersFunctor : public LLFolderViewFunctor
{
public:
LLCloseAllFoldersFunctor(BOOL close) { mOpen = !close; }
virtual ~LLCloseAllFoldersFunctor() {}
virtual void doFolder(LLFolderViewFolder* folder);
virtual void doItem(LLFolderViewItem* item);
BOOL mOpen;
};
// Set the sort order.
void LLCloseAllFoldersFunctor::doFolder(LLFolderViewFolder* folder)
{
folder->setOpenArrangeRecursively(mOpen);
}
// Do nothing.
void LLCloseAllFoldersFunctor::doItem(LLFolderViewItem* item)
{ }
///----------------------------------------------------------------------------
/// Class LLFolderView
///----------------------------------------------------------------------------
// Default constructor
LLFolderView::LLFolderView(const Params& p)
: LLFolderViewFolder(p),
mScrollContainer( NULL ),
mPopupMenuHandle(),
mAllowMultiSelect(TRUE),
mShowFolderHierarchy(FALSE),
mSourceID(p.task_id),
mRenameItem( NULL ),
mNeedsScroll( FALSE ),
mPinningSelectedItem(FALSE),
mNeedsAutoSelect( FALSE ),
mAutoSelectOverride(FALSE),
mNeedsAutoRename(FALSE),
mDebugFilters(FALSE),
mSortOrder(LLInventoryFilter::SO_FOLDERS_BY_NAME), // This gets overridden by a pref immediately
mFilter( new LLInventoryFilter(p.name) ),
mShowSelectionContext(FALSE),
mShowSingleSelection(FALSE),
mArrangeGeneration(0),
mSignalSelectCallback(0),
mMinWidth(0),
mDragAndDropThisFrame(FALSE),
mCallbackRegistrar(NULL),
mParentPanel(p.parent_panel)
, mUseEllipses(false)
, mDraggingOverItem(NULL)
{
LLRect rect = p.rect;
LLRect new_rect(rect.mLeft, rect.mBottom + getRect().getHeight(), rect.mLeft + getRect().getWidth(), rect.mBottom);
setRect( rect );
reshape(rect.getWidth(), rect.getHeight());
mIsOpen = TRUE; // this view is always open.
mAutoOpenItems.setDepth(AUTO_OPEN_STACK_DEPTH);
mAutoOpenCandidate = NULL;
mAutoOpenTimer.stop();
mKeyboardSelection = FALSE;
mIndentation = -LEFT_INDENTATION; // children start at indentation 0
gIdleCallbacks.addFunction(idle, this);
//clear label
// go ahead and render root folder as usual
// just make sure the label ("Inventory Folder") never shows up
mLabel = LLStringUtil::null;
//mRenamer->setWriteableBgColor(LLColor4::white);
// Escape is handled by reverting the rename, not commiting it (default behavior)
LLLineEditor::Params params;
params.name("ren");
params.rect(getRect());
params.font(getLabelFontForStyle(LLFontGL::NORMAL));
params.max_length_bytes(DB_INV_ITEM_NAME_STR_LEN);
params.commit_callback.function(boost::bind(&LLFolderView::commitRename, this, _2));
params.prevalidate_callback(&LLLineEditor::prevalidatePrintableNotPipe);
params.commit_on_focus_lost(true);
params.visible(false);
mRenamer = LLUICtrlFactory::create<LLLineEditor> (params);
addChild(mRenamer);
// make the popup menu available
LLMenuGL* menu = LLUICtrlFactory::getInstance()->createFromFile<LLMenuGL>("menu_inventory.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance());
if (!menu)
{
menu = LLUICtrlFactory::getDefaultWidget<LLMenuGL>("inventory_menu");
}
menu->setBackgroundColor(LLUIColorTable::instance().getColor("MenuPopupBgColor"));
mPopupMenuHandle = menu->getHandle();
}
// Destroys the object
LLFolderView::~LLFolderView( void )
{
// The release focus call can potentially call the
// scrollcontainer, which can potentially be called with a partly
// destroyed scollcontainer. Just null it out here, and no worries
// about calling into the invalid scroll container.
// Same with the renamer.
mScrollContainer = NULL;
mRenameItem = NULL;
mRenamer = NULL;
if( gEditMenuHandler == this )
{
gEditMenuHandler = NULL;
}
mAutoOpenItems.removeAllNodes();
gIdleCallbacks.deleteFunction(idle, this);
LLView::deleteViewByHandle(mPopupMenuHandle);
if(mRenamer == gFocusMgr.getTopCtrl())
{
gFocusMgr.setTopCtrl(NULL);
}
mAutoOpenItems.removeAllNodes();
clearSelection();
mItems.clear();
mFolders.clear();
mItemMap.clear();
delete mFilter;
mFilter = NULL;
}
BOOL LLFolderView::canFocusChildren() const
{
return FALSE;
}
void LLFolderView::checkTreeResortForModelChanged()
{
if (mSortOrder & LLInventoryFilter::SO_DATE && !(mSortOrder & LLInventoryFilter::SO_FOLDERS_BY_NAME))
{
// This is the case where something got added or removed. If we are date sorting
// everything including folders, then we need to rebuild the whole tree.
// Just set to something not SO_DATE to force the folder most resent date resort.
mSortOrder = mSortOrder & ~LLInventoryFilter::SO_DATE;
setSortOrder(mSortOrder | LLInventoryFilter::SO_DATE);
}
}
static LLFastTimer::DeclareTimer FTM_SORT("Sort Inventory");
void LLFolderView::setSortOrder(U32 order)
{
if (order != mSortOrder)
{
LLFastTimer t(FTM_SORT);
mSortOrder = order;
for (folders_t::iterator iter = mFolders.begin();
iter != mFolders.end();)
{
folders_t::iterator fit = iter++;
(*fit)->sortBy(order);
}
arrangeAll();
}
}
U32 LLFolderView::getSortOrder() const
{
return mSortOrder;
}
BOOL LLFolderView::addFolder( LLFolderViewFolder* folder)
{
// enforce sort order of My Inventory followed by Library
if (folder->getListener()->getUUID() == gInventory.getLibraryRootFolderID())
{
mFolders.push_back(folder);
}
else
{
mFolders.insert(mFolders.begin(), folder);
}
folder->setOrigin(0, 0);
folder->reshape(getRect().getWidth(), 0);
folder->setVisible(FALSE);
addChild( folder );
folder->dirtyFilter();
folder->requestArrange();
return TRUE;
}
void LLFolderView::closeAllFolders()
{
// Close all the folders
setOpenArrangeRecursively(FALSE, LLFolderViewFolder::RECURSE_DOWN);
arrangeAll();
}
void LLFolderView::openFolder(const std::string& foldername)
{
LLFolderViewFolder* inv = findChild<LLFolderViewFolder>(foldername);
if (inv)
{
setSelection(inv, FALSE, FALSE);
inv->setOpen(TRUE);
}
}
void LLFolderView::setOpenArrangeRecursively(BOOL openitem, ERecurseType recurse)
{
// call base class to do proper recursion
LLFolderViewFolder::setOpenArrangeRecursively(openitem, recurse);
// make sure root folder is always open
mIsOpen = TRUE;
}
static LLFastTimer::DeclareTimer FTM_ARRANGE("Arrange");
// This view grows and shinks to enclose all of its children items and folders.
S32 LLFolderView::arrange( S32* unused_width, S32* unused_height, S32 filter_generation )
{
LLFastTimer t2(FTM_ARRANGE);
filter_generation = mFilter->getMinRequiredGeneration();
mMinWidth = 0;
mHasVisibleChildren = hasFilteredDescendants(filter_generation);
// arrange always finishes, so optimistically set the arrange generation to the most current
mLastArrangeGeneration = getRoot()->getArrangeGeneration();
LLInventoryFilter::EFolderShow show_folder_state =
getRoot()->getFilter()->getShowFolderState();
S32 total_width = LEFT_PAD;
S32 running_height = mDebugFilters ? llceil(sSmallFont->getLineHeight()) : 0;
S32 target_height = running_height;
S32 parent_item_height = getRect().getHeight();
for (folders_t::iterator iter = mFolders.begin();
iter != mFolders.end();)
{
folders_t::iterator fit = iter++;
LLFolderViewFolder* folderp = (*fit);
if (getDebugFilters())
{
folderp->setVisible(TRUE);
}
else
{
folderp->setVisible(show_folder_state == LLInventoryFilter::SHOW_ALL_FOLDERS || // always show folders?
(folderp->getFiltered(filter_generation) || folderp->hasFilteredDescendants(filter_generation))); // passed filter or has descendants that passed filter
}
if (folderp->getVisible())
{
S32 child_height = 0;
S32 child_width = 0;
S32 child_top = parent_item_height - running_height;
target_height += folderp->arrange( &child_width, &child_height, filter_generation );
mMinWidth = llmax(mMinWidth, child_width);
total_width = llmax( total_width, child_width );
running_height += child_height;
folderp->setOrigin( ICON_PAD, child_top - (*fit)->getRect().getHeight() );
}
}
for (items_t::iterator iter = mItems.begin();
iter != mItems.end();)
{
items_t::iterator iit = iter++;
LLFolderViewItem* itemp = (*iit);
itemp->setVisible(itemp->getFiltered(filter_generation));
if (itemp->getVisible())
{
S32 child_width = 0;
S32 child_height = 0;
S32 child_top = parent_item_height - running_height;
target_height += itemp->arrange( &child_width, &child_height, filter_generation );
itemp->reshape(itemp->getRect().getWidth(), child_height);
mMinWidth = llmax(mMinWidth, child_width);
total_width = llmax( total_width, child_width );
running_height += child_height;
itemp->setOrigin( ICON_PAD, child_top - itemp->getRect().getHeight() );
}
}
LLRect scroll_rect = mScrollContainer->getContentWindowRect();
reshape( llmax(scroll_rect.getWidth(), total_width), running_height );
LLRect new_scroll_rect = mScrollContainer->getContentWindowRect();
if (new_scroll_rect.getWidth() != scroll_rect.getWidth())
{
reshape( llmax(scroll_rect.getWidth(), total_width), running_height );
}
// move item renamer text field to item's new position
updateRenamerPosition();
mTargetHeight = (F32)target_height;
return llround(mTargetHeight);
}
const std::string LLFolderView::getFilterSubString(BOOL trim)
{
return mFilter->getFilterSubString(trim);
}
static LLFastTimer::DeclareTimer FTM_FILTER("Filter Inventory");
void LLFolderView::filter( LLInventoryFilter& filter )
{
LLFastTimer t2(FTM_FILTER);
filter.setFilterCount(llclamp(gSavedSettings.getS32("FilterItemsPerFrame"), 1, 5000));
if (getCompletedFilterGeneration() < filter.getCurrentGeneration())
{
mFiltered = FALSE;
mMinWidth = 0;
LLFolderViewFolder::filter(filter);
}
else
{
mFiltered = TRUE;
}
}
void LLFolderView::reshape(S32 width, S32 height, BOOL called_from_parent)
{
LLRect scroll_rect;
if (mScrollContainer)
{
scroll_rect = mScrollContainer->getContentWindowRect();
}
width = llmax(mMinWidth, scroll_rect.getWidth());
// restrict width with scroll container's width
if (mUseEllipses)
width = scroll_rect.getWidth();
LLView::reshape(width, height, called_from_parent);
mReshapeSignal(mSelectedItems, FALSE);
}
void LLFolderView::addToSelectionList(LLFolderViewItem* item)
{
if (item->isSelected())
{
removeFromSelectionList(item);
}
if (mSelectedItems.size())
{
mSelectedItems.back()->setIsCurSelection(FALSE);
}
item->setIsCurSelection(TRUE);
mSelectedItems.push_back(item);
}
void LLFolderView::removeFromSelectionList(LLFolderViewItem* item)
{
if (mSelectedItems.size())
{
mSelectedItems.back()->setIsCurSelection(FALSE);
}
selected_items_t::iterator item_iter;
for (item_iter = mSelectedItems.begin(); item_iter != mSelectedItems.end();)
{
if (*item_iter == item)
{
item_iter = mSelectedItems.erase(item_iter);
}
else
{
++item_iter;
}
}
if (mSelectedItems.size())
{
mSelectedItems.back()->setIsCurSelection(TRUE);
}
}
LLFolderViewItem* LLFolderView::getCurSelectedItem( void )
{
if(mSelectedItems.size())
{
LLFolderViewItem* itemp = mSelectedItems.back();
llassert(itemp->getIsCurSelection());
return itemp;
}
return NULL;
}
// Record the selected item and pass it down the hierachy.
BOOL LLFolderView::setSelection(LLFolderViewItem* selection, BOOL openitem,
BOOL take_keyboard_focus)
{
if( selection == this )
{
return FALSE;
}
if( selection && take_keyboard_focus)
{
mParentPanel->setFocus(TRUE);
}
// clear selection down here because change of keyboard focus can potentially
// affect selection
clearSelection();
if(selection)
{
addToSelectionList(selection);
}
BOOL rv = LLFolderViewFolder::setSelection(selection, openitem, take_keyboard_focus);
if(openitem && selection)
{
selection->getParentFolder()->requestArrange();
}
llassert(mSelectedItems.size() <= 1);
mSignalSelectCallback = take_keyboard_focus ? SIGNAL_KEYBOARD_FOCUS : SIGNAL_NO_KEYBOARD_FOCUS;
return rv;
}
void LLFolderView::setSelectionByID(const LLUUID& obj_id, BOOL take_keyboard_focus)
{
LLFolderViewItem* itemp = getItemByID(obj_id);
if(itemp && itemp->getListener())
{
itemp->arrangeAndSet(TRUE, take_keyboard_focus);
mSelectThisID.setNull();
return;
}
else
{
// save the desired item to be selected later (if/when ready)
mSelectThisID = obj_id;
}
}
void LLFolderView::updateSelection()
{
if (mSelectThisID.notNull())
{
setSelectionByID(mSelectThisID, false);
}
}
BOOL LLFolderView::changeSelection(LLFolderViewItem* selection, BOOL selected)
{
BOOL rv = FALSE;
// can't select root folder
if(!selection || selection == this)
{
return FALSE;
}
if (!mAllowMultiSelect)
{
clearSelection();
}
selected_items_t::iterator item_iter;
for (item_iter = mSelectedItems.begin(); item_iter != mSelectedItems.end(); ++item_iter)
{
if (*item_iter == selection)
{
break;
}
}
BOOL on_list = (item_iter != mSelectedItems.end());
if(selected && !on_list)
{
addToSelectionList(selection);
}
if(!selected && on_list)
{
removeFromSelectionList(selection);
}
rv = LLFolderViewFolder::changeSelection(selection, selected);
mSignalSelectCallback = SIGNAL_KEYBOARD_FOCUS;
return rv;
}
S32 LLFolderView::extendSelection(LLFolderViewItem* selection, LLFolderViewItem* last_selected, LLDynamicArray<LLFolderViewItem*>& items)
{
S32 rv = 0;
// now store resulting selection
if (mAllowMultiSelect)
{
LLFolderViewItem *cur_selection = getCurSelectedItem();
rv = LLFolderViewFolder::extendSelection(selection, cur_selection, items);
for (S32 i = 0; i < items.count(); i++)
{
addToSelectionList(items[i]);
rv++;
}
}
else
{
setSelection(selection, FALSE, FALSE);
rv++;
}
mSignalSelectCallback = SIGNAL_KEYBOARD_FOCUS;
return rv;
}
void LLFolderView::sanitizeSelection()
{
// store off current item in case it is automatically deselected
// and we want to preserve context
LLFolderViewItem* original_selected_item = getCurSelectedItem();
// Cache "Show all folders" filter setting
BOOL show_all_folders = (getRoot()->getFilter()->getShowFolderState() == LLInventoryFilter::SHOW_ALL_FOLDERS);
std::vector<LLFolderViewItem*> items_to_remove;
selected_items_t::iterator item_iter;
for (item_iter = mSelectedItems.begin(); item_iter != mSelectedItems.end(); ++item_iter)
{
LLFolderViewItem* item = *item_iter;
// ensure that each ancestor is open and potentially passes filtering
BOOL visible = item->potentiallyVisible(); // initialize from filter state for this item
// modify with parent open and filters states
LLFolderViewFolder* parent_folder = item->getParentFolder();
if ( parent_folder )
{
if ( show_all_folders )
{ // "Show all folders" is on, so this folder is visible
visible = TRUE;
}
else
{ // Move up through parent folders and see what's visible
while(parent_folder)
{
visible = visible && parent_folder->isOpen() && parent_folder->potentiallyVisible();
parent_folder = parent_folder->getParentFolder();
}
}
}
// deselect item if any ancestor is closed or didn't pass filter requirements.
if (!visible)
{
items_to_remove.push_back(item);
}
// disallow nested selections (i.e. folder items plus one or more ancestors)
// could check cached mum selections count and only iterate if there are any
// but that may be a premature optimization.
selected_items_t::iterator other_item_iter;
for (other_item_iter = mSelectedItems.begin(); other_item_iter != mSelectedItems.end(); ++other_item_iter)
{
LLFolderViewItem* other_item = *other_item_iter;
for( parent_folder = other_item->getParentFolder(); parent_folder; parent_folder = parent_folder->getParentFolder())
{
if (parent_folder == item)
{
// this is a descendent of the current folder, remove from list
items_to_remove.push_back(other_item);
break;
}
}
}
}
std::vector<LLFolderViewItem*>::iterator item_it;
for (item_it = items_to_remove.begin(); item_it != items_to_remove.end(); ++item_it )
{
changeSelection(*item_it, FALSE); // toggle selection (also removes from list)
}
// if nothing selected after prior constraints...
if (mSelectedItems.empty())
{
// ...select first available parent of original selection, or "My Inventory" otherwise
LLFolderViewItem* new_selection = NULL;
if (original_selected_item)
{
for(LLFolderViewFolder* parent_folder = original_selected_item->getParentFolder();
parent_folder;
parent_folder = parent_folder->getParentFolder())
{
if (parent_folder->potentiallyVisible())
{
// give initial selection to first ancestor folder that potentially passes the filter
if (!new_selection)
{
new_selection = parent_folder;
}
// if any ancestor folder of original item is closed, move the selection up
// to the highest closed
if (!parent_folder->isOpen())
{
new_selection = parent_folder;
}
}
}
}
else
{
// nothing selected to start with, so pick "My Inventory" as best guess
new_selection = getItemByID(gInventory.getRootFolderID());
}
if (new_selection)
{
setSelection(new_selection, FALSE, FALSE);
}
}
}
void LLFolderView::clearSelection()
{
if (mSelectedItems.size() > 0)
{
recursiveDeselect(FALSE);
mSelectedItems.clear();
}
mSelectThisID.setNull();
}
BOOL LLFolderView::getSelectionList(std::set<LLUUID> &selection)
{
selected_items_t::iterator item_it;
for (item_it = mSelectedItems.begin(); item_it != mSelectedItems.end(); ++item_it)
{
selection.insert((*item_it)->getListener()->getUUID());
}
return (selection.size() != 0);
}
BOOL LLFolderView::startDrag(LLToolDragAndDrop::ESource source)
{
std::vector<EDragAndDropType> types;
std::vector<LLUUID> cargo_ids;
selected_items_t::iterator item_it;
BOOL can_drag = TRUE;
if (!mSelectedItems.empty())
{
for (item_it = mSelectedItems.begin(); item_it != mSelectedItems.end(); ++item_it)
{
EDragAndDropType type = DAD_NONE;
LLUUID id = LLUUID::null;
can_drag = can_drag && (*item_it)->getListener()->startDrag(&type, &id);
types.push_back(type);
cargo_ids.push_back(id);
}
LLToolDragAndDrop::getInstance()->beginMultiDrag(types, cargo_ids, source, mSourceID);
}
return can_drag;
}
void LLFolderView::commitRename( const LLSD& data )
{
finishRenamingItem();
}
void LLFolderView::draw()
{
static LLUIColor sSearchStatusColor = LLUIColorTable::instance().getColor("InventorySearchStatusColor", LLColor4::white);
if (mDebugFilters)
{
std::string current_filter_string = llformat("Current Filter: %d, Least Filter: %d, Auto-accept Filter: %d",
mFilter->getCurrentGeneration(), mFilter->getMinRequiredGeneration(), mFilter->getMustPassGeneration());
sSmallFont->renderUTF8(current_filter_string, 0, 2,
getRect().getHeight() - sSmallFont->getLineHeight(), LLColor4(0.5f, 0.5f, 0.8f, 1.f),
LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, S32_MAX, S32_MAX, NULL, FALSE );
}
LLFontGL* font = getLabelFontForStyle(mLabelStyle);
// if cursor has moved off of me during drag and drop
// close all auto opened folders
if (!mDragAndDropThisFrame)
{
closeAutoOpenedFolders();
}
// while dragging, update selection rendering to reflect single/multi drag status
if (LLToolDragAndDrop::getInstance()->hasMouseCapture())
{
EAcceptance last_accept = LLToolDragAndDrop::getInstance()->getLastAccept();
if (last_accept == ACCEPT_YES_SINGLE || last_accept == ACCEPT_YES_COPY_SINGLE)
{
setShowSingleSelection(TRUE);
}
else
{
setShowSingleSelection(FALSE);
}
}
else
{
setShowSingleSelection(FALSE);
}
if (mSearchTimer.getElapsedTimeF32() > gSavedSettings.getF32("TypeAheadTimeout") || !mSearchString.size())
{
mSearchString.clear();
}
if (hasVisibleChildren()
|| mFilter->getShowFolderState() == LLInventoryFilter::SHOW_ALL_FOLDERS)
{
mStatusText.clear();
}
else
{
if (gInventory.backgroundFetchActive() || mCompletedFilterGeneration < mFilter->getMinRequiredGeneration())
{
mStatusText = LLTrans::getString("Searching");
font->renderUTF8(mStatusText, 0, 2, 1, sSearchStatusColor, LLFontGL::LEFT, LLFontGL::TOP, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, S32_MAX, S32_MAX, NULL, FALSE );
}
else
{
mStatusText = LLTrans::getString("InventoryNoMatchingItems");
font->renderUTF8(mStatusText, 0, 2, 1, sSearchStatusColor, LLFontGL::LEFT, LLFontGL::TOP, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, S32_MAX, S32_MAX, NULL, FALSE );
}
}
LLFolderViewFolder::draw();
mDragAndDropThisFrame = FALSE;
}
void LLFolderView::finishRenamingItem( void )
{
if(!mRenamer)
{
return;
}
if( mRenameItem )
{
mRenameItem->rename( mRenamer->getText() );
}
mRenamer->setCommitOnFocusLost( FALSE );
mRenamer->setFocus( FALSE );
mRenamer->setVisible( FALSE );
mRenamer->setCommitOnFocusLost( TRUE );
gFocusMgr.setTopCtrl( NULL );
if( mRenameItem )
{
setSelectionFromRoot( mRenameItem, TRUE );
mRenameItem = NULL;
}
// List is re-sorted alphabeticly, so scroll to make sure the selected item is visible.
scrollToShowSelection();
}
void LLFolderView::closeRenamer( void )
{
// will commit current name (which could be same as original name)
mRenamer->setFocus( FALSE );
mRenamer->setVisible( FALSE );
gFocusMgr.setTopCtrl( NULL );
if( mRenameItem )
{
setSelectionFromRoot( mRenameItem, TRUE );
mRenameItem = NULL;
}
}
void LLFolderView::removeSelectedItems( void )
{
if(getVisible() && getEnabled())
{
// just in case we're removing the renaming item.
mRenameItem = NULL;
// create a temporary structure which we will use to remove
// items, since the removal will futz with internal data
// structures.
std::vector<LLFolderViewItem*> items;
S32 count = mSelectedItems.size();
if(count == 0) return;
LLFolderViewItem* item = NULL;
selected_items_t::iterator item_it;
for (item_it = mSelectedItems.begin(); item_it != mSelectedItems.end(); ++item_it)
{
item = *item_it;
if(item->isRemovable())
{
items.push_back(item);
}
else
{
llinfos << "Cannot delete " << item->getName() << llendl;
return;
}
}
// iterate through the new container.
count = items.size();
LLUUID new_selection_id;
if(count == 1)
{
LLFolderViewItem* item_to_delete = items[0];
LLFolderViewFolder* parent = item_to_delete->getParentFolder();
LLFolderViewItem* new_selection = item_to_delete->getNextOpenNode(FALSE);
if (!new_selection)
{
new_selection = item_to_delete->getPreviousOpenNode(FALSE);
}
if(parent)
{
if (parent->removeItem(item_to_delete))
{
// change selection on successful delete
if (new_selection)
{
setSelectionFromRoot(new_selection, new_selection->isOpen(), mParentPanel->hasFocus());
}
else
{
setSelectionFromRoot(NULL, mParentPanel->hasFocus());
}
}
}
arrangeAll();
}
else if (count > 1)
{
LLDynamicArray<LLFolderViewEventListener*> listeners;
LLFolderViewEventListener* listener;
LLFolderViewItem* last_item = items[count - 1];
LLFolderViewItem* new_selection = last_item->getNextOpenNode(FALSE);
while(new_selection && new_selection->isSelected())
{
new_selection = new_selection->getNextOpenNode(FALSE);
}
if (!new_selection)
{
new_selection = last_item->getPreviousOpenNode(FALSE);
while (new_selection && new_selection->isSelected())
{
new_selection = new_selection->getPreviousOpenNode(FALSE);
}
}
if (new_selection)
{
setSelectionFromRoot(new_selection, new_selection->isOpen(), mParentPanel->hasFocus());
}
else
{
setSelectionFromRoot(NULL, mParentPanel->hasFocus());
}
for(S32 i = 0; i < count; ++i)
{
listener = items[i]->getListener();
if(listener && (listeners.find(listener) == LLDynamicArray<LLFolderViewEventListener*>::FAIL))
{
listeners.put(listener);
}
}
listener = listeners.get(0);
if(listener)
{
listener->removeBatch(listeners);
}
}
arrangeAll();
scrollToShowSelection();
}
}
// open the selected item.
void LLFolderView::openSelectedItems( void )
{
if(getVisible() && getEnabled())
{
if (mSelectedItems.size() == 1)
{
mSelectedItems.front()->openItem();
}
else
{
LLMultiPreview* multi_previewp = new LLMultiPreview();
LLMultiProperties* multi_propertiesp = new LLMultiProperties();
selected_items_t::iterator item_it;
for (item_it = mSelectedItems.begin(); item_it != mSelectedItems.end(); ++item_it)
{
// IT_{OBJECT,ATTACHMENT} creates LLProperties
// floaters; others create LLPreviews. Put
// each one in the right type of container.
LLFolderViewEventListener* listener = (*item_it)->getListener();
bool is_prop = listener && (listener->getInventoryType() == LLInventoryType::IT_OBJECT || listener->getInventoryType() == LLInventoryType::IT_ATTACHMENT);
if (is_prop)
LLFloater::setFloaterHost(multi_propertiesp);
else
LLFloater::setFloaterHost(multi_previewp);
(*item_it)->openItem();
}
LLFloater::setFloaterHost(NULL);
// *NOTE: LLMulti* will safely auto-delete when open'd
// without any children.
multi_previewp->openFloater(LLSD());
multi_propertiesp->openFloater(LLSD());
}
}
}
void LLFolderView::propertiesSelectedItems( void )
{
if(getVisible() && getEnabled())
{
if (mSelectedItems.size() == 1)
{
LLFolderViewItem* folder_item = mSelectedItems.front();
if(!folder_item) return;
folder_item->getListener()->showProperties();
}
else
{
LLMultiProperties* multi_propertiesp = new LLMultiProperties();
LLFloater::setFloaterHost(multi_propertiesp);
selected_items_t::iterator item_it;
for (item_it = mSelectedItems.begin(); item_it != mSelectedItems.end(); ++item_it)
{
(*item_it)->getListener()->showProperties();
}
LLFloater::setFloaterHost(NULL);
multi_propertiesp->openFloater(LLSD());
}
}
}
void LLFolderView::changeType(LLInventoryModel *model, LLAssetType::EType new_folder_type)
{
LLFolderBridge *folder_bridge = LLFolderBridge::sSelf;
if (!folder_bridge) return;
LLViewerInventoryCategory *cat = folder_bridge->getCategory();
if (!cat) return;
cat->changeType(new_folder_type);
}
void LLFolderView::autoOpenItem( LLFolderViewFolder* item )
{
if (mAutoOpenItems.check() == item || mAutoOpenItems.getDepth() >= (U32)AUTO_OPEN_STACK_DEPTH)
{
return;
}
// close auto-opened folders
LLFolderViewFolder* close_item = mAutoOpenItems.check();
while (close_item && close_item != item->getParentFolder())
{
mAutoOpenItems.pop();
close_item->setOpenArrangeRecursively(FALSE);
close_item = mAutoOpenItems.check();
}
item->requestArrange();
mAutoOpenItems.push(item);
item->setOpen(TRUE);
LLRect content_rect = mScrollContainer->getContentWindowRect();
LLRect constraint_rect(0,content_rect.getHeight(), content_rect.getWidth(), 0);
scrollToShowItem(item, constraint_rect);
}
void LLFolderView::closeAutoOpenedFolders()
{
while (mAutoOpenItems.check())
{
LLFolderViewFolder* close_item = mAutoOpenItems.pop();
close_item->setOpen(FALSE);
}
if (mAutoOpenCandidate)
{
mAutoOpenCandidate->setAutoOpenCountdown(0.f);
}
mAutoOpenCandidate = NULL;
mAutoOpenTimer.stop();
}
BOOL LLFolderView::autoOpenTest(LLFolderViewFolder* folder)
{
if (folder && mAutoOpenCandidate == folder)
{
if (mAutoOpenTimer.getStarted())
{
if (!mAutoOpenCandidate->isOpen())
{
mAutoOpenCandidate->setAutoOpenCountdown(clamp_rescale(mAutoOpenTimer.getElapsedTimeF32(), 0.f, sAutoOpenTime, 0.f, 1.f));
}
if (mAutoOpenTimer.getElapsedTimeF32() > sAutoOpenTime)
{
autoOpenItem(folder);
mAutoOpenTimer.stop();
return TRUE;
}
}
return FALSE;
}
// otherwise new candidate, restart timer
if (mAutoOpenCandidate)
{
mAutoOpenCandidate->setAutoOpenCountdown(0.f);
}
mAutoOpenCandidate = folder;
mAutoOpenTimer.start();
return FALSE;
}
BOOL LLFolderView::canCopy() const
{
if (!(getVisible() && getEnabled() && (mSelectedItems.size() > 0)))
{
return FALSE;
}
for (selected_items_t::const_iterator selected_it = mSelectedItems.begin(); selected_it != mSelectedItems.end(); ++selected_it)
{
const LLFolderViewItem* item = *selected_it;
if (!item->getListener()->isItemCopyable())
{
return FALSE;
}
}
return TRUE;
}
// copy selected item
void LLFolderView::copy()
{
// *NOTE: total hack to clear the inventory clipboard
LLInventoryClipboard::instance().reset();
S32 count = mSelectedItems.size();
if(getVisible() && getEnabled() && (count > 0))
{
LLFolderViewEventListener* listener = NULL;
selected_items_t::iterator item_it;
for (item_it = mSelectedItems.begin(); item_it != mSelectedItems.end(); ++item_it)
{
listener = (*item_it)->getListener();
if(listener)
{
listener->copyToClipboard();
}
}
}
mSearchString.clear();
}
BOOL LLFolderView::canCut() const
{
if (!(getVisible() && getEnabled() && (mSelectedItems.size() > 0)))
{
return FALSE;
}
for (selected_items_t::const_iterator selected_it = mSelectedItems.begin(); selected_it != mSelectedItems.end(); ++selected_it)
{
const LLFolderViewItem* item = *selected_it;
const LLFolderViewEventListener* listener = item->getListener();
// *WARKAROUND: it is too many places where the "isItemRemovable" method should be changed with "const" modifier
if (!listener || !(const_cast<LLFolderViewEventListener*>(listener))->isItemRemovable())
{
return FALSE;
}
}
return TRUE;
}
void LLFolderView::cut()
{
// clear the inventory clipboard
LLInventoryClipboard::instance().reset();
S32 count = mSelectedItems.size();
if(getVisible() && getEnabled() && (count > 0))
{
LLFolderViewEventListener* listener = NULL;
selected_items_t::iterator item_it;
for (item_it = mSelectedItems.begin(); item_it != mSelectedItems.end(); ++item_it)
{
listener = (*item_it)->getListener();
if(listener)
{
listener->cutToClipboard();
}
}
}
mSearchString.clear();
}
BOOL LLFolderView::canPaste() const
{
if (mSelectedItems.empty())
{
return FALSE;
}
if(getVisible() && getEnabled())
{
for (selected_items_t::const_iterator item_it = mSelectedItems.begin();
item_it != mSelectedItems.end(); ++item_it)
{
// *TODO: only check folders and parent folders of items
const LLFolderViewItem* item = (*item_it);
const LLFolderViewEventListener* listener = item->getListener();
if(!listener || !listener->isClipboardPasteable())
{
const LLFolderViewFolder* folderp = item->getParentFolder();
listener = folderp->getListener();
if (!listener || !listener->isClipboardPasteable())
{
return FALSE;
}
}
}
return TRUE;
}
return FALSE;
}
// paste selected item
void LLFolderView::paste()
{
if(getVisible() && getEnabled())
{
// find set of unique folders to paste into
std::set<LLFolderViewItem*> folder_set;
selected_items_t::iterator selected_it;
for (selected_it = mSelectedItems.begin(); selected_it != mSelectedItems.end(); ++selected_it)
{
LLFolderViewItem* item = *selected_it;
LLFolderViewEventListener* listener = item->getListener();
if (listener->getInventoryType() != LLInventoryType::IT_CATEGORY)
{
item = item->getParentFolder();
}
folder_set.insert(item);
}
std::set<LLFolderViewItem*>::iterator set_iter;
for(set_iter = folder_set.begin(); set_iter != folder_set.end(); ++set_iter)
{
LLFolderViewEventListener* listener = (*set_iter)->getListener();
if(listener && listener->isClipboardPasteable())
{
listener->pasteFromClipboard();
}
}
}
mSearchString.clear();
}
// public rename functionality - can only start the process
void LLFolderView::startRenamingSelectedItem( void )
{
// make sure selection is visible
scrollToShowSelection();
S32 count = mSelectedItems.size();
LLFolderViewItem* item = NULL;
if(count > 0)
{
item = mSelectedItems.front();
}
if(getVisible() && getEnabled() && (count == 1) && item && item->getListener() &&
item->getListener()->isItemRenameable())
{
mRenameItem = item;
updateRenamerPosition();
mRenamer->setText(item->getName());
mRenamer->selectAll();
mRenamer->setVisible( TRUE );
// set focus will fail unless item is visible
mRenamer->setFocus( TRUE );
mRenamer->setTopLostCallback(boost::bind(onRenamerLost, _1));
gFocusMgr.setTopCtrl( mRenamer );
}
}
BOOL LLFolderView::handleKeyHere( KEY key, MASK mask )
{
BOOL handled = FALSE;
// SL-51858: Key presses are not being passed to the Popup menu.
// A proper fix is non-trivial so instead just close the menu.
LLMenuGL* menu = (LLMenuGL*)mPopupMenuHandle.get();
if (menu && menu->isOpen())
{
LLMenuGL::sMenuContainer->hideMenus();
}
LLView *item = NULL;
if (getChildCount() > 0)
{
item = *(getChildList()->begin());
}
switch( key )
{
case KEY_F2:
mSearchString.clear();
startRenamingSelectedItem();
handled = TRUE;
break;
case KEY_RETURN:
if (mask == MASK_NONE)
{
if( mRenameItem && mRenamer->getVisible() )
{
finishRenamingItem();
mSearchString.clear();
handled = TRUE;
}
else
{
LLFolderView::openSelectedItems();
handled = TRUE;
}
}
break;
case KEY_ESCAPE:
if( mRenameItem && mRenamer->getVisible() )
{
closeRenamer();
handled = TRUE;
}
mSearchString.clear();
break;
case KEY_PAGE_UP:
mSearchString.clear();
mScrollContainer->pageUp(30);
handled = TRUE;
break;
case KEY_PAGE_DOWN:
mSearchString.clear();
mScrollContainer->pageDown(30);
handled = TRUE;
break;
case KEY_HOME:
mSearchString.clear();
mScrollContainer->goToTop();
handled = TRUE;
break;
case KEY_END:
mSearchString.clear();
mScrollContainer->goToBottom();
break;
case KEY_DOWN:
if((mSelectedItems.size() > 0) && mScrollContainer)
{
LLFolderViewItem* last_selected = getCurSelectedItem();
if (!mKeyboardSelection)
{
setSelection(last_selected, FALSE, TRUE);
mKeyboardSelection = TRUE;
}
LLFolderViewItem* next = NULL;
if (mask & MASK_SHIFT)
{
// don't shift select down to children of folders (they are implicitly selected through parent)
next = last_selected->getNextOpenNode(FALSE);
if (next)
{
if (next->isSelected())
{
// shrink selection
changeSelectionFromRoot(last_selected, FALSE);
}
else if (last_selected->getParentFolder() == next->getParentFolder())
{
// grow selection
changeSelectionFromRoot(next, TRUE);
}
}
}
else
{
next = last_selected->getNextOpenNode();
if( next )
{
if (next == last_selected)
{
return FALSE;
}
setSelection( next, FALSE, TRUE );
}
}
scrollToShowSelection();
mSearchString.clear();
handled = TRUE;
}
break;
case KEY_UP:
if((mSelectedItems.size() > 0) && mScrollContainer)
{
LLFolderViewItem* last_selected = mSelectedItems.back();
if (!mKeyboardSelection)
{
setSelection(last_selected, FALSE, TRUE);
mKeyboardSelection = TRUE;
}
LLFolderViewItem* prev = NULL;
if (mask & MASK_SHIFT)
{
// don't shift select down to children of folders (they are implicitly selected through parent)
prev = last_selected->getPreviousOpenNode(FALSE);
if (prev)
{
if (prev->isSelected())
{
// shrink selection
changeSelectionFromRoot(last_selected, FALSE);
}
else if (last_selected->getParentFolder() == prev->getParentFolder())
{
// grow selection
changeSelectionFromRoot(prev, TRUE);
}
}
}
else
{
prev = last_selected->getPreviousOpenNode();
if( prev )
{
if (prev == this)
{
return FALSE;
}
setSelection( prev, FALSE, TRUE );
}
}
scrollToShowSelection();
mSearchString.clear();
handled = TRUE;
}
break;
case KEY_RIGHT:
if(mSelectedItems.size())
{
LLFolderViewItem* last_selected = getCurSelectedItem();
last_selected->setOpen( TRUE );
mSearchString.clear();
handled = TRUE;
}
break;
case KEY_LEFT:
if(mSelectedItems.size())
{
LLFolderViewItem* last_selected = getCurSelectedItem();
LLFolderViewItem* parent_folder = last_selected->getParentFolder();
if (!last_selected->isOpen() && parent_folder && parent_folder->getParentFolder())
{
setSelection(parent_folder, FALSE, TRUE);
}
else
{
last_selected->setOpen( FALSE );
}
mSearchString.clear();
scrollToShowSelection();
handled = TRUE;
}
break;
}
if (!handled && mParentPanel->hasFocus())
{
if (key == KEY_BACKSPACE)
{
mSearchTimer.reset();
if (mSearchString.size())
{
mSearchString.erase(mSearchString.size() - 1, 1);
}
search(getCurSelectedItem(), mSearchString, FALSE);
handled = TRUE;
}
}
return handled;
}
BOOL LLFolderView::handleUnicodeCharHere(llwchar uni_char)
{
if ((uni_char < 0x20) || (uni_char == 0x7F)) // Control character or DEL
{
return FALSE;
}
if (uni_char > 0x7f)
{
llwarns << "LLFolderView::handleUnicodeCharHere - Don't handle non-ascii yet, aborting" << llendl;
return FALSE;
}
BOOL handled = FALSE;
if (gFocusMgr.childHasKeyboardFocus(getRoot()))
{
// SL-51858: Key presses are not being passed to the Popup menu.
// A proper fix is non-trivial so instead just close the menu.
LLMenuGL* menu = (LLMenuGL*)mPopupMenuHandle.get();
if (menu && menu->isOpen())
{
LLMenuGL::sMenuContainer->hideMenus();
}
//do text search
if (mSearchTimer.getElapsedTimeF32() > gSavedSettings.getF32("TypeAheadTimeout"))
{
mSearchString.clear();
}
mSearchTimer.reset();
if (mSearchString.size() < 128)
{
mSearchString += uni_char;
}
search(getCurSelectedItem(), mSearchString, FALSE);
handled = TRUE;
}
return handled;
}
BOOL LLFolderView::canDoDelete() const
{
if (mSelectedItems.size() == 0) return FALSE;
for (selected_items_t::const_iterator item_it = mSelectedItems.begin(); item_it != mSelectedItems.end(); ++item_it)
{
if (!(*item_it)->getListener()->isItemRemovable())
{
return FALSE;
}
}
return TRUE;
}
void LLFolderView::doDelete()
{
if(mSelectedItems.size() > 0)
{
removeSelectedItems();
}
}
BOOL LLFolderView::handleMouseDown( S32 x, S32 y, MASK mask )
{
mKeyboardSelection = FALSE;
mSearchString.clear();
mParentPanel->setFocus(TRUE);
return LLView::handleMouseDown( x, y, mask );
}
BOOL LLFolderView::search(LLFolderViewItem* first_item, const std::string &search_string, BOOL backward)
{
// get first selected item
LLFolderViewItem* search_item = first_item;
// make sure search string is upper case
std::string upper_case_string = search_string;
LLStringUtil::toUpper(upper_case_string);
// if nothing selected, select first item in folder
if (!search_item)
{
// start from first item
search_item = getNextFromChild(NULL);
}
// search over all open nodes for first substring match (with wrapping)
BOOL found = FALSE;
LLFolderViewItem* original_search_item = search_item;
do
{
// wrap at end
if (!search_item)
{
if (backward)
{
search_item = getPreviousFromChild(NULL);
}
else
{
search_item = getNextFromChild(NULL);
}
if (!search_item || search_item == original_search_item)
{
break;
}
}
const std::string current_item_label(search_item->getSearchableLabel());
S32 search_string_length = llmin(upper_case_string.size(), current_item_label.size());
if (!current_item_label.compare(0, search_string_length, upper_case_string))
{
found = TRUE;
break;
}
if (backward)
{
search_item = search_item->getPreviousOpenNode();
}
else
{
search_item = search_item->getNextOpenNode();
}
} while(search_item != original_search_item);
if (found)
{
setSelection(search_item, FALSE, TRUE);
scrollToShowSelection();
}
return found;
}
BOOL LLFolderView::handleDoubleClick( S32 x, S32 y, MASK mask )
{
// skip LLFolderViewFolder::handleDoubleClick()
return LLView::handleDoubleClick( x, y, mask );
}
BOOL LLFolderView::handleRightMouseDown( S32 x, S32 y, MASK mask )
{
// all user operations move keyboard focus to inventory
// this way, we know when to stop auto-updating a search
mParentPanel->setFocus(TRUE);
BOOL handled = childrenHandleRightMouseDown(x, y, mask) != NULL;
S32 count = mSelectedItems.size();
LLMenuGL* menu = (LLMenuGL*)mPopupMenuHandle.get();
if(handled && (count > 0) && menu)
{
if (mCallbackRegistrar)
mCallbackRegistrar->pushScope();
//menu->empty();
const LLView::child_list_t *list = menu->getChildList();
LLView::child_list_t::const_iterator menu_itor;
for (menu_itor = list->begin(); menu_itor != list->end(); ++menu_itor)
{
(*menu_itor)->setVisible(TRUE);
(*menu_itor)->setEnabled(TRUE);
}
// Successively filter out invalid options
selected_items_t::iterator item_itor;
U32 flags = FIRST_SELECTED_ITEM;
for (item_itor = mSelectedItems.begin(); item_itor != mSelectedItems.end(); ++item_itor)
{
(*item_itor)->buildContextMenu(*menu, flags);
flags = 0x0;
}
menu->updateParent(LLMenuGL::sMenuContainer);
LLMenuGL::showPopup(this, menu, x, y);
if (mCallbackRegistrar)
mCallbackRegistrar->popScope();
}
else
{
if(menu && menu->getVisible())
{
menu->setVisible(FALSE);
}
setSelection(NULL, FALSE, TRUE);
}
return handled;
}
BOOL LLFolderView::handleHover( S32 x, S32 y, MASK mask )
{
return LLView::handleHover( x, y, mask );
}
BOOL LLFolderView::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
EDragAndDropType cargo_type,
void* cargo_data,
EAcceptance* accept,
std::string& tooltip_msg)
{
mDragAndDropThisFrame = TRUE;
BOOL handled = LLView::handleDragAndDrop(x, y, mask, drop, cargo_type, cargo_data,
accept, tooltip_msg);
if (handled)
{
lldebugst(LLERR_USER_INPUT) << "dragAndDrop handled by LLFolderView" << llendl;
}
return handled;
}
BOOL LLFolderView::handleScrollWheel(S32 x, S32 y, S32 clicks)
{
if (mScrollContainer)
{
return mScrollContainer->handleScrollWheel(x, y, clicks);
}
return FALSE;
}
void LLFolderView::deleteAllChildren()
{
if(mRenamer == gFocusMgr.getTopCtrl())
{
gFocusMgr.setTopCtrl(NULL);
}
LLView::deleteViewByHandle(mPopupMenuHandle);
mPopupMenuHandle = LLHandle<LLView>();
mRenamer = NULL;
mRenameItem = NULL;
clearSelection();
LLView::deleteAllChildren();
}
void LLFolderView::scrollToShowSelection()
{
if (mSelectedItems.size())
{
mNeedsScroll = TRUE;
}
}
// If the parent is scroll containter, scroll it to make the selection
// is maximally visible.
void LLFolderView::scrollToShowItem(LLFolderViewItem* item, const LLRect& constraint_rect)
{
if (!mScrollContainer) return;
// don't scroll to items when mouse is being used to scroll/drag and drop
if (gFocusMgr.childHasMouseCapture(mScrollContainer))
{
mNeedsScroll = FALSE;
return;
}
// if item exists and is in visible portion of parent folder...
if(item)
{
LLRect local_rect = item->getLocalRect();
LLRect item_scrolled_rect; // item position relative to display area of scroller
LLRect visible_doc_rect = mScrollContainer->getVisibleContentRect();
S32 icon_height = mIcon.isNull() ? 0 : mIcon->getHeight();
S32 label_height = llround(getLabelFontForStyle(mLabelStyle)->getLineHeight());
// when navigating with keyboard, only move top of folders on screen, otherwise show whole folder
S32 max_height_to_show = mScrollContainer->hasFocus() ? (llmax( icon_height, label_height ) + ICON_PAD) : local_rect.getHeight();
// get portion of item that we want to see...
LLRect item_local_rect = LLRect(item->getIndentation(),
local_rect.getHeight(),
llmin(MIN_ITEM_WIDTH_VISIBLE, local_rect.getWidth()),
llmax(0, local_rect.getHeight() - max_height_to_show));
LLRect item_doc_rect;
item->localRectToOtherView(item_local_rect, &item_doc_rect, this);
mScrollContainer->scrollToShowRect( item_doc_rect, constraint_rect );
}
}
LLRect LLFolderView::getVisibleRect()
{
S32 visible_height = mScrollContainer->getRect().getHeight();
S32 visible_width = mScrollContainer->getRect().getWidth();
LLRect visible_rect;
visible_rect.setLeftTopAndSize(-getRect().mLeft, visible_height - getRect().mBottom, visible_width, visible_height);
return visible_rect;
}
BOOL LLFolderView::getShowSelectionContext()
{
if (mShowSelectionContext)
{
return TRUE;
}
LLMenuGL* menu = (LLMenuGL*)mPopupMenuHandle.get();
if (menu && menu->getVisible())
{
return TRUE;
}
return FALSE;
}
void LLFolderView::setShowSingleSelection(BOOL show)
{
if (show != mShowSingleSelection)
{
mMultiSelectionFadeTimer.reset();
mShowSingleSelection = show;
}
}
void LLFolderView::addItemID(const LLUUID& id, LLFolderViewItem* itemp)
{
mItemMap[id] = itemp;
}
void LLFolderView::removeItemID(const LLUUID& id)
{
mItemMap.erase(id);
}
LLFolderViewItem* LLFolderView::getItemByID(const LLUUID& id)
{
if (id.isNull())
{
return this;
}
std::map<LLUUID, LLFolderViewItem*>::iterator map_it;
map_it = mItemMap.find(id);
if (map_it != mItemMap.end())
{
return map_it->second;
}
return NULL;
}
bool LLFolderView::doToSelected(LLInventoryModel* model, const LLSD& userdata)
{
std::string action = userdata.asString();
if ("rename" == action)
{
startRenamingSelectedItem();
return true;
}
if ("delete" == action)
{
removeSelectedItems();
return true;
}
if ("copy" == action)
{
LLInventoryClipboard::instance().reset();
}
static const std::string change_folder_string = "change_folder_type_";
if (action.length() > change_folder_string.length() &&
(action.compare(0,change_folder_string.length(),"change_folder_type_") == 0))
{
LLAssetType::EType new_folder_type = LLFolderType::lookupTypeFromXUIName(action.substr(change_folder_string.length()));
changeType(model, new_folder_type);
return true;
}
std::set<LLUUID> selected_items;
getSelectionList(selected_items);
LLMultiPreview* multi_previewp = NULL;
LLMultiProperties* multi_propertiesp = NULL;
if (("task_open" == action || "open" == action) && selected_items.size() > 1)
{
multi_previewp = new LLMultiPreview();
gFloaterView->addChild(multi_previewp);
LLFloater::setFloaterHost(multi_previewp);
}
else if (("task_properties" == action || "properties" == action) && selected_items.size() > 1)
{
multi_propertiesp = new LLMultiProperties();
gFloaterView->addChild(multi_propertiesp);
LLFloater::setFloaterHost(multi_propertiesp);
}
std::set<LLUUID>::iterator set_iter;
for (set_iter = selected_items.begin(); set_iter != selected_items.end(); ++set_iter)
{
LLFolderViewItem* folder_item = getItemByID(*set_iter);
if(!folder_item) continue;
LLInvFVBridge* bridge = (LLInvFVBridge*)folder_item->getListener();
if(!bridge) continue;
bridge->performAction(this, model, action);
}
LLFloater::setFloaterHost(NULL);
if (multi_previewp)
{
multi_previewp->openFloater(LLSD());
}
else if (multi_propertiesp)
{
multi_propertiesp->openFloater(LLSD());
}
return true;
}
static LLFastTimer::DeclareTimer FTM_AUTO_SELECT("Open and Select");
static LLFastTimer::DeclareTimer FTM_INVENTORY("Inventory");
// Main idle routine
void LLFolderView::doIdle()
{
LLFastTimer t2(FTM_INVENTORY);
BOOL debug_filters = gSavedSettings.getBOOL("DebugInventoryFilters");
if (debug_filters != getDebugFilters())
{
mDebugFilters = debug_filters;
arrangeAll();
}
mFilter->clearModified();
BOOL filter_modified_and_active = mCompletedFilterGeneration < mFilter->getCurrentGeneration() &&
mFilter->isNotDefault();
mNeedsAutoSelect = filter_modified_and_active &&
!(gFocusMgr.childHasKeyboardFocus(this) || gFocusMgr.getMouseCapture());
// filter to determine visiblity before arranging
filterFromRoot();
// automatically show matching items, and select first one
// do this every frame until user puts keyboard focus into the inventory window
// signaling the end of the automatic update
// only do this when mNeedsFilter is set, meaning filtered items have
// potentially changed
if (mNeedsAutoSelect)
{
LLFastTimer t3(FTM_AUTO_SELECT);
// select new item only if a filtered item not currently selected
LLFolderViewItem* selected_itemp = mSelectedItems.empty() ? NULL : mSelectedItems.back();
if ((!selected_itemp || !selected_itemp->getFiltered()) && !mAutoSelectOverride)
{
// select first filtered item
LLSelectFirstFilteredItem filter;
applyFunctorRecursively(filter);
}
scrollToShowSelection();
}
// during filtering process, try to pin selected item's location on screen
// this will happen when searching your inventory and when new items arrive
if (filter_modified_and_active)
{
// calculate rectangle to pin item to at start of animated rearrange
if (!mPinningSelectedItem && !mSelectedItems.empty())
{
// lets pin it!
mPinningSelectedItem = TRUE;
LLRect visible_content_rect = mScrollContainer->getVisibleContentRect();
LLFolderViewItem* selected_item = mSelectedItems.back();
LLRect item_rect;
selected_item->localRectToOtherView(selected_item->getLocalRect(), &item_rect, this);
// if item is visible in scrolled region
if (visible_content_rect.overlaps(item_rect))
{
// then attempt to keep it in same place on screen
mScrollConstraintRect = item_rect;
mScrollConstraintRect.translate(-visible_content_rect.mLeft, -visible_content_rect.mBottom);
}
else
{
// otherwise we just want it onscreen somewhere
LLRect content_rect = mScrollContainer->getContentWindowRect();
mScrollConstraintRect.setOriginAndSize(0, 0, content_rect.getWidth(), content_rect.getHeight());
}
}
}
else
{
// stop pinning selected item after folders stop rearranging
if (!needsArrange())
{
mPinningSelectedItem = FALSE;
}
}
LLRect constraint_rect;
if (mPinningSelectedItem)
{
// use last known constraint rect for pinned item
constraint_rect = mScrollConstraintRect;
}
else
{
// during normal use (page up/page down, etc), just try to fit item on screen
LLRect content_rect = mScrollContainer->getContentWindowRect();
constraint_rect.setOriginAndSize(0, 0, content_rect.getWidth(), content_rect.getHeight());
}
BOOL is_visible = isInVisibleChain();
if ( is_visible )
{
sanitizeSelection();
if( needsArrange() )
{
arrangeFromRoot();
}
}
if (mSelectedItems.size() && mNeedsScroll)
{
scrollToShowItem(mSelectedItems.back(), constraint_rect);
// continue scrolling until animated layout change is done
if (!filter_modified_and_active
&& (!needsArrange() || !is_visible))
{
mNeedsScroll = FALSE;
}
}
if (mSignalSelectCallback)
{
//RN: we use keyboard focus as a proxy for user-explicit actions
BOOL take_keyboard_focus = (mSignalSelectCallback == SIGNAL_KEYBOARD_FOCUS);
mSelectSignal(mSelectedItems, take_keyboard_focus);
}
mSignalSelectCallback = FALSE;
}
//static
void LLFolderView::idle(void* user_data)
{
LLFolderView* self = (LLFolderView*)user_data;
if ( self )
{ // Do the real idle
self->doIdle();
}
}
void LLFolderView::dumpSelectionInformation()
{
llinfos << "LLFolderView::dumpSelectionInformation()" << llendl;
llinfos << "****************************************" << llendl;
selected_items_t::iterator item_it;
for (item_it = mSelectedItems.begin(); item_it != mSelectedItems.end(); ++item_it)
{
llinfos << " " << (*item_it)->getName() << llendl;
}
llinfos << "****************************************" << llendl;
}
void LLFolderView::updateRenamerPosition()
{
if(mRenameItem)
{
LLFontGL* font = getLabelFontForStyle(mLabelStyle);
S32 x = ARROW_SIZE + TEXT_PAD + ICON_WIDTH + ICON_PAD - 1 + mRenameItem->getIndentation();
S32 y = llfloor(mRenameItem->getRect().getHeight() - font->getLineHeight()-2);
mRenameItem->localPointToScreen( x, y, &x, &y );
screenPointToLocal( x, y, &x, &y );
mRenamer->setOrigin( x, y );
LLRect scroller_rect(0, 0, gViewerWindow->getWindowWidth(), 0);
if (mScrollContainer)
{
scroller_rect = mScrollContainer->getContentWindowRect();
}
S32 width = llmax(llmin(mRenameItem->getRect().getWidth() - x, scroller_rect.getWidth() - x - getRect().mLeft), MINIMUM_RENAMER_WIDTH);
S32 height = llfloor(font->getLineHeight() + RENAME_HEIGHT_PAD);
mRenamer->reshape( width, height, TRUE );
}
}
///----------------------------------------------------------------------------
/// Local function definitions
///----------------------------------------------------------------------------
//static
void LLFolderView::onRenamerLost( LLFocusableElement* renamer)
{
LLUICtrl* uictrl = dynamic_cast<LLUICtrl*>(renamer);
if (uictrl)
{
uictrl->setVisible(FALSE);
}
}
LLInventoryFilter* LLFolderView::getFilter()
{
return mFilter;
}
void LLFolderView::setFilterPermMask( PermissionMask filter_perm_mask )
{
mFilter->setFilterPermissions(filter_perm_mask);
}
U32 LLFolderView::getFilterTypes() const
{
return mFilter->getFilterTypes();
}
PermissionMask LLFolderView::getFilterPermissions() const
{
return mFilter->getFilterPermissions();
}
BOOL LLFolderView::isFilterModified()
{
return mFilter->isNotDefault();
}
BOOL LLFolderView::getAllowMultiSelect()
{
return mAllowMultiSelect;
}
void delete_selected_item(void* user_data)
{
if(user_data)
{
LLFolderView* fv = reinterpret_cast<LLFolderView*>(user_data);
fv->removeSelectedItems();
}
}
void copy_selected_item(void* user_data)
{
if(user_data)
{
LLFolderView* fv = reinterpret_cast<LLFolderView*>(user_data);
fv->copy();
}
}
void paste_items(void* user_data)
{
if(user_data)
{
LLFolderView* fv = reinterpret_cast<LLFolderView*>(user_data);
fv->paste();
}
}
void open_selected_items(void* user_data)
{
if(user_data)
{
LLFolderView* fv = reinterpret_cast<LLFolderView*>(user_data);
fv->openSelectedItems();
}
}
void properties_selected_items(void* user_data)
{
if(user_data)
{
LLFolderView* fv = reinterpret_cast<LLFolderView*>(user_data);
fv->propertiesSelectedItems();
}
}
|