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
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
|
/**
* $Id$
*
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#include <string.h>
#include <math.h>
#include <sys/types.h>
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifdef WIN32
#include "BLI_winstuff.h"
#endif
#include "MEM_guardedalloc.h"
#include "BMF_Api.h"
#include "BIF_language.h"
#ifdef INTERNATIONAL
#include "FTF_Api.h"
#endif
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "BLI_editVert.h"
#include "BLI_storage_types.h"
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
#include "DNA_ID.h"
#include "DNA_action_types.h"
#include "DNA_armature_types.h"
#include "DNA_camera_types.h"
#include "DNA_curve_types.h"
#include "DNA_group_types.h"
#include "DNA_image_types.h"
#include "DNA_ipo_types.h"
#include "DNA_key_types.h"
#include "DNA_lamp_types.h"
#include "DNA_lattice_types.h"
#include "DNA_material_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meta_types.h"
#include "DNA_object_types.h"
#include "DNA_oops_types.h"
#include "DNA_packedFile_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "DNA_sequence_types.h"
#include "DNA_sound_types.h"
#include "DNA_space_types.h"
#include "DNA_texture_types.h"
#include "DNA_text_types.h"
#include "DNA_userdef_types.h"
#include "DNA_view2d_types.h"
#include "DNA_view3d_types.h"
#include "DNA_world_types.h"
#include "DNA_constraint_types.h"
#include "BKE_utildefines.h"
#include "BKE_constraint.h"
#include "BKE_action.h"
#include "BKE_armature.h"
#include "BKE_blender.h"
#include "BKE_curve.h"
#include "BKE_displist.h"
#include "BKE_exotic.h"
#include "BKE_global.h"
#include "BKE_image.h"
#include "BKE_ika.h"
#include "BKE_ipo.h"
#include "BKE_key.h"
#include "BKE_lattice.h"
#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_material.h"
#include "BKE_mball.h"
#include "BKE_mesh.h"
#include "BKE_object.h"
#include "BKE_packedFile.h"
#include "BKE_sca.h"
#include "BKE_scene.h"
#include "BKE_texture.h"
#include "BKE_text.h"
#include "BKE_world.h"
#include "BLO_readfile.h"
#include "BLO_writefile.h"
#include "BIF_drawimage.h"
#include "BIF_drawoops.h"
#include "BIF_drawscene.h"
#include "BIF_drawtext.h"
#include "BIF_editarmature.h"
#include "BIF_editfont.h"
#include "BIF_editlattice.h"
#include "BIF_editconstraint.h"
#include "BIF_editmesh.h"
#include "BIF_editmesh.h"
#include "BIF_editsima.h"
#include "BIF_editsound.h"
#include "BIF_editsound.h"
#include "BIF_gl.h"
#include "BIF_imasel.h"
#include "BIF_interface.h"
#include "BIF_mainqueue.h"
#include "BIF_mywindow.h"
#include "BIF_poseobject.h"
#include "BIF_renderwin.h"
#include "BIF_resources.h"
#include "BIF_screen.h"
#include "BIF_space.h"
#include "BIF_toets.h"
#include "BIF_toets.h"
#include "BIF_toolbox.h"
#include "BIF_usiblender.h"
#include "BIF_previewrender.h"
#include "BIF_writeimage.h"
#include "BSE_edit.h"
#include "BSE_filesel.h"
#include "BSE_headerbuttons.h"
#include "BSE_view.h"
#include "BSE_sequence.h"
#include "BSE_editaction.h"
#include "BSE_editaction_types.h"
#include "BSE_editipo.h"
#include "BSE_drawipo.h"
#include "BDR_drawmesh.h"
#include "BDR_vpaint.h"
#include "BDR_editface.h"
#include "BDR_editobject.h"
#include "BDR_editcurve.h"
#include "BDR_editmball.h"
#include "BPY_extern.h" // Blender Python library
#include "interface.h"
#include "mydevice.h"
#include "blendef.h"
#include "render.h"
#include "ipo.h"
#include "nla.h" /* __NLA : To be removed later */
#include "TPT_DependKludge.h"
/* local (?) functions */
void do_file_buttons(short event);
void do_text_buttons(unsigned short event);
void load_space_sound(char *str);
void load_sound_buttons(char *str);
void load_space_image(char *str);
void image_replace(Image *old, Image *new);
void replace_space_image(char *str);
void do_image_buttons(unsigned short event);
void do_imasel_buttons(short event);
static void check_packAll(void);
static void unique_bone_name(Bone *bone, bArmature *arm);
static int bonename_exists(Bone *orig, char *name, ListBase *list);
static void test_idbutton_cb(void *namev, void *arg2_unused)
{
char *name= namev;
test_idbutton(name+2);
}
#define SPACEICONMAX 13 /* See release/datafiles/blenderbuttons */
#include "BIF_poseobject.h"
#include "SYS_System.h"
static int std_libbuttons(uiBlock *block,
int xco, int pin, short *pinpoin,
int browse, ID *id, ID *parid,
short *menupoin, int users,
int lib, int del, int autobut, int keepbut);
extern char versionstr[]; /* from blender.c */
/* extern void add_text_fs(char *file); *//* from text.c, BIF_text.h*/
/* WATCH IT: always give all headerbuttons for same window the same name
* event B_REDR is a standard redraw
*
*/
/*
* The next define turns the newest menu structure on.
* There are some loose ends here at the moment so leave this undefined for now.
*/
/* #define EXPERIMENTAL_MENUS */
#define XIC 20
#define YIC 20
static int viewmovetemp=0;
/* extern void info_buttons(); in BSE_headerbuttons.c */
extern char videosc_dir[]; /* exotic.c */
/* *********************************************************************** */
void write_videoscape_fs()
{
if(G.obedit) {
error("Can't save Videoscape. Press TAB to leave EditMode");
}
else {
if(videosc_dir[0]==0) strcpy(videosc_dir, G.sce);
activate_fileselect(FILE_SPECIAL, "SAVE VIDEOSCAPE", videosc_dir, write_videoscape);
}
}
void write_vrml_fs()
{
if(G.obedit) {
error("Can't save VRML. Press TAB to leave EditMode");
}
else {
if(videosc_dir[0]==0) strcpy(videosc_dir, G.sce);
activate_fileselect(FILE_SPECIAL, "SAVE VRML1", videosc_dir, write_vrml);
}
}
void write_dxf_fs()
{
if(G.obedit) {
error("Can't save DXF. Press TAB to leave EditMode");
}
else {
if(videosc_dir[0]==0) strcpy(videosc_dir, G.sce);
activate_fileselect(FILE_SPECIAL, "SAVE DXF", videosc_dir, write_dxf);
}
}
/* ********************** GLOBAL ****************************** */
static int std_libbuttons(uiBlock *block, int xco, int pin, short *pinpoin, int browse, ID *id, ID *parid, short *menupoin, int users, int lib, int del, int autobut, int keepbut)
{
ListBase *lb;
Object *ob;
Ipo *ipo;
uiBut *but;
int len, idwasnul=0, idtype, oldcol;
char *str=NULL, str1[10];
oldcol= uiBlockGetCol(block);
if(id && pin) {
uiDefIconButS(block, ICONTOG, pin, ICON_PIN_DEHLT, (short)xco,0,XIC,YIC, pinpoin, 0, 0, 0, 0, "Keeps this view displaying the current data regardless of what object is selected");
xco+= XIC;
}
if(browse) {
if(id==0) {
idwasnul= 1;
/* only the browse button */
ob= OBACT;
if(curarea->spacetype==SPACE_IMAGE) {
id= G.main->image.first;
}
else if(curarea->spacetype==SPACE_SOUND) {
id= G.main->sound.first;
}
else if(curarea->spacetype==SPACE_ACTION) {
id= G.main->action.first;
}
else if(curarea->spacetype==SPACE_NLA) {
id=NULL;
}
else if(curarea->spacetype==SPACE_IPO) {
id= G.main->ipo.first;
/* test for ipotype */
while(id) {
ipo= (Ipo *)id;
if(G.sipo->blocktype==ipo->blocktype) break;
id= id->next;
}
}
else if(curarea->spacetype==SPACE_BUTS) {
if(browse==B_WORLDBROWSE) {
id= G.main->world.first;
}
else if(ob && ob->type && (ob->type<OB_LAMP)) {
if(G.buts->mainb==BUTS_MAT) id= G.main->mat.first;
else if(G.buts->mainb==BUTS_TEX) id= G.main->tex.first;
}
}
else if(curarea->spacetype==SPACE_TEXT) {
id= G.main->text.first;
}
}
if(id) {
char *extrastr= NULL;
idtype= GS(id->name);
lb= wich_libbase(G.main, GS(id->name));
if(idwasnul) id= NULL;
else if(id->us>1) uiBlockSetCol(block, BUTDBLUE);
if (pin && *pinpoin) {
uiBlockSetCol(block, BUTDPINK);
}
if ELEM7( idtype, ID_SCE, ID_SCR, ID_MA, ID_TE, ID_WO, ID_IP, ID_AC) extrastr= "ADD NEW %x 32767";
else if (idtype==ID_TXT) extrastr= "OPEN NEW %x 32766 |ADD NEW %x 32767";
else if (idtype==ID_SO) extrastr= "OPEN NEW %x 32766";
uiSetButLock(G.scene->id.lib!=0, "Can't edit library data");
if( idtype==ID_SCE || idtype==ID_SCR ) uiClearButLock();
if(curarea->spacetype==SPACE_BUTS)
uiSetButLock(idtype!=ID_SCR && G.obedit!=0 && G.buts->mainb==BUTS_EDIT, NULL);
if(parid) uiSetButLock(parid->lib!=0, "Can't edit library data");
if (lb) {
if( idtype==ID_IP)
IPOnames_to_pupstring(&str, NULL, extrastr, lb, id, menupoin, G.sipo->blocktype);
else
IDnames_to_pupstring(&str, NULL, extrastr, lb, id, menupoin);
}
uiDefButS(block, MENU, browse, str, (short)xco,0,XIC,YIC, menupoin, 0, 0, 0, 0, "Browses existing choices or adds NEW");
uiClearButLock();
MEM_freeN(str);
xco+= XIC;
}
else if(curarea->spacetype==SPACE_BUTS) {
if ELEM3(G.buts->mainb, BUTS_MAT, BUTS_TEX, BUTS_WORLD) {
uiSetButLock(G.scene->id.lib!=0, "Can't edit library data");
if(parid) uiSetButLock(parid->lib!=0, "Can't edit library data");
uiDefButS(block, MENU, browse, "ADD NEW %x 32767",(short) xco,0,XIC,YIC, menupoin, 0, 0, 0, 0, "Browses Datablock");
uiClearButLock();
} else if (G.buts->mainb == BUTS_SOUND) {
uiDefButS(block, MENU, browse, "OPEN NEW %x 32766",(short) xco,0,XIC,YIC, menupoin, 0, 0, 0, 0, "Browses Datablock");
}
}
else if(curarea->spacetype==SPACE_TEXT) {
uiDefButS(block, MENU, browse, "OPEN NEW %x 32766 | ADD NEW %x 32767", (short)xco,0,XIC,YIC, menupoin, 0, 0, 0, 0, "Browses Datablock");
}
else if(curarea->spacetype==SPACE_SOUND) {
uiDefButS(block, MENU, browse, "OPEN NEW %x 32766",(short)xco,0,XIC,YIC, menupoin, 0, 0, 0, 0, "Browses Datablock");
}
else if(curarea->spacetype==SPACE_NLA) {
}
else if(curarea->spacetype==SPACE_ACTION) {
uiSetButLock(G.scene->id.lib!=0, "Can't edit library data");
if(parid) uiSetButLock(parid->lib!=0, "Can't edit library data");
uiDefButS(block, MENU, browse, "ADD NEW %x 32767", xco,0,XIC,YIC, menupoin, 0, 0, 0, 0, "Browses Datablock");
uiClearButLock();
}
else if(curarea->spacetype==SPACE_IPO) {
uiSetButLock(G.scene->id.lib!=0, "Can't edit library data");
if(parid) uiSetButLock(parid->lib!=0, "Can't edit library data");
uiDefButS(block, MENU, browse, "ADD NEW %x 32767", (short)xco,0,XIC,YIC, menupoin, 0, 0, 0, 0, "Browses Datablock");
uiClearButLock();
}
}
uiBlockSetCol(block, oldcol);
if(id) {
/* name */
if(id->us>1) uiBlockSetCol(block, BUTDBLUE);
/* Pinned data ? */
if (pin && *pinpoin) {
uiBlockSetCol(block, BUTDPINK);
}
/* Redalert overrides pin color */
if(id->us<=0) uiBlockSetCol(block, REDALERT);
uiSetButLock(id->lib!=0, "Can't edit library data");
str1[0]= id->name[0];
str1[1]= id->name[1];
str1[2]= ':';
str1[3]= 0;
if(strcmp(str1, "SC:")==0) strcpy(str1, "SCE:");
else if(strcmp(str1, "SR:")==0) strcpy(str1, "SCR:");
if( GS(id->name)==ID_IP) len= 110;
else len= 120;
but= uiDefBut(block, TEX, B_IDNAME, str1,(short)xco, 0, (short)len, YIC, id->name+2, 0.0, 19.0, 0, 0, "Displays current Datablock name. Click to change.");
uiButSetFunc(but, test_idbutton_cb, id->name, NULL);
uiClearButLock();
xco+= len;
if(id->lib) {
if(parid && parid->lib) uiDefIconBut(block, BUT, 0, ICON_DATALIB,(short)xco,0,XIC,YIC, 0, 0, 0, 0, 0, "Displays name of the current Indirect Library Datablock. Click to change.");
else uiDefIconBut(block, BUT, lib, ICON_PARLIB, (short)xco,0,XIC,YIC, 0, 0, 0, 0, 0, "Displays current Library Datablock name. Click to make local.");
xco+= XIC;
}
if(users && id->us>1) {
uiSetButLock (pin && *pinpoin, "Can't make pinned data single-user");
sprintf(str1, "%d", id->us);
if(id->us<100) {
uiDefBut(block, BUT, users, str1, (short)xco,0,XIC,YIC, 0, 0, 0, 0, 0, "Displays number of users of this data. Click to make a single-user copy.");
xco+= XIC;
}
else {
uiDefBut(block, BUT, users, str1, (short)xco, 0, XIC+10, YIC, 0, 0, 0, 0, 0, "Displays number of users of this data. Click to make a single-user copy.");
xco+= XIC+10;
}
uiClearButLock();
}
if(del) {
uiSetButLock (pin && *pinpoin, "Can't unlink pinned data");
if(parid && parid->lib);
else {
uiDefIconBut(block, BUT, del, ICON_X, (short)xco,0,XIC,YIC, 0, 0, 0, 0, 0, "Deletes link to this Datablock");
xco+= XIC;
}
uiClearButLock();
}
if(autobut) {
if(parid && parid->lib);
else {
uiDefIconBut(block, BUT, autobut, ICON_AUTO,(short)xco,0,XIC,YIC, 0, 0, 0, 0, 0, "Generates an automatic name");
xco+= XIC;
}
}
if(keepbut) {
uiDefBut(block, BUT, keepbut, "F", (short)xco,0,XIC,YIC, 0, 0, 0, 0, 0, "Saves this datablock even if it has no users");
xco+= XIC;
}
}
else xco+=XIC;
uiBlockSetCol(block, oldcol);
return xco;
}
void do_update_for_newframe(int mute)
{
allqueue(REDRAWVIEW3D, 0);
allqueue(REDRAWACTION,0);
allqueue(REDRAWNLA,0);
allqueue(REDRAWIPO, 0);
allqueue(REDRAWINFO, 1);
allqueue(REDRAWSEQ, 1);
allqueue(REDRAWSOUND, 1);
allqueue(REDRAWBUTSHEAD, 1);
allqueue(REDRAWBUTSMAT, 1);
allqueue(REDRAWBUTSLAMP, 1);
/* layers/materials, object ipos are calculted in where_is_object (too) */
do_all_ipos();
BPY_do_all_scripts(SCRIPT_FRAMECHANGED);
do_all_keys();
do_all_actions();
do_all_ikas();
test_all_displists();
if ( (CFRA>1) && (!mute) && (G.scene->audio.flag & AUDIO_SCRUB)) audiostream_scrub( CFRA );
}
void update_for_newframe(void)
{
do_update_for_newframe(0);
}
void update_for_newframe_muted(void)
{
do_update_for_newframe(1);
}
static void show_splash(void)
{
extern char datatoc_splash_jpg[];
extern int datatoc_splash_jpg_size;
char *string = NULL;
#ifdef NAN_BUILDINFO
char buffer[1024];
extern char * build_date;
extern char * build_time;
extern char * build_platform;
extern char * build_type;
string = &buffer[0];
sprintf(string,"Built on %s %s Version %s %s", build_date, build_time, build_platform, build_type);
#endif
splash((void *)datatoc_splash_jpg, datatoc_splash_jpg_size, string);
}
/* Functions for user preferences fileselect windows */
void filesel_u_fontdir(char *name)
{
char dir[FILE_MAXDIR], file[FILE_MAXFILE];
BLI_split_dirfile(name, dir, file);
strcpy(U.fontdir, dir);
allqueue(REDRAWALL, 0);
}
void filesel_u_textudir(char *name)
{
char dir[FILE_MAXDIR], file[FILE_MAXFILE];
BLI_split_dirfile(name, dir, file);
strcpy(U.textudir, dir);
allqueue(REDRAWALL, 0);
}
void filesel_u_plugtexdir(char *name)
{
char dir[FILE_MAXDIR], file[FILE_MAXFILE];
BLI_split_dirfile(name, dir, file);
strcpy(U.plugtexdir, dir);
allqueue(REDRAWALL, 0);
}
void filesel_u_plugseqdir(char *name)
{
char dir[FILE_MAXDIR], file[FILE_MAXFILE];
BLI_split_dirfile(name, dir, file);
strcpy(U.plugseqdir, dir);
allqueue(REDRAWALL, 0);
}
void filesel_u_renderdir(char *name)
{
char dir[FILE_MAXDIR], file[FILE_MAXFILE];
BLI_split_dirfile(name, dir, file);
strcpy(U.renderdir, dir);
allqueue(REDRAWALL, 0);
}
void filesel_u_pythondir(char *name)
{
char dir[FILE_MAXDIR], file[FILE_MAXFILE];
BLI_split_dirfile(name, dir, file);
strcpy(U.pythondir, dir);
allqueue(REDRAWALL, 0);
}
void filesel_u_sounddir(char *name)
{
char dir[FILE_MAXDIR], file[FILE_MAXFILE];
BLI_split_dirfile(name, dir, file);
strcpy(U.sounddir, dir);
allqueue(REDRAWALL, 0);
}
void filesel_u_tempdir(char *name)
{
char dir[FILE_MAXDIR], file[FILE_MAXFILE];
BLI_split_dirfile(name, dir, file);
strcpy(U.tempdir, dir);
allqueue(REDRAWALL, 0);
}
/* END Functions for user preferences fileselect windows */
void do_global_buttons(unsigned short event)
{
ListBase *lb;
Object *ob;
Material *ma;
MTex *mtex;
Ipo *ipo;
Lamp *la;
World *wrld;
Sequence *seq;
bAction *act;
ID *id, *idtest, *from;
ScrArea *sa;
int nr= 1;
char buf[FILE_MAXDIR+FILE_MAXFILE];
ob= OBACT;
id= 0; /* id at null for texbrowse */
switch(event) {
case B_NEWFRAME:
scrarea_queue_winredraw(curarea);
scrarea_queue_headredraw(curarea);
update_for_newframe();
break;
case B_REDR:
scrarea_queue_winredraw(curarea);
scrarea_queue_headredraw(curarea);
break;
case B_EDITBROWSE:
if(ob==0) return;
if(ob->id.lib) return;
id= ob->data;
if(id==0) return;
if(G.buts->menunr== -2) {
activate_databrowse((ID *)G.buts->lockpoin, GS(id->name), 0, B_EDITBROWSE, &G.buts->menunr, do_global_buttons);
return;
}
if(G.buts->menunr < 0) return;
lb= wich_libbase(G.main, GS(id->name));
idtest= lb->first;
while(idtest) {
if(nr==G.buts->menunr) {
if(idtest!=id) {
id->us--;
id_us_plus(idtest);
ob->data= idtest;
test_object_materials(idtest);
if( GS(idtest->name)==ID_CU ) {
test_curve_type(ob);
allqueue(REDRAWBUTSEDIT, 0);
makeDispList(ob);
}
else if( ob->type==OB_MESH ) {
makeDispList(ob);
}
allqueue(REDRAWBUTSEDIT, 0);
allqueue(REDRAWVIEW3D, 0);
allqueue(REDRAWACTION,0);
allqueue(REDRAWIPO, 0);
allqueue(REDRAWNLA,0);
}
break;
}
nr++;
idtest= idtest->next;
}
break;
case B_MESHBROWSE:
if(ob==0) return;
if(ob->id.lib) return;
id= ob->data;
if(id==0) id= G.main->mesh.first;
if(id==0) return;
if(G.buts->menunr== -2) {
activate_databrowse((ID *)G.buts->lockpoin, GS(id->name), 0, B_MESHBROWSE, &G.buts->menunr, do_global_buttons);
return;
}
if(G.buts->menunr < 0) return;
idtest= G.main->mesh.first;
while(idtest) {
if(nr==G.buts->menunr) {
set_mesh(ob, (Mesh *)idtest);
allqueue(REDRAWBUTSEDIT, 0);
allqueue(REDRAWVIEW3D, 0);
allqueue(REDRAWACTION,0);
allqueue(REDRAWIPO, 0);
break;
}
nr++;
idtest= idtest->next;
}
break;
case B_MATBROWSE:
if(G.buts->menunr== -2) {
activate_databrowse((ID *)G.buts->lockpoin, ID_MA, 0, B_MATBROWSE, &G.buts->menunr, do_global_buttons);
return;
}
if(G.buts->menunr < 0) return;
if(G.buts->pin) {
}
else {
ma= give_current_material(ob, ob->actcol);
nr= 1;
id= (ID *)ma;
idtest= G.main->mat.first;
while(idtest) {
if(nr==G.buts->menunr) {
break;
}
nr++;
idtest= idtest->next;
}
if(idtest==0) { /* new mat */
if(id) idtest= (ID *)copy_material((Material *)id);
else {
idtest= (ID *)add_material("Material");
}
idtest->us--;
}
if(idtest!=id) {
assign_material(ob, (Material *)idtest, ob->actcol);
allqueue(REDRAWBUTSHEAD, 0);
allqueue(REDRAWBUTSMAT, 0);
allqueue(REDRAWIPO, 0);
BIF_preview_changed(G.buts);
}
}
break;
case B_MATDELETE:
if(G.buts->pin) {
}
else {
ma= give_current_material(ob, ob->actcol);
if(ma) {
assign_material(ob, 0, ob->actcol);
allqueue(REDRAWBUTSHEAD, 0);
allqueue(REDRAWBUTSMAT, 0);
allqueue(REDRAWIPO, 0);
BIF_preview_changed(G.buts);
}
}
break;
case B_TEXDELETE:
if(G.buts->pin) {
}
else {
if(G.buts->texfrom==0) { /* from mat */
ma= give_current_material(ob, ob->actcol);
if(ma) {
mtex= ma->mtex[ ma->texact ];
if(mtex) {
if(mtex->tex) mtex->tex->id.us--;
MEM_freeN(mtex);
ma->mtex[ ma->texact ]= 0;
allqueue(REDRAWBUTSTEX, 0);
allqueue(REDRAWIPO, 0);
BIF_preview_changed(G.buts);
}
}
}
else if(G.buts->texfrom==1) { /* from world */
wrld= G.scene->world;
if(wrld) {
mtex= wrld->mtex[ wrld->texact ];
if(mtex) {
if(mtex->tex) mtex->tex->id.us--;
MEM_freeN(mtex);
wrld->mtex[ wrld->texact ]= 0;
allqueue(REDRAWBUTSTEX, 0);
allqueue(REDRAWIPO, 0);
BIF_preview_changed(G.buts);
}
}
}
else { /* from lamp */
la= ob->data;
if(la && ob->type==OB_LAMP) { /* to be sure */
mtex= la->mtex[ la->texact ];
if(mtex) {
if(mtex->tex) mtex->tex->id.us--;
MEM_freeN(mtex);
la->mtex[ la->texact ]= 0;
allqueue(REDRAWBUTSTEX, 0);
allqueue(REDRAWIPO, 0);
BIF_preview_changed(G.buts);
}
}
}
}
break;
case B_EXTEXBROWSE:
case B_TEXBROWSE:
if(G.buts->texnr== -2) {
id= G.buts->lockpoin;
if(event==B_EXTEXBROWSE) {
id= 0;
ma= give_current_material(ob, ob->actcol);
if(ma) {
mtex= ma->mtex[ ma->texact ];
if(mtex) id= (ID *)mtex->tex;
}
}
activate_databrowse(id, ID_TE, 0, B_TEXBROWSE, &G.buts->texnr, do_global_buttons);
return;
}
if(G.buts->texnr < 0) break;
if(G.buts->pin) {
}
else {
id= 0;
ma= give_current_material(ob, ob->actcol);
if(ma) {
mtex= ma->mtex[ ma->texact ];
if(mtex) id= (ID *)mtex->tex;
}
idtest= G.main->tex.first;
while(idtest) {
if(nr==G.buts->texnr) {
break;
}
nr++;
idtest= idtest->next;
}
if(idtest==0) { /* new tex */
if(id) idtest= (ID *)copy_texture((Tex *)id);
else idtest= (ID *)add_texture("Tex");
idtest->us--;
}
if(idtest!=id && ma) {
if( ma->mtex[ma->texact]==0) ma->mtex[ma->texact]= add_mtex();
ma->mtex[ ma->texact ]->tex= (Tex *)idtest;
id_us_plus(idtest);
if(id) id->us--;
allqueue(REDRAWBUTSHEAD, 0);
allqueue(REDRAWBUTSTEX, 0);
allqueue(REDRAWBUTSMAT, 0);
allqueue(REDRAWIPO, 0);
BIF_preview_changed(G.buts);
}
}
break;
case B_ACTIONDELETE:
act=ob->action;
if (act)
act->id.us--;
ob->action=NULL;
allqueue(REDRAWACTION, 0);
allqueue(REDRAWNLA, 0);
allqueue(REDRAWIPO, 0);
break;
case B_ACTIONBROWSE:
if (!ob)
break;
act=ob->action;
id= (ID *)act;
if (G.saction->actnr== -2){
activate_databrowse((ID *)G.saction->action, ID_AC, 0, B_ACTIONBROWSE, &G.saction->actnr, do_global_buttons);
return;
}
if(G.saction->actnr < 0) break;
/* See if we have selected a valid action */
for (idtest= G.main->action.first; idtest; idtest= idtest->next) {
if(nr==G.saction->actnr) {
break;
}
nr++;
}
if(G.saction->pin) {
G.saction->action= (bAction *)idtest;
allqueue(REDRAWACTION, 0);
}
else {
/* Store current action */
if (!idtest){
if (act)
idtest= (ID *)copy_action(act);
else
idtest=(ID *)add_empty_action();
idtest->us--;
}
if(idtest!=id && ob) {
act= (bAction *)idtest;
ob->action= act;
ob->activecon=NULL;
id_us_plus(idtest);
if(id) id->us--;
// Update everything
do_global_buttons (B_NEWFRAME);
allqueue(REDRAWVIEW3D, 0);
allqueue(REDRAWNLA, 0);
allqueue(REDRAWACTION, 0);
allqueue(REDRAWHEADERS, 0);
}
}
break;
case B_IPOBROWSE:
ipo= get_ipo_to_edit(&from);
id= (ID *)ipo;
if(from==0) return;
if(G.sipo->menunr== -2) {
activate_databrowse((ID *)G.sipo->ipo, ID_IP, GS(from->name), B_IPOBROWSE, &G.sipo->menunr, do_global_buttons);
return;
}
if(G.sipo->menunr < 0) break;
idtest= G.main->ipo.first;
while(idtest) {
if( ((Ipo *)idtest)->blocktype == G.sipo->blocktype) {
if(nr==G.sipo->menunr) {
break;
}
nr++;
}
idtest= idtest->next;
}
if(G.sipo->pin) {
if(idtest) {
G.sipo->ipo= (Ipo *)idtest;
allspace(REMAKEIPO, 0); // in fact it should only do this one, but there is no function for it
}
}
else {
// assign the ipo to ...
if(idtest==0) {
if(ipo) idtest= (ID *)copy_ipo(ipo);
else {
nr= GS(from->name);
if(nr==ID_OB){
if (G.sipo->blocktype==IPO_CO)
idtest= (ID *)add_ipo("CoIpo", IPO_CO); /* BLEARGH! */
else
idtest= (ID *)add_ipo("ObIpo", nr);
}
else if(nr==ID_MA) idtest= (ID *)add_ipo("MatIpo", nr);
else if(nr==ID_SEQ) idtest= (ID *)add_ipo("MatSeq", nr);
else if(nr==ID_CU) idtest= (ID *)add_ipo("CuIpo", nr);
else if(nr==ID_KE) idtest= (ID *)add_ipo("KeyIpo", nr);
else if(nr==ID_WO) idtest= (ID *)add_ipo("WoIpo", nr);
else if(nr==ID_LA) idtest= (ID *)add_ipo("LaIpo", nr);
else if(nr==ID_CA) idtest= (ID *)add_ipo("CaIpo", nr);
else if(nr==ID_SO) idtest= (ID *)add_ipo("SndIpo", nr);
else if(nr==ID_AC) idtest= (ID *)add_ipo("ActIpo", nr);
else error("Warn bugs@blender.nl!");
}
idtest->us--;
}
if(idtest!=id && from) {
ipo= (Ipo *)idtest;
if (ipo->blocktype==IPO_CO){
((Object*)from)->activecon->ipo = ipo;
id_us_plus(idtest);
allqueue(REDRAWVIEW3D, 0);
allqueue(REDRAWACTION, 0);
allqueue(REDRAWNLA, 0);
}
else if(ipo->blocktype==ID_OB) {
( (Object *)from)->ipo= ipo;
id_us_plus(idtest);
allqueue(REDRAWVIEW3D, 0);
}
else if(ipo->blocktype==ID_AC) {
bActionChannel *chan;
chan = get_hilighted_action_channel ((bAction*)from);
if (!chan){
error ("Create an action channel first");
return;
}
chan->ipo=ipo;
id_us_plus(idtest);
allqueue(REDRAWNLA, 0);
allqueue(REDRAWACTION, 0);
}
else if(ipo->blocktype==ID_MA) {
( (Material *)from)->ipo= ipo;
id_us_plus(idtest);
allqueue(REDRAWBUTSMAT, 0);
}
else if(ipo->blocktype==ID_SEQ) {
seq= (Sequence *)from;
if((seq->type & SEQ_EFFECT)||(seq->type == SEQ_SOUND)) {
id_us_plus(idtest);
seq->ipo= ipo;
}
}
else if(ipo->blocktype==ID_CU) {
( (Curve *)from)->ipo= ipo;
id_us_plus(idtest);
allqueue(REDRAWVIEW3D, 0);
}
else if(ipo->blocktype==ID_KE) {
( (Key *)from)->ipo= ipo;
id_us_plus(idtest);
allqueue(REDRAWVIEW3D, 0);
}
else if(ipo->blocktype==ID_WO) {
( (World *)from)->ipo= ipo;
id_us_plus(idtest);
allqueue(REDRAWBUTSWORLD, 0);
}
else if(ipo->blocktype==ID_LA) {
( (Lamp *)from)->ipo= ipo;
id_us_plus(idtest);
allqueue(REDRAWBUTSLAMP, 0);
}
else if(ipo->blocktype==ID_CA) {
( (Camera *)from)->ipo= ipo;
id_us_plus(idtest);
allqueue(REDRAWBUTSEDIT, 0);
}
else if(ipo->blocktype==ID_SO) {
( (bSound *)from)->ipo= ipo;
id_us_plus(idtest);
allqueue(REDRAWBUTSEDIT, 0);
}
else
printf("error in browse ipo \n");
if(id) id->us--;
scrarea_queue_winredraw(curarea);
scrarea_queue_headredraw(curarea);
allqueue(REDRAWIPO, 0);
}
}
break;
case B_IPODELETE:
ipo= get_ipo_to_edit(&from);
if(from==0) return;
ipo->id.us--;
if(ipo->blocktype==ID_OB) ( (Object *)from)->ipo= 0;
else if(ipo->blocktype==ID_MA) ( (Material *)from)->ipo= 0;
else if(ipo->blocktype==ID_SEQ) ( (Sequence *)from)->ipo= 0;
else if(ipo->blocktype==ID_CU) ( (Curve *)from)->ipo= 0;
else if(ipo->blocktype==ID_KE) ( (Key *)from)->ipo= 0;
else if(ipo->blocktype==ID_WO) ( (World *)from)->ipo= 0;
else if(ipo->blocktype==ID_LA) ( (Lamp *)from)->ipo= 0;
else if(ipo->blocktype==ID_WO) ( (World *)from)->ipo= 0;
else if(ipo->blocktype==ID_CA) ( (Camera *)from)->ipo= 0;
else if(ipo->blocktype==ID_SO) ( (bSound *)from)->ipo= 0;
else if(ipo->blocktype==ID_AC) {
bAction *act = (bAction*) from;
bActionChannel *chan =
get_hilighted_action_channel((bAction*)from);
BLI_freelinkN (&act->chanbase, chan);
}
else if(ipo->blocktype==IPO_CO) ((Object *)from)->activecon->ipo= 0;
else error("Warn bugs@blender.nl!");
editipo_changed(G.sipo, 1); /* doredraw */
allqueue(REDRAWIPO, 0);
allqueue(REDRAWNLA, 0);
allqueue (REDRAWACTION, 0);
break;
case B_WORLDBROWSE:
if(G.buts->menunr==-2) {
activate_databrowse((ID *)G.scene->world, ID_WO, 0, B_WORLDBROWSE, &G.buts->menunr, do_global_buttons);
break;
}
if(G.buts->menunr < 0) break;
/* no lock */
wrld= G.scene->world;
nr= 1;
id= (ID *)wrld;
idtest= G.main->world.first;
while(idtest) {
if(nr==G.buts->menunr) {
break;
}
nr++;
idtest= idtest->next;
}
if(idtest==0) { /* new world */
if(id) idtest= (ID *)copy_world((World *)id);
else idtest= (ID *)add_world("World");
idtest->us--;
}
if(idtest!=id) {
G.scene->world= (World *)idtest;
id_us_plus(idtest);
if(id) id->us--;
allqueue(REDRAWBUTSHEAD, 0);
allqueue(REDRAWBUTSWORLD, 0);
allqueue(REDRAWIPO, 0);
BIF_preview_changed(G.buts);
}
break;
case B_WORLDDELETE:
if(G.scene->world) {
G.scene->world->id.us--;
G.scene->world= 0;
allqueue(REDRAWBUTSWORLD, 0);
allqueue(REDRAWIPO, 0);
}
break;
case B_WTEXBROWSE:
if(G.buts->texnr== -2) {
id= 0;
wrld= G.scene->world;
if(wrld) {
mtex= wrld->mtex[ wrld->texact ];
if(mtex) id= (ID *)mtex->tex;
}
activate_databrowse((ID *)id, ID_TE, 0, B_WTEXBROWSE, &G.buts->texnr, do_global_buttons);
return;
}
if(G.buts->texnr < 0) break;
if(G.buts->pin) {
}
else {
id= 0;
wrld= G.scene->world;
if(wrld) {
mtex= wrld->mtex[ wrld->texact ];
if(mtex) id= (ID *)mtex->tex;
}
idtest= G.main->tex.first;
while(idtest) {
if(nr==G.buts->texnr) {
break;
}
nr++;
idtest= idtest->next;
}
if(idtest==0) { /* new tex */
if(id) idtest= (ID *)copy_texture((Tex *)id);
else idtest= (ID *)add_texture("Tex");
idtest->us--;
}
if(idtest!=id && wrld) {
if( wrld->mtex[wrld->texact]==0) {
wrld->mtex[wrld->texact]= add_mtex();
wrld->mtex[wrld->texact]->texco= TEXCO_VIEW;
}
wrld->mtex[ wrld->texact ]->tex= (Tex *)idtest;
id_us_plus(idtest);
if(id) id->us--;
allqueue(REDRAWBUTSHEAD, 0);
allqueue(REDRAWBUTSTEX, 0);
allqueue(REDRAWBUTSWORLD, 0);
allqueue(REDRAWIPO, 0);
BIF_preview_changed(G.buts);
}
}
break;
case B_LAMPBROWSE:
/* no lock */
if(ob==0) return;
if(ob->type!=OB_LAMP) return;
if(G.buts->menunr== -2) {
activate_databrowse((ID *)G.buts->lockpoin, ID_LA, 0, B_LAMPBROWSE, &G.buts->menunr, do_global_buttons);
return;
}
if(G.buts->menunr < 0) break;
la= ob->data;
nr= 1;
id= (ID *)la;
idtest= G.main->lamp.first;
while(idtest) {
if(nr==G.buts->menunr) {
break;
}
nr++;
idtest= idtest->next;
}
if(idtest==0) { /* no new lamp */
return;
}
if(idtest!=id) {
ob->data= (Lamp *)idtest;
id_us_plus(idtest);
if(id) id->us--;
allqueue(REDRAWBUTSHEAD, 0);
allqueue(REDRAWBUTSLAMP, 0);
allqueue(REDRAWVIEW3D, 0);
allqueue(REDRAWIPO, 0);
BIF_preview_changed(G.buts);
}
break;
case B_LTEXBROWSE:
if(ob==0) return;
if(ob->type!=OB_LAMP) return;
if(G.buts->texnr== -2) {
id= 0;
la= ob->data;
mtex= la->mtex[ la->texact ];
if(mtex) id= (ID *)mtex->tex;
activate_databrowse(id, ID_TE, 0, B_LTEXBROWSE, &G.buts->texnr, do_global_buttons);
return;
}
if(G.buts->texnr < 0) break;
if(G.buts->pin) {
}
else {
id= 0;
la= ob->data;
mtex= la->mtex[ la->texact ];
if(mtex) id= (ID *)mtex->tex;
idtest= G.main->tex.first;
while(idtest) {
if(nr==G.buts->texnr) {
break;
}
nr++;
idtest= idtest->next;
}
if(idtest==0) { /* new tex */
if(id) idtest= (ID *)copy_texture((Tex *)id);
else idtest= (ID *)add_texture("Tex");
idtest->us--;
}
if(idtest!=id && la) {
if( la->mtex[la->texact]==0) {
la->mtex[la->texact]= add_mtex();
la->mtex[la->texact]->texco= TEXCO_GLOB;
}
la->mtex[ la->texact ]->tex= (Tex *)idtest;
id_us_plus(idtest);
if(id) id->us--;
allqueue(REDRAWBUTSHEAD, 0);
allqueue(REDRAWBUTSTEX, 0);
allqueue(REDRAWBUTSLAMP, 0);
allqueue(REDRAWIPO, 0);
BIF_preview_changed(G.buts);
}
}
break;
case B_IMAGEDELETE:
G.sima->image= 0;
image_changed(G.sima, 0);
allqueue(REDRAWIMAGE, 0);
break;
case B_AUTOMATNAME:
automatname(G.buts->lockpoin);
allqueue(REDRAWBUTSHEAD, 0);
break;
case B_AUTOTEXNAME:
if(G.buts->mainb==BUTS_TEX) {
autotexname(G.buts->lockpoin);
allqueue(REDRAWBUTSHEAD, 0);
allqueue(REDRAWBUTSTEX, 0);
}
else if(G.buts->mainb==BUTS_MAT) {
ma= G.buts->lockpoin;
if(ma->mtex[ ma->texact]) autotexname(ma->mtex[ma->texact]->tex);
allqueue(REDRAWBUTSMAT, 0);
}
else if(G.buts->mainb==BUTS_WORLD) {
wrld= G.buts->lockpoin;
if(wrld->mtex[ wrld->texact]) autotexname(wrld->mtex[wrld->texact]->tex);
allqueue(REDRAWBUTSWORLD, 0);
}
else if(G.buts->mainb==BUTS_LAMP) {
la= G.buts->lockpoin;
if(la->mtex[ la->texact]) autotexname(la->mtex[la->texact]->tex);
allqueue(REDRAWBUTSLAMP, 0);
}
break;
case B_RESETAUTOSAVE:
reset_autosave();
allqueue(REDRAWINFO, 0);
break;
case B_SOUNDTOGGLE:
SYS_WriteCommandLineInt(SYS_GetSystem(), "noaudio", (U.gameflags & USERDEF_DISABLE_SOUND));
break;
case B_SHOWSPLASH:
show_splash();
break;
case B_MIPMAPCHANGED:
set_mipmap(!(U.gameflags & USERDEF_DISABLE_SOUND));
allqueue(REDRAWVIEW3D, 0);
break;
case B_NEWSPACE:
newspace(curarea, curarea->butspacetype);
break;
case B_LOADTEMP: /* is button from space.c */
BIF_read_autosavefile();
break;
case B_USERPREF:
allqueue(REDRAWINFO, 0);
// BIF_printf("userpref %d\n", U.userpref);
break;
case B_DRAWINFO: /* is button from space.c *info* */
allqueue(REDRAWVIEW3D, 0);
break;
case B_FLIPINFOMENU: /* is button uit space.c *info* */
scrarea_queue_headredraw(curarea);
break;
#ifdef _WIN32 // FULLSCREEN
case B_FLIPFULLSCREEN:
if(U.uiflag & FLIPFULLSCREEN)
U.uiflag &= ~FLIPFULLSCREEN;
else
U.uiflag |= FLIPFULLSCREEN;
mainwindow_toggle_fullscreen((U.uiflag & FLIPFULLSCREEN));
break;
#endif
/* Fileselect windows for user preferences file paths */
case B_FONTDIRFILESEL: /* is button from space.c *info* */
if(curarea->spacetype==SPACE_INFO) {
sa= closest_bigger_area();
areawinset(sa->win);
}
activate_fileselect(FILE_SPECIAL, "SELECT FONT PATH", U.fontdir, filesel_u_fontdir);
break;
case B_TEXTUDIRFILESEL: /* is button from space.c *info* */
if(curarea->spacetype==SPACE_INFO) {
sa= closest_bigger_area();
areawinset(sa->win);
}
activate_fileselect(FILE_SPECIAL, "SELECT TEXTURE PATH", U.textudir, filesel_u_textudir);
break;
case B_PLUGTEXDIRFILESEL: /* is button form space.c *info* */
if(curarea->spacetype==SPACE_INFO) {
sa= closest_bigger_area();
areawinset(sa->win);
}
activate_fileselect(FILE_SPECIAL, "SELECT TEX PLUGIN PATH", U.plugtexdir, filesel_u_plugtexdir);
break;
case B_PLUGSEQDIRFILESEL: /* is button from space.c *info* */
if(curarea->spacetype==SPACE_INFO) {
sa= closest_bigger_area();
areawinset(sa->win);
}
activate_fileselect(FILE_SPECIAL, "SELECT SEQ PLUGIN PATH", U.plugseqdir, filesel_u_plugseqdir);
break;
case B_RENDERDIRFILESEL: /* is button from space.c *info* */
if(curarea->spacetype==SPACE_INFO) {
sa= closest_bigger_area();
areawinset(sa->win);
}
activate_fileselect(FILE_SPECIAL, "SELECT RENDER PATH", U.renderdir, filesel_u_renderdir);
break;
case B_PYTHONDIRFILESEL: /* is button from space.c *info* */
if(curarea->spacetype==SPACE_INFO) {
sa= closest_bigger_area();
areawinset(sa->win);
}
activate_fileselect(FILE_SPECIAL, "SELECT SCRIPT PATH", U.pythondir, filesel_u_pythondir);
break;
case B_SOUNDDIRFILESEL: /* is button from space.c *info* */
if(curarea->spacetype==SPACE_INFO) {
sa= closest_bigger_area();
areawinset(sa->win);
}
activate_fileselect(FILE_SPECIAL, "SELECT SOUND PATH", U.sounddir, filesel_u_sounddir);
break;
case B_TEMPDIRFILESEL: /* is button from space.c *info* */
if(curarea->spacetype==SPACE_INFO) {
sa= closest_bigger_area();
areawinset(sa->win);
}
activate_fileselect(FILE_SPECIAL, "SELECT TEMP FILE PATH", U.tempdir, filesel_u_tempdir);
break;
/* END Fileselect windows for user preferences file paths */
#ifdef INTERNATIONAL
case B_LOADUIFONT: /* is button from space.c *info* */
if(curarea->spacetype==SPACE_INFO) {
sa= closest_bigger_area();
areawinset(sa->win);
}
BLI_make_file_string("/", buf, U.fontdir, U.fontname);
activate_fileselect(FILE_SPECIAL, "LOAD UI FONT", buf, set_interface_font);
break;
case B_SETLANGUAGE: /* is button from space.c *info* */
lang_setlanguage();
allqueue(REDRAWALL, 0);
break;
case B_SETFONTSIZE: /* is button from space.c *info* */
FTF_SetSize(U.fontsize);
allqueue(REDRAWALL, 0);
break;
case B_SETTRANSBUTS: /* is button from space.c *info* */
allqueue(REDRAWALL, 0);
break;
case B_DOLANGUIFONT: /* is button from space.c *info* */
if(U.transopts & TR_ALL)
start_interface_font();
else
G.ui_international = FALSE;
allqueue(REDRAWALL, 0);
break;
#endif
case B_FULL:
if(curarea->spacetype!=SPACE_INFO) {
area_fullscreen();
}
break;
case B_IDNAME:
/* changing a metaballs name, sadly enough,
* can require it to be updated because its
* basis might have changed... -zr
*/
if (OBACT && OBACT->type==OB_MBALL)
makeDispList(OBACT);
/* redraw because name has changed: new pup */
scrarea_queue_headredraw(curarea);
allqueue(REDRAWBUTSHEAD, 0);
allqueue(REDRAWINFO, 1);
allqueue(REDRAWOOPS, 1);
/* name scene also in set PUPmenu */
if ELEM(curarea->spacetype, SPACE_BUTS, SPACE_INFO) allqueue(REDRAWBUTSALL, 0);
allqueue(REDRAWHEADERS, 0);
break;
case B_KEEPDATA:
/* keep datablock. similar to pressing FKEY in a fileselect window
* maybe we can move that stuff to a seperate function? -- sg
*/
if (curarea->spacetype==SPACE_BUTS) {
id= (ID *)G.buts->lockpoin;
} else if(curarea->spacetype==SPACE_IPO) {
id = (ID *)G.sipo->ipo;
} /* similar for other spacetypes ? */
if (id) {
if( id->flag & LIB_FAKEUSER) {
id->flag -= LIB_FAKEUSER;
id->us--;
} else {
id->flag |= LIB_FAKEUSER;
id->us++;
}
}
allqueue(REDRAWHEADERS, 0);
break;
}
}
void do_global_buttons2(short event)
{
Base *base;
Object *ob;
Material *ma;
MTex *mtex;
Mesh *me;
Curve *cu;
MetaBall *mb;
Ipo *ipo;
Lamp *la;
Lattice *lt;
World *wrld;
ID *idfrom;
bAction *act;
/* general: Single User is allowed when from==LOCAL
* Make Local is allowed when (from==LOCAL && id==LIB)
*/
ob= OBACT;
switch(event) {
case B_LAMPALONE:
if(ob && ob->id.lib==0) {
la= ob->data;
if(la->id.us>1) {
if(okee("Single user")) {
ob->data= copy_lamp(la);
la->id.us--;
}
}
}
break;
case B_LAMPLOCAL:
if(ob && ob->id.lib==0) {
la= ob->data;
if(la->id.lib) {
if(okee("Make local")) {
make_local_lamp(la);
}
}
}
break;
case B_ARMLOCAL:
if (ob&&ob->id.lib==0){
bArmature *arm=ob->data;
if (arm->id.lib){
if(okee("Make local")) {
make_local_armature(arm);
}
}
}
break;
case B_ARMALONE:
if(ob && ob->id.lib==0) {
bArmature *arm=ob->data;
if(arm->id.us>1) {
if(okee("Single user")) {
ob->data= copy_armature(arm);
arm->id.us--;
}
}
}
break;
case B_ACTLOCAL:
if(ob && ob->id.lib==0) {
act= ob->action;
if(act->id.lib) {
if(okee("Make local")) {
make_local_action(act);
allqueue(REDRAWACTION,0);
}
}
}
break;
case B_ACTALONE:
if(ob && ob->id.lib==0) {
act= ob->action;
if(act->id.us>1) {
if(okee("Single user")) {
ob->action=copy_action(act);
ob->activecon=NULL;
act->id.us--;
allqueue(REDRAWACTION, 0);
}
}
}
break;
case B_CAMERAALONE:
if(ob && ob->id.lib==0) {
Camera *ca= ob->data;
if(ca->id.us>1) {
if(okee("Single user")) {
ob->data= copy_camera(ca);
ca->id.us--;
}
}
}
break;
case B_CAMERALOCAL:
if(ob && ob->id.lib==0) {
Camera *ca= ob->data;
if(ca->id.lib) {
if(okee("Make local")) {
make_local_camera(ca);
}
}
}
break;
case B_WORLDALONE:
wrld= G.scene->world;
if(wrld->id.us>1) {
if(okee("Single user")) {
G.scene->world= copy_world(wrld);
wrld->id.us--;
}
}
break;
case B_WORLDLOCAL:
wrld= G.scene->world;
if(wrld && wrld->id.lib) {
if(okee("Make local")) {
make_local_world(wrld);
}
}
break;
case B_LATTALONE:
if(ob && ob->id.lib==0) {
lt= ob->data;
if(lt->id.us>1) {
if(okee("Single user")) {
ob->data= copy_lattice(lt);
lt->id.us--;
}
}
}
break;
case B_LATTLOCAL:
if(ob && ob->id.lib==0) {
lt= ob->data;
if(lt->id.lib) {
if(okee("Make local")) {
make_local_lattice(lt);
}
}
}
break;
case B_MATALONE:
if(ob==0) return;
ma= give_current_material(ob, ob->actcol);
idfrom= material_from(ob, ob->actcol);
if(idfrom && idfrom->lib==0) {
if(ma->id.us>1) {
if(okee("Single user")) {
ma= copy_material(ma);
ma->id.us= 0;
assign_material(ob, ma, ob->actcol);
}
}
}
break;
case B_MATLOCAL:
if(ob==0) return;
idfrom= material_from(ob, ob->actcol);
if(idfrom->lib==0) {
ma= give_current_material(ob, ob->actcol);
if(ma && ma->id.lib) {
if(okee("Make local")) {
make_local_material(ma);
}
}
}
break;
case B_MESHLOCAL:
if(ob && ob->id.lib==0) {
me= ob->data;
if(me && me->id.lib) {
if(okee("Make local")) {
make_local_mesh(me);
make_local_key( me->key );
}
}
}
break;
case B_MBALLALONE:
if(ob && ob->id.lib==0) {
mb= ob->data;
if(mb->id.us>1) {
if(okee("Single user")) {
ob->data= copy_mball(mb);
mb->id.us--;
if(ob==G.obedit) allqueue(REDRAWVIEW3D, 0);
}
}
}
break;
case B_MBALLLOCAL:
if(ob && ob->id.lib==0) {
mb= ob->data;
if(mb->id.lib) {
if(okee("Make local")) {
make_local_mball(mb);
}
}
}
break;
case B_CURVEALONE:
if(ob && ob->id.lib==0) {
cu= ob->data;
if(cu->id.us>1) {
if(okee("Single user")) {
ob->data= copy_curve(cu);
cu->id.us--;
makeDispList(ob);
if(ob==G.obedit) allqueue(REDRAWVIEW3D, 0);
}
}
}
break;
case B_CURVELOCAL:
if(ob && ob->id.lib==0) {
cu= ob->data;
if(cu->id.lib) {
if(okee("Make local")) {
make_local_curve(cu);
make_local_key( cu->key );
makeDispList(ob);
}
}
}
break;
case B_TEXALONE:
if(G.buts->texfrom==0) { /* from mat */
if(ob==0) return;
ma= give_current_material(ob, ob->actcol);
if(ma && ma->id.lib==0) {
mtex= ma->mtex[ ma->texact ];
if(mtex->tex && mtex->tex->id.us>1) {
if(okee("Single user")) {
mtex->tex->id.us--;
mtex->tex= copy_texture(mtex->tex);
}
}
}
}
else if(G.buts->texfrom==1) { /* from world */
wrld= G.scene->world;
if(wrld->id.lib==0) {
mtex= wrld->mtex[ wrld->texact ];
if(mtex->tex && mtex->tex->id.us>1) {
if(okee("Single user")) {
mtex->tex->id.us--;
mtex->tex= copy_texture(mtex->tex);
}
}
}
}
else if(G.buts->texfrom==2) { /* from lamp */
if(ob==0 || ob->type!=OB_LAMP) return;
la= ob->data;
if(la->id.lib==0) {
mtex= la->mtex[ la->texact ];
if(mtex->tex && mtex->tex->id.us>1) {
if(okee("Single user")) {
mtex->tex->id.us--;
mtex->tex= copy_texture(mtex->tex);
}
}
}
}
break;
case B_TEXLOCAL:
if(G.buts->texfrom==0) { /* from mat */
if(ob==0) return;
ma= give_current_material(ob, ob->actcol);
if(ma && ma->id.lib==0) {
mtex= ma->mtex[ ma->texact ];
if(mtex->tex && mtex->tex->id.lib) {
if(okee("Make local")) {
make_local_texture(mtex->tex);
}
}
}
}
else if(G.buts->texfrom==1) { /* from world */
wrld= G.scene->world;
if(wrld->id.lib==0) {
mtex= wrld->mtex[ wrld->texact ];
if(mtex->tex && mtex->tex->id.lib) {
if(okee("Make local")) {
make_local_texture(mtex->tex);
}
}
}
}
else if(G.buts->texfrom==2) { /* from lamp */
if(ob==0 || ob->type!=OB_LAMP) return;
la= ob->data;
if(la->id.lib==0) {
mtex= la->mtex[ la->texact ];
if(mtex->tex && mtex->tex->id.lib) {
if(okee("Make local")) {
make_local_texture(mtex->tex);
}
}
}
}
break;
case B_IPOALONE:
ipo= get_ipo_to_edit(&idfrom);
if(idfrom && idfrom->lib==0) {
if(ipo->id.us>1) {
if(okee("Single user")) {
if(ipo->blocktype==ID_OB) ((Object *)idfrom)->ipo= copy_ipo(ipo);
else if(ipo->blocktype==ID_MA) ((Material *)idfrom)->ipo= copy_ipo(ipo);
else if(ipo->blocktype==ID_SEQ) ((Sequence *)idfrom)->ipo= copy_ipo(ipo);
else if(ipo->blocktype==ID_CU) ((Curve *)idfrom)->ipo= copy_ipo(ipo);
else if(ipo->blocktype==ID_KE) ((Key *)idfrom)->ipo= copy_ipo(ipo);
else if(ipo->blocktype==ID_LA) ((Lamp *)idfrom)->ipo= copy_ipo(ipo);
else if(ipo->blocktype==ID_WO) ((World *)idfrom)->ipo= copy_ipo(ipo);
else if(ipo->blocktype==ID_CA) ((Camera *)idfrom)->ipo= copy_ipo(ipo);
else if(ipo->blocktype==ID_SO) ((bSound *)idfrom)->ipo= copy_ipo(ipo);
else if(ipo->blocktype==ID_AC) get_hilighted_action_channel((bAction *)idfrom)->ipo= copy_ipo(ipo);
else if(ipo->blocktype==IPO_CO) ((Object *)idfrom)->activecon->ipo= copy_ipo(ipo);
else error("Warn ton!");
ipo->id.us--;
allqueue(REDRAWIPO, 0);
}
}
}
break;
case B_IPOLOCAL:
ipo= get_ipo_to_edit(&idfrom);
if(idfrom && idfrom->lib==0) {
if(ipo->id.lib) {
if(okee("Make local")) {
make_local_ipo(ipo);
allqueue(REDRAWIPO, 0);
}
}
}
break;
case B_OBALONE:
if(G.scene->id.lib==0) {
if(ob->id.us>1) {
if(okee("Single user")) {
base= FIRSTBASE;
while(base) {
if(base->object==ob) {
base->object= copy_object(ob);
ob->id.us--;
allqueue(REDRAWVIEW3D, 0);
break;
}
base= base->next;
}
}
}
}
break;
case B_OBLOCAL:
if(G.scene->id.lib==0) {
if(ob->id.lib) {
if(okee("Make local")) {
make_local_object(ob);
allqueue(REDRAWVIEW3D, 0);
}
}
}
break;
case B_MESHALONE:
if(ob && ob->id.lib==0) {
me= ob->data;
if(me && me->id.us>1) {
if(okee("Single user")) {
Mesh *men= copy_mesh(me);
men->id.us= 0;
set_mesh(ob, men);
if(ob==G.obedit) allqueue(REDRAWVIEW3D, 0);
}
}
}
break;
}
allqueue(REDRAWBUTSALL, 0);
allqueue(REDRAWOOPS, 0);
}
/* ********************** EMPTY ****************************** */
/* ********************** INFO ****************************** */
int buttons_do_unpack()
{
int how;
char menu[2048];
char line[128];
int ret_value = RET_OK, count = 0;
count = countPackedFiles();
if (count) {
if (count == 1) {
sprintf(menu, "Unpack 1 file%%t");
} else {
sprintf(menu, "Unpack %d files%%t", count);
}
sprintf(line, "|Use files in current directory (create when necessary)%%x%d", PF_USE_LOCAL);
strcat(menu, line);
sprintf(line, "|Write files to current directory (overwrite existing files)%%x%d", PF_WRITE_LOCAL);
strcat(menu, line);
sprintf(line, "|%%l|Use files in original location (create when necessary)%%x%d", PF_USE_ORIGINAL);
strcat(menu, line);
sprintf(line, "|Write files to original location (overwrite existing files)%%x%d", PF_WRITE_ORIGINAL);
strcat(menu, line);
sprintf(line, "|%%l|Disable AutoPack, keep all packed files %%x%d", PF_KEEP);
strcat(menu, line);
sprintf(line, "|Ask for each file %%x%d", PF_ASK);
strcat(menu, line);
how = pupmenu(menu);
if(how != -1) {
if (how != PF_KEEP) {
unpackAll(how);
}
G.fileflags &= ~G_AUTOPACK;
} else {
ret_value = RET_CANCEL;
}
} else {
pupmenu("No packed files. Autopack disabled");
}
return (ret_value);
}
/* here, because of all creator stuff */
Scene *copy_scene(Scene *sce, int level)
{
/* level 0: al objects shared
* level 1: al object-data shared
* level 2: full copy
*/
Scene *scen;
Base *base, *obase;
/* level 0 */
scen= copy_libblock(sce);
duplicatelist(&(scen->base), &(sce->base));
clear_id_newpoins();
id_us_plus((ID *)scen->world);
id_us_plus((ID *)scen->set);
scen->ed= 0;
scen->radio= 0;
obase= sce->base.first;
base= scen->base.first;
while(base) {
base->object->id.us++;
if(obase==sce->basact) scen->basact= base;
obase= obase->next;
base= base->next;
}
if(level==0) return scen;
/* level 1 */
G.scene= scen;
single_object_users(0);
/* camera */
ID_NEW(G.scene->camera);
/* level 2 */
if(level>=2) {
if(scen->world) {
scen->world->id.us--;
scen->world= copy_world(scen->world);
}
single_obdata_users(0);
single_mat_users_expand();
single_tex_users_expand();
}
clear_id_newpoins();
BPY_copy_scriptlink(&sce->scriptlink);
// make a private copy of the avicodecdata
if (sce->r.avicodecdata) {
scen->r.avicodecdata = MEM_dupallocN(sce->r.avicodecdata);
scen->r.avicodecdata->lpFormat = MEM_dupallocN(scen->r.avicodecdata->lpFormat);
scen->r.avicodecdata->lpParms = MEM_dupallocN(scen->r.avicodecdata->lpParms);
}
// make a private copy of the qtcodecdata
if (sce->r.qtcodecdata) {
scen->r.qtcodecdata = MEM_dupallocN(sce->r.qtcodecdata);
scen->r.qtcodecdata->cdParms = MEM_dupallocN(scen->r.qtcodecdata->cdParms);
}
return scen;
}
void do_info_buttons(unsigned short event)
{
bScreen *sc, *oldscreen;
Scene *sce, *sce1;
ScrArea *sa;
int nr;
switch(event) {
case B_INFOSCR: /* menu select screen */
if( G.curscreen->screennr== -2) {
if(curarea->winy <50) {
sa= closest_bigger_area();
areawinset(sa->win);
}
activate_databrowse((ID *)G.curscreen, ID_SCR, 0, B_INFOSCR, &G.curscreen->screennr, do_info_buttons);
return;
}
if( G.curscreen->screennr < 0) return;
sc= G.main->screen.first;
nr= 1;
while(sc) {
if(nr==G.curscreen->screennr) {
if(is_allowed_to_change_screen(sc)) setscreen(sc);
else error("Unable to perform function in EditMode");
break;
}
nr++;
sc= sc->id.next;
}
/* last item: NEW SCREEN */
if(sc==0) {
duplicate_screen();
}
break;
case B_INFODELSCR:
/* do this event only with buttons, so it can never be called with full-window */
if(G.curscreen->id.prev) sc= G.curscreen->id.prev;
else if(G.curscreen->id.next) sc= G.curscreen->id.next;
else return;
if(okee("Delete current screen")) {
/* find new G.curscreen */
oldscreen= G.curscreen;
setscreen(sc); /* this test if sc has a full */
unlink_screen(oldscreen);
free_libblock(&G.main->screen, oldscreen);
}
scrarea_queue_headredraw(curarea);
break;
case B_INFOSCE: /* menu select scene */
if( G.obedit) {
error("Unable to perform function in EditMode");
return;
}
if( G.curscreen->scenenr== -2) {
if(curarea->winy <50) {
sa= closest_bigger_area();
areawinset(sa->win);
}
activate_databrowse((ID *)G.scene, ID_SCE, 0, B_INFOSCE, &G.curscreen->scenenr, do_info_buttons);
return;
}
if( G.curscreen->scenenr < 0) return;
sce= G.main->scene.first;
nr= 1;
while(sce) {
if(nr==G.curscreen->scenenr) {
if(sce!=G.scene) set_scene(sce);
break;
}
nr++;
sce= sce->id.next;
}
/* last item: NEW SCENE */
if(sce==0) {
nr= pupmenu("Add scene%t|Empty|Link Objects|Link ObData|Full Copy");
if(nr<= 0) return;
if(nr==1) {
sce= add_scene(G.scene->id.name+2);
sce->r= G.scene->r;
#ifdef _WIN32
if (sce->r.avicodecdata) {
sce->r.avicodecdata = MEM_dupallocN(G.scene->r.avicodecdata);
sce->r.avicodecdata->lpFormat = MEM_dupallocN(G.scene->r.avicodecdata->lpFormat);
sce->r.avicodecdata->lpParms = MEM_dupallocN(G.scene->r.avicodecdata->lpParms);
}
#endif
#ifdef WITH_QUICKTIME
if (sce->r.qtcodecdata) {
sce->r.qtcodecdata = MEM_dupallocN(G.scene->r.qtcodecdata);
sce->r.qtcodecdata->cdParms = MEM_dupallocN(G.scene->r.qtcodecdata->cdParms);
}
#endif
}
else sce= copy_scene(G.scene, nr-2);
set_scene(sce);
}
BIF_preview_changed(G.buts);
break;
case B_INFODELSCE:
if(G.scene->id.prev) sce= G.scene->id.prev;
else if(G.scene->id.next) sce= G.scene->id.next;
else return;
if(okee("Delete current scene")) {
/* check all sets */
sce1= G.main->scene.first;
while(sce1) {
if(sce1->set == G.scene) sce1->set= 0;
sce1= sce1->id.next;
}
/* check all sequences */
clear_scene_in_allseqs(G.scene);
/* al screens */
sc= G.main->screen.first;
while(sc) {
if(sc->scene == G.scene) sc->scene= sce;
sc= sc->id.next;
}
free_libblock(&G.main->scene, G.scene);
set_scene(sce);
}
break;
case B_FILEMENU:
tbox_setmain(9);
toolbox();
break;
}
}
/* strubi shamelessly abused the status line as a progress bar...
feel free to kill him after release */
static int g_progress_bar = 0;
static char *g_progress_info = 0;
static float g_done;
int start_progress_bar(void)
{
g_progress_bar = 1;
return 1; // we never fail (yet)
}
void end_progress_bar(void)
{
g_progress_bar = 0;
}
static void update_progress_bar(float done, char *info)
{
g_done = done;
g_progress_info = info;
}
/** Progress bar
'done': a value between 0.0 and 1.0, showing progress
'info': a info text what is currently being done
Make sure that the progress bar is always called with:
done = 0.0 first
and
done = 1.0 last -- or alternatively use:
start_progressbar();
do_stuff_and_callback_progress_bar();
end_progressbar();
*/
int progress_bar(float done, char *busy_info)
{
ScrArea *sa;
short val;
/* User break (ESC) */
while (qtest()) {
if (extern_qread(&val) == ESCKEY)
return 0;
}
if (done == 0.0) {
start_progress_bar();
} else if (done > 0.99) {
end_progress_bar();
}
sa= G.curscreen->areabase.first;
while(sa) {
if (sa->spacetype == SPACE_INFO) {
update_progress_bar(done, busy_info);
curarea = sa;
scrarea_do_headdraw(curarea);
areawinset(curarea->win);
sa->head_swap= WIN_BACK_OK;
screen_swapbuffers();
}
sa = sa->next;
}
return 1;
}
static void check_packAll()
{
// first check for dirty images
Image *ima;
ima = G.main->image.first;
while (ima) {
if (ima->ibuf && (ima->ibuf->userflags &= IB_BITMAPDIRTY)) {
break;
}
ima= ima->id.next;
}
if (ima == 0 || okee("Some images are painted on. These changes will be lost. Continue ?")) {
packAll();
G.fileflags |= G_AUTOPACK;
}
}
int write_runtime(char *str, char *exename)
{
char *freestr= NULL;
char *ext = 0;
#ifdef _WIN32
ext = ".exe";
#endif
#ifdef __APPLE__
ext = ".app";
#endif
if (ext && (!BLI_testextensie(str, ext))) {
freestr= MEM_mallocN(strlen(str) + strlen(ext) + 1, "write_runtime_check");
strcpy(freestr, str);
strcat(freestr, ext);
str= freestr;
}
if (!BLI_exists(str) || saveover(str))
BLO_write_runtime(str, exename);
if (freestr)
MEM_freeN(freestr);
return 0;
}
static void write_runtime_check_dynamic(char *str)
{
write_runtime(str, "blenderdynplayer.exe");
}
static void write_runtime_check(char *str)
{
char player[128];
strcpy(player, "blenderplayer");
#ifdef _WIN32
strcat(player, ".exe");
#endif
#ifdef __APPLE__
strcat(player, ".app");
#endif
write_runtime(str, player);
}
/* end keyed functions */
static void do_info_filemenu(void *arg, int event)
{
ScrArea *sa;
char dir[FILE_MAXDIR];
if(curarea->spacetype==SPACE_INFO) {
sa= closest_bigger_area();
areawinset(sa->win);
}
/* these are no defines, easier this way, the codes are in the function below */
switch(event) {
case 0:
if (okee("ERASE ALL")) {
if (!BIF_read_homefile())
error("No file ~/.B.blend");
}
break;
case 1:
activate_fileselect(FILE_BLENDER, "LOAD FILE", G.sce, BIF_read_file);
break;
case 2:
{
char *s= MEM_mallocN(strlen(G.sce) + 11 + 1, "okee_reload");
strcpy(s, "Open file: ");
strcat(s, G.sce);
if (okee(s))
BIF_read_file(G.sce);
MEM_freeN(s);
}
break;
case 3:
activate_fileselect(FILE_LOADLIB, "LOAD LIBRARY", G.lib, 0);
break;
case 4:
strcpy(dir, G.sce);
untitled(dir);
activate_fileselect(FILE_BLENDER, "SAVE FILE", dir, BIF_write_file);
break;
case 5:
strcpy(dir, G.sce);
if (untitled(dir)) {
activate_fileselect(FILE_BLENDER, "SAVE FILE", dir, BIF_write_file);
} else {
BIF_write_file(dir);
free_filesel_spec(dir);
}
break;
case 6:
mainqenter(F3KEY, 1);
break;
case 7:
write_vrml_fs();
break;
case 8:
write_dxf_fs();
break;
case 9:
write_videoscape_fs();
break;
/*
case 20:
strcpy(dir, G.sce);
activate_fileselect(FILE_SPECIAL, "INSTALL LICENSE KEY", dir, loadKeyboard);
break;
case 21:
SHOW_LICENSE_KEY();
break;
*/
case 22:
activate_fileselect(FILE_SPECIAL, "WRITE RUNTIME", "", write_runtime_check);
break;
case 23:
activate_fileselect(FILE_SPECIAL, "WRITE DYNAMIC RUNTIME", "", write_runtime_check_dynamic);
break;
case 30:
// import menu, no handling
break;
#ifdef EXPERIMENTAL_MENUS
case 10:
check_packAll();
break;
case 11:
unpackAll(PF_WRITE_LOCAL);
G.fileflags &= ~G_AUTOPACK;
break;
case 12:
if (buttons_do_unpack() != RET_CANCEL) {
/* Clear autopack bit only if user selected one of the unpack options */
G.fileflags &= ~G_AUTOPACK;
}
break;
case 13:
#else /* EXPERIMENTAL_MENUS */
case 10:
#endif /* EXPERIMENTAL_MENUS */
exit_usiblender();
break;
}
allqueue(REDRAWINFO, 0);
}
void do_info_file_optionsmenu(void *arg, int event)
{
G.fileflags ^= (1 << event);
// allqueue(REDRAWINFO, 0);
}
//#ifdef NEW_WINDOW_TYPE_MENUS
static char *windowtype_pup(void)
{
static char string[1024];
strcpy(string, "Window type:%t"); //14
strcat(string, "|3D Viewport %x1"); //30
strcat(string, "|%l"); // 33
strcat(string, "|Ipo Curve Editor %x2"); //54
strcat(string, "|Action Editor %x12"); //73
strcat(string, "|NLA Editor %x13"); //94
strcat(string, "|%l"); //97
strcat(string, "|UV/Image Editor %x6"); //117
strcat(string, "|Video Sequence Editor %x8"); //143
strcat(string, "|Audio Timeline %x11"); //163
strcat(string, "|Text Editor %x9"); //179
strcat(string, "|%l"); //192
strcat(string, "|User Preferences %x7"); //213
strcat(string, "|OOPS Schematic %x3"); //232
strcat(string, "|Buttons Window %x4"); //251
strcat(string, "|%l"); //254
strcat(string, "|Image Browser %x10");
strcat(string, "|File Browser %x5");
return (string);
}
static uiBlock *info_file_optionsmenu(void *arg_unused)
{
uiBlock *block;
short yco= 0, xco = 20;
block= uiNewBlock(&curarea->uiblocks, "runtime_options", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
uiBlockSetButmFunc(block, do_info_file_optionsmenu, NULL);
uiBlockSetXOfs(block,-40); // offset to parent button
/* flags are case-values */
uiDefBut(block, BUTM, 1, "Compress File", xco, yco-=20, 100, 19, NULL, 0.0, 0.0, 0, G_FILE_COMPRESS_BIT, "Enables file compression");
/*
uiDefBut(block, BUTM, 1, "Sign File", xco, yco-=20, 100, 19, NULL, 0.0, 0.0, 0, G_FILE_SIGN_BIT, "Add signature to file");
uiDefBut(block, BUTM, 1, "Lock File", xco, yco-=20, 100, 19, NULL, 0.0, 0.0, 0, G_FILE_LOCK_BIT, "Protect the file from editing by others");
*/
uiTextBoundsBlock(block, 50);
/* Toggle buttons */
yco= 0;
xco -= 20;
uiBlockSetEmboss(block, UI_EMBOSSW);
uiBlockSetButmFunc(block, NULL, NULL);
/* flags are defines */
uiDefIconButI(block, ICONTOG|BIT|G_FILE_COMPRESS_BIT, 0, ICON_CHECKBOX_DEHLT, xco, yco-=20, 19, 19, &G.fileflags, 0.0, 0.0, 0, 0, "");
/*
uiDefIconButI(block, ICONTOG|BIT|G_FILE_SIGN_BIT, 0, ICON_CHECKBOX_DEHLT, xco, yco-=20, 19, 19, &G.fileflags, 0.0, 0.0, 0, 0, "");
uiDefIconButI(block, ICONTOG|BIT|G_FILE_LOCK_BIT, 0, ICON_CHECKBOX_DEHLT, xco, yco-=20, 19, 19, &G.fileflags, 0.0, 0.0, 0, 0, "");
*/
uiBlockSetDirection(block, UI_RIGHT);
return block;
}
static uiBlock *info_runtime_optionsmenu(void *arg_unused)
{
uiBlock *block;
short yco= 0, xco = 20;
block= uiNewBlock(&curarea->uiblocks, "add_surfacemenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
uiBlockSetXOfs(block, -40); // offset to parent button
uiBlockSetEmboss(block, UI_EMBOSSW);
uiDefBut(block, LABEL, 0, "Size options:", xco, yco-=20, 114, 19, 0, 0.0, 0.0, 0, 0, "");
uiDefButS(block, NUM, 0, "X:", xco+19, yco-=20, 95, 19, &G.scene->r.xplay, 10.0, 2000.0, 0, 0, "Displays current X screen/window resolution. Click to change.");
uiDefButS(block, NUM, 0, "Y:", xco+19, yco-=20, 95, 19, &G.scene->r.yplay, 10.0, 2000.0, 0, 0, "Displays current Y screen/window resolution. Click to change.");
uiDefBut(block, SEPR, 0, "", xco, yco-=4, 114, 4, NULL, 0.0, 0.0, 0, 0, "");
uiDefBut(block, LABEL, 0, "Fullscreen options:", xco, yco-=20, 114, 19, 0, 0.0, 0.0, 0, 0, "");
uiDefButS(block, TOG, 0, "Fullscreen", xco + 19, yco-=20, 95, 19, &G.scene->r.fullscreen, 0.0, 0.0, 0, 0, "Starts player in a new fullscreen display");
uiDefButS(block, NUM, 0, "Freq:", xco+19, yco-=20, 95, 19, &G.scene->r.freqplay, 10.0, 120.0, 0, 0, "Displays clock frequency of fullscreen display. Click to change.");
uiDefButS(block, NUM, 0, "Bits:", xco+19, yco-=20, 95, 19, &G.scene->r.depth, 1.0, 32.0, 0, 0, "Displays bit depth of full screen display. Click to change.");
uiDefBut(block, SEPR, 0, "", xco, yco-=4, 114, 4, NULL, 0.0, 0.0, 0, 0, "");
/* stereo settings */
/* can't use any definition from the game engine here so hardcode it. Change it here when it changes there!
* RAS_IRasterizer has definitions:
* RAS_STEREO_NOSTEREO 1
* RAS_STEREO_QUADBUFFERED 2
* RAS_STEREO_ABOVEBELOW 3
* RAS_STEREO_INTERLACED 4 future
*/
uiDefBut(block, LABEL, 0, "Stereo options", xco, yco-=20, 114, 19, 0, 0.0, 0.0, 0, 0, "");
uiDefButS(block, ROW, 0, "no stereo", xco+19, yco-=20, 95, 19, &(G.scene->r.stereomode), 6.0, 1.0, 0, 0, "Disables stereo");
uiDefButS(block, ROW, 0, "h/w pageflip", xco+19, yco-=20, 95, 19, &(G.scene->r.stereomode), 6.0, 2.0, 0, 0, "Enables hardware pageflip stereo method");
uiDefButS(block, ROW, 0, "syncdoubling", xco+19, yco-=20, 95, 19, &(G.scene->r.stereomode), 6.0, 3.0, 0, 0, "Enables syncdoubling stereo method");
#if 0
// future
uiDefButS(block, ROW, 0, "syncdoubling", xco+19, yco, 95, 19, &(G.scene->r.stereomode), 5.0, 4.0, 0, 0, "Enables interlaced stereo method");
#endif
uiBlockSetDirection(block, UI_RIGHT);
uiTextBoundsBlock(block, 50);
return block;
}
static uiBlock *info_file_importmenu(void *arg_unused)
{
uiBlock *block;
short yco= 0, xco = 20;
block= uiNewBlock(&curarea->uiblocks, "importmenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
uiBlockSetXOfs(block, -40); // offset to parent button
uiBlockSetEmboss(block, UI_EMBOSSW);
/* flags are defines */
uiDefBut(block, LABEL, 0, "VRML 2.0 options", xco, yco, 125, 19, NULL, 0.0, 0.0, 0, 0, "");
uiDefButS(block, TOG|BIT|0, 0, "SepLayers", xco, yco-=20, 75, 19, &U.vrmlflag, 0.0, 0.0, 0, 0, "Separates Empties, Lamps, etc. into Layers");
uiDefButS(block, TOG|BIT|1, 0, "Scale 1/100", xco, yco-=20, 75, 19, &U.vrmlflag, 0.0, 0.0, 0, 0, "Scales scene by 1/100 (3DS VRML)");
uiDefButS(block, TOG|BIT|2, 0, "Two Sided", xco, yco-=20, 75, 19, &U.vrmlflag, 0.0, 0.0, 0, 0, "Enables import of two sided faces");
uiBlockSetDirection(block, UI_RIGHT);
uiTextBoundsBlock(block, 50);
return block;
}
static uiBlock *info_filemenu(void *arg_unused)
{
uiBlock *block;
short xco=0;
block= uiNewBlock(&curarea->uiblocks, "filemenu", UI_EMBOSSP, UI_HELV, curarea->headwin);
uiBlockSetButmFunc(block, do_info_filemenu, NULL);
uiDefBut(block, BUTM, 1, "New|Ctrl X", 0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "Starts a new project (WARNING! Closes current project!)");
uiDefBut(block, BUTM, 1, "Open|F1", 0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 1, "Opens a new file");
uiDefBut(block, BUTM, 1, "Reopen Last|Ctrl O", 0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 2, "Reverts to the last version saved to file");
uiDefBut(block, BUTM, 1, "Append|Shift F1", 0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 3, "Appends contents of a file to the current project");
uiDefBlockBut(block, info_file_importmenu, NULL, "Import Settings|>>", 0, xco-=20, 160, 19, "");
uiDefBut(block, SEPR, 0, "", 0, xco-=6, 160, 6, NULL, 0.0, 0.0, 0, 0, "");
uiDefBut(block, BUTM, 1, "Save As|F2", 0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 4, "Saves to a new file");
uiDefBut(block, BUTM, 1, "Save|Ctrl W", 0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 5, "Saves to the current file");
uiDefBlockBut(block, info_file_optionsmenu, NULL, "File options|>>", 0, xco-=20, 160, 19, "Opens the File Options menu");
uiDefBut(block, SEPR, 0, "", 0, xco-=6, 160, 6, NULL, 0.0, 0.0, 0, 0, "");
uiDefBut(block, BUTM, 1, "Save Runtime", 0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 22, "Creates a runtime executable with the current project");
#ifdef _WIN32
uiDefBut(block, BUTM, 1, "Save dynamic Runtime", 0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 23, "Creates a dynamic runtime executable with the current project (requieres extenal python20.dll)");
#endif
uiDefBlockBut(block, info_runtime_optionsmenu, NULL, "Runtime options|>>", 0, xco-=20, 160, 19, "Opens the File Options menu");
uiDefBut(block, SEPR, 0, "", 0, xco-=6, 160, 6, NULL, 0.0, 0.0, 0, 0, "");
uiDefBut(block, BUTM, 1, "Save Image|F3", 0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 6, "Saves the rendered image to a file");
uiDefBut(block, BUTM, 1, "Save VRML 1.0|Ctrl F2", 0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 7, "Saves the current scene to a file in VRML 1.0 format");
uiDefBut(block, BUTM, 1, "Save DXF|Shift F2", 0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 8, "Saves the current scene to a file in DXF format");
uiDefBut(block, BUTM, 1, "Save VideoScape|Alt W", 0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 9, "Saves the current scene to a file in VideoScape format");
/*
if (LICENSE_KEY_VALID) {
uiDefBut(block, SEPR, 0, "", 0, xco-=6, 160, 6, NULL, 0.0, 0.0, 1, 0, "");
uiDefBut(block, BUTM, 1, "Show License Key", 0, xco-=20, 140, 19, NULL, 0.0, 0.0, 1, 21, "Show the personal information stored in your Blender License Key");
uiDefIconBut(block, BUTM, 1, ICON_PUBLISHER, 141,xco, 19, 19, NULL, 0.0, 0.0, 1, 21, "Show the personal information stored in your Blender License Key");
} else if (I_AM_PUBLISHER) {
uiDefBut(block, SEPR, 0, "", 0, xco-=6, 160, 6, NULL, 0.0, 0.0, 1, 0, "");
uiDefBut(block, BUTM, 1, "Install License Key", 0, xco-=20, 140, 19, NULL, 0.0, 0.0, 1, 20, "Install your Blender License Key");
uiDefIconBut(block, BUTM, 1, ICON_PUBLISHER, 141,xco, 19, 19, NULL, 0.0, 0.0, 1, 20, "Install your Blender License Key");
}
*/
uiDefBut(block, SEPR, 0, "", 0, xco-=6, 160, 6, NULL, 0.0, 0.0, 1, 0, "");
#ifdef EXPERIMENTAL_MENUS
uiDefBut(block, BUTM, 1, "Pack Data", 0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 10, "Saves a copy of all packed external files inside the project file");
uiDefBut(block, BUTM, 1, "Unpack Data to current dir", 0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 11, "Removes all packed files from the project and saves them to the current directory");
uiDefBut(block, BUTM, 1, "Advanced Unpack", 0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 12, "");
uiDefBut(block, SEPR, 0, "", 0, xco-=6, 160, 6, NULL, 0.0, 0.0, 1, 0, "");
uiDefBut(block, BUTM, 1, "Quit | Q", 0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 13, "Quits Blender immediately (WARNING! Save your project first!)");
#else /* EXPERIMENTAL_MENUS */
uiDefBut(block, BUTM, 1, "Quit | Q", 0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 10, "Quits Blender immediately (WARNING! Save your project first!)");
#endif /* EXPERIMENTAL_MENUS */
uiBlockSetDirection(block, UI_DOWN);
uiTextBoundsBlock(block, 80);
return block;
}
static void do_info_editmenu(void *arg, int event)
{
/* needed to check for valid selected objects */
Base *base=NULL;
Object *ob=NULL;
base= BASACT;
if (base) ob= base->object;
switch(event) {
case 0:
/* (De)Select All */
if(select_area(SPACE_VIEW3D)) mainqenter(AKEY, 1);
break;
/* Border Select */
case 1:
if(select_area(SPACE_VIEW3D)) mainqenter(BKEY, 1);
break;
case 2:
/* Circle Select */
/*if(select_area(SPACE_VIEW3D)) {
;
}*/
break;
case 3:
/* Duplicate */
if(select_area(SPACE_VIEW3D)) {
duplicate_context_selected();
}
break;
case 4:
/* Delete */
if(select_area(SPACE_VIEW3D)) {
delete_context_selected();
}
break;
case 5:
/* Edit Mode */
if(select_area(SPACE_VIEW3D)) {
blenderqread(TABKEY, 1);
}
break;
case 6:
/* Grabber */
if(select_area(SPACE_VIEW3D)) {
transform('g');
}
break;
case 7:
/* Rotate */
if(select_area(SPACE_VIEW3D)) {
transform('r');
}
break;
case 8:
/* Scale */
if(select_area(SPACE_VIEW3D)) {
transform('s');
}
break;
case 9:
/* Shear */
/* check that a valid object is selected to prevent crash */
if (!ob) error ("Only selected objects can be sheared");
else if ((ob->type==OB_LAMP) || (ob->type==OB_EMPTY) || (ob->type==OB_FONT) || (ob->type==OB_CAMERA)) {
error("Only editable 3D objects can be sheared");
}
else if ((base->lay & G.vd->lay)==0) {
error("Only objects on visible layers can be sheared");
}
else {
if (!G.obedit) {
enter_editmode();
/* ### put these into a deselectall_gen() */
if(G.obedit->type==OB_MESH) deselectall_mesh();
else if ELEM(G.obedit->type, OB_CURVE, OB_SURF) deselectall_nurb();
else if(G.obedit->type==OB_MBALL) deselectall_mball();
else if(G.obedit->type==OB_LATTICE) deselectall_Latt();
else if(G.obedit->type==OB_ARMATURE) deselectall_armature();
/* ### */
}
if(select_area(SPACE_VIEW3D)) {
transform('S');
}
}
if(select_area(SPACE_VIEW3D)) {
transform('S');
}
break;
case 10:
/* Warp/Bend */
/* check that a valid object is selected to prevent crash */
if (!ob) error("Only selected objects can be warped");
else if ((ob->type==OB_LAMP) || (ob->type==OB_EMPTY) || (ob->type==OB_FONT) || (ob->type==OB_CAMERA)) {
error("Only editable 3D objects can be warped");
}
else if ((base->lay & G.vd->lay)==0) {
error("Only objects on visible layers can be warped");
}
else {
if (!G.obedit) {
enter_editmode();
/* ### put these into a deselectall_gen() */
if(G.obedit->type==OB_MESH) deselectall_mesh();
else if ELEM(G.obedit->type, OB_CURVE, OB_SURF) deselectall_nurb();
else if(G.obedit->type==OB_MBALL) deselectall_mball();
else if(G.obedit->type==OB_LATTICE) deselectall_Latt();
else if(G.obedit->type==OB_ARMATURE) deselectall_armature();
/* ### */
}
if(select_area(SPACE_VIEW3D)) {
transform('w');
}
}
break;
case 11:
/* Snap */
if(select_area(SPACE_VIEW3D)) {
snapmenu();
}
break;
}
allqueue(REDRAWINFO, 0);
}
static uiBlock *info_editmenu(void *arg_unused)
{
/* static short tog=0; */
uiBlock *block;
short xco= 0;
block= uiNewBlock(&curarea->uiblocks, "editmenu", UI_EMBOSSP, UI_HELV, curarea->headwin);
uiBlockSetButmFunc(block, do_info_editmenu, NULL);
uiDefBut(block, BUTM, 1, "(De)Select All|A", 0, xco-=20, 120, 19, NULL, 0.0, 0.0, 1, 0, "Toggles between selecting all objects in the scene and selecting no objects");
uiDefBut(block, BUTM, 1, "Border Select|B", 0, xco-=20, 120, 19, NULL, 0.0, 0.0, 1, 1, "Selects objects in a rectangular area (press B again to activate circle select in edit mode)");
/* uiDefBut(block, BUTM, 1, "Circle Select", 0, xco-=20, 120, 19, NULL, 0.0, 0.0, 1, 2, "Select objects in a circular area"); */
uiDefBut(block, SEPR, 0, "", 0, xco-=6, 120, 6, NULL, 0.0, 0.0, 0, 0, "");
uiDefBut(block, BUTM, 1, "Duplicate|Shift D", 0, xco-=20, 120, 19, NULL, 0.0, 0.0, 1, 3, "Creates a copy of the selected object(s)");
uiDefBut(block, BUTM, 1, "Delete|X", 0, xco-=20, 120, 19, NULL, 0.0, 0.0, 1, 4, "Deletes the selected object(s)");
uiDefBut(block, BUTM, 1, "Edit Mode|Tab", 0, xco-=20, 120, 19, NULL, 0.0, 0.0, 1, 5, "Toggles the current object between object mode and edit mode");
uiDefBut(block, SEPR, 0, "", 0, xco-=6, 120, 6, NULL, 0.0, 0.0, 0, 0, "");
uiDefBut(block, BUTM, 1, "Grabber|G", 0, xco-=20, 120, 19, NULL, 0.0, 0.0, 1, 6, "Moves the selected object(s)");
uiDefBut(block, BUTM, 1, "Rotate|R", 0, xco-=20, 120, 19, NULL, 0.0, 0.0, 1, 7, "Rotates the selected object(s)");
uiDefBut(block, BUTM, 1, "Scale|S", 0, xco-=20, 120, 19, NULL, 0.0, 0.0, 1, 8, "Scales the selected object(s)");
uiDefBut(block, SEPR, 0, "", 0, xco-=6, 120, 6, NULL, 0.0, 0.0, 0, 0, "");
uiDefBut(block, BUTM, 1, "Shear|Ctrl S", 0, xco-=20, 120, 19, NULL, 0.0, 0.0, 1, 9, "Shears the selected object(s)");
uiDefBut(block, BUTM, 1, "Warp/Bend|Shift W", 0, xco-=20, 120, 19, NULL, 0.0, 0.0, 1, 10, "Warps or bends the selected objects");
uiDefBut(block, BUTM, 1, "Snap Menu|Shift S", 0, xco-=20, 120, 19, NULL, 0.0, 0.0, 1, 11, "Activates the snap menu");
uiBlockSetDirection(block, UI_DOWN);
uiTextBoundsBlock(block, 80);
return block;
}
static void do_info_add_meshmenu(void *arg, int event)
{
switch(event) {
#ifdef EXPERIMENTAL_MENUS
/* Maarten's proposal for a new Add Mesh menu */
case 0:
/* Line */
//add_primitiveMesh(4);
break;
case 1:
/* Circle */
if(select_area(SPACE_VIEW3D)) {
add_primitiveMesh(4);
}
break;
case 2:
/* Plane */
add_primitiveMesh(0);
break;
case 3:
/* Cube */
add_primitiveMesh(1);
break;
case 4:
/* UVsphere */
add_primitiveMesh(11);
break;
case 5:
/* IcoSphere */
add_primitiveMesh(12);
break;
case 6:
/* Cylinder */
add_primitiveMesh(5);
break;
case 7:
/* Tube */
add_primitiveMesh(6);
break;
case 8:
/* Cone */
add_primitiveMesh(7);
break;
case 9:
/* Grid */
add_primitiveMesh(10);
break;
#else /* EXPERIMENTAL_MENUS*/
case 0:
/* Plane */
add_primitiveMesh(0);
break;
case 1:
/* Cube */
add_primitiveMesh(1);
break;
case 2:
/* Circle */
add_primitiveMesh(4);
break;
case 3:
/* UVsphere */
add_primitiveMesh(11);
break;
case 4:
/* IcoSphere */
add_primitiveMesh(12);
break;
case 5:
/* Cylinder */
add_primitiveMesh(5);
break;
case 6:
/* Tube */
add_primitiveMesh(6);
break;
case 7:
/* Cone */
add_primitiveMesh(7);
break;
case 8:
/* Grid */
add_primitiveMesh(10);
break;
#endif /* EXPERIMENTAL_MENUS */
default:
break;
}
allqueue(REDRAWINFO, 0);
}
static uiBlock *info_add_meshmenu(void *arg_unused)
{
/* static short tog=0; */
uiBlock *block;
short xco= 0;
block= uiNewBlock(&curarea->uiblocks, "add_meshmenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
uiBlockSetButmFunc(block, do_info_add_meshmenu, NULL);
#ifdef EXPERIMENTAL_MENUS
/* Maarten's proposal for a new Add Mesh menu */
uiDefBut(block, BUTM, 1, "Line|", 0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "Adds a Mesh Line");
uiDefBut(block, BUTM, 1, "Circle|", 0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 1, "Adds a Mesh Circle");
uiDefBut(block, SEPR, 0, "", 0, xco-=6, 160, 6, NULL, 0.0, 0.0, 0, 0, "");
uiDefBut(block, BUTM, 1, "Plane|", 0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 2, "Adds a Mesh Plane");
uiDefBut(block, BUTM, 1, "Cube|", 0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 3, "Adds a Mesh Cube");
uiDefBut(block, BUTM, 1, "UVsphere", 0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 4, "Adds a Mesh Sphere");
uiDefBut(block, BUTM, 1, "IcoSphere|", 0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 5, "Adds a Mesh Isocohedron Sphere");
uiDefBut(block, BUTM, 1, "Cylinder With Caps|", 0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 6, "Adds a Mesh Cylinder with caps");
uiDefBut(block, BUTM, 1, "Cylinder Without Caps|", 0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 7, "Adds a Mesh Cylinder without caps");
uiDefBut(block, BUTM, 1, "Cone|", 0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 8, "Adds a Mesh Cone");
uiDefBut(block, BUTM, 1, "Grid|", 0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 9, "Adds a Mesh Grid");
#else /* EXPERIMENTAL_MENUS */
uiDefBut(block, BUTM, 1, "Plane|", 0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "Adds a Mesh Plane");
uiDefBut(block, BUTM, 1, "Cube|", 0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 1, "Adds a Mesh Cube");
uiDefBut(block, BUTM, 1, "Circle|", 0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 2, "Adds a Mesh Circle");
uiDefBut(block, BUTM, 1, "UVsphere", 0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 3, "Adds a Mesh Sphere");
uiDefBut(block, BUTM, 1, "IcoSphere|", 0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 4, "Adds a Mesh Isocohedron Sphere");
uiDefBut(block, BUTM, 1, "Cylinder|", 0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 5, "Adds a Mesh Cylinder with closed ends");
uiDefBut(block, BUTM, 1, "Tube|", 0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 6, "Adds a Mesh Tube with open ends");
uiDefBut(block, BUTM, 1, "Cone|", 0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 7, "Adds a Mesh Cone");
uiDefBut(block, SEPR, 0, "", 0, xco-=6, 160, 6, NULL, 0.0, 0.0, 0, 0, "");
uiDefBut(block, BUTM, 1, "Grid|", 0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 8, "Adds a Mesh Grid");
#endif /* EXPERIMENTAL_MENUS */
uiBlockSetDirection(block, UI_RIGHT);
uiTextBoundsBlock(block, 50);
return block;
}
static void do_info_add_curvemenu(void *arg, int event)
{
switch(event) {
case 0:
/* Bezier Curve */
add_primitiveCurve(10);
break;
case 1:
/* Bezier Circle */
add_primitiveCurve(11);
break;
case 2:
/* NURB Curve */
add_primitiveCurve(40);
break;
case 3:
/* NURB Circle */
add_primitiveCurve(41);
break;
case 4:
/* Path */
add_primitiveCurve(46);
break;
default:
break;
}
allqueue(REDRAWINFO, 0);
}
static uiBlock *info_add_curvemenu(void *arg_unused)
{
/* static short tog=0; */
uiBlock *block;
short xco= 0;
block= uiNewBlock(&curarea->uiblocks, "add_curvemenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
uiBlockSetButmFunc(block, do_info_add_curvemenu, NULL);
uiDefBut(block, BUTM, 1, "Bezier Curve|", 0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "Adds a Bezier Curve");
uiDefBut(block, BUTM, 1, "Bezier Circle|", 0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 1, "Adds a Bezier Circle");
uiDefBut(block, BUTM, 1, "NURBS Curve|", 0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 2, "Adds a NURBS Curve");
uiDefBut(block, BUTM, 1, "NURBS Circle", 0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 3, "Adds a NURBS Circle");
uiDefBut(block, BUTM, 1, "Path|", 0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 4, "Adds a Path");
uiBlockSetDirection(block, UI_RIGHT);
uiTextBoundsBlock(block, 50);
return block;
}
static void do_info_add_surfacemenu(void *arg, int event)
{
switch(event) {
case 0:
/* Curve */
add_primitiveNurb(0);
break;
case 1:
/* Circle */
add_primitiveNurb(1);
break;
case 2:
/* Surface */
add_primitiveNurb(2);
break;
case 3:
/* Tube */
add_primitiveNurb(3);
break;
case 4:
/* Sphere */
add_primitiveNurb(4);
break;
case 5:
/* Donut */
add_primitiveNurb(5);
break;
default:
break;
}
allqueue(REDRAWINFO, 0);
}
static uiBlock *info_add_surfacemenu(void *arg_unused)
{
/* static short tog=0; */
uiBlock *block;
short xco= 0;
block= uiNewBlock(&curarea->uiblocks, "add_surfacemenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
uiBlockSetButmFunc(block, do_info_add_surfacemenu, NULL);
uiDefBut(block, BUTM, 1, "NURBS Curve|", 0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "Adds a NURBS Curve");
uiDefBut(block, BUTM, 1, "NURBS Circle|", 0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 1, "Adds a NURBS Circle");
uiDefBut(block, BUTM, 1, "NURBS Surface|", 0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 2, "Adds a NURBS Surface");
uiDefBut(block, BUTM, 1, "NURBS Tube", 0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 3, "Adds a NURBS Tube");
uiDefBut(block, BUTM, 1, "NURBS Sphere|", 0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 4, "Adds a NURBS Sphere");
uiDefBut(block, BUTM, 1, "NURBS Donut|", 0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 5, "Adds a NURBS Donut (Torus)");
uiBlockSetDirection(block, UI_RIGHT);
uiTextBoundsBlock(block, 50);
return block;
}
static void do_info_add_metamenu(void *arg, int event)
{
switch(event) {
case 0:
/* Ball */
add_primitiveMball(1);
break;
case 1:
/* Tube */
add_primitiveMball(2);
break;
case 2:
/* Plane */
add_primitiveMball(3);
break;
case 3:
/* Elipsoid */
add_primitiveMball(4);
break;
case 4:
/* Cube */
add_primitiveMball(5);
break;
default:
break;
}
allqueue(REDRAWINFO, 0);
}
static uiBlock *info_add_metamenu(void *arg_unused)
{
/* static short tog=0; */
uiBlock *block;
short xco= 0;
block= uiNewBlock(&curarea->uiblocks, "add_metamenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
uiBlockSetButmFunc(block, do_info_add_metamenu, NULL);
uiDefBut(block, BUTM, 1, "Meta Ball|", 0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "Add a ball");
uiDefBut(block, BUTM, 1, "Meta Tube|", 0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 1, "Add a tube");
uiDefBut(block, BUTM, 1, "Meta Plane|", 0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 2, "Add a square");
uiDefBut(block, BUTM, 1, "Meta Elipsoid|", 0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 3, "Add a elipsoid");
uiDefBut(block, BUTM, 1, "Meta Cube|", 0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 4, "Add a circle");
uiBlockSetDirection(block, UI_RIGHT);
uiTextBoundsBlock(block, 50);
return block;
}
static void do_info_addmenu(void *arg, int event)
{
switch(event) {
case 0:
/* Mesh */
break;
case 1:
/* Curve */
break;
case 2:
/* Surface */
break;
case 3:
/* Metaball */
break;
case 4:
/* Text (argument is discarded) */
add_primitiveFont(event);
break;
case 5:
/* Empty */
add_object_draw(OB_EMPTY);
break;
case 6:
/* Camera */
add_object_draw(OB_CAMERA);
break;
case 7:
/* Lamp */
add_object_draw(OB_LAMP);
break;
case 8:
/* Armature */
add_primitiveArmature(OB_ARMATURE);
break;
case 9:
/* Lattice */
add_object_draw(OB_LATTICE);
break;
default:
break;
}
allqueue(REDRAWINFO, 0);
}
static uiBlock *info_addmenu(void *arg_unused)
{
/* static short tog=0; */
uiBlock *block;
short xco= 0;
block= uiNewBlock(&curarea->uiblocks, "addmenu", UI_EMBOSSP, UI_HELV, curarea->headwin);
uiBlockSetButmFunc(block, do_info_addmenu, NULL);
uiDefBlockBut(block, info_add_meshmenu, NULL, "Mesh|>>", 0, xco-=20, 120, 19, "Opens the Add Mesh menu");
uiDefBlockBut(block, info_add_curvemenu, NULL, "Curve|>>", 0, xco-=20, 120, 19, "Opens the Add Curve menu");
uiDefBlockBut(block, info_add_surfacemenu, NULL, "Surface|>>", 0, xco-=20, 120, 19, "Opens the Add Surface menu");
uiDefBlockBut(block, info_add_metamenu, NULL, "Meta|>>", 0, xco-=20, 120, 19, "Click to open the Add Meta menu");
uiDefBut(block, SEPR, 0, "", 0, xco-=6, 120, 6, NULL, 0.0, 0.0, 0, 0, "");
uiDefBut(block, BUTM, 1, "Text|", 0, xco-=20, 120, 19, NULL, 0.0, 0.0, 1, 3, "Adds a Text object");
uiDefBut(block, BUTM, 1, "Empty|", 0, xco-=20, 120, 19, NULL, 0.0, 0.0, 1, 5, "Adds an Empty object");
uiDefBut(block, SEPR, 0, "", 0, xco-=6, 120, 6, NULL, 0.0, 0.0, 0, 0, "");
uiDefBut(block, BUTM, 1, "Camera|", 0, xco-=20, 120, 19, NULL, 0.0, 0.0, 1, 6, "Adds a Camera");
uiDefBut(block, BUTM, 1, "Lamp|", 0, xco-=20, 120, 19, NULL, 0.0, 0.0, 1, 7, "Adds a Lamp");
// uiDefBut(block, BUTM, 1, "Armature|", 0, xco-=20, 120, 19, NULL, 0.0, 0.0, 1, 8, "Adds an Armature");
uiDefBut(block, SEPR, 0, "", 0, xco-=6, 120, 6, NULL, 0.0, 0.0, 0, 0, "");
uiDefBut(block, BUTM, 1, "Lattice|", 0, xco-=20, 120, 19, NULL, 0.0, 0.0, 1, 9, "Adds a Lattice");
uiBlockSetDirection(block, UI_DOWN);
uiTextBoundsBlock(block, 80);
return block;
}
static void do_info_viewmenu(void *arg, int event)
{
switch(event) {
case 0:
if(select_area(SPACE_VIEW3D)) mainqenter(PAD1, 1);
break;
case 1:
if(select_area(SPACE_VIEW3D)) mainqenter(PAD3, 1);
break;
case 2:
if(select_area(SPACE_VIEW3D)) mainqenter(PAD7, 1);
break;
case 3:
if(select_area(SPACE_VIEW3D)) mainqenter(PAD0, 1);
break;
case 4:
if(select_area(SPACE_VIEW3D)) mainqenter(PADPLUSKEY, 1);
break;
case 5:
if(select_area(SPACE_VIEW3D)) mainqenter(PADMINUS, 1);
break;
case 6:
if(select_area(SPACE_VIEW3D)) mainqenter(CKEY, 1);
break;
case 7:
if(select_area(SPACE_VIEW3D)) mainqenter(HOMEKEY, 1);
break;
}
allqueue(REDRAWINFO, 0);
}
static uiBlock *info_viewmenu(void *arg_unused)
{
/* static short tog=0; */
uiBlock *block;
short xco= 0;
block= uiNewBlock(&curarea->uiblocks, "filemenu", UI_EMBOSSP, UI_HELV, curarea->headwin);
uiBlockSetButmFunc(block, do_info_viewmenu, NULL);
// uiBlockSetCol(block, BUTBLUE);
uiDefBut(block, BUTM, 1, "Front|NumPad 1", 0, xco-=20, 140, 19, NULL, 0.0, 0.0, 0, 0, "Sets current viewport to Front view");
uiDefBut(block, BUTM, 1, "Right|NumPad 3", 0, xco-=20, 140, 19, NULL, 0.0, 0.0, 0, 1, "Sets current viewport to Right view");
uiDefBut(block, BUTM, 1, "Top|NumPad 7", 0, xco-=20, 140, 19, NULL, 0.0, 0.0, 0, 2, "Sets current viewport to Top view");
uiDefBut(block, BUTM, 1, "Camera|NumPad 0", 0, xco-=20, 140, 19, NULL, 0.0, 0.0, 0, 3, "Sets current viewport to Camera view");
uiDefBut(block, SEPR, 0, "", 0, xco-=6, 140, 6, NULL, 0.0, 0.0, 0, 0, "");
uiDefBut(block, BUTM, 1, "Zoom In|NumPad +", 0, xco-=20, 140, 19, NULL, 0.0, 0.0, 0, 4, "Zooms In current viewport");
uiDefBut(block, BUTM, 1, "Zoom Out|NumPad -", 0, xco-=20, 140, 19, NULL, 0.0, 0.0, 0, 5, "Zooms Out current viewport");
uiDefBut(block, SEPR, 0, "", 0, xco-=6, 140, 6, NULL, 0.0, 0.0, 0, 0, "");
uiDefBut(block, BUTM, 1, "Center|C", 0, xco-=20, 140, 19, NULL, 0.0, 0.0, 0, 6, "Centers selected item in current viewport");
uiDefBut(block, BUTM, 1, "View All|Home", 0, xco-=20, 140, 19, NULL, 0.0, 0.0, 0, 7, "Zooms In or Out to fit all objects in current viewport");
uiBlockSetDirection(block, UI_DOWN);
uiTextBoundsBlock(block, 50);
return block;
}
static void do_game_menu(void *arg, int event)
{
switch (event) {
case G_FILE_ENABLE_ALL_FRAMES_BIT:
case G_FILE_SHOW_FRAMERATE_BIT:
case G_FILE_SHOW_DEBUG_PROPS_BIT:
case G_FILE_AUTOPLAY_BIT:
G.fileflags ^= (1 << event);
break;
default:
; /* ignore the rest */
}
}
static uiBlock *info_gamemenu(void *arg_unused)
{
uiBlock *block;
short yco= 0;
block= uiNewBlock(&curarea->uiblocks, "gamemenu", UI_EMBOSSP, UI_HELV, curarea->headwin);
uiBlockSetCol(block, BUTBLUE);
uiBlockSetDirection(block, UI_DOWN);
#if GAMEBLENDER == 1
uiDefBut(block, BUTM, B_STARTGAME, "Starts Game|P",
0, yco-=20, 160, 19, NULL, 0.0, 0.0, 0, 0,
"Start the game (press the Escape key to stop)");
uiDefBut(block, SEPR, 0, "",
-20, yco-=6, 180, 6, NULL, 0.0, 0.0, 1, 0, "");
#endif
/* flags are case-values */
uiBlockSetButmFunc(block, do_game_menu, NULL);
uiDefBut(block, BUTM, 1, "Enable All Frames",
0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, G_FILE_ENABLE_ALL_FRAMES_BIT,
"Toggles between draw all frames on (no frames dropped) and off (full speed)");
uiDefBut(block, BUTM, 1, "Show framerate and profile",
0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, G_FILE_SHOW_FRAMERATE_BIT,
"Toggles between showing and not showing the framerate and profile");
uiDefBut(block, BUTM, 1, "Show debug properties",
0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, G_FILE_SHOW_DEBUG_PROPS_BIT,
"Toggles between showing and not showing debug properties");
uiDefBut(block, SEPR, 0, "", -20, yco-=6, 180, 6, NULL, 0.0, 0.0, 1, 0, "");
uiDefBut(block, BUTM, 1, "Autostart",
0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, G_FILE_AUTOPLAY_BIT,
"Toggles between automatic game start on and off");
uiTextBoundsBlock(block, 50);
/* Toggle buttons */
#if GAMEBLENDER == 1
yco= -26;
#else
yco= 0;
#endif
uiBlockSetEmboss(block, UI_EMBOSSW);
/* flags are defines */
uiBlockSetButmFunc(block, NULL, NULL); // to prevent it from calling the menu function
uiDefIconButI(block, ICONTOG|BIT|G_FILE_ENABLE_ALL_FRAMES_BIT,
0, ICON_CHECKBOX_DEHLT, -20, yco-=20, 19, 19,
&G.fileflags, 0.0, 0.0, 0, 0, "");
uiDefIconButI(block, ICONTOG|BIT|G_FILE_SHOW_FRAMERATE_BIT,
0, ICON_CHECKBOX_DEHLT, -20, yco-=20, 19, 19,
&G.fileflags, 0.0, 0.0, 0, 0, "");
uiDefIconButI(block, ICONTOG|BIT|G_FILE_SHOW_DEBUG_PROPS_BIT,
0, ICON_CHECKBOX_DEHLT, -20, yco-=20, 19, 19,
&G.fileflags, 0.0, 0.0, 0, 0, "");
yco-=6;
uiDefIconButI(block, ICONTOG|BIT|G_FILE_AUTOPLAY_BIT,
0, ICON_CHECKBOX_DEHLT, -20, yco-=20, 19, 19,
&G.fileflags, 0.0, 0.0, 0, 0, "");
return block;
}
#ifndef EXPERIMENTAL_MENUS
/* In the Maarten's new menu structure proposal, the tools menu moved to the file menu */
static void do_info_toolsmenu(void *arg, int event)
{
switch(event) {
case 0:
check_packAll();
break;
case 1:
unpackAll(PF_WRITE_LOCAL);
G.fileflags &= ~G_AUTOPACK;
break;
case 2:
if (buttons_do_unpack() != RET_CANCEL) {
// clear autopack bit only if
// user selected one of the unpack options
G.fileflags &= ~G_AUTOPACK;
}
break;
}
allqueue(REDRAWINFO, 0);
}
static uiBlock *info_toolsmenu(void *arg_unused)
{
/* static short tog=0; */
uiBlock *block;
short xco= 0;
block= uiNewBlock(&curarea->uiblocks, "toolsmenu", UI_EMBOSSP, UI_HELV, curarea->headwin);
uiBlockSetButmFunc(block, do_info_toolsmenu, NULL);
// uiBlockSetCol(block, BUTBLUE);
uiDefBut(block, BUTM, 1, "Pack Data", 0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "Saves a copy of all packed external files inside the project file");
uiDefBut(block, BUTM, 1, "Unpack Data to current dir", 0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 1, "Removes all packed files from the project and saves them to the current directory");
uiDefBut(block, BUTM, 1, "Advanced Unpack", 0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 2, "");
uiBlockSetDirection(block, UI_DOWN);
uiTextBoundsBlock(block, 20);
return block;
}
#endif /* EXPERIMENTAL_MENUS */
static void info_text(int x, int y)
{
Object *ob;
extern float hashvectf[];
extern int mem_in_use;
unsigned int swatch_color;
float fac1, fac2, fac3;
char infostr[300];
char *headerstr;
int hsize;
if(G.obedit) {
sprintf(infostr,"Ve:%d-%d Fa:%d-%d Mem:%.2fM ",
G.totvertsel, G.totvert, G.totfacesel, G.totface,
(mem_in_use>>10)/1024.0);
}
else {
sprintf(infostr,"Ve:%d Fa:%d Ob:%d-%d La:%d Mem:%.2fM ",
G.totvert, G.totface, G.totobj, G.totobjsel, G.totlamp, (mem_in_use>>10)/1024.0);
}
ob= OBACT;
if(ob) {
strcat(infostr, ob->id.name+2);
}
if (g_progress_bar) {
hsize = 4 + (138.0 * g_done);
fac1 = 0.5 * g_done; // do some rainbow colours on progress
fac2 = 1.0;
fac3 = 0.9;
} else {
hsize = 150;
/* promise! Never change these lines again! (zr & ton did!) */
fac1= fabs(hashvectf[ 2*G.version+5]);
fac2= 0.5+0.1*hashvectf[ G.version+4]; /* was '4 and 3', for 2.28a patch... */
fac3= 0.7;
}
if (g_progress_bar && g_progress_info) {
headerstr= g_progress_info;
} else {
headerstr= versionstr;
headerstr= "www.blender.org 2.28c"; /* patch! */
}
swatch_color= hsv_to_cpack(fac1, fac2, fac3);
cpack( swatch_color );
glRecti(x-24, y-4, x-24+hsize, y+13);
glColor3ub(0, 0, 0);
glRasterPos2i(x, y);
BIF_DrawString(G.font, headerstr, (U.transopts & TR_MENUS), 0);
glRasterPos2i(x-20+hsize, y);
BIF_DrawString(G.font, infostr, (U.transopts & TR_MENUS), 0);
}
static int GetButStringLength(char *str) {
int rt;
rt= BIF_GetStringWidth(G.font, str, (U.transopts & TR_BUTTONS));
return rt + 15;
}
void info_buttons(void)
{
uiBlock *block;
short xco= 32;
char naam[20];
int xmax;
sprintf(naam, "header %d", curarea->headwin);
block= uiNewBlock(&curarea->uiblocks, naam, UI_EMBOSSN, UI_HELV, curarea->headwin);
uiBlockSetCol(block, BUTGREY);
if(U.uiflag & FLIPINFOMENU) {
uiDefIconButS(block, TOG|BIT|6, B_FLIPINFOMENU, ICON_DISCLOSURE_TRI_RIGHT,
xco,2,XIC,YIC-2,
&(U.uiflag), 0, 0, 0, 0, "Enables display of pulldown menus");/* dir */
} else {
uiDefIconButS(block, TOG|BIT|6, B_FLIPINFOMENU, ICON_DISCLOSURE_TRI_DOWN,
xco,2,XIC,YIC-2,
&(U.uiflag), 0, 0, 0, 0, "Hides pulldown menus");/* dir */
}
xco+=XIC;
if(U.uiflag & FLIPINFOMENU) {
} else {
uiBlockSetEmboss(block, UI_EMBOSSP);
xmax= GetButStringLength("File");
uiDefBlockBut(block, info_filemenu, NULL, "File", xco, 3, xmax, 15, "");
xco+= xmax;
xmax= GetButStringLength("Edit");
uiDefBlockBut(block, info_editmenu, NULL, "Edit", xco, 3, xmax, 15, "");
xco+= xmax;
xmax= GetButStringLength("Add");
uiDefBlockBut(block, info_addmenu, NULL, "Add", xco, 3, xmax, 15, "");
xco+= xmax;
xmax= GetButStringLength("View");
uiDefBlockBut(block, info_viewmenu, NULL, "View", xco, 3, xmax, 15, "");
xco+= xmax;
xmax= GetButStringLength("Game");
uiDefBlockBut(block, info_gamemenu, NULL, "Game", xco, 3, xmax, 15, "");
xco+= xmax;
#ifndef EXPERIMENTAL_MENUS
// In the Maarten's new menu structure proposal, the tools menu moved to the file menu
xmax= GetButStringLength("Tools");
uiDefBlockBut(block, info_toolsmenu, NULL, "Tools", xco, 3, xmax, 15, "");
xco+= xmax;
#endif // EXPERIMENTAL_MENUS
}
/* pack icon indicates a packed file */
if (G.fileflags & G_AUTOPACK) {
uiBlockSetEmboss(block, UI_EMBOSSN);
uiDefIconBut(block, LABEL, 0, ICON_PACKAGE, xco, 0, XIC, YIC, &G.fileflags, 0.0, 0.0, 0, 0, "Indicates this is a Packed file. See File menu.");
xco += XIC;
uiBlockSetEmboss(block, UI_EMBOSSX);
}
uiBlockSetEmboss(block, UI_EMBOSSX);
if (curarea->full == 0) {
curarea->butspacetype= SPACE_INFO;
uiDefIconTextButC(block, ICONTEXTROW,B_NEWSPACE, ICON_VIEW3D, windowtype_pup(), 6,0,XIC,YIC, &(curarea->butspacetype), 1.0, SPACEICONMAX, 0, 0, "Displays Current Window Type. Click for menu of available types.");
/* STD SCREEN BUTTONS */
// xco+= XIC;
xco+= 4;
xco= std_libbuttons(block, xco, 0, NULL, B_INFOSCR, (ID *)G.curscreen, 0, &G.curscreen->screennr, 1, 1, B_INFODELSCR, 0, 0);
/* STD SCENE BUTTONS */
xco+= 5;
xco= std_libbuttons(block, xco, 0, NULL, B_INFOSCE, (ID *)G.scene, 0, &G.curscreen->scenenr, 1, 1, B_INFODELSCE, 0, 0);
}
else xco= 430;
info_text(xco+24, 6);
uiBlockSetEmboss(block, UI_EMBOSSN);
uiDefIconBut(block, BUT, B_SHOWSPLASH, ICON_BLENDER, xco+1, 0,XIC,YIC, 0, 0, 0, 0, 0, "Click to display Splash Screen");
uiBlockSetEmboss(block, UI_EMBOSSX);
/*
uiBlockSetEmboss(block, UI_EMBOSSN);
uiDefIconBut(block, LABEL, 0, ICON_PUBLISHER, xco+125, 0,XIC,YIC, 0, 0, 0, 0, 0, "");
uiBlockSetEmboss(block, UI_EMBOSSX);
*/
/* always do as last */
curarea->headbutlen= xco+2*XIC;
if(curarea->headbutlen + 4*XIC < curarea->winx) {
uiDefIconBut(block, BUT, B_FILEMENU, ICON_HELP,
(short)(curarea->winx-XIC-2), 0,XIC,YIC,
0, 0, 0, 0, 0, "Displays Toolbox menu (SPACE)");
#ifdef _WIN32 // FULLSCREEN
if(U.uiflag & FLIPFULLSCREEN) {
uiDefIconBut(block, BUT, B_FLIPFULLSCREEN, ICON_WINDOW_WINDOW,
(short)(curarea->winx-(XIC*2)-2), 0,XIC,YIC,
0, 0, 0, 0, 0, "Toggles Blender to fullscreen mode");/* dir */
} else {
uiDefIconBut(block, BUT, B_FLIPFULLSCREEN, ICON_WINDOW_FULLSCREEN,
(short)(curarea->winx-(XIC*2)-2), 0,XIC,YIC,
0, 0, 0, 0, 0, "Toggles Blender to fullscreen mode");/* dir */
}
#endif
/*
#ifdef _WIN32 // FULLSCREEN
if(U.uiflag & FLIPFULLSCREEN) {
uiDefIconButS(block, TOG|BIT|7, B_FLIPFULLSCREEN, ICON_WINDOW_WINDOW,
(short)(curarea->winx-(XIC*2)-2), 0,XIC,YIC,
&(U.uiflag), 0, 0, 0, 0, "Toggle Blender fullscreen");
} else {
uiDefIconButS(block, TOG|BIT|7, B_FLIPFULLSCREEN, ICON_WINDOW_FULLSCREEN,
(short)(curarea->winx-(XIC*2)-2), 0,XIC,YIC,
&(U.uiflag), 0, 0, 0, 0, "Toggle Blender fullscreen");
}
#endif
*/
}
uiDrawBlock(block);
}
/* ********************** END INFO ****************************** */
/* ********************** SEQUENCE ****************************** */
void do_seq_buttons(short event)
{
Editing *ed;
ed= G.scene->ed;
if(ed==0) return;
switch(event) {
case B_SEQHOME:
G.v2d->cur= G.v2d->tot;
test_view2d(G.v2d, curarea->winx, curarea->winy);
scrarea_queue_winredraw(curarea);
break;
case B_SEQCLEAR:
free_imbuf_seq();
allqueue(REDRAWSEQ, 1);
break;
}
}
void seq_buttons()
{
SpaceSeq *sseq;
short xco;
char naam[20];
uiBlock *block;
sseq= curarea->spacedata.first;
sprintf(naam, "header %d", curarea->headwin);
block= uiNewBlock(&curarea->uiblocks, naam, UI_EMBOSSX, UI_HELV, curarea->headwin);
uiBlockSetCol(block, BUTPURPLE);
curarea->butspacetype= SPACE_SEQ;
uiDefIconTextButC(block, ICONTEXTROW,B_NEWSPACE, ICON_VIEW3D, windowtype_pup(), 6,0,XIC,YIC, &(curarea->butspacetype), 1.0, SPACEICONMAX, 0, 0, "Displays Current Window Type. Click for menu of available types.");
/* FULL WINDOW */
xco= 25;
if(curarea->full) uiDefIconBut(block, BUT,B_FULL, ICON_SPLITSCREEN, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Returns to multiple views window (CTRL+Up arrow)");
else uiDefIconBut(block, BUT,B_FULL, ICON_FULLSCREEN, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Makes current window full screen (CTRL+Down arrow)");
/* HOME */
uiDefIconBut(block, BUT, B_SEQHOME, ICON_HOME, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Zooms window to home view showing all items (HOMEKEY)");
xco+= XIC;
/* IMAGE */
uiDefIconButS(block, TOG, B_REDR, ICON_IMAGE_COL, xco+=XIC,0,XIC,YIC, &sseq->mainb, 0, 0, 0, 0, "Toggles image display");
/* ZOOM and BORDER */
xco+= XIC;
uiDefIconButI(block, TOG, B_VIEW2DZOOM, ICON_VIEWZOOM, xco+=XIC,0,XIC,YIC, &viewmovetemp, 0, 0, 0, 0, "Zooms view in and out (CTRL+MiddleMouse)");
uiDefIconBut(block, BUT, B_IPOBORDER, ICON_BORDERMOVE, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Zooms view to fit area");
/* CLEAR MEM */
xco+= XIC;
uiDefBut(block, BUT, B_SEQCLEAR, "Clear", xco+=XIC,0,2*XIC,YIC, 0, 0, 0, 0, 0, "Forces a clear of all buffered images in memory");
uiDrawBlock(block);
}
/* ********************** END SEQ ****************************** */
/* ********************** VIEW3D ****************************** */
void do_view3d_buttons(short event)
{
int bit;
/* watch it: if curarea->win does not exist, check that when calling direct drawing routines */
switch(event) {
case B_HOME:
view3d_home(0);
break;
case B_SCENELOCK:
if(G.vd->scenelock) {
G.vd->lay= G.scene->lay;
/* seek for layact */
bit= 0;
while(bit<32) {
if(G.vd->lay & (1<<bit)) {
G.vd->layact= 1<<bit;
break;
}
bit++;
}
G.vd->camera= G.scene->camera;
scrarea_queue_winredraw(curarea);
scrarea_queue_headredraw(curarea);
}
break;
case B_LOCALVIEW:
if(G.vd->localview) initlocalview();
else endlocalview(curarea);
scrarea_queue_headredraw(curarea);
break;
case B_EDITMODE:
if (G.f & G_VERTEXPAINT) {
/* Switch off vertex paint */
G.f &= ~G_VERTEXPAINT;
}
if (G.f & G_WEIGHTPAINT){
/* Switch off weight paint */
G.f &= ~G_WEIGHTPAINT;
}
#ifdef NAN_TPT
if (G.f & G_TEXTUREPAINT) {
/* Switch off texture paint */
G.f &= ~G_TEXTUREPAINT;
}
#endif /* NAN_VPT */
if(G.obedit==0) enter_editmode();
else exit_editmode(1);
scrarea_queue_headredraw(curarea);
break;
case B_POSEMODE:
/* if (G.obedit){
error("Unable to perform function in EditMode");
G.vd->flag &= ~V3D_POSEMODE;
scrarea_queue_headredraw(curarea);
}
else{
*/
if (G.obpose==NULL) enter_posemode();
else exit_posemode(1);
allqueue(REDRAWHEADERS, 0);
break;
case B_WPAINT:
if (G.f & G_VERTEXPAINT) {
/* Switch off vertex paint */
G.f &= ~G_VERTEXPAINT;
}
#ifdef NAN_TPT
if ((!(G.f & G_WEIGHTPAINT)) && (G.f & G_TEXTUREPAINT)) {
/* Switch off texture paint */
G.f &= ~G_TEXTUREPAINT;
}
#endif /* NAN_VPT */
if(G.obedit) {
error("Unable to perform function in EditMode");
G.vd->flag &= ~V3D_WEIGHTPAINT;
scrarea_queue_headredraw(curarea);
}
else if(G.obpose) {
error("Unable to perform function in PoseMode");
G.vd->flag &= ~V3D_WEIGHTPAINT;
scrarea_queue_headredraw(curarea);
}
else set_wpaint();
break;
case B_VPAINT:
if ((!(G.f & G_VERTEXPAINT)) && (G.f & G_WEIGHTPAINT)) {
G.f &= ~G_WEIGHTPAINT;
}
#ifdef NAN_TPT
if ((!(G.f & G_VERTEXPAINT)) && (G.f & G_TEXTUREPAINT)) {
/* Switch off texture paint */
G.f &= ~G_TEXTUREPAINT;
}
#endif /* NAN_VPT */
if(G.obedit) {
error("Unable to perform function in EditMode");
G.vd->flag &= ~V3D_VERTEXPAINT;
scrarea_queue_headredraw(curarea);
}
else if(G.obpose) {
error("Unable to perform function in PoseMode");
G.vd->flag &= ~V3D_VERTEXPAINT;
scrarea_queue_headredraw(curarea);
}
else set_vpaint();
break;
#ifdef NAN_TPT
case B_TEXTUREPAINT:
if (G.f & G_TEXTUREPAINT) {
G.f &= ~G_TEXTUREPAINT;
}
else {
if (G.obedit) {
error("Unable to perform function in EditMode");
G.vd->flag &= ~V3D_TEXTUREPAINT;
}
else {
if (G.f & G_WEIGHTPAINT){
/* Switch off weight paint */
G.f &= ~G_WEIGHTPAINT;
}
if (G.f & G_VERTEXPAINT) {
/* Switch off vertex paint */
G.f &= ~G_VERTEXPAINT;
}
if (G.f & G_FACESELECT) {
/* Switch off face select */
G.f &= ~G_FACESELECT;
}
G.f |= G_TEXTUREPAINT;
scrarea_queue_headredraw(curarea);
}
}
break;
#endif /* NAN_TPT */
case B_FACESEL:
if(G.obedit) {
error("Unable to perform function in EditMode");
G.vd->flag &= ~V3D_FACESELECT;
scrarea_queue_headredraw(curarea);
}
else if(G.obpose) {
error("Unable to perform function in PoseMode");
G.vd->flag &= ~V3D_FACESELECT;
scrarea_queue_headredraw(curarea);
}
else set_faceselect();
break;
case B_VIEWBUT:
if(G.vd->viewbut==1) persptoetsen(PAD7);
else if(G.vd->viewbut==2) persptoetsen(PAD1);
else if(G.vd->viewbut==3) persptoetsen(PAD3);
break;
case B_PERSP:
if(G.vd->persp==2) persptoetsen(PAD0);
else {
G.vd->persp= 1-G.vd->persp;
persptoetsen(PAD5);
}
break;
case B_PROPTOOL:
allqueue(REDRAWHEADERS, 0);
break;
case B_VIEWRENDER:
if (curarea->spacetype==SPACE_VIEW3D) {
BIF_do_ogl_render(curarea->spacedata.first, G.qual!=0 );
}
break;
case B_STARTGAME:
if (select_area(SPACE_VIEW3D)) {
start_game();
}
break;
case B_VIEWZOOM:
viewmovetemp= 0;
viewmove(2);
scrarea_queue_headredraw(curarea);
break;
case B_VIEWTRANS:
viewmovetemp= 0;
viewmove(1);
scrarea_queue_headredraw(curarea);
break;
default:
if(event>=B_LAY && event<B_LAY+31) {
if(G.vd->lay!=0 && (G.qual & LR_SHIFTKEY)) {
/* but do find active layer */
bit= event-B_LAY;
if( G.vd->lay & (1<<bit)) G.vd->layact= 1<<bit;
else {
if( (G.vd->lay & G.vd->layact) == 0) {
bit= 0;
while(bit<32) {
if(G.vd->lay & (1<<bit)) {
G.vd->layact= 1<<bit;
break;
}
bit++;
}
}
}
}
else {
bit= event-B_LAY;
G.vd->lay= 1<<bit;
G.vd->layact= G.vd->lay;
scrarea_queue_headredraw(curarea);
}
scrarea_queue_winredraw(curarea);
countall();
if(G.vd->scenelock) handle_view3d_lock();
allqueue(REDRAWOOPS, 0);
}
break;
}
}
void do_layer_buttons(short event)
{
static int oldlay= 1;
if(G.vd==0) return;
if(G.vd->localview) return;
if(event==-1 && (G.qual & LR_CTRLKEY)) {
G.vd->scenelock= !G.vd->scenelock;
do_view3d_buttons(B_SCENELOCK);
} else if (event==-1) {
if(G.vd->lay== (2<<20)-1) {
if(G.qual & LR_SHIFTKEY) G.vd->lay= oldlay;
}
else {
oldlay= G.vd->lay;
G.vd->lay= (2<<20)-1;
}
if(G.vd->scenelock) handle_view3d_lock();
scrarea_queue_winredraw(curarea);
}
else {
if(G.qual & LR_ALTKEY) {
if(event<11) event+= 10;
}
if(G.qual & LR_SHIFTKEY) {
if(G.vd->lay & (1<<event)) G.vd->lay -= (1<<event);
else G.vd->lay += (1<<event);
}
do_view3d_buttons(event+B_LAY);
}
/* redraw seems double: but the queue nicely handles that */
scrarea_queue_headredraw(curarea);
if(curarea->spacetype==SPACE_OOPS) allqueue(REDRAWVIEW3D, 1); /* 1==also do headwin */
}
void do_nla_buttons(unsigned short event)
{
View2D *v2d;
switch(event){
case B_NLAHOME:
// Find X extents
v2d= &(G.snla->v2d);
v2d->cur.xmin = G.scene->r.sfra;
v2d->cur.ymin=-SCROLLB;
// if (!G.saction->action){
v2d->cur.xmax=G.scene->r.efra;
// }
// else
// {
// v2d->cur.xmax=calc_action_length(G.saction->action)+1;
// }
test_view2d(G.v2d, curarea->winx, curarea->winy);
addqueue (curarea->win, REDRAW, 1);
break;
}
}
void nla_buttons(void)
{
SpaceNla *snla;
short xco;
char naam[20];
uiBlock *block;
snla= curarea->spacedata.first;
sprintf(naam, "header %d", curarea->headwin);
block= uiNewBlock(&curarea->uiblocks, naam, UI_EMBOSSX, UI_HELV, curarea->headwin);
uiBlockSetCol(block, BUTCHOKE);
curarea->butspacetype= SPACE_NLA;
uiDefIconTextButC(block, ICONTEXTROW,B_NEWSPACE, ICON_VIEW3D, windowtype_pup(), 6,0,XIC,YIC, &(curarea->butspacetype), 1.0, SPACEICONMAX, 0, 0, "Displays Current Window Type. Click for menu of available types.");
/* FULL WINDOW */
xco= 25;
if(curarea->full) uiDefIconBut(block, BUT,B_FULL, ICON_SPLITSCREEN, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Returns to multiple views window (CTRL+Up arrow)");
else uiDefIconBut(block, BUT,B_FULL, ICON_FULLSCREEN, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Makes current window full screen (CTRL+Down arrow)");
/* HOME */
uiDefIconBut(block, BUT, B_NLAHOME, ICON_HOME, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Zooms window to home view showing all items (HOMEKEY)");
xco+= XIC;
/* IMAGE */
// uiDefIconButS(block, TOG, B_REDR, ICON_IMAGE_COL, xco+=XIC,0,XIC,YIC, &sseq->mainb, 0, 0, 0, 0, "Toggles image display");
/* ZOOM en BORDER */
// xco+= XIC;
// uiDefIconButI(block, TOG, B_VIEW2DZOOM, ICON_VIEWZOOM, xco+=XIC,0,XIC,YIC, &viewmovetemp, 0, 0, 0, 0, "Zoom view (CTRL+MiddleMouse)");
// uiDefIconBut(block, BUT, B_NLABORDER, ICON_BORDERMOVE, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Zoom view to area");
/* draw LOCK */
xco+= XIC/2;
uiDefIconButS(block, ICONTOG, 1, ICON_UNLOCKED, xco+=XIC,0,XIC,YIC, &(snla->lock), 0, 0, 0, 0, "Toggles forced redraw of other windows to reflect changes in real time");
uiDrawBlock(block);}
void action_buttons(void)
{
uiBlock *block;
short xco;
char naam[256];
Object *ob;
ID *from;
if (!G.saction)
return;
// copy from drawactionspace....
if (!G.saction->pin) {
if (OBACT)
G.saction->action = OBACT->action;
else
G.saction->action=NULL;
}
sprintf(naam, "header %d", curarea->headwin);
block= uiNewBlock(&curarea->uiblocks, naam, UI_EMBOSSX, UI_HELV, curarea->headwin);
uiBlockSetCol(block, BUTPINK);
curarea->butspacetype= SPACE_ACTION;
uiDefIconTextButC(block, ICONTEXTROW,B_NEWSPACE, ICON_VIEW3D, windowtype_pup(), 6,0,XIC,YIC, &(curarea->butspacetype), 1.0, SPACEICONMAX, 0, 0, "Displays Current Window Type. Click for menu of available types.");
/* FULL WINDOW */
xco= 25;
if(curarea->full) uiDefIconBut(block, BUT,B_FULL, ICON_SPLITSCREEN, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Returns to multiple views window (CTRL+Up arrow)");
else uiDefIconBut(block, BUT,B_FULL, ICON_FULLSCREEN, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Makes current window full screen (CTRL+Down arrow)");
uiDefIconBut(block, BUT, B_ACTHOME, ICON_HOME, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Zooms window to home view showing all items (HOMEKEY)");
if (!get_action_mesh_key()) {
/* NAME ETC */
ob=OBACT;
from = (ID*) ob;
xco= std_libbuttons(block, xco+1.5*XIC, B_ACTPIN, &G.saction->pin,
B_ACTIONBROWSE, (ID*)G.saction->action,
from, &(G.saction->actnr), B_ACTALONE,
B_ACTLOCAL, B_ACTIONDELETE, 0, 0);
#ifdef __NLA_BAKE
/* Draw action baker */
uiDefBut(block, BUT, B_ACTBAKE, "Bake",
xco+=XIC, 0, 64, YIC, 0, 0, 0, 0, 0,
"Generate an action with the constraint "
"effects converted into ipo keys");
xco+=64;
#endif
}
uiClearButLock();
/* draw LOCK */
xco+= XIC/2;
uiDefIconButS(block, ICONTOG, 1, ICON_UNLOCKED, xco+=XIC,0,XIC,YIC, &(G.saction->lock), 0, 0, 0, 0, "Toggles forced redraw of other windows to reflect changes in real time");
/* always as last */
curarea->headbutlen= xco+2*XIC;
uiDrawBlock(block);
}
void view3d_buttons(void)
{
uiBlock *block;
int a;
short xco;
char naam[20];
sprintf(naam, "header %d", curarea->headwin);
block= uiNewBlock(&curarea->uiblocks, naam, UI_EMBOSSX, UI_HELV, curarea->headwin);
uiBlockSetCol(block, BUTBLUE);
curarea->butspacetype= SPACE_VIEW3D;
uiDefIconTextButC(block, ICONTEXTROW,B_NEWSPACE, ICON_VIEW3D, windowtype_pup(), 6,0,XIC,YIC, &(curarea->butspacetype), 1.0, SPACEICONMAX, 0, 0, "Displays Current Window Type. Click for menu of available types.");
/* FULL WINDOW */
xco= 25;
if(curarea->full) uiDefIconBut(block, BUT,B_FULL, ICON_SPLITSCREEN, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Returns to multiple views window (CTRL+Up arrow)");
else uiDefIconBut(block, BUT,B_FULL, ICON_FULLSCREEN, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Makes current window full screen (CTRL+Down arrow)");
/* HOME */
uiDefIconBut(block, BUT, B_HOME, ICON_HOME, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Zooms window to home view showing all items (HOMEKEY)");
xco+= XIC+8;
if(G.vd->localview==0) {
/* LAYERS */
for(a=0; a<10; a++) {
uiDefButI(block, TOG|BIT|(a+10), B_LAY+10+a, "",(short)(xco+a*(XIC/2)), 0, XIC/2, (YIC)/2, &(G.vd->lay), 0, 0, 0, 0, "Toggles Layer visibility");
uiDefButI(block, TOG|BIT|a, B_LAY+a, "", (short)(xco+a*(XIC/2)), (short)(YIC/2),(short)(XIC/2),(short)(YIC/2), &(G.vd->lay), 0, 0, 0, 0, "Toggles Layer visibility");
if(a==4) xco+= 5;
}
xco+= (a-2)*(XIC/2)+5;
/* LOCK */
uiDefIconButS(block, ICONTOG, B_SCENELOCK, ICON_UNLOCKED, xco+=XIC,0,XIC,YIC, &(G.vd->scenelock), 0, 0, 0, 0, "Locks layers and used Camera to Scene");
xco+= XIC;
}
else xco+= (10+2)*(XIC/2)+10;
/* LOCALVIEW */
uiDefIconButS(block, ICONROW, B_LOCALVIEW, ICON_LOCALVIEW, xco+=XIC,0,XIC,YIC, &(G.vd->localview), 0.0, 1.0, 0, 0, "Toggles Local View (NumPad /)");
/* PERSP */
xco+= XIC/2;
uiDefIconButS(block, ICONROW, B_PERSP, ICON_ORTHO, xco+=XIC,0,XIC,YIC, &(G.vd->persp), 0.0, 2.0, 0, 0, "Toggles Perspective mode (NumPad 5, Numpad 0)");
xco+= XIC/2;
/* VIEW */
if(G.vd->view==7) G.vd->viewbut= 1;
else if(G.vd->view==1) G.vd->viewbut= 2;
else if(G.vd->view==3) G.vd->viewbut= 3;
else G.vd->viewbut= 0;
uiDefIconButS(block, ICONROW, B_VIEWBUT, ICON_VIEW_AXIS_NONE2, xco+=XIC,0,XIC,YIC, &G.vd->viewbut, 0.0, 3.0, 0, 0, "Selects Top, Front or Side views (Numpad 7, 1, 3)");
/* DRAWTYPE */
xco+= XIC/2;
uiDefIconButS(block, ICONROW, B_REDR, ICON_BBOX, xco+=XIC,0,XIC,YIC, &(G.vd->drawtype), 1.0, 5.0, 0, 0, "Sets view draw mode to Boundbox, Wire, Solid, or Shaded (ZKEY, SHIFT+Z)");
/* VIEWMOVE */
xco+= XIC/2;
uiDefIconButI(block, TOG, B_VIEWTRANS, ICON_VIEWMOVE, xco+=XIC,0,XIC,YIC, &viewmovetemp, 0, 0, 0, 0, "Translates view (SHIFT+MiddleMouse)");
uiDefIconButI(block, TOG, B_VIEWZOOM, ICON_VIEWZOOM, xco+=XIC,0,XIC,YIC, &viewmovetemp, 0, 0, 0, 0, "Zooms view (CTRL+MiddleMouse)");
/* around */
xco+= XIC/2;
uiDefIconButS(block, ROW, 1, ICON_ROTATE, xco+=XIC,0,XIC,YIC, &G.vd->around, 3.0, 0.0, 0, 0, "Enables Rotation or Scaling around boundbox center (COMMAKEY)");
uiDefIconButS(block, ROW, 1, ICON_ROTATECENTER, xco+=XIC,0,XIC,YIC, &G.vd->around, 3.0, 3.0, 0, 0, "Enables Rotation or Scaling around median point");
uiDefIconButS(block, ROW, 1, ICON_CURSOR, xco+=XIC,0,XIC,YIC, &G.vd->around, 3.0, 1.0, 0, 0, "Enables Rotation or Scaling around cursor (DOTKEY)");
uiDefIconButS(block, ROW, 1, ICON_ROTATECOLLECTION, xco+=XIC,0,XIC,YIC, &G.vd->around, 3.0, 2.0, 0, 0, "Enables Rotation or Scaling around individual object centers");
/* mode */
G.vd->flag &= ~V3D_MODE;
if(G.obedit) G.vd->flag |= V3D_EDITMODE;
if(G.f & G_VERTEXPAINT) G.vd->flag |= V3D_VERTEXPAINT;
if(G.f & G_WEIGHTPAINT) G.vd->flag |= V3D_WEIGHTPAINT;
#ifdef NAN_TPT
if (G.f & G_TEXTUREPAINT) G.vd->flag |= V3D_TEXTUREPAINT;
#endif /* NAN_TPT */
if(G.f & G_FACESELECT) G.vd->flag |= V3D_FACESELECT;
if(G.obpose){
G.vd->flag |= V3D_POSEMODE;
}
xco+= XIC/2;
/* If there is a posable object hilighted & selected, display this button */
if (OBACT){
if (OBACT->type==OB_ARMATURE){
uiDefIconButS(block, ICONTOG|BIT|7, B_POSEMODE, ICON_POSE_DEHLT, xco+=XIC,0,XIC,YIC, &G.vd->flag, 0, 0, 0, 0, "Toggles PoseMode (CTRL+TAB)");
}
}
uiDefIconButS(block, ICONTOG|BIT|4, B_EDITMODE, ICON_EDITMODE_DEHLT, xco+=XIC,0,XIC,YIC, &G.vd->flag, 0, 0, 0, 0, "Toggles EditMode (TAB)");
if (!G.obpose && !G.obedit)
{
xco+= XIC/2;
/* Only if mesh is selected */
if (OBACT && OBACT->type == OB_MESH){
uiDefIconButS(block, ICONTOG|BIT|5, B_VPAINT, ICON_VPAINT_DEHLT, xco+=XIC,0,XIC,YIC, &G.vd->flag, 0, 0, 0, 0, "Toggles VertexPaint Mode (VKEY)");
/* Only if deformable mesh is selected */
if ((((Mesh*)(OBACT->data))->dvert))
uiDefIconButS(block, ICONTOG|BIT|9, B_WPAINT, ICON_WPAINT_DEHLT, xco+=XIC,0,XIC,YIC, &G.vd->flag, 0, 0, 0, 0, "Toggles WeightPaint Mode");
#ifdef NAN_TPT
uiDefIconButS(block, ICONTOG|BIT|8, B_TEXTUREPAINT, ICON_TPAINT_DEHLT, xco+=XIC,0,XIC,YIC, &G.vd->flag, 0, 0, 0, 0, "Toggles TexturePaint Mode");
#endif /* NAN_TPT */
uiDefIconButS(block, ICONTOG|BIT|6, B_FACESEL, ICON_FACESEL_DEHLT, xco+=XIC,0,XIC,YIC, &G.vd->flag, 0, 0, 0, 0, "Toggles FaceSelect Mode (FKEY)");
}
}
if (G.obpose){
/* Copy paste - WAS in action window */
xco+= XIC/2;
// xco-= XIC/2; // Used in action window
if(curarea->headertype==HEADERTOP) {
uiDefIconBut(block, BUT, B_ACTCOPY, ICON_COPYUP, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Copies the current pose to the buffer");
uiSetButLock(G.obpose->id.lib!=0, "Can't edit library data");
uiDefIconBut(block, BUT, B_ACTPASTE, ICON_PASTEUP, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Pastes the pose from the buffer");
uiDefIconBut(block, BUT, B_ACTPASTEFLIP, ICON_PASTEFLIPUP, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Pastes the mirrored pose from the buffer");
}
else {
uiDefIconBut(block, BUT, B_ACTCOPY, ICON_COPYDOWN, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Copies the current pose to the buffer");
uiSetButLock(G.obpose->id.lib!=0, "Can't edit library data");
uiDefIconBut(block, BUT, B_ACTPASTE, ICON_PASTEDOWN, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Pastes the pose from the buffer");
uiDefIconBut(block, BUT, B_ACTPASTEFLIP, ICON_PASTEFLIPDOWN, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Pastes the mirrored pose from the buffer");
}
// xco+=XIC/2; // Used in action window
}
if(G.vd->bgpic) {
xco+= XIC/2;
uiDefIconButS(block, TOG|BIT|1, B_REDR, ICON_IMAGE_COL, xco+=XIC,0,XIC,YIC, &G.vd->flag, 0, 0, 0, 0, "Displays a Background picture");
}
if(G.obedit) {
extern int prop_mode;
xco+= XIC/2;
uiDefIconButI(block, ICONTOG|BIT|14, B_PROPTOOL, ICON_GRID, xco+=XIC,0,XIC,YIC, &G.f, 0, 0, 0, 0, "Toggles Proportional Vertex Editing (OKEY)");
if(G.f & G_PROPORTIONAL) {
uiDefIconButI(block, ROW, 0, ICON_SHARPCURVE, xco+=XIC,0,XIC,YIC, &prop_mode, 4.0, 0.0, 0, 0, "Enables Sharp falloff (SHIFT+OKEY)");
uiDefIconButI(block, ROW, 0, ICON_SMOOTHCURVE, xco+=XIC,0,XIC,YIC, &prop_mode, 4.0, 1.0, 0, 0, "Enables Smooth falloff (SHIFT+OKEY)");
}
}
xco+=XIC;
uiDefIconBut(block, BUT, B_VIEWRENDER, ICON_SCENE, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Renders this view (Hold SHIFT for Anim render)");
xco+=XIC;
#if GAMEBLENDER == 1
uiDefIconBut(block, BUT, B_STARTGAME, ICON_GAME, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Starts game (PKEY)");
#endif
/* Always do this last */
curarea->headbutlen= xco+2*XIC;
uiDrawBlock(block);
}
/* ********************** VIEW3D ****************************** */
/* ********************** IPO ****************************** */
void do_ipo_buttons(short event)
{
EditIpo *ei;
View2D *v2d;
rcti rect;
float xmin, ymin, dx, dy;
int a, val, first;
short mval[2];
if(curarea->win==0) return;
switch(event) {
case B_IPOHOME:
/* boundbox */
v2d= &(G.sipo->v2d);
first= 1;
ei= G.sipo->editipo;
if(ei==0) return;
for(a=0; a<G.sipo->totipo; a++, ei++) {
if ISPOIN(ei, flag & IPO_VISIBLE, icu) {
boundbox_ipocurve(ei->icu);
if(first) {
v2d->tot= ei->icu->totrct;
first= 0;
}
else BLI_union_rctf(&(v2d->tot), &(ei->icu->totrct));
}
}
/* speciale home */
if(G.qual & LR_SHIFTKEY) {
v2d->tot.xmin= SFRA;
v2d->tot.xmax= EFRA;
}
/* zoom out a bit */
dx= 0.10*(v2d->tot.xmax-v2d->tot.xmin);
dy= 0.10*(v2d->tot.ymax-v2d->tot.ymin);
if(dx<v2d->min[0]) dx= v2d->min[0];
if(dy<v2d->min[1]) dy= v2d->min[1];
v2d->cur.xmin= v2d->tot.xmin- dx;
v2d->cur.xmax= v2d->tot.xmax+ dx;
v2d->cur.ymin= v2d->tot.ymin- dy;
v2d->cur.ymax= v2d->tot.ymax+ dy;
test_view2d(G.v2d, curarea->winx, curarea->winy);
scrarea_queue_winredraw(curarea);
break;
case B_IPOBORDER:
val= get_border(&rect, 2);
if(val) {
mval[0]= rect.xmin;
mval[1]= rect.ymin;
areamouseco_to_ipoco(G.v2d, mval, &xmin, &ymin);
mval[0]= rect.xmax;
mval[1]= rect.ymax;
areamouseco_to_ipoco(G.v2d, mval, &(G.v2d->cur.xmax), &(G.v2d->cur.ymax));
G.v2d->cur.xmin= xmin;
G.v2d->cur.ymin= ymin;
test_view2d(G.v2d, curarea->winx, curarea->winy);
scrarea_queue_winredraw(curarea);
}
break;
case B_IPOPIN:
allqueue (REDRAWIPO, 0);
break;
case B_IPOCOPY:
copy_editipo();
break;
case B_IPOPASTE:
paste_editipo();
break;
case B_IPOCONT:
set_exprap_ipo(IPO_HORIZ);
break;
case B_IPOEXTRAP:
set_exprap_ipo(IPO_DIR);
break;
case B_IPOCYCLIC:
set_exprap_ipo(IPO_CYCL);
break;
case B_IPOCYCLICX:
set_exprap_ipo(IPO_CYCLX);
break;
case B_IPOMAIN:
make_editipo();
scrarea_queue_winredraw(curarea);
scrarea_queue_headredraw(curarea);
break;
case B_IPOSHOWKEY:
/* reverse value because of winqread */
G.sipo->showkey= 1-G.sipo->showkey;
ipo_toggle_showkey();
scrarea_queue_headredraw(curarea);
scrarea_queue_winredraw(curarea);
allqueue(REDRAWVIEW3D, 0);
break;
case B_VIEW2DZOOM:
viewmovetemp= 0;
view2dzoom(event);
scrarea_queue_headredraw(curarea);
break;
}
}
void ipo_buttons(void)
{
Object *ob;
ID *id, *from;
uiBlock *block;
short xco;
char naam[20];
sprintf(naam, "header %d", curarea->headwin);
block= uiNewBlock(&curarea->uiblocks, naam, UI_EMBOSSX, UI_HELV, curarea->headwin);
uiBlockSetCol(block, BUTSALMON);
curarea->butspacetype= SPACE_IPO;
uiDefIconTextButC(block, ICONTEXTROW,B_NEWSPACE, ICON_VIEW3D, windowtype_pup(), 6,0,XIC,YIC, &(curarea->butspacetype), 1.0, SPACEICONMAX, 0, 0, "Displays Current Window Type. Click for menu of available types.");
test_editipo(); /* test if current editipo is OK, make_editipo sets v2d->cur */
/* FULL WINDOW en HOME */
xco= 25;
if(curarea->full) uiDefIconBut(block, BUT,B_FULL, ICON_SPLITSCREEN, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Returns to multiple views window (CTRL+Up arrow)");
else uiDefIconBut(block, BUT,B_FULL, ICON_FULLSCREEN, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Makes current window full screen (CTRL+Down arrow)");
uiDefIconBut(block, BUT, B_IPOHOME, ICON_HOME, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Zooms window to home view showing all items (HOMEKEY)");
uiDefIconButS(block, ICONTOG, B_IPOSHOWKEY, ICON_KEY_DEHLT, xco+=XIC,0,XIC,YIC, &G.sipo->showkey, 0, 0, 0, 0, "Toggles between Curve and Key display (KKEY)");
/* mainmenu, only when data is there and no pin */
uiSetButLock(G.sipo->pin, "Can't change because of pinned data");
ob= OBACT;
xco+= XIC/2;
uiDefIconButS(block, ROW, B_IPOMAIN, ICON_OBJECT, xco+=XIC,0,XIC,YIC, &G.sipo->blocktype, 1.0, (float)ID_OB, 0, 0, "Displays Object Ipos");
if(ob && give_current_material(ob, ob->actcol)) {
uiDefIconButS(block, ROW, B_IPOMAIN, ICON_MATERIAL, xco+=XIC,0,XIC,YIC, &G.sipo->blocktype, 1.0, (float)ID_MA, 0, 0, "Displays Material Ipos");
if(G.sipo->blocktype==ID_MA) {
uiDefButS(block, NUM, B_IPOMAIN, "", xco+=XIC,0,XIC-4,YIC, &G.sipo->channel, 0.0, 7.0, 0, 0, "Displays Channel Number of the active Material texture. Click to change.");
xco-= 4;
}
}
if(G.scene->world) {
uiDefIconButS(block, ROW, B_IPOMAIN, ICON_WORLD, xco+=XIC,0,XIC,YIC, &G.sipo->blocktype, 1.0, (float)ID_WO, 0, 0, "Display World Ipos");
if(G.sipo->blocktype==ID_WO) {
uiDefButS(block, NUM, B_IPOMAIN, "", xco+=XIC,0,XIC-4,YIC, &G.sipo->channel, 0.0, 7.0, 0, 0, "Displays Channel Number of the active World texture. Click to change.");
xco-= 4;
}
}
if(ob && ob->type==OB_CURVE)
uiDefIconButS(block, ROW, B_IPOMAIN, ICON_ANIM, xco+=XIC,0,XIC,YIC, &G.sipo->blocktype, 1.0, (float)ID_CU, 0, 0, "Display Curve Ipos");
if(ob && ob->type==OB_CAMERA)
uiDefIconButS(block, ROW, B_IPOMAIN, ICON_CAMERA, xco+=XIC,0,XIC,YIC, &G.sipo->blocktype, 1.0, (float)ID_CA, 0, 0, "Display Camera Ipos");
if(ob && ob->type==OB_LAMP) {
uiDefIconButS(block, ROW, B_IPOMAIN, ICON_LAMP, xco+=XIC,0,XIC,YIC, &G.sipo->blocktype, 1.0, (float)ID_LA, 0, 0, "Display Lamp Ipos");
if(G.sipo->blocktype==ID_LA) {
uiDefButS(block, NUM, B_IPOMAIN, "", xco+=XIC,0,XIC-4,YIC, &G.sipo->channel, 0.0, 7.0, 0, 0, "Displays Channel Number of the active Lamp texture. Click to change.");
xco-= 4;
}
}
if(ob) {
if ELEM4(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_LATTICE)
uiDefIconButS(block, ROW, B_IPOMAIN, ICON_EDIT, xco+=XIC,0,XIC,YIC, &G.sipo->blocktype, 1.0, (float)ID_KE, 0, 0, "Displays VertexKeys Ipos");
if (ob->action)
uiDefIconButS(block, ROW, B_IPOMAIN, ICON_ACTION, xco+=XIC,0,XIC,YIC, &G.sipo->blocktype, 1.0, (float)ID_AC, 0, 0, "Displays Action Ipos");
#ifdef __CON_IPO
uiDefIconButS(block, ROW, B_IPOMAIN, ICON_CONSTRAINT, xco+=XIC,0,XIC,YIC, &G.sipo->blocktype, 1.0, (float)IPO_CO, 0, 0, "Displays Constraint Ipos");
#endif
}
uiDefIconButS(block, ROW, B_IPOMAIN, ICON_SEQUENCE, xco+=XIC,0,XIC,YIC, &G.sipo->blocktype, 1.0, (float)ID_SEQ, 0, 0, "Displays Sequence Ipos");
if(G.buts && G.buts->mainb == BUTS_SOUND && G.buts->lockpoin)
uiDefIconButS(block, ROW, B_IPOMAIN, ICON_SOUND, xco+=XIC,0,XIC,YIC, &G.sipo->blocktype, 1.0, (float)ID_SO, 0, 0, "Displays Sound Ipos");
uiClearButLock();
/* NAME ETC */
id= (ID *)get_ipo_to_edit(&from);
xco= std_libbuttons(block, (short)(xco+1.5*XIC), B_IPOPIN, &G.sipo->pin, B_IPOBROWSE, (ID*)G.sipo->ipo, from, &(G.sipo->menunr), B_IPOALONE, B_IPOLOCAL, B_IPODELETE, 0, B_KEEPDATA);
uiSetButLock(id && id->lib, "Can't edit library data");
/* COPY PASTE */
xco-= XIC/2;
if(curarea->headertype==HEADERTOP) {
uiDefIconBut(block, BUT, B_IPOCOPY, ICON_COPYUP, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Copies the selected curves to the buffer");
uiSetButLock(id && id->lib, "Can't edit library data");
uiDefIconBut(block, BUT, B_IPOPASTE, ICON_PASTEUP, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Pastes the curves from the buffer");
}
else {
uiDefIconBut(block, BUT, B_IPOCOPY, ICON_COPYDOWN, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Copies the selected curves to the buffer");
uiSetButLock(id && id->lib, "Can't edit library data");
uiDefIconBut(block, BUT, B_IPOPASTE, ICON_PASTEDOWN, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Pastes the curves from the buffer");
}
xco+=XIC/2;
/* EXTRAP */
uiDefIconBut(block, BUT, B_IPOCONT, ICON_CONSTANT, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Sets the extend mode to constant");
uiDefIconBut(block, BUT, B_IPOEXTRAP, ICON_LINEAR, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Sets the extend mode to extrapolation");
uiDefIconBut(block, BUT, B_IPOCYCLIC, ICON_CYCLIC, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Sets the extend mode to cyclic");
uiDefIconBut(block, BUT, B_IPOCYCLICX, ICON_CYCLICLINEAR, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Sets the extend mode to cyclic extrapolation");
xco+= XIC/2;
uiClearButLock();
/* ZOOM en BORDER */
uiDefIconButI(block, TOG, B_VIEW2DZOOM, ICON_VIEWZOOM, xco+=XIC,0,XIC,YIC, &viewmovetemp, 0, 0, 0, 0, "Zooms view (CTRL+MiddleMouse)");
uiDefIconBut(block, BUT, B_IPOBORDER, ICON_BORDERMOVE, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Zooms view to area");
/* draw LOCK */
uiDefIconButS(block, ICONTOG, 1, ICON_UNLOCKED, xco+=XIC,0,XIC,YIC, &(G.sipo->lock), 0, 0, 0, 0, "Toggles forced redraw of other windows to reflect changes in real time");
/* always do as last */
curarea->headbutlen= xco+2*XIC;
uiDrawBlock(block);
}
/* ********************** IPO ****************************** */
/* ********************** BUTS ****************************** */
Material matcopybuf;
void clear_matcopybuf(void)
{
memset(&matcopybuf, 0, sizeof(Material));
}
void free_matcopybuf(void)
{
extern MTex mtexcopybuf; /* buttons.c */
int a;
for(a=0; a<8; a++) {
if(matcopybuf.mtex[a]) {
MEM_freeN(matcopybuf.mtex[a]);
matcopybuf.mtex[a]= 0;
}
}
default_mtex(&mtexcopybuf);
}
void do_buts_buttons(short event)
{
static short matcopied=0;
MTex *mtex;
Material *ma;
ID id;
int a;
if(curarea->win==0) return;
switch(event) {
case B_BUTSHOME:
G.v2d->cur= G.v2d->tot;
test_view2d(G.v2d, curarea->winx, curarea->winy);
scrarea_queue_winredraw(curarea);
break;
case B_BUTSPREVIEW:
BIF_preview_changed(G.buts);
scrarea_queue_headredraw(curarea);
scrarea_queue_winredraw(curarea);
break;
case B_MATCOPY:
if(G.buts->lockpoin) {
if(matcopied) free_matcopybuf();
memcpy(&matcopybuf, G.buts->lockpoin, sizeof(Material));
for(a=0; a<8; a++) {
mtex= matcopybuf.mtex[a];
if(mtex) {
matcopybuf.mtex[a]= MEM_dupallocN(mtex);
}
}
matcopied= 1;
}
break;
case B_MATPASTE:
if(matcopied && G.buts->lockpoin) {
ma= G.buts->lockpoin;
/* free current mat */
for(a=0; a<8; a++) {
mtex= ma->mtex[a];
if(mtex && mtex->tex) mtex->tex->id.us--;
if(mtex) MEM_freeN(mtex);
}
id= (ma->id);
memcpy(G.buts->lockpoin, &matcopybuf, sizeof(Material));
(ma->id)= id;
for(a=0; a<8; a++) {
mtex= ma->mtex[a];
if(mtex) {
ma->mtex[a]= MEM_dupallocN(mtex);
if(mtex->tex) id_us_plus((ID *)mtex->tex);
}
}
BIF_preview_changed(G.buts);
scrarea_queue_winredraw(curarea);
}
break;
case B_MESHTYPE:
allqueue(REDRAWBUTSEDIT, 0);
allqueue(REDRAWVIEW3D, 0);
break;
}
}
void buttons_active_id(ID **id, ID **idfrom)
{
Object *ob= OBACT;
Material *ma;
ID * search;
*id= NULL;
*idfrom= (ID *)ob;
if(G.buts->mainb==BUTS_LAMP) {
if(ob && ob->type==OB_LAMP) {
*id= ob->data;
}
}
else if(G.buts->mainb==BUTS_MAT) {
if(ob && (ob->type<OB_LAMP) && ob->type) {
*id= (ID *)give_current_material(ob, ob->actcol);
*idfrom= material_from(ob, ob->actcol);
}
}
else if(G.buts->mainb==BUTS_TEX) {
MTex *mtex;
if(G.buts->mainbo != G.buts->mainb) {
if(G.buts->mainbo==BUTS_LAMP) G.buts->texfrom= 2;
else if(G.buts->mainbo==BUTS_WORLD) G.buts->texfrom= 1;
else if(G.buts->mainbo==BUTS_MAT) G.buts->texfrom= 0;
}
if(G.buts->texfrom==0) {
if(ob && ob->type<OB_LAMP && ob->type) {
ma= give_current_material(ob, ob->actcol);
*idfrom= (ID *)ma;
if(ma) {
mtex= ma->mtex[ ma->texact ];
if(mtex) *id= (ID *)mtex->tex;
}
}
}
else if(G.buts->texfrom==1) {
World *wrld= G.scene->world;
*idfrom= (ID *)wrld;
if(wrld) {
mtex= wrld->mtex[ wrld->texact];
if(mtex) *id= (ID *)mtex->tex;
}
}
else if(G.buts->texfrom==2) {
Lamp *la;
if(ob && ob->type==OB_LAMP) {
la= ob->data;
*idfrom= (ID *)la;
mtex= la->mtex[ la->texact];
if(mtex) *id= (ID *)mtex->tex;
}
}
}
else if ELEM3(G.buts->mainb, BUTS_ANIM, BUTS_GAME, BUTS_CONSTRAINT) {
if(ob) {
*idfrom= (ID *)G.scene;
*id= (ID *)ob;
}
}
else if(G.buts->mainb==BUTS_WORLD) {
*id= (ID *)G.scene->world;
*idfrom= (ID *)G.scene;
}
else if(G.buts->mainb==BUTS_RENDER) {
*id= (ID *)G.scene;
}
else if(G.buts->mainb==BUTS_EDIT) {
if(ob && ob->data) {
*id= ob->data;
}
}
else if (G.buts->mainb == BUTS_SOUND) {
// printf("lockp: %d\n", G.buts->lockpoin);
if (G.buts->lockpoin) {
search = G.main->sound.first;
while (search) {
if (search == G.buts->lockpoin) {
break;
}
search = search->next;
}
if (search == NULL) {
*id = G.main->sound.first;
} else {
*id = search;
}
} else {
*id = G.main->sound.first;
}
// printf("id: %d\n\n", *id);
}
}
#if 0
static void validate_bonebutton(void *bonev, void *data2_unused){
Bone *bone= bonev;
bArmature *arm;
arm = get_armature(G.obpose);
unique_bone_name(bone, arm);
}
#endif
static int bonename_exists(Bone *orig, char *name, ListBase *list)
{
Bone *curbone;
for (curbone=list->first; curbone; curbone=curbone->next){
/* Check this bone */
if (orig!=curbone){
if (!strcmp(curbone->name, name))
return 1;
}
/* Check Children */
if (bonename_exists(orig, name, &curbone->childbase))
return 1;
}
return 0;
}
static void unique_bone_name (Bone *bone, bArmature *arm)
{
char tempname[64];
char oldname[64];
int number;
char *dot;
if (!arm)
return;
strcpy(oldname, bone->name);
/* See if we even need to do this */
if (!bonename_exists(bone, bone->name, &arm->bonebase))
return;
/* Strip off the suffix */
dot=strchr(bone->name, '.');
if (dot)
*dot=0;
for (number = 1; number <=999; number++){
sprintf (tempname, "%s.%03d", bone->name, number);
if (!bonename_exists(bone, tempname, &arm->bonebase)){
strcpy (bone->name, tempname);
return;
}
}
}
void buts_buttons(void)
{
ID *id, *idfrom;
Object *ob;
uiBlock *block;
uiBut *but;
short xco;
int alone, local, browse;
char naam[20];
short type;
void *data=NULL;
char str[256];
sprintf(naam, "header %d", curarea->headwin);
block= uiNewBlock(&curarea->uiblocks, naam, UI_EMBOSSX, UI_HELV, curarea->headwin);
uiBlockSetCol(block, BUTGREY);
curarea->butspacetype= SPACE_BUTS;
uiDefIconTextButC(block, ICONTEXTROW,B_NEWSPACE, ICON_VIEW3D, windowtype_pup(), 6,0,XIC,YIC, &(curarea->butspacetype), 1.0, SPACEICONMAX, 0, 0, "Displays Current Window Type. Click for menu of available types.");
/* FULL WINDOW */
xco= 25;
if(curarea->full) uiDefIconBut(block, BUT,B_FULL, ICON_SPLITSCREEN, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Returns to multiple views window (CTRL+Up arrow)");
else uiDefIconBut(block, BUT,B_FULL, ICON_FULLSCREEN, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Makes current window full screen (CTRL+Down arrow)");
/* HOME */
uiDefIconBut(block, BUT, B_BUTSHOME, ICON_HOME, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Zooms window to home view showing all items (HOMEKEY)");
ob= OBACT;
/* choice menu */
xco+= 2*XIC;
uiDefIconButS(block, ROW, B_REDR, ICON_EYE, xco+=XIC, 0, 30, YIC, &(G.buts->mainb), 1.0, (float)BUTS_VIEW, 0, 0, "View buttons");
uiDefIconButS(block, ROW, B_BUTSPREVIEW, ICON_LAMP, xco+=30, 0, 30, YIC, &(G.buts->mainb), 1.0, (float)BUTS_LAMP, 0, 0, "Lamp buttons (F4)");
uiDefIconButS(block, ROW, B_BUTSPREVIEW, ICON_MATERIAL, xco+=30, 0, 30, YIC, &(G.buts->mainb), 1.0, (float)BUTS_MAT, 0, 0, "Material buttons (F5)");
uiDefIconButS(block, ROW, B_BUTSPREVIEW, ICON_TEXTURE, xco+=30, 0, 30, YIC, &(G.buts->mainb), 1.0, (float)BUTS_TEX, 0, 0, "Texture buttons (F6)");
uiDefIconButS(block, ROW, B_REDR, ICON_ANIM, xco+=30, 0, 30, YIC, &(G.buts->mainb), 1.0, (float)BUTS_ANIM, 0, 0, "Animation buttons (F7)");
uiDefIconButS(block, ROW, B_REDR, ICON_GAME, xco+=30, 0, 30, YIC, &(G.buts->mainb), 1.0, (float)BUTS_GAME, 0, 0, "Realtime buttons (F8)");
uiDefIconButS(block, ROW, B_REDR, ICON_EDIT, xco+=30, 0, 30, YIC, &(G.buts->mainb), 1.0, (float)BUTS_EDIT, 0, 0, "Edit buttons (F9)");
uiDefIconButS(block, ROW, B_REDR, ICON_CONSTRAINT,xco+=30, 0, 30, YIC, &(G.buts->mainb), 1.0, (float)BUTS_CONSTRAINT, 0, 0, "Constraint buttons");
uiDefIconButS(block, ROW, B_REDR, ICON_SPEAKER,xco+=30, 0, 30, YIC, &(G.buts->mainb), 1.0, (float)BUTS_SOUND, 0, 0, "Sound buttons");
uiDefIconButS(block, ROW, B_BUTSPREVIEW, ICON_WORLD, xco+=30, 0, 30, YIC, &(G.buts->mainb), 1.0, (float)BUTS_WORLD, 0, 0, "World buttons");
uiDefIconButS(block, ROW, B_REDR, ICON_PAINT,xco+=30, 0, 30, YIC, &(G.buts->mainb), 1.0, (float)BUTS_FPAINT, 0, 0, "Paint buttons");
uiDefIconButS(block, ROW, B_REDR, ICON_RADIO,xco+=30, 0, 30, YIC, &(G.buts->mainb), 1.0, (float)BUTS_RADIO, 0, 0, "Radiosity buttons");
uiDefIconButS(block, ROW, B_REDR, ICON_SCRIPT,xco+=30, 0, 30, YIC, &(G.buts->mainb), 1.0, (float)BUTS_SCRIPT, 0, 0, "Script buttons");
uiDefIconButS(block, ROW, B_REDR, ICON_SCENE, xco+=30, 0, 50, YIC, &(G.buts->mainb), 1.0, (float)BUTS_RENDER, 0, 0, "Display buttons (F10)");
xco+= 80;
buttons_active_id(&id, &idfrom);
G.buts->lockpoin= id;
if(G.buts->mainb==BUTS_LAMP) {
if(id) {
xco= std_libbuttons(block, xco, 0, NULL, B_LAMPBROWSE, id, (ID *)ob, &(G.buts->menunr), B_LAMPALONE, B_LAMPLOCAL, 0, 0, 0);
}
}
else if(G.buts->mainb==BUTS_MAT) {
if(ob && (ob->type<OB_LAMP) && ob->type) {
xco= std_libbuttons(block, xco, 0, NULL, B_MATBROWSE, id, idfrom, &(G.buts->menunr), B_MATALONE, B_MATLOCAL, B_MATDELETE, B_AUTOMATNAME, B_KEEPDATA);
}
/* COPY PASTE */
if(curarea->headertype==HEADERTOP) {
uiDefIconBut(block, BUT, B_MATCOPY, ICON_COPYUP, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Copies Material to the buffer");
uiSetButLock(id && id->lib, "Can't edit library data");
uiDefIconBut(block, BUT, B_MATPASTE, ICON_PASTEUP, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Pastes Material from the buffer");
}
else {
uiDefIconBut(block, BUT, B_MATCOPY, ICON_COPYDOWN, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Copies Material to the buffer");
uiSetButLock(id && id->lib, "Can't edit library data");
uiDefIconBut(block, BUT, B_MATPASTE, ICON_PASTEDOWN, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Pastes Material from the buffer");
}
xco+=XIC;
}
else if(G.buts->mainb==BUTS_TEX) {
if(G.buts->texfrom==0) {
if(idfrom) {
xco= std_libbuttons(block, xco, 0, NULL, B_TEXBROWSE, id, idfrom, &(G.buts->texnr), B_TEXALONE, B_TEXLOCAL, B_TEXDELETE, B_AUTOTEXNAME, B_KEEPDATA);
}
}
else if(G.buts->texfrom==1) {
if(idfrom) {
xco= std_libbuttons(block, xco, 0, NULL, B_WTEXBROWSE, id, idfrom, &(G.buts->texnr), B_TEXALONE, B_TEXLOCAL, B_TEXDELETE, B_AUTOTEXNAME, B_KEEPDATA);
}
}
else if(G.buts->texfrom==2) {
if(idfrom) {
xco= std_libbuttons(block, xco, 0, NULL, B_LTEXBROWSE, id, idfrom, &(G.buts->texnr), B_TEXALONE, B_TEXLOCAL, B_TEXDELETE, B_AUTOTEXNAME, B_KEEPDATA);
}
}
}
else if(G.buts->mainb==BUTS_ANIM) {
if(id) {
xco= std_libbuttons(block, xco, 0, NULL, 0, id, idfrom, &(G.buts->menunr), B_OBALONE, B_OBLOCAL, 0, 0, 0);
if(G.scene->group) {
Group *group= G.scene->group;
but= uiDefBut(block, TEX, B_IDNAME, "GR:", xco, 0, 135, YIC, group->id.name+2, 0.0, 19.0, 0, 0, "Displays Active Group name. Click to change.");
uiButSetFunc(but, test_idbutton_cb, group->id.name, NULL);
xco+= 135;
}
}
}
else if(G.buts->mainb==BUTS_GAME) {
if(id) {
xco= std_libbuttons(block, xco, 0, NULL, 0, id, idfrom, &(G.buts->menunr), B_OBALONE, B_OBLOCAL, 0, 0, 0);
}
}
else if(G.buts->mainb==BUTS_WORLD) {
xco= std_libbuttons(block, xco, 0, NULL, B_WORLDBROWSE, id, idfrom, &(G.buts->menunr), B_WORLDALONE, B_WORLDLOCAL, B_WORLDDELETE, 0, B_KEEPDATA);
}
else if (G.buts->mainb==BUTS_SOUND) {
xco= std_libbuttons(block, xco, 0, NULL, B_SOUNDBROWSE2, id, idfrom, &(G.buts->texnr), 1, 0, 0, 0, 0);
}
else if(G.buts->mainb==BUTS_RENDER) {
xco= std_libbuttons(block, xco, 0, NULL, B_INFOSCE, (ID *)G.scene, 0, &(G.curscreen->scenenr), 1, 1, B_INFODELSCE, 0, B_KEEPDATA);
}
else if(G.buts->mainb==BUTS_EDIT) {
if(id) {
alone= 0;
local= 0;
browse= B_EDITBROWSE;
xco+= 10;
if(ob->type==OB_MESH) {
browse= B_MESHBROWSE;
alone= B_MESHALONE;
local= B_MESHLOCAL;
uiSetButLock(G.obedit!=0, "Unable to perform function in EditMode");
}
else if(ob->type==OB_MBALL) {
alone= B_MBALLALONE;
local= B_MBALLLOCAL;
}
else if ELEM3(ob->type, OB_CURVE, OB_FONT, OB_SURF) {
alone= B_CURVEALONE;
local= B_CURVELOCAL;
}
else if(ob->type==OB_CAMERA) {
alone= B_CAMERAALONE;
local= B_CAMERALOCAL;
}
else if(ob->type==OB_LAMP) {
alone= B_LAMPALONE;
local= B_LAMPLOCAL;
}
else if (ob->type==OB_ARMATURE){
alone = B_ARMALONE;
local = B_ARMLOCAL;
}
else if(ob->type==OB_LATTICE) {
alone= B_LATTALONE;
local= B_LATTLOCAL;
}
xco= std_libbuttons(block, xco, 0, NULL, browse, id, idfrom, &(G.buts->menunr), alone, local, 0, 0, B_KEEPDATA);
xco+= XIC;
}
if(ob) {
but= uiDefBut(block, TEX, B_IDNAME, "OB:", xco, 0, 135, YIC, ob->id.name+2, 0.0, 19.0, 0, 0, "Displays Active Object name. Click to change.");
uiButSetFunc(but, test_idbutton_cb, ob->id.name, NULL);
xco+= 135;
}
}
else if(G.buts->mainb==BUTS_CONSTRAINT){
if(id) {
xco= std_libbuttons(block, xco, 0, NULL, 0, id, idfrom, &(G.buts->menunr), B_OBALONE, B_OBLOCAL, 0, 0, 0);
get_constraint_client(NULL, &type, &data);
if (data && type==TARGET_BONE){
sprintf(str, "BO:%s", ((Bone*)data)->name);
#if 0
/* XXXXX, not idname... but check redrawing */
but= uiDefBut(block, TEX, 1, "BO:", xco, 0, 135, YIC, ((Bone*)data)->name, 0.0, 19.0, 0, 0, "Displays Active Bone name. Click to change.");
uiButSetFunc(but, validate_bonebutton, data, NULL);
#else
but= uiDefBut(block, LABEL, 1, str, xco, 0, 135, YIC, ((Bone*)data)->name, 0.0, 19.0, 0, 0, "Displays Active Bone name. Click to change.");
#endif
xco+= 135;
}
}
}
else if(G.buts->mainb==BUTS_SCRIPT) {
if(ob)
uiDefIconButS(block, ROW, B_REDR, ICON_OBJECT, xco,0,XIC,YIC, &G.buts->scriptblock, 2.0, (float)ID_OB, 0, 0, "Displays Object script links");
if(ob && give_current_material(ob, ob->actcol))
uiDefIconButS(block, ROW, B_REDR, ICON_MATERIAL, xco+=XIC,0,XIC,YIC, &G.buts->scriptblock, 2.0, (float)ID_MA, 0, 0, "Displays Material script links ");
if(G.scene->world)
uiDefIconButS(block, ROW, B_REDR, ICON_WORLD, xco+=XIC,0,XIC,YIC, &G.buts->scriptblock, 2.0, (float)ID_WO, 0, 0, "Displays World script links");
if(ob && ob->type==OB_CAMERA)
uiDefIconButS(block, ROW, B_REDR, ICON_CAMERA, xco+=XIC,0,XIC,YIC, &G.buts->scriptblock, 2.0, (float)ID_CA, 0, 0, "Displays Camera script links");
if(ob && ob->type==OB_LAMP)
uiDefIconButS(block, ROW, B_REDR, ICON_LAMP, xco+=XIC,0,XIC,YIC, &G.buts->scriptblock, 2.0, (float)ID_LA, 0, 0, "Displays Lamp script links");
xco+= 20;
}
uiDefButS(block, NUM, B_NEWFRAME, "", (short)(xco+20),0,60,YIC, &(G.scene->r.cfra), 1.0, 18000.0, 0, 0, "Displays Current Frame of animation. Click to change.");
xco+= 80;
G.buts->mainbo= G.buts->mainb;
/* always do as last */
uiDrawBlock(block);
curarea->headbutlen= xco;
}
/* ********************** BUTS ****************************** */
/* ******************** FILE ********************** */
void do_file_buttons(short event)
{
SpaceFile *sfile;
if(curarea->win==0) return;
sfile= curarea->spacedata.first;
switch(event) {
case B_SORTFILELIST:
sort_filelist(sfile);
scrarea_queue_winredraw(curarea);
break;
case B_RELOADDIR:
freefilelist(sfile);
scrarea_queue_winredraw(curarea);
break;
}
}
void file_buttons(void)
{
SpaceFile *sfile;
uiBlock *block;
float df, totlen, sellen;
short xco;
int totfile, selfile;
char naam[256];
sfile= curarea->spacedata.first;
sprintf(naam, "header %d", curarea->headwin);
block= uiNewBlock(&curarea->uiblocks, naam, UI_EMBOSSX, UI_HELV, curarea->headwin);
uiBlockSetCol(block, BUTGREY);
curarea->butspacetype= SPACE_FILE;
uiDefIconTextButC(block, ICONTEXTROW,B_NEWSPACE, ICON_VIEW3D, windowtype_pup(), 6,0,XIC,YIC, &(curarea->butspacetype), 1.0, SPACEICONMAX, 0, 0, "Displays Current Window Type. Click for menu of available types.");
/* FULL WINDOW */
xco= 25;
if(curarea->full) uiDefIconBut(block, BUT,B_FULL, ICON_SPLITSCREEN, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Returns to multiple views window (CTRL+Up arrow)");
else uiDefIconBut(block, BUT,B_FULL, ICON_FULLSCREEN, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Makes current window full screen (CTRL+Down arrow)");
/* SORT TYPE */
xco+=XIC;
uiDefIconButS(block, ROW, B_SORTFILELIST, ICON_SORTALPHA, xco+=XIC,0,XIC,YIC, &sfile->sort, 1.0, 0.0, 0, 0, "Sorts files alphabetically");
uiDefIconButS(block, ROW, B_SORTFILELIST, ICON_SORTTIME, xco+=XIC,0,XIC,YIC, &sfile->sort, 1.0, 1.0, 0, 0, "Sorts files by time");
uiDefIconButS(block, ROW, B_SORTFILELIST, ICON_SORTSIZE, xco+=XIC,0,XIC,YIC, &sfile->sort, 1.0, 2.0, 0, 0, "Sorts files by size");
cpack(0x0);
glRasterPos2i(xco+=XIC+10, 5);
BIF_DrawString(uiBlockGetCurFont(block), sfile->title, (U.transopts & TR_BUTTONS), 0);
xco+= BIF_GetStringWidth(G.font, sfile->title, (U.transopts & TR_BUTTONS));
uiDefIconButS(block, ICONTOG|BIT|0, B_SORTFILELIST, ICON_LONGDISPLAY,xco+=XIC,0,XIC,YIC, &sfile->flag, 0, 0, 0, 0, "Toggles long info");
uiDefIconButS(block, TOG|BIT|3, B_RELOADDIR, ICON_GHOST,xco+=XIC,0,XIC,YIC, &sfile->flag, 0, 0, 0, 0, "Hides dot files");
xco+=XIC+10;
if(sfile->type==FILE_LOADLIB) {
uiDefButS(block, TOGN|BIT|2, B_REDR, "Append", xco+=XIC,0,100,YIC, &sfile->flag, 0, 0, 0, 0, "Copies selected data into current project");
uiDefButS(block, TOG|BIT|2, B_REDR, "Link", xco+=100,0,100,YIC, &sfile->flag, 0, 0, 0, 0, "Creates a link to selected data from current project");
}
if(sfile->type==FILE_UNIX) {
df= BLI_diskfree(sfile->dir)/(1048576.0);
filesel_statistics(sfile, &totfile, &selfile, &totlen, &sellen);
sprintf(naam, "Free: %.3f Mb Files: (%d) %d (%.3f) %.3f Mb",
df, selfile,totfile, sellen, totlen);
cpack(0x0);
glRasterPos2i(xco, 5);
BIF_DrawString(uiBlockGetCurFont(block), naam, 0, 0);
}
/* always do as last */
curarea->headbutlen= xco+2*XIC;
uiDrawBlock(block);
}
/* ********************** FILE ****************************** */
/* ******************** OOPS ********************** */
void do_oops_buttons(short event)
{
float dx, dy;
if(curarea->win==0) return;
switch(event) {
case B_OOPSHOME:
boundbox_oops();
G.v2d->cur= G.v2d->tot;
dx= 0.15*(G.v2d->cur.xmax-G.v2d->cur.xmin);
dy= 0.15*(G.v2d->cur.ymax-G.v2d->cur.ymin);
G.v2d->cur.xmin-= dx;
G.v2d->cur.xmax+= dx;
G.v2d->cur.ymin-= dy;
G.v2d->cur.ymax+= dy;
test_view2d(G.v2d, curarea->winx, curarea->winy);
scrarea_queue_winredraw(curarea);
break;
case B_NEWOOPS:
scrarea_queue_winredraw(curarea);
scrarea_queue_headredraw(curarea);
G.soops->lockpoin= 0;
break;
}
}
void oops_buttons(void)
{
SpaceOops *soops;
Oops *oops;
uiBlock *block;
short xco;
char naam[256];
soops= curarea->spacedata.first;
sprintf(naam, "header %d", curarea->headwin);
block= uiNewBlock(&curarea->uiblocks, naam, UI_EMBOSSX, UI_HELV, curarea->headwin);
uiBlockSetCol(block, BUTGREEN);
curarea->butspacetype= SPACE_OOPS;
uiDefIconTextButC(block, ICONTEXTROW,B_NEWSPACE, ICON_VIEW3D, windowtype_pup(), 6,0,XIC,YIC, &(curarea->butspacetype), 1.0, SPACEICONMAX, 0, 0, "Displays Current Window Type. Click for menu of available types.");
/* FULL WINDOW */
xco= 25;
if(curarea->full) uiDefIconBut(block, BUT,B_FULL, ICON_SPLITSCREEN, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Returns to multiple views window (CTRL+Up arrow)");
else uiDefIconBut(block, BUT,B_FULL, ICON_FULLSCREEN, (short)(xco+=XIC),0,XIC,YIC, 0, 0, 0, 0, 0, "Makes current window full screen (CTRL+Down arrow)");
/* HOME */
uiDefIconBut(block, BUT, B_OOPSHOME, ICON_HOME, (short)(xco+=XIC),0,XIC,YIC, 0, 0, 0, 0, 0, "Zooms window to home view showing all items (HOMEKEY)");
xco+= XIC;
/* ZOOM and BORDER */
xco+= XIC;
uiDefIconButI(block, TOG, B_VIEW2DZOOM, ICON_VIEWZOOM, (short)(xco+=XIC),0,XIC,YIC, &viewmovetemp, 0, 0, 0, 0, "Zooms view (CTRL+MiddleMouse)");
uiDefIconBut(block, BUT, B_IPOBORDER, ICON_BORDERMOVE, (short)(xco+=XIC),0,XIC,YIC, 0, 0, 0, 0, 0, "Zooms view to area");
/* VISIBLE */
xco+= XIC;
uiDefButS(block, TOG|BIT|10,B_NEWOOPS, "lay", (short)(xco+=XIC),0,XIC+10,YIC, &soops->visiflag, 0, 0, 0, 0, "Displays Objects based on layer");
uiDefIconButS(block, TOG|BIT|0, B_NEWOOPS, ICON_SCENE_HLT, (short)(xco+=XIC+10),0,XIC,YIC, &soops->visiflag, 0, 0, 0, 0, "Displays Scene data");
uiDefIconButS(block, TOG|BIT|1, B_NEWOOPS, ICON_OBJECT_HLT, (short)(xco+=XIC),0,XIC,YIC, &soops->visiflag, 0, 0, 0, 0, "Displays Object data");
uiDefIconButS(block, TOG|BIT|2, B_NEWOOPS, ICON_MESH_HLT, (short)(xco+=XIC),0,XIC,YIC, &soops->visiflag, 0, 0, 0, 0, "Displays Mesh data");
uiDefIconButS(block, TOG|BIT|3, B_NEWOOPS, ICON_CURVE_HLT, (short)(xco+=XIC),0,XIC,YIC, &soops->visiflag, 0, 0, 0, 0, "Displays Curve/Surface/Font data");
uiDefIconButS(block, TOG|BIT|4, B_NEWOOPS, ICON_MBALL_HLT, (short)(xco+=XIC),0,XIC,YIC, &soops->visiflag, 0, 0, 0, 0, "Displays Metaball data");
uiDefIconButS(block, TOG|BIT|5, B_NEWOOPS, ICON_LATTICE_HLT, (short)(xco+=XIC),0,XIC,YIC, &soops->visiflag, 0, 0, 0, 0, "Displays Lattice data");
uiDefIconButS(block, TOG|BIT|6, B_NEWOOPS, ICON_LAMP_HLT, (short)(xco+=XIC),0,XIC,YIC, &soops->visiflag, 0, 0, 0, 0, "Displays Lamp data");
uiDefIconButS(block, TOG|BIT|7, B_NEWOOPS, ICON_MATERIAL_HLT, (short)(xco+=XIC),0,XIC,YIC, &soops->visiflag, 0, 0, 0, 0, "Displays Material data");
uiDefIconButS(block, TOG|BIT|8, B_NEWOOPS, ICON_TEXTURE_HLT, (short)(xco+=XIC),0,XIC,YIC, &soops->visiflag, 0, 0, 0, 0, "Displays Texture data");
uiDefIconButS(block, TOG|BIT|9, B_NEWOOPS, ICON_IPO_HLT, (short)(xco+=XIC),0,XIC,YIC, &soops->visiflag, 0, 0, 0, 0, "Displays Ipo data");
uiDefIconButS(block, TOG|BIT|12, B_NEWOOPS, ICON_IMAGE_HLT, (short)(xco+=XIC),0,XIC,YIC, &soops->visiflag, 0, 0, 0, 0, "Displays Image data");
uiDefIconButS(block, TOG|BIT|11, B_NEWOOPS, ICON_LIBRARY_HLT, (short)(xco+=XIC),0,XIC,YIC, &soops->visiflag, 0, 0, 0, 0, "Displays Library data");
/* name */
if(G.soops->lockpoin) {
oops= G.soops->lockpoin;
if(oops->type==ID_LI) strcpy(naam, ((Library *)oops->id)->name);
else strcpy(naam, oops->id->name);
cpack(0x0);
glRasterPos2i(xco+=XIC+10, 5);
BMF_DrawString(uiBlockGetCurFont(block), naam);
}
/* always do as last */
curarea->headbutlen= xco+2*XIC;
uiDrawBlock(block);
}
/* ********************** OOPS ****************************** */
/* ********************** TEXT ****************************** */
void do_text_buttons(unsigned short event)
{
SpaceText *st= curarea->spacedata.first;
ID *id, *idtest;
int nr= 1;
Text *text;
if (!st) return;
if (st->spacetype != SPACE_TEXT) return;
switch (event) {
case B_TEXTBROWSE:
if (st->menunr==-2) {
activate_databrowse((ID *)st->text, ID_TXT, 0, B_TEXTBROWSE, &st->menunr, do_text_buttons);
break;
}
if(st->menunr < 0) break;
text= st->text;
nr= 1;
id= (ID *)text;
if (st->menunr==32767) {
st->text= (Text *)add_empty_text();
st->top= 0;
allqueue(REDRAWTEXT, 0);
allqueue(REDRAWHEADERS, 0);
}
else if (st->menunr==32766) {
activate_fileselect(FILE_SPECIAL, "LOAD TEXT FILE", G.sce, add_text_fs);
return;
}
else {
idtest= G.main->text.first;
while(idtest) {
if(nr==st->menunr) {
break;
}
nr++;
idtest= idtest->next;
}
if(idtest==0) { /* new text */
activate_fileselect(FILE_SPECIAL, "LOAD TEXT FILE", G.sce, add_text_fs);
return;
}
if(idtest!=id) {
st->text= (Text *)idtest;
st->top= 0;
pop_space_text(st);
allqueue(REDRAWTEXT, 0);
allqueue(REDRAWHEADERS, 0);
}
}
break;
case B_TEXTDELETE:
if(!okee("Really delete text?")) return;
text= st->text;
if (!text) return;
BPY_clear_bad_scriptlinks(text);
free_text_controllers(text);
unlink_text(text);
free_libblock(&G.main->text, text);
break;
/*
case B_TEXTSTORE:
st->text->flags ^= TXT_ISEXT;
allqueue(REDRAWHEADERS, 0);
break;
*/
case B_TEXTLINENUM:
if(st->showlinenrs)
st->showlinenrs = 0;
else
st->showlinenrs = 1;
allqueue(REDRAWTEXT, 0);
allqueue(REDRAWHEADERS, 0);
break;
case B_TEXTFONT:
switch(st->font_id) {
case 0:
st->lheight= 12; break;
case 1:
st->lheight= 15; break;
}
allqueue(REDRAWTEXT, 0);
allqueue(REDRAWHEADERS, 0);
break;
}
}
void text_buttons(void)
{
uiBlock *block;
SpaceText *st= curarea->spacedata.first;
short xco;
char naam[256];
if (!st || st->spacetype != SPACE_TEXT) return;
sprintf(naam, "header %d", curarea->headwin);
block= uiNewBlock(&curarea->uiblocks, naam, UI_EMBOSSX, UI_HELV, curarea->headwin);
uiBlockSetCol(block, BUTGREY);
curarea->butspacetype= SPACE_TEXT;
uiDefIconTextButC(block, ICONTEXTROW,B_NEWSPACE, ICON_VIEW3D, windowtype_pup(), 6,0,XIC,YIC, &(curarea->butspacetype), 1.0, SPACEICONMAX, 0, 0, "Displays Current Window Type. Click for menu of available types.");
/* FULL WINDOW */
xco= 25;
if(curarea->full) uiDefIconBut(block, BUT,B_FULL, ICON_SPLITSCREEN, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Returns to multiple views window (CTRL+Up arrow)");
else uiDefIconBut(block, BUT,B_FULL, ICON_FULLSCREEN, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Makes current window full screen (CTRL+Down arrow)");
if(st->showlinenrs)
uiDefIconBut(block, BUT, B_TEXTLINENUM, ICON_SHORTDISPLAY, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Hides line numbers");
else
uiDefIconBut(block, BUT, B_TEXTLINENUM, ICON_LONGDISPLAY, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Displays line numbers");
/* STD TEXT BUTTONS */
if (!BPY_spacetext_is_pywin(st)) {
xco+= 2*XIC;
xco= std_libbuttons(block, xco, 0, NULL, B_TEXTBROWSE, (ID*)st->text, 0, &(st->menunr), 0, 0, B_TEXTDELETE, 0, 0);
/*
if (st->text) {
if (st->text->flags & TXT_ISDIRTY && (st->text->flags & TXT_ISEXT || !(st->text->flags & TXT_ISMEM)))
uiDefIconBut(block, BUT,0, ICON_ERROR, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "The text has been changed");
if (st->text->flags & TXT_ISEXT)
uiDefBut(block, BUT,B_TEXTSTORE, ICON(), xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Stores text in project file");
else
uiDefBut(block, BUT,B_TEXTSTORE, ICON(), xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Disables storing of text in project file");
xco+=10;
}
*/
xco+=XIC;
if(st->font_id>1) st->font_id= 0;
uiDefButI(block, MENU, B_TEXTFONT, "Screen 12 %x0|Screen 15%x1", xco,0,100,YIC, &st->font_id, 0, 0, 0, 0, "Displays available fonts");
xco+=100;
}
/* always as last */
curarea->headbutlen= xco+2*XIC;
uiDrawBlock(block);
}
/* ******************** TEXT ********************** */
/* ******************** SOUND ********************** */
void load_space_sound(char *str) /* called from fileselect */
{
bSound *sound;
sound= sound_new_sound(str);
if (sound) {
if (G.ssound) {
G.ssound->sound= sound;
}
} else {
error("Not a valid sample: %s", str);
}
allqueue(REDRAWSOUND, 0);
allqueue(REDRAWBUTSGAME, 0);
}
void load_sound_buttons(char *str) /* called from fileselect */
{
bSound *sound;
sound= sound_new_sound(str);
if (sound) {
if (curarea && curarea->spacetype==SPACE_BUTS) {
if (G.buts->mainb == BUTS_SOUND) {
G.buts->lockpoin = sound;
}
}
} else {
error("Not a valid sample: %s", str);
}
allqueue(REDRAWBUTSSOUND, 0);
}
void do_action_buttons(unsigned short event)
{
switch(event){
#ifdef __NLA_BAKE
case B_ACTBAKE:
bake_action_with_client (G.saction->action, OBACT, 0.01);
break;
#endif
case B_ACTCONT:
set_exprap_action(IPO_HORIZ);
break;
// case B_ACTEXTRAP:
// set_exprap_ipo(IPO_DIR);
// break;
case B_ACTCYCLIC:
set_exprap_action(IPO_CYCL);
break;
// case B_ACTCYCLICX:
// set_exprap_ipo(IPO_CYCLX);
// break;
case B_ACTHOME:
// Find X extents
//v2d= &(G.saction->v2d);
G.v2d->cur.xmin = 0;
G.v2d->cur.ymin=-SCROLLB;
if (!G.saction->action){ // here the mesh rvk?
G.v2d->cur.xmax=100;
}
else {
float extra;
G.v2d->cur.xmin= calc_action_start(G.saction->action);
G.v2d->cur.xmax= calc_action_end(G.saction->action);
extra= 0.05*(G.v2d->cur.xmax - G.v2d->cur.xmin);
G.v2d->cur.xmin-= extra;
G.v2d->cur.xmax+= extra;
}
G.v2d->tot= G.v2d->cur;
test_view2d(G.v2d, curarea->winx, curarea->winy);
addqueue (curarea->win, REDRAW, 1);
break;
case B_ACTCOPY:
copy_posebuf();
allqueue(REDRAWVIEW3D, 1);
break;
case B_ACTPASTE:
paste_posebuf(0);
allqueue(REDRAWVIEW3D, 1);
break;
case B_ACTPASTEFLIP:
paste_posebuf(1);
allqueue(REDRAWVIEW3D, 1);
break;
case B_ACTPIN: /* __PINFAKE */
/* if (G.saction->flag & SACTION_PIN){
if (G.saction->action)
G.saction->action->id.us ++;
}
else {
if (G.saction->action)
G.saction->action->id.us --;
}
*/ /* end PINFAKE */
allqueue(REDRAWACTION, 1);
break;
}
}
void do_sound_buttons(unsigned short event)
{
ID *id, *idtest;
int nr;
char name[256];
switch(event) {
case B_SOUNDBROWSE:
if(G.ssound->sndnr== -2) {
activate_databrowse((ID *)G.ssound->sound, ID_SO, 0, B_SOUNDBROWSE, &G.ssound->sndnr, do_sound_buttons);
return;
}
if (G.ssound->sndnr < 0) break;
if (G.ssound->sndnr == 32766) {
if (G.ssound && G.ssound->sound) strcpy(name, G.ssound->sound->name);
else strcpy(name, U.sounddir);
activate_fileselect(FILE_SPECIAL, "SELECT WAV FILE", name, load_space_sound);
} else {
nr= 1;
id= (ID *)G.ssound->sound;
idtest= G.main->sound.first;
while(idtest) {
if(nr==G.ssound->sndnr) {
break;
}
nr++;
idtest= idtest->next;
}
if(idtest==0) { /* no new */
return;
}
if(idtest!=id) {
G.ssound->sound= (bSound *)idtest;
if(idtest->us==0) idtest->us= 1;
allqueue(REDRAWSOUND, 0);
}
}
break;
case B_SOUNDBROWSE2:
id = (ID *)G.buts->lockpoin;
if(G.buts->texnr == -2) {
activate_databrowse(id, ID_SO, 0, B_SOUNDBROWSE2, &G.buts->texnr, do_sound_buttons);
return;
}
if (G.buts->texnr < 0) break;
if (G.buts->texnr == 32766) {
if (id) strcpy(name, ((bSound *)id)->name);
else strcpy(name, U.sounddir);
activate_fileselect(FILE_SPECIAL, "SELECT WAV FILE", name, load_sound_buttons);
} else {
nr= 1;
idtest= G.main->sound.first;
while (idtest) {
if(nr == G.buts->texnr) {
break;
}
nr++;
idtest = idtest->next;
}
if (idtest == 0) { /* geen new */
return;
}
if (idtest != id) {
G.buts->lockpoin = (bSound *)idtest;
if(idtest->us==0) idtest->us= 1;
allqueue(REDRAWBUTSSOUND, 0);
BIF_preview_changed(G.buts);
}
}
break;
case B_SOUNDHOME:
G.v2d->cur= G.v2d->tot;
test_view2d(G.v2d, curarea->winx, curarea->winy);
scrarea_queue_winredraw(curarea);
break;
}
}
void sound_buttons(void)
{
uiBlock *block;
short xco;
char naam[256];
char ch[20];
sprintf(naam, "header %d", curarea->headwin);
block= uiNewBlock(&curarea->uiblocks, naam, UI_EMBOSSX, UI_HELV, curarea->headwin);
uiBlockSetCol(block, BUTYELLOW);
curarea->butspacetype= SPACE_SOUND;
uiDefIconTextButC(block, ICONTEXTROW,B_NEWSPACE, ICON_VIEW3D, windowtype_pup(), 6,0,XIC,YIC, &(curarea->butspacetype), 1.0, SPACEICONMAX, 0, 0, "Displays Current Window Type. Click for menu of available types.");
/* FULL WINDOW */
xco= 25;
if(curarea->full) uiDefIconBut(block, BUT,B_FULL, ICON_SPLITSCREEN, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Returns to multiple views window (CTRL+Up arrow)");
else uiDefIconBut(block, BUT,B_FULL, ICON_FULLSCREEN, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Makes current window full screen (CTRL+Down arrow)");
uiDefIconBut(block, BUT, B_SOUNDHOME, ICON_HOME, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Zooms window to home view showing all items (HOMEKEY)");
xco= std_libbuttons(block, xco+40, 0, NULL, B_SOUNDBROWSE, (ID *)G.ssound->sound, 0, &(G.ssound->sndnr), 1, 0, 0, 0, 0);
if(G.ssound->sound) {
bSound *sound= G.ssound->sound;
if (sound->sample && sound->sample->len)
{
if (sound->sample->channels == 1)
strcpy(ch, "Mono");
else if (sound->sample->channels == 2)
strcpy(ch, "Stereo");
else
strcpy(ch, "Unknown");
sprintf(naam, "Sample: %s, %d bit, %d Hz, %d samples", ch, sound->sample->bits, sound->sample->rate, sound->sample->len);
cpack(0x0);
glRasterPos2i(xco+10, 5);
BMF_DrawString(uiBlockGetCurFont(block), naam);
}
else
{
sprintf(naam, "No sample info available.");
cpack(0x0);
glRasterPos2i(xco+10, 5);
BMF_DrawString(uiBlockGetCurFont(block), naam);
}
}
/* always as last */
curarea->headbutlen= xco+2*XIC;
uiDrawBlock(block);
}
/* ******************** SOUND ********************** */
/* ******************** IMAGE ********************** */
void load_space_image(char *str) /* called from fileselect */
{
Image *ima=0;
if(G.obedit) {
error("Can't perfom this in editmode");
return;
}
ima= add_image(str);
if(ima) {
G.sima->image= ima;
free_image_buffers(ima); /* force read again */
ima->ok= 1;
image_changed(G.sima, 0);
}
allqueue(REDRAWIMAGE, 0);
}
void image_replace(Image *old, Image *new)
{
TFace *tface;
Mesh *me;
int a, rep=0;
new->tpageflag= old->tpageflag;
new->twsta= old->twsta;
new->twend= old->twend;
new->xrep= old->xrep;
new->yrep= old->yrep;
me= G.main->mesh.first;
while(me) {
if(me->tface) {
tface= me->tface;
a= me->totface;
while(a--) {
if(tface->tpage==old) {
tface->tpage= new;
rep++;
}
tface++;
}
}
me= me->id.next;
}
if(rep) {
if(new->id.us==0) new->id.us= 1;
}
else error("Nothing replaced");
}
void replace_space_image(char *str) /* called from fileselect */
{
Image *ima=0;
if(G.obedit) {
error("Can't perfom this in editmode");
return;
}
ima= add_image(str);
if(ima) {
if(G.sima->image != ima) {
image_replace(G.sima->image, ima);
}
G.sima->image= ima;
free_image_buffers(ima); /* force read again */
ima->ok= 1;
/* replace also assigns: */
image_changed(G.sima, 0);
}
allqueue(REDRAWIMAGE, 0);
}
void save_paint(char *name)
{
char str[FILE_MAXDIR+FILE_MAXFILE];
Image *ima = G.sima->image;
ImBuf *ibuf;
if (ima && ima->ibuf) {
BLI_strncpy(str, name, sizeof(str));
BLI_convertstringcode(str, G.sce, G.scene->r.cfra);
if (saveover(str)) {
ibuf = IMB_dupImBuf(ima->ibuf);
if (ibuf) {
if (BIF_write_ibuf(ibuf, str)) {
BLI_strncpy(ima->name, name, sizeof(ima->name));
ima->ibuf->userflags &= ~IB_BITMAPDIRTY;
allqueue(REDRAWHEADERS, 0);
allqueue(REDRAWBUTSTEX, 0);
} else {
error("Couldn't write image: %s", str);
}
IMB_freeImBuf(ibuf);
}
}
}
}
void do_image_buttons(unsigned short event)
{
Image *ima;
ID *id, *idtest;
int nr;
char name[256], str[256];
if(curarea->win==0) return;
switch(event) {
case B_SIMAGEHOME:
image_home();
break;
case B_SIMABROWSE:
if(G.sima->imanr== -2) {
activate_databrowse((ID *)G.sima->image, ID_IM, 0, B_SIMABROWSE, &G.sima->imanr, do_image_buttons);
return;
}
if(G.sima->imanr < 0) break;
nr= 1;
id= (ID *)G.sima->image;
idtest= G.main->image.first;
while(idtest) {
if(nr==G.sima->imanr) {
break;
}
nr++;
idtest= idtest->next;
}
if(idtest==0) { /* no new */
return;
}
if(idtest!=id) {
G.sima->image= (Image *)idtest;
if(idtest->us==0) idtest->us= 1;
allqueue(REDRAWIMAGE, 0);
}
image_changed(G.sima, 0); /* also when image is the same: assign! 0==no tileflag */
break;
case B_SIMAGELOAD:
case B_SIMAGELOAD1:
if(G.sima->image) strcpy(name, G.sima->image->name);
else strcpy(name, U.textudir);
if(event==B_SIMAGELOAD)
activate_imageselect(FILE_SPECIAL, "SELECT IMAGE", name, load_space_image);
else
activate_fileselect(FILE_SPECIAL, "SELECT IMAGE", name, load_space_image);
break;
case B_SIMAGEREPLACE:
case B_SIMAGEREPLACE1:
if(G.sima->image) strcpy(name, G.sima->image->name);
else strcpy(name, U.textudir);
if(event==B_SIMAGEREPLACE)
activate_imageselect(FILE_SPECIAL, "REPLACE IMAGE", name, replace_space_image);
else
activate_fileselect(FILE_SPECIAL, "REPLACE IMAGE", name, replace_space_image);
break;
case B_SIMAGEDRAW:
if(G.f & G_FACESELECT) {
make_repbind(G.sima->image);
image_changed(G.sima, 1);
}
allqueue(REDRAWVIEW3D, 0);
allqueue(REDRAWIMAGE, 0);
break;
case B_SIMAGEDRAW1:
image_changed(G.sima, 2); /* 2: only tileflag */
allqueue(REDRAWVIEW3D, 0);
allqueue(REDRAWIMAGE, 0);
break;
case B_TWINANIM:
ima = G.sima->image;
if (ima) {
if(ima->flag & IMA_TWINANIM) {
nr= ima->xrep*ima->yrep;
if(ima->twsta>=nr) ima->twsta= 1;
if(ima->twend>=nr) ima->twend= nr-1;
if(ima->twsta>ima->twend) ima->twsta= 1;
allqueue(REDRAWIMAGE, 0);
}
}
break;
case B_CLIP_UV:
tface_do_clip();
allqueue(REDRAWIMAGE, 0);
allqueue(REDRAWVIEW3D, 0);
break;
case B_SIMAGEPAINTTOOL:
// check for packed file here
allqueue(REDRAWIMAGE, 0);
allqueue(REDRAWVIEW3D, 0);
break;
case B_SIMAPACKIMA:
ima = G.sima->image;
if (ima) {
if (ima->packedfile) {
if (G.fileflags & G_AUTOPACK) {
if (okee("Disable AutoPack ?")) {
G.fileflags &= ~G_AUTOPACK;
}
}
if ((G.fileflags & G_AUTOPACK) == 0) {
unpackImage(ima, PF_ASK);
}
} else {
if (ima->ibuf && (ima->ibuf->userflags & IB_BITMAPDIRTY)) {
error("Can't pack painted image. Save image first.");
} else {
ima->packedfile = newPackedFile(ima->name);
}
}
allqueue(REDRAWBUTSTEX, 0);
allqueue(REDRAWHEADERS, 0);
}
break;
case B_SIMAGESAVE:
ima = G.sima->image;
if (ima) {
strcpy(name, ima->name);
if (ima->ibuf) {
save_image_filesel_str(str);
activate_fileselect(FILE_SPECIAL, str, name, save_paint);
}
}
break;
}
}
/* This should not be a stack var! */
static int headerbuttons_packdummy;
void image_buttons(void)
{
uiBlock *block;
short xco;
char naam[256];
headerbuttons_packdummy = 0;
sprintf(naam, "header %d", curarea->headwin);
block= uiNewBlock(&curarea->uiblocks, naam, UI_EMBOSSX, UI_HELV, curarea->headwin);
uiBlockSetCol(block, BUTBLUE);
what_image(G.sima);
curarea->butspacetype= SPACE_IMAGE;
uiDefIconTextButC(block, ICONTEXTROW,B_NEWSPACE, ICON_VIEW3D, windowtype_pup(), 6,0,XIC,YIC, &(curarea->butspacetype), 1.0, SPACEICONMAX, 0, 0, "Displays Current Window Type. Click for menu of available types.");
/* FULL WINDOW */
xco= 25;
if(curarea->full) uiDefIconBut(block, BUT,B_FULL, ICON_SPLITSCREEN, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Returns to multiple views window (CTRL+Up arrow)");
else uiDefIconBut(block, BUT,B_FULL, ICON_FULLSCREEN, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Makes current window full screen (CTRL+Down arrow)");
/* HOME*/
uiDefIconBut(block, BUT, B_SIMAGEHOME, ICON_HOME, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Zooms window to home view showing all items (HOMEKEY)");
uiDefIconButS(block, TOG|BIT|0, B_BE_SQUARE, ICON_KEEPRECT, xco+=XIC,0,XIC,YIC, &G.sima->flag, 0, 0, 0, 0, "Toggles constraining UV polygons to squares while editing");
uiDefIconButS(block, ICONTOG|BIT|2, B_CLIP_UV, ICON_CLIPUV_DEHLT,xco+=XIC,0,XIC,YIC, &G.sima->flag, 0, 0, 0, 0, "Toggles clipping UV with image size");
xco= std_libbuttons(block, xco+40, 0, NULL, B_SIMABROWSE, (ID *)G.sima->image, 0, &(G.sima->imanr), 0, 0, B_IMAGEDELETE, 0, 0);
if (G.sima->image) {
if (G.sima->image->packedfile) {
headerbuttons_packdummy = 1;
}
uiDefIconButI(block, TOG|BIT|0, B_SIMAPACKIMA, ICON_PACKAGE, xco,0,XIC,YIC, &headerbuttons_packdummy, 0, 0, 0, 0, "Toggles packed status of this Image");
xco += XIC;
}
uiBlockSetCol(block, BUTSALMON);
uiDefBut(block, BUT, B_SIMAGELOAD, "Load", xco+=XIC,0,2*XIC,YIC, 0, 0, 0, 0, 0, "Loads image - thumbnail view");
uiBlockSetCol(block, BUTGREY);
uiDefBut(block, BUT, B_SIMAGELOAD1, "", (short)(xco+=2*XIC+2),0,10,YIC, 0, 0, 0, 0, 0, "Loads image - file select view");
xco+=XIC/2;
if (G.sima->image) {
uiBlockSetCol(block, BUTSALMON);
uiDefBut(block, BUT, B_SIMAGEREPLACE, "Replace",xco+=XIC,0,(short)(3*XIC),YIC, 0, 0, 0, 0, 0, "Replaces current image - thumbnail view");
uiBlockSetCol(block, BUTGREY);
uiDefBut(block, BUT, B_SIMAGEREPLACE1, "", (short)(xco+=3*XIC+2),0,10,YIC, 0, 0, 0, 0, 0, "Replaces current image - file select view");
xco+=XIC/2;
uiDefIconButS(block, TOG|BIT|4, 0, ICON_ENVMAP, xco+=XIC,0,XIC,YIC, &G.sima->image->flag, 0, 0, 0, 0, "Uses this image as a reflection map (Ignores UV Coordinates)");
xco+=XIC/2;
uiDefIconButS(block, TOG|BIT|0, B_SIMAGEDRAW1, ICON_GRID, xco+=XIC,0,XIC,YIC, &G.sima->image->flag, 0, 0, 0, 0, "");
uiDefButS(block, NUM, B_SIMAGEDRAW, "", xco+=XIC,0,XIC,YIC, &G.sima->image->xrep, 1.0, 16.0, 0, 0, "Sets the degree of repetition in the X direction");
uiDefButS(block, NUM, B_SIMAGEDRAW, "", xco+=XIC,0,XIC,YIC, &G.sima->image->yrep, 1.0, 16.0, 0, 0, "Sets the degree of repetition in the Y direction");
uiDefButS(block, TOG|BIT|1, B_TWINANIM, "Anim", xco+=XIC,0,(short)(2*XIC),YIC, &G.sima->image->tpageflag, 0, 0, 0, 0, "Toggles use of animated texture");
uiDefButS(block, NUM, B_TWINANIM, "", (short)(xco+=2*XIC),0,XIC,YIC, &G.sima->image->twsta, 0.0, 128.0, 0, 0, "Displays the start frame of an animated texture. Click to change.");
uiDefButS(block, NUM, B_TWINANIM, "", xco+=XIC,0,XIC,YIC, &G.sima->image->twend, 0.0, 128.0, 0, 0, "Displays the end frame of an animated texture. Click to change.");
// uiDefButS(block, TOG|BIT|2, 0, "Cycle", xco+=XIC,0,2*XIC,YIC, &G.sima->image->tpageflag, 0, 0, 0, 0, "");
uiDefButS(block, NUM, 0, "Speed", xco+=(2*XIC),0,4*XIC,YIC, &G.sima->image->animspeed, 1.0, 100.0, 0, 0, "Displays Speed of the animation in frames per second. Click to change.");
#ifdef NAN_TPT
xco+= 4*XIC;
uiDefIconButS(block, ICONTOG|BIT|3, B_SIMAGEPAINTTOOL, ICON_TPAINT_DEHLT, xco+=XIC,0,XIC,YIC, &G.sima->flag, 0, 0, 0, 0, "Enables TexturePaint Mode");
if (G.sima->image && G.sima->image->ibuf && (G.sima->image->ibuf->userflags & IB_BITMAPDIRTY)) {
uiDefBut(block, BUT, B_SIMAGESAVE, "Save", xco+=XIC,0,2*XIC,YIC, 0, 0, 0, 0, 0, "Saves image");
xco += XIC;
}
#endif /* NAN_TPT */
xco+= XIC;
}
/* draw LOCK */
xco+= XIC/2;
uiDefIconButS(block, ICONTOG, 0, ICON_UNLOCKED, (short)(xco+=XIC),0,XIC,YIC, &(G.sima->lock), 0, 0, 0, 0, "Toggles forced redraw of other windows to reflect changes in real time");
/* Always do this last */
curarea->headbutlen= xco+2*XIC;
uiDrawBlock(block);
}
/* ********************** IMAGE ****************************** */
/* ******************** IMASEL ********************** */
void do_imasel_buttons(short event)
{
SpaceImaSel *simasel;
char name[256];
simasel= curarea->spacedata.first;
if(curarea->win==0) return;
switch(event) {
case B_IMASELHOME:
break;
case B_IMASELREMOVEBIP:
if(bitset(simasel->fase, IMS_FOUND_BIP)){
strcpy(name, simasel->dir);
strcat(name, ".Bpib");
remove(name);
simasel->fase &= ~ IMS_FOUND_BIP;
}
break;
}
}
void imasel_buttons(void)
{
SpaceImaSel *simasel;
uiBlock *block;
short xco;
char naam[256];
simasel= curarea->spacedata.first;
sprintf(naam, "header %d", curarea->headwin);
block= uiNewBlock(&curarea->uiblocks, naam, UI_EMBOSSX, UI_HELV, curarea->headwin);
uiBlockSetCol(block, BUTBLUE);
curarea->butspacetype= SPACE_IMASEL;
uiDefIconTextButC(block, ICONTEXTROW,B_NEWSPACE, ICON_VIEW3D, windowtype_pup(), 6,0,XIC,YIC, &(curarea->butspacetype), 1.0, SPACEICONMAX, 0, 0, "Displays Current Window Type. Click for menu of available types.");
/* FULL WINDOW */
xco= 25;
if(curarea->full) uiDefIconBut(block, BUT,B_FULL, ICON_SPLITSCREEN, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "");
else uiDefIconBut(block, BUT,B_FULL, ICON_FULLSCREEN, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "");
xco+=XIC;
if (simasel->title){
xco+=25;
glRasterPos2i(xco, 4);
BMF_DrawString(G.font, simasel->title);
xco+=BMF_GetStringWidth(G.fonts, simasel->title);
xco+=25;
}
uiDefIconBut(block, BUT, B_IMASELREMOVEBIP, ICON_BPIBFOLDER_X, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "");/* remove */
uiDefIconButS(block, TOG|BIT|0, B_REDR, ICON_BPIBFOLDERGREY, xco+=XIC,0,XIC,YIC, &simasel->mode, 0, 0, 0, 0, "Toggles display of directory information");/* dir */
uiDefIconButS(block, TOG|BIT|1, B_REDR, ICON_INFO, xco+=XIC,0,XIC,YIC, &simasel->mode, 0, 0, 0, 0, "Toggles display of selected image information");/* info */
uiDefIconButS(block, TOG|BIT|2, B_REDR, ICON_IMAGE_COL, xco+=XIC,0,XIC,YIC, &simasel->mode, 0, 0, 0, 0, "");/* image */
uiDefIconButS(block, TOG|BIT|3, B_REDR, ICON_MAGNIFY, xco+=XIC,0,XIC,YIC, &simasel->mode, 0, 0, 0, 0, "Toggles magnified view of thumbnail of images under mouse pointer");/* magnify */
/* always do as last */
curarea->headbutlen= xco+2*XIC;
uiDrawBlock(block);
}
/* ********************** IMASEL ****************************** */
/* ******************** GENERAL ********************** */
void do_headerbuttons(short event)
{
if(event<=50) do_global_buttons2(event);
else if(event<=100) do_global_buttons(event);
else if(event<200) do_view3d_buttons(event);
else if(event<250) do_ipo_buttons(event);
else if(event<300) do_oops_buttons(event);
else if(event<350) do_info_buttons(event);
else if(event<400) do_image_buttons(event);
else if(event<450) do_buts_buttons(event);
else if(event<500) do_imasel_buttons(event);
else if(event<550) do_text_buttons(event);
else if(event<600) do_file_buttons(event);
else if(event<650) do_seq_buttons(event);
else if(event<700) do_sound_buttons(event);
else if(event<800) do_action_buttons(event);
else if(event<900) do_nla_buttons(event);
}
|