Welcome to mirror list, hosted at ThFree Co, Russian Federation.

space_view3d_spacebar_menu.py - git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3ba517e7105981b70bad1c510576c1f7f84063d8 (plain)
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
# ##### BEGIN GPL 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.
#
#  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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####
# Contributed to by: meta-androcto, JayDez, sim88, sam, lijenstina, mkb, wisaac, CoDEmanX #

bl_info = {
    "name": "Dynamic Context Menu",
    "author": "meta-androcto",
    "version": (1, 8, 6),
    "blender": (2, 77, 0),
    "location": "View3D > Spacebar",
    "description": "Object Mode Context Sensitive Spacebar Menu",
    "warning": "",
    "wiki_url": "https://wiki.blender.org/index.php/Extensions:2.6/Py/"
                "Scripts/3D_interaction/Dynamic_Spacebar_Menu",
    "category": "3D View",
}

import bpy
from bpy.types import (
        Operator,
        Menu,
        AddonPreferences,
        )
from bpy.props import (
        BoolProperty,
        StringProperty,
        )

from bl_ui.properties_paint_common import UnifiedPaintPanel


# Dynamic Context Sensitive Menu #
# Main Menu based on Object Type & 3d View Editor Mode #

class VIEW3D_MT_Space_Dynamic_Menu(Menu):
    bl_label = "Dynamic Context Menu"

    def draw(self, context):
        layout = self.layout
        settings = context.tool_settings
        layout.operator_context = 'INVOKE_REGION_WIN'
        obj = context.object

# No Object Selected #
        if not context.active_object:

            layout.operator_context = 'INVOKE_REGION_WIN'
            layout.operator("wm.search_menu", text="Search", icon='VIEWZOOM')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_AddMenu", icon='OBJECT_DATAMODE')
            layout.menu("VIEW3D_MT_View_Directions", icon='ZOOM_ALL')
            layout.menu("VIEW3D_MT_View_Navigation", icon='ROTATE')
            layout.menu("VIEW3D_MT_View_Toggle", icon='SPLITSCREEN')
            layout.operator("view3d.snap_cursor_to_center",
                            text="Cursor to Center")
            layout.operator("view3d.snap_cursor_to_grid",
                            text="Cursor to Grid")
            layout.menu("VIEW3D_MT_UndoS", icon='ARROW_LEFTRIGHT')
            UseSeparator(self, context)
            layout.operator("view3d.toolshelf", icon='MENU_PANEL')
            layout.operator("view3d.properties", icon='MENU_PANEL')
            if context.gpencil_data and context.gpencil_data.use_stroke_edit_mode:
                layout.menu("VIEW3D_MT_Edit_Gpencil", icon='GREASEPENCIL')

# Mesh Object Mode #
        if obj and obj.type == 'MESH' and obj.mode in {'OBJECT'}:

            layout.operator_context = 'INVOKE_REGION_WIN'
            layout.operator("wm.search_menu", text="Search", icon='VIEWZOOM')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_View_Menu", icon='ZOOM_ALL')
            layout.menu("VIEW3D_MT_Select_Object", icon='RESTRICT_SELECT_OFF')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_AddMenu", icon='OBJECT_DATAMODE')
            layout.menu("VIEW3D_MT_Object", icon='VIEW3D')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_TransformMenu", icon='MANIPUL')
            layout.menu("VIEW3D_MT_MirrorMenu", icon='MOD_MIRROR')
            layout.menu("VIEW3D_MT_CursorMenu", icon='CURSOR')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_ParentMenu", icon='ROTACTIVE')
            layout.menu("VIEW3D_MT_GroupMenu", icon='GROUP')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_object_specials", text="Specials", icon='SOLO_OFF')
            if context.gpencil_data and context.gpencil_data.use_stroke_edit_mode:
                layout.menu("VIEW3D_MT_Edit_Gpencil", icon='GREASEPENCIL')
            layout.menu("VIEW3D_MT_Camera_Options", icon='OUTLINER_OB_CAMERA')
            layout.operator_menu_enum("object.modifier_add", "type", icon='MODIFIER')
            layout.operator_menu_enum("object.constraint_add",
                                      "type", text="Add Constraint", icon='CONSTRAINT')
            UseSeparator(self, context)
            layout.operator("object.delete", text="Delete Object", icon='X')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_UndoS", icon='ARROW_LEFTRIGHT')
            layout.menu("VIEW3D_MT_Object_Interactive_Mode", icon='EDIT')
            UseSeparator(self, context)
            layout.operator("view3d.toolshelf", icon='MENU_PANEL')
            layout.operator("view3d.properties", icon='MENU_PANEL')

# Mesh Edit Mode #
        if obj and obj.type == 'MESH' and obj.mode in {'EDIT'}:
            layout.operator("wm.search_menu", text="Search", icon='VIEWZOOM')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_View_Menu", icon='ZOOM_ALL')
            layout.menu("VIEW3D_MT_Select_Edit_Mesh", icon='RESTRICT_SELECT_OFF')
            layout.menu("VIEW3D_MT_Edit_Multi", icon='VERTEXSEL')
            UseSeparator(self, context)
            layout.menu("INFO_MT_mesh_add", text="Add Mesh", icon='OUTLINER_OB_MESH')
            layout.menu("VIEW3D_MT_Edit_Mesh", text="Mesh", icon='MESH_DATA')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_TransformMenuEdit", icon='MANIPUL')
            layout.menu("VIEW3D_MT_MirrorMenu", icon='MOD_MIRROR')
            layout.menu("VIEW3D_MT_EditCursorMenu", icon='CURSOR')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_UV_Map", icon='MOD_UVPROJECT')
            layout.menu("VIEW3D_MT_edit_mesh_specials", icon='SOLO_OFF')
            layout.menu("VIEW3D_MT_edit_mesh_extrude", icon='ORTHO')
            UseSeparator(self, context)
            layout.operator_menu_enum("object.modifier_add", "type", icon='MODIFIER')
            layout.operator_menu_enum("object.constraint_add",
                                      "type", text="Add Constraint", icon='CONSTRAINT')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_edit_mesh_delete", icon='X')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_UndoS", icon='ARROW_LEFTRIGHT')
            layout.menu("VIEW3D_MT_Object_Interactive_Mode", icon='EDIT')
            UseSeparator(self, context)
            layout.operator("view3d.toolshelf", icon='MENU_PANEL')
            layout.operator("view3d.properties", icon='MENU_PANEL')

# Sculpt Mode #
        if obj and obj.type == 'MESH' and obj.mode in {'SCULPT'}:

            layout.operator("wm.search_menu", text="Search", icon='VIEWZOOM')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_View_Menu", icon='ZOOM_ALL')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_Sculpts", icon='SCULPTMODE_HLT')
            layout.menu("VIEW3D_MT_Brush_Selection", text="Sculpt Tool", icon='BRUSH_SCULPT_DRAW')
            layout.menu("VIEW3D_MT_Brush_Settings", icon='BRUSH_DATA')
            layout.menu("VIEW3D_MT_Hide_Masks", icon='RESTRICT_VIEW_OFF')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_Sculpt_Specials", icon='SOLO_OFF')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_UndoS", icon='ARROW_LEFTRIGHT')
            layout.menu("VIEW3D_MT_Object_Interactive_Mode", icon='EDIT')
            UseSeparator(self, context)
            layout.operator("view3d.toolshelf", icon='MENU_PANEL')
            layout.operator("view3d.properties", icon='MENU_PANEL')

# Vertex Paint #
        if obj and obj.type == 'MESH' and obj.mode in {'VERTEX_PAINT'}:

            layout.operator("wm.search_menu", text="Search", icon='VIEWZOOM')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_View_Menu", icon='ZOOM_ALL')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_Brush_Settings", icon='BRUSH_DATA')
            layout.menu("VIEW3D_MT_Brush_Selection",
                        text="Vertex Paint Tool", icon='BRUSH_VERTEXDRAW')
            layout.menu("VIEW3D_MT_Vertex_Colors", icon='GROUP_VCOL')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_UndoS", icon='ARROW_LEFTRIGHT')
            layout.menu("VIEW3D_MT_Object_Interactive_Mode", icon='EDIT')
            UseSeparator(self, context)
            layout.operator("view3d.toolshelf", icon='MENU_PANEL')
            layout.operator("view3d.properties", icon='MENU_PANEL')

# Weight Paint Menu #
        if obj and obj.type == 'MESH' and obj.mode in {'WEIGHT_PAINT'}:

            layout.operator("wm.search_menu", text="Search", icon='VIEWZOOM')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_View_Menu", icon='ZOOM_ALL')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_Paint_Weights", icon='WPAINT_HLT')
            layout.menu("VIEW3D_MT_Brush_Settings", icon='BRUSH_DATA')
            layout.menu("VIEW3D_MT_Brush_Selection",
                        text="Weight Paint Tool", icon='BRUSH_TEXMASK')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_UndoS", icon='ARROW_LEFTRIGHT')
            layout.menu("VIEW3D_MT_Object_Interactive_Mode", icon='EDIT')
            UseSeparator(self, context)
            layout.operator("view3d.toolshelf", icon='MENU_PANEL')
            layout.operator("view3d.properties", icon='MENU_PANEL')

# Texture Paint #
        if obj and obj.type == 'MESH' and obj.mode in {'TEXTURE_PAINT'}:

            layout.operator("wm.search_menu", text="Search", icon='VIEWZOOM')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_View_Menu", icon='ZOOM_ALL')
            layout.menu("VIEW3D_MT_Brush_Settings", icon='BRUSH_DATA')
            layout.menu("VIEW3D_MT_Brush_Selection",
                        text="Texture Paint Tool", icon='SCULPTMODE_HLT')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_UndoS", icon='ARROW_LEFTRIGHT')
            layout.menu("VIEW3D_MT_Object_Interactive_Mode", icon='EDIT')
            UseSeparator(self, context)
            layout.operator("view3d.toolshelf", icon='MENU_PANEL')
            layout.operator("view3d.properties", icon='MENU_PANEL')

# Curve Object Mode #
        if obj and obj.type == 'CURVE' and obj.mode in {'OBJECT'}:

            layout.operator_context = 'INVOKE_REGION_WIN'
            layout.operator("wm.search_menu", text="Search", icon='VIEWZOOM')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_View_Menu", icon='ZOOM_ALL')
            layout.menu("VIEW3D_MT_Select_Object", icon='RESTRICT_SELECT_OFF')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_AddMenu", icon='OBJECT_DATAMODE')
            layout.menu("VIEW3D_MT_Object", icon='VIEW3D')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_TransformMenu", icon='MANIPUL')
            layout.menu("VIEW3D_MT_MirrorMenu", icon='MOD_MIRROR')
            layout.menu("VIEW3D_MT_CursorMenu", icon='CURSOR')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_ParentMenu", icon='ROTACTIVE')
            layout.menu("VIEW3D_MT_GroupMenu", icon='GROUP')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_object_specials", text="Specials", icon='SOLO_OFF')
            layout.menu("VIEW3D_MT_Camera_Options", icon='OUTLINER_OB_CAMERA')
            UseSeparator(self, context)
            layout.operator_menu_enum("object.modifier_add", "type", icon='MODIFIER')
            layout.operator_menu_enum("object.constraint_add",
                                      "type", text="Add Constraint", icon='CONSTRAINT')
            UseSeparator(self, context)
            layout.operator("object.delete", text="Delete Object", icon='X')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_UndoS", icon='ARROW_LEFTRIGHT')
            layout.menu("VIEW3D_MT_Object_Interactive_Other", icon='OBJECT_DATA')
            UseSeparator(self, context)
            layout.operator("view3d.toolshelf", icon='MENU_PANEL')
            layout.operator("view3d.properties", icon='MENU_PANEL')

# Edit Curve #
        if obj and obj.type == 'CURVE' and obj.mode in {'EDIT'}:

            layout.operator("wm.search_menu", text="Search", icon='VIEWZOOM')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_View_Menu", icon='ZOOM_ALL')
            layout.menu("VIEW3D_MT_Select_Edit_Curve",
                        icon='RESTRICT_SELECT_OFF')
            UseSeparator(self, context)
            layout.menu("INFO_MT_curve_add", text="Add Curve",
                        icon='OUTLINER_OB_CURVE')
            layout.menu("VIEW3D_MT_Edit_Curve", icon='CURVE_DATA')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_TransformMenu", icon='MANIPUL')
            layout.menu("VIEW3D_MT_MirrorMenu", icon='MOD_MIRROR')
            layout.menu("VIEW3D_MT_CursorMenu", icon='CURSOR')
            layout.menu("VIEW3D_MT_EditCurveCtrlpoints",
                        icon='CURVE_BEZCURVE')
            layout.menu("VIEW3D_MT_EditCurveSpecials",
                        icon='SOLO_OFF')
            UseSeparator(self, context)
            layout.operator("curve.delete", text="Delete Object",
                            icon='X')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_UndoS", icon='ARROW_LEFTRIGHT')
            layout.menu("VIEW3D_MT_Object_Interactive_Other", icon='OBJECT_DATA')
            UseSeparator(self, context)
            layout.operator("view3d.toolshelf", icon='MENU_PANEL')
            layout.operator("view3d.properties", icon='MENU_PANEL')

# Surface Object Mode #
        if obj and obj.type == 'SURFACE' and obj.mode in {'OBJECT'}:

            layout.operator_context = 'INVOKE_REGION_WIN'
            layout.operator("wm.search_menu", text="Search", icon='VIEWZOOM')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_View_Menu", icon='ZOOM_ALL')
            layout.menu("VIEW3D_MT_Select_Object", icon='RESTRICT_SELECT_OFF')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_AddMenu", icon='OBJECT_DATAMODE')
            layout.menu("VIEW3D_MT_Object", icon='VIEW3D')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_TransformMenu", icon='MANIPUL')
            layout.menu("VIEW3D_MT_MirrorMenu", icon='MOD_MIRROR')
            layout.menu("VIEW3D_MT_CursorMenu", icon='CURSOR')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_ParentMenu", icon='ROTACTIVE')
            layout.menu("VIEW3D_MT_GroupMenu", icon='GROUP')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_object_specials", text="Specials", icon='SOLO_OFF')
            layout.menu("VIEW3D_MT_Camera_Options", icon='OUTLINER_OB_CAMERA')
            layout.operator_menu_enum("object.modifier_add", "type", icon='MODIFIER')
            layout.operator_menu_enum("object.constraint_add",
                                      "type", text="Add Constraint", icon='CONSTRAINT')
            UseSeparator(self, context)
            layout.operator("object.delete", text="Delete Object", icon='X')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_UndoS", icon='ARROW_LEFTRIGHT')
            layout.menu("VIEW3D_MT_Object_Interactive_Other", icon='OBJECT_DATA')
            UseSeparator(self, context)
            layout.operator("view3d.toolshelf", icon='MENU_PANEL')
            layout.operator("view3d.properties", icon='MENU_PANEL')

# Edit Surface #
        if obj and obj.type == 'SURFACE' and obj.mode in {'EDIT'}:

            layout.operator("wm.search_menu", text="Search", icon='VIEWZOOM')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_View_Menu", icon='ZOOM_ALL')
            layout.menu("VIEW3D_MT_Select_Edit_Surface", icon='RESTRICT_SELECT_OFF')
            UseSeparator(self, context)
            layout.menu("INFO_MT_surface_add", text="Add Surface",
                        icon='OUTLINER_OB_SURFACE')
            layout.menu("VIEW3D_MT_TransformMenu", icon='MANIPUL')
            layout.menu("VIEW3D_MT_MirrorMenu", icon='MOD_MIRROR')
            layout.menu("VIEW3D_MT_CursorMenu", icon='CURSOR')
            UseSeparator(self, context)
            layout.prop_menu_enum(settings, "proportional_edit",
                                  icon="PROP_CON")
            layout.prop_menu_enum(settings, "proportional_edit_falloff",
                                  icon="SMOOTHCURVE")
            layout.menu("VIEW3D_MT_EditCurveSpecials",
                        icon='SOLO_OFF')
            UseSeparator(self, context)
            layout.operator("curve.delete", text="Delete Object",
                            icon='CANCEL')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_UndoS", icon='ARROW_LEFTRIGHT')
            layout.menu("VIEW3D_MT_Object_Interactive_Other", icon='OBJECT_DATA')
            UseSeparator(self, context)
            layout.operator("view3d.toolshelf", icon='MENU_PANEL')
            layout.operator("view3d.properties", icon='MENU_PANEL')

# Metaball Object Mode #
        if obj and obj.type == 'META' and obj.mode in {'OBJECT'}:

            layout.operator_context = 'INVOKE_REGION_WIN'
            layout.operator("wm.search_menu", text="Search", icon='VIEWZOOM')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_View_Menu", icon='ZOOM_ALL')
            layout.menu("VIEW3D_MT_Select_Object", icon='RESTRICT_SELECT_OFF')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_AddMenu", icon='OBJECT_DATAMODE')
            layout.menu("VIEW3D_MT_Object", icon='VIEW3D')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_TransformMenu", icon='MANIPUL')
            layout.menu("VIEW3D_MT_MirrorMenu", icon='MOD_MIRROR')
            layout.menu("VIEW3D_MT_CursorMenu", icon='CURSOR')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_ParentMenu", icon='ROTACTIVE')
            layout.menu("VIEW3D_MT_GroupMenu", icon='GROUP')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_object_specials", text="Specials", icon='SOLO_OFF')
            layout.menu("VIEW3D_MT_Camera_Options", icon='OUTLINER_OB_CAMERA')
            UseSeparator(self, context)
            layout.operator_menu_enum("object.constraint_add",
                                      "type", text="Add Constraint", icon='CONSTRAINT')
            layout.operator("object.delete", text="Delete Object", icon='X')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_UndoS", icon='ARROW_LEFTRIGHT')
            layout.menu("VIEW3D_MT_Object_Interactive_Other", icon='OBJECT_DATA')
            UseSeparator(self, context)
            layout.operator("view3d.toolshelf", icon='MENU_PANEL')
            layout.operator("view3d.properties", icon='MENU_PANEL')

# Edit Metaball #
        if obj and obj.type == 'META' and obj.mode in {'EDIT'}:

            layout.operator("wm.search_menu", text="Search", icon='VIEWZOOM')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_View_Menu", icon='ZOOM_ALL')
            layout.menu("VIEW3D_MT_SelectMetaball", icon='RESTRICT_SELECT_OFF')
            UseSeparator(self, context)
            layout.operator_menu_enum("object.metaball_add", "type",
                                      text="Add Metaball",
                                      icon='OUTLINER_OB_META')
            layout.menu("VIEW3D_MT_TransformMenu", icon='MANIPUL')
            layout.menu("VIEW3D_MT_MirrorMenu", icon='MOD_MIRROR')
            layout.menu("VIEW3D_MT_CursorMenu", icon='CURSOR')
            UseSeparator(self, context)
            layout.prop_menu_enum(settings, "proportional_edit",
                                  icon="PROP_CON")
            layout.prop_menu_enum(settings, "proportional_edit_falloff",
                                  icon="SMOOTHCURVE")
            UseSeparator(self, context)
            layout.operator("mball.delete_metaelems", text="Delete Object",
                            icon='CANCEL')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_UndoS", icon='ARROW_LEFTRIGHT')
            layout.menu("VIEW3D_MT_Object_Interactive_Other", icon='OBJECT_DATA')
            UseSeparator(self, context)
            layout.operator("view3d.toolshelf", icon='MENU_PANEL')
            layout.operator("view3d.properties", icon='MENU_PANEL')

# Text Object Mode #
        if obj and obj.type == 'FONT' and obj.mode in {'OBJECT'}:

            layout.operator_context = 'INVOKE_REGION_WIN'
            layout.operator("wm.search_menu", text="Search", icon='VIEWZOOM')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_View_Menu", icon='ZOOM_ALL')
            layout.menu("VIEW3D_MT_Select_Object", icon='RESTRICT_SELECT_OFF')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_AddMenu", icon='OBJECT_DATAMODE')
            layout.menu("VIEW3D_MT_Object", icon='VIEW3D')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_TransformMenu", icon='MANIPUL')
            layout.menu("VIEW3D_MT_MirrorMenu", icon='MOD_MIRROR')
            layout.menu("VIEW3D_MT_CursorMenu", icon='CURSOR')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_ParentMenu", icon='ROTACTIVE')
            layout.menu("VIEW3D_MT_GroupMenu", icon='GROUP')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_object_specials", text="Specials", icon='SOLO_OFF')
            layout.menu("VIEW3D_MT_Camera_Options", icon='OUTLINER_OB_CAMERA')
            UseSeparator(self, context)
            layout.operator_menu_enum("object.modifier_add", "type", icon='MODIFIER')
            layout.operator_menu_enum("object.constraint_add",
                                      "type", text="Add Constraint", icon='CONSTRAINT')
            UseSeparator(self, context)
            layout.operator("object.delete", text="Delete Object", icon='X')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_UndoS", icon='ARROW_LEFTRIGHT')
            # New Entry For Switching to Editmode
            layout.operator("view3d.interactive_mode_text", icon='VIEW3D')
            UseSeparator(self, context)
            layout.operator("view3d.toolshelf", icon='MENU_PANEL')
            layout.operator("view3d.properties", icon='MENU_PANEL')

# Text Edit Mode #
        # To Do: Space is already reserved for the typing tool
        if obj and obj.type == 'FONT' and obj.mode in {'EDIT'}:

            layout.operator_context = 'INVOKE_REGION_WIN'
            layout.operator("wm.search_menu", text="Search", icon='VIEWZOOM')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_View_Menu", icon='ZOOM_ALL')
            layout.menu("VIEW3D_MT_select_edit_text", icon='VIEW3D')
            layout.menu("VIEW3D_MT_edit_font", icon='RESTRICT_SELECT_OFF')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_UndoS", icon='ARROW_LEFTRIGHT')
            layout.operator("object.editmode_toggle", text="Enter Object Mode",
                            icon='OBJECT_DATA')
            UseSeparator(self, context)
            layout.operator("view3d.toolshelf", icon='MENU_PANEL')
            layout.operator("view3d.properties", icon='MENU_PANEL')

# Camera Object Mode #
        if obj and obj.type == 'CAMERA' and obj.mode in {'OBJECT'}:

            layout.operator_context = 'INVOKE_REGION_WIN'
            layout.operator("wm.search_menu", text="Search", icon='VIEWZOOM')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_View_Menu", icon='ZOOM_ALL')
            layout.menu("VIEW3D_MT_Select_Object", icon='RESTRICT_SELECT_OFF')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_AddMenu", icon='OBJECT_DATAMODE')
            layout.menu("VIEW3D_MT_Object", icon='VIEW3D')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_TransformMenu", icon='MANIPUL')
            layout.menu("VIEW3D_MT_CursorMenuLite", icon='CURSOR')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_ParentMenu", icon='ROTACTIVE')
            layout.menu("VIEW3D_MT_GroupMenu", icon='GROUP')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_object_specials", text="Specials", icon='SOLO_OFF')
            layout.menu("VIEW3D_MT_Camera_Options", icon='OUTLINER_OB_CAMERA')
            UseSeparator(self, context)
            layout.operator_menu_enum("object.constraint_add",
                                      "type", text="Add Constraint", icon='CONSTRAINT')
            UseSeparator(self, context)
            layout.operator("object.delete", text="Delete Object", icon='X')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_UndoS", icon='ARROW_LEFTRIGHT')
            UseSeparator(self, context)
            layout.operator("view3d.toolshelf", icon='MENU_PANEL')
            layout.operator("view3d.properties", icon='MENU_PANEL')

# Lamp Object Mode #
        if obj and obj.type == 'LAMP' and obj.mode in {'OBJECT'}:

            layout.operator_context = 'INVOKE_REGION_WIN'
            layout.operator("wm.search_menu", text="Search", icon='VIEWZOOM')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_View_Menu", icon='ZOOM_ALL')
            layout.menu("VIEW3D_MT_Select_Object", icon='RESTRICT_SELECT_OFF')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_AddMenu", icon='OBJECT_DATAMODE')
            layout.menu("VIEW3D_MT_Object", icon='VIEW3D')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_TransformMenuLite", icon='MANIPUL')
            layout.menu("VIEW3D_MT_CursorMenuLite", icon='CURSOR')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_ParentMenu", icon='ROTACTIVE')
            layout.menu("VIEW3D_MT_GroupMenu", icon='GROUP')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_object_specials", text="Specials", icon='SOLO_OFF')
            layout.menu("VIEW3D_MT_Camera_Options", icon='OUTLINER_OB_CAMERA')
            UseSeparator(self, context)
            layout.operator_menu_enum("object.constraint_add",
                                      "type", text="Add Constraint", icon='CONSTRAINT')
            UseSeparator(self, context)
            layout.operator("object.delete", text="Delete Object", icon='X')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_UndoS", icon='ARROW_LEFTRIGHT')
            UseSeparator(self, context)
            layout.operator("view3d.toolshelf", icon='MENU_PANEL')
            layout.operator("view3d.properties", icon='MENU_PANEL')

# Armature Object Mode #
        if obj and obj.type == 'ARMATURE' and obj.mode in {'OBJECT'}:

            layout.operator_context = 'INVOKE_REGION_WIN'
            layout.operator("wm.search_menu", text="Search", icon='VIEWZOOM')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_View_Menu", icon='ZOOM_ALL')
            layout.menu("VIEW3D_MT_Select_Object", icon='RESTRICT_SELECT_OFF')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_AddMenu", icon='OBJECT_DATAMODE')
            layout.menu("VIEW3D_MT_Object", icon='VIEW3D')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_TransformMenuArmature", icon='MANIPUL')
            layout.menu("VIEW3D_MT_MirrorMenu", icon='MOD_MIRROR')
            layout.menu("VIEW3D_MT_CursorMenuLite", icon='CURSOR')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_ParentMenu", icon='ROTACTIVE')
            layout.menu("VIEW3D_MT_GroupMenu", icon='GROUP')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_object_specials", text="Specials", icon='SOLO_OFF')
            layout.menu("VIEW3D_MT_Camera_Options", icon='OUTLINER_OB_CAMERA')
            UseSeparator(self, context)
            layout.operator_menu_enum("object.constraint_add",
                                      "type", text="Add Constraint", icon='CONSTRAINT')
            UseSeparator(self, context)
            layout.operator("object.delete", text="Delete Object", icon='X')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_UndoS", icon='ARROW_LEFTRIGHT')
            layout.menu("VIEW3D_MT_Object_Interactive_Armature", icon='VIEW3D')
            UseSeparator(self, context)
            layout.operator("view3d.toolshelf", icon='MENU_PANEL')
            layout.operator("view3d.properties", icon='MENU_PANEL')

# Armature Edit #
        if obj and obj.type == 'ARMATURE' and obj.mode in {'EDIT'}:

            layout.operator("wm.search_menu", text="Search", icon='VIEWZOOM')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_View_Menu", icon='ZOOM_ALL')
            layout.menu("VIEW3D_MT_Select_Edit_Armature",
                        icon='RESTRICT_SELECT_OFF')
            UseSeparator(self, context)
            layout.menu("INFO_MT_armature_add", text="Add Armature",
                        icon='OUTLINER_OB_ARMATURE')
            layout.menu("VIEW3D_MT_Edit_Armature", text="Armature",
                        icon='OUTLINER_DATA_ARMATURE')
            layout.menu("VIEW3D_MT_EditArmatureTK",
                        icon='ARMATURE_DATA')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_TransformMenuArmatureEdit", icon='MANIPUL')
            layout.menu("VIEW3D_MT_MirrorMenu", icon='MOD_MIRROR')
            layout.menu("VIEW3D_MT_CursorMenuLite", icon='CURSOR')
            layout.menu("VIEW3D_MT_ParentMenu", icon='ROTACTIVE')
            layout.menu("VIEW3D_MT_armature_specials", icon='SOLO_OFF')
            layout.menu("VIEW3D_MT_edit_armature_roll",
                        icon='BONE_DATA')
            UseSeparator(self, context)
            layout.operator("armature.delete", text="Delete Object",
                            icon='X')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_UndoS", icon='ARROW_LEFTRIGHT')
            layout.menu("VIEW3D_MT_Object_Interactive_Armature", icon='VIEW3D')
            UseSeparator(self, context)
            layout.operator("view3d.toolshelf", icon='MENU_PANEL')
            layout.operator("view3d.properties", icon='MENU_PANEL')

# Armature Pose #
        if obj and obj.type == 'ARMATURE' and obj.mode in {'POSE'}:

            arm = context.active_object.data

            layout.operator("wm.search_menu", text="Search", icon='VIEWZOOM')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_View_Menu", icon='ZOOM_ALL')
            layout.menu("VIEW3D_MT_Select_Pose", icon='RESTRICT_SELECT_OFF')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_Pose", icon='OUTLINER_DATA_POSE')
            layout.menu("VIEW3D_MT_TransformMenuArmaturePose", icon='MANIPUL')
            layout.menu("VIEW3D_MT_pose_transform", icon='EMPTY_DATA')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_CursorMenuLite", icon='CURSOR')
            layout.menu("VIEW3D_MT_PoseCopy", icon='FILE')

            if arm.draw_type in {'BBONE', 'ENVELOPE'}:
                layout.operator("transform.transform",
                                text="Scale Envelope Distance").mode = 'BONE_SIZE'

            layout.menu("VIEW3D_MT_pose_apply", icon='AUTO')
            layout.operator("pose.relax", icon='ARMATURE_DATA')
            layout.menu("VIEW3D_MT_KeyframeMenu", icon='KEY_HLT')
            layout.menu("VIEW3D_MT_pose_specials", icon='SOLO_OFF')
            layout.menu("VIEW3D_MT_pose_group", icon='GROUP_BONE')
            UseSeparator(self, context)
            layout.operator_menu_enum("pose.constraint_add",
                                      "type", text="Add Constraint", icon='CONSTRAINT_BONE')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_UndoS", icon='ARROW_LEFTRIGHT')
            layout.menu("VIEW3D_MT_Object_Interactive_Armature", icon='VIEW3D')
            UseSeparator(self, context)
            layout.operator("view3d.toolshelf", icon='MENU_PANEL')
            layout.operator("view3d.properties", icon='MENU_PANEL')

# Lattice Object Mode #
        if obj and obj.type == 'LATTICE' and obj.mode in {'OBJECT'}:

            layout.operator_context = 'INVOKE_REGION_WIN'
            layout.operator("wm.search_menu", text="Search", icon='VIEWZOOM')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_View_Menu", icon='ZOOM_ALL')
            layout.menu("VIEW3D_MT_Select_Object", icon='RESTRICT_SELECT_OFF')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_AddMenu", icon='OBJECT_DATAMODE')
            layout.menu("VIEW3D_MT_Object", icon='VIEW3D')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_TransformMenu", icon='MANIPUL')
            layout.menu("VIEW3D_MT_MirrorMenu", icon='MOD_MIRROR')
            layout.menu("VIEW3D_MT_CursorMenu", icon='CURSOR')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_ParentMenu", icon='ROTACTIVE')
            layout.menu("VIEW3D_MT_GroupMenu", icon='GROUP')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_object_specials", text="Specials", icon='SOLO_OFF')
            layout.menu("VIEW3D_MT_Camera_Options", icon='OUTLINER_OB_CAMERA')
            UseSeparator(self, context)
            layout.operator_menu_enum("object.modifier_add", "type", icon='MODIFIER')
            layout.operator_menu_enum("object.constraint_add",
                                      "type", text="Add Constraint", icon='CONSTRAINT')
            UseSeparator(self, context)
            layout.operator("object.delete", text="Delete Object", icon='X')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_UndoS", icon='ARROW_LEFTRIGHT')
            layout.menu("VIEW3D_MT_Object_Interactive_Other", icon='OBJECT_DATA')
            UseSeparator(self, context)
            layout.operator("view3d.toolshelf", icon='MENU_PANEL')
            layout.operator("view3d.properties", icon='MENU_PANEL')

# Edit Lattice #
        if obj and obj.type == 'LATTICE' and obj.mode in {'EDIT'}:

            layout.operator("wm.search_menu", text="Search", icon='VIEWZOOM')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_View_Menu", icon='ZOOM_ALL')
            layout.menu("VIEW3D_MT_Select_Edit_Lattice",
                        icon='RESTRICT_SELECT_OFF')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_TransformMenu", icon='MANIPUL')
            layout.menu("VIEW3D_MT_MirrorMenu", icon='MOD_MIRROR')
            layout.menu("VIEW3D_MT_CursorMenu", icon='CURSOR')
            UseSeparator(self, context)
            layout.prop_menu_enum(settings, "proportional_edit",
                                  icon="PROP_CON")
            layout.prop_menu_enum(settings, "proportional_edit_falloff",
                                  icon="SMOOTHCURVE")
            UseSeparator(self, context)
            layout.operator("lattice.make_regular")
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_UndoS", icon='ARROW_LEFTRIGHT')
            layout.menu("VIEW3D_MT_Object_Interactive_Other", icon='OBJECT_DATA')
            UseSeparator(self, context)
            layout.operator("view3d.toolshelf", icon='MENU_PANEL')
            layout.operator("view3d.properties", icon='MENU_PANEL')

# Empty Object Mode #
        if obj and obj.type == 'EMPTY' and obj.mode in {'OBJECT'}:

            layout.operator_context = 'INVOKE_REGION_WIN'
            layout.operator("wm.search_menu", text="Search", icon='VIEWZOOM')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_View_Menu", icon='ZOOM_ALL')
            layout.menu("VIEW3D_MT_Select_Object", icon='RESTRICT_SELECT_OFF')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_AddMenu", icon='OBJECT_DATAMODE')
            layout.menu("VIEW3D_MT_Object", icon='VIEW3D')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_TransformMenuLite", icon='MANIPUL')
            layout.menu("VIEW3D_MT_MirrorMenu", icon='MOD_MIRROR')
            layout.menu("VIEW3D_MT_CursorMenuLite", icon='CURSOR')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_ParentMenu", icon='ROTACTIVE')
            layout.menu("VIEW3D_MT_GroupMenu", icon='GROUP')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_object_specials", text="Specials", icon='SOLO_OFF')
            layout.menu("VIEW3D_MT_Camera_Options", icon='OUTLINER_OB_CAMERA')
            UseSeparator(self, context)
            layout.operator_menu_enum("object.constraint_add",
                                      "type", text="Add Constraint", icon='CONSTRAINT')
            UseSeparator(self, context)
            layout.operator("object.delete", text="Delete Object", icon='X')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_UndoS", icon='ARROW_LEFTRIGHT')
            UseSeparator(self, context)
            layout.operator("view3d.toolshelf", icon='MENU_PANEL')
            layout.operator("view3d.properties", icon='MENU_PANEL')

# Speaker Object Mode #
        if obj and obj.type == 'SPEAKER' and obj.mode in {'OBJECT'}:

            layout.operator_context = 'INVOKE_REGION_WIN'
            layout.operator("wm.search_menu", text="Search", icon='VIEWZOOM')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_View_Menu", icon='ZOOM_ALL')
            layout.menu("VIEW3D_MT_Select_Object", icon='RESTRICT_SELECT_OFF')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_AddMenu", icon='OBJECT_DATAMODE')
            layout.menu("VIEW3D_MT_Object", icon='VIEW3D')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_TransformMenuLite", icon='MANIPUL')
            layout.menu("VIEW3D_MT_CursorMenuLite", icon='CURSOR')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_ParentMenu", icon='ROTACTIVE')
            layout.menu("VIEW3D_MT_GroupMenu", icon='GROUP')
            UseSeparator(self, context)
            layout.operator_menu_enum("object.constraint_add",
                                      "type", text="Add Constraint", icon='CONSTRAINT')
            UseSeparator(self, context)
            layout.operator("object.delete", text="Delete Object", icon='X')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_UndoS", icon='ARROW_LEFTRIGHT')
            UseSeparator(self, context)
            layout.operator("view3d.toolshelf", icon='MENU_PANEL')
            layout.operator("view3d.properties", icon='MENU_PANEL')

# Particle Menu #
        if obj and context.mode == 'PARTICLE':

            layout.operator("wm.search_menu", text="Search", icon='VIEWZOOM')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_View_Menu", icon='ZOOM_ALL')
            layout.menu("VIEW3D_MT_Select_Particle",
                        icon='RESTRICT_SELECT_OFF')
            layout.menu("VIEW3D_MT_Selection_Mode_Particle",
                        text="Select and Display Mode", icon='PARTICLE_PATH')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_TransformMenu", icon='MANIPUL')
            layout.menu("VIEW3D_MT_MirrorMenu", icon='MOD_MIRROR')
            layout.menu("VIEW3D_MT_CursorMenuLite", icon='CURSOR')
            UseSeparator(self, context)
            layout.prop_menu_enum(settings, "proportional_edit",
                                  icon="PROP_CON")
            layout.prop_menu_enum(settings, "proportional_edit_falloff",
                                  icon="SMOOTHCURVE")
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_particle", icon='PARTICLEMODE')
            layout.menu("VIEW3D_MT_particle_specials", text="Hair Specials", icon='HAIR')
            UseSeparator(self, context)
            layout.operator("object.delete", text="Delete Object", icon='X')
            UseSeparator(self, context)
            layout.menu("VIEW3D_MT_UndoS", icon='ARROW_LEFTRIGHT')
            layout.menu("VIEW3D_MT_Object_Interactive_Mode", icon='VIEW3D')
            UseSeparator(self, context)
            layout.operator("view3d.toolshelf", icon='MENU_PANEL')
            layout.operator("view3d.properties", icon='MENU_PANEL')


# Object Menus #

# ********** Object Menu **********
class VIEW3D_MT_Object(Menu):
    bl_context = "objectmode"
    bl_label = "Object"

    def draw(self, context):
        layout = self.layout
        view = context.space_data
        is_local_view = (view.local_view is not None)

        layout.operator("object.delete", text="Delete...").use_global = False
        UseSeparator(self, context)
        layout.menu("VIEW3D_MT_object_parent")
        layout.menu("VIEW3D_MT_Duplicate")
        layout.operator("object.join")

        if is_local_view:
            layout.operator_context = 'EXEC_REGION_WIN'
            layout.operator("object.move_to_layer", text="Move out of Local View")
            layout.operator_context = 'INVOKE_REGION_WIN'
        else:
            layout.operator("object.move_to_layer", text="Move to Layer...")

        layout.menu("VIEW3D_MT_make_links", text="Make Links...")
        layout.menu("VIEW3D_MT_Object_Data_Link")
        UseSeparator(self, context)
        layout.menu("VIEW3D_MT_AutoSmooth", icon='ALIASED')
        UseSeparator(self, context)
        layout.menu("VIEW3D_MT_object_constraints")
        layout.menu("VIEW3D_MT_object_track")
        layout.menu("VIEW3D_MT_object_animation")
        UseSeparator(self, context)
        layout.menu("VIEW3D_MT_object_game")
        layout.menu("VIEW3D_MT_object_showhide")
        UseSeparator(self, context)
        layout.operator_menu_enum("object.convert", "target")


# ********** Object Add **********
class VIEW3D_MT_AddMenu(Menu):
    bl_label = "Add Object"

    def draw(self, context):
        layout = self.layout
        layout.operator_context = 'INVOKE_REGION_WIN'

        layout.menu("INFO_MT_mesh_add", text="Add Mesh",
                    icon='OUTLINER_OB_MESH')
        layout.menu("INFO_MT_curve_add", text="Add Curve",
                    icon='OUTLINER_OB_CURVE')
        layout.menu("INFO_MT_surface_add", text="Add Surface",
                    icon='OUTLINER_OB_SURFACE')
        layout.operator_menu_enum("object.metaball_add", "type",
                                  icon='OUTLINER_OB_META')
        layout.operator("object.text_add", text="Add Text",
                        icon='OUTLINER_OB_FONT')
        UseSeparator(self, context)
        layout.menu("INFO_MT_armature_add", text="Add Armature",
                    icon='OUTLINER_OB_ARMATURE')
        layout.operator("object.add", text="Lattice",
                        icon='OUTLINER_OB_LATTICE').type = 'LATTICE'
        layout.operator_menu_enum("object.empty_add", "type", text="Empty", icon='OUTLINER_OB_EMPTY')
        UseSeparator(self, context)
        layout.operator("object.speaker_add", text="Speaker", icon='OUTLINER_OB_SPEAKER')
        UseSeparator(self, context)
        layout.operator("object.camera_add", text="Camera",
                        icon='OUTLINER_OB_CAMERA')
        layout.operator_menu_enum("object.lamp_add", "type",
                                  icon="OUTLINER_OB_LAMP")
        UseSeparator(self, context)
        layout.operator_menu_enum("object.effector_add", "type",
                                  text="Force Field",
                                  icon='FORCE_FORCE')
        layout.menu("VIEW3D_MT_object_quick_effects", text="Quick Effects", icon='PARTICLES')
        UseSeparator(self, context)

        has_groups = (len(bpy.data.groups) > 0)
        col_group = layout.column()
        col_group.enabled = has_groups

        if not has_groups or len(bpy.data.groups) > 10:
            col_group.operator_context = 'INVOKE_REGION_WIN'
            col_group.operator("object.group_instance_add",
                                text="Group Instance..." if has_groups else "No Groups in Data",
                                icon='GROUP_VERTEX')
        else:
            col_group.operator_menu_enum("object.group_instance_add", "group",
                                text="Group Instance", icon='GROUP_VERTEX')


# ********** Object Manipulator **********
class VIEW3D_MT_ManipulatorMenu1(Menu):
    bl_label = "Manipulator"

    def draw(self, context):
        layout = self.layout
        layout.operator_context = 'INVOKE_REGION_WIN'
        props = layout.operator("view3d.enable_manipulator", text='Translate', icon='MAN_TRANS')
        props.translate = True
        props = layout.operator("view3d.enable_manipulator", text='Rotate', icon='MAN_ROT')
        props.rotate = True
        props = layout.operator("view3d.enable_manipulator", text='Scale', icon='MAN_SCALE')
        props.scale = True
        UseSeparator(self, context)
        props = layout.operator("view3d.enable_manipulator", text='Combo', icon='MAN_SCALE')
        props.scale = True
        props.rotate = True
        props.translate = True
        props = layout.operator("view3d.enable_manipulator", text='Hide', icon='MAN_SCALE')
        props.scale = False
        props.rotate = False
        props.translate = False


# ********** Object Mirror **********
class VIEW3D_MT_MirrorMenu(Menu):
    bl_label = "Mirror"

    def draw(self, context):
        layout = self.layout
        layout.operator("transform.mirror", text="Interactive Mirror")
        UseSeparator(self, context)
        layout.operator_context = 'INVOKE_REGION_WIN'
        props = layout.operator("transform.mirror", text="X Global")
        props.constraint_axis = (True, False, False)
        props.constraint_orientation = 'GLOBAL'
        props = layout.operator("transform.mirror", text="Y Global")
        props.constraint_axis = (False, True, False)
        props.constraint_orientation = 'GLOBAL'
        props = layout.operator("transform.mirror", text="Z Global")
        props.constraint_axis = (False, False, True)
        props.constraint_orientation = 'GLOBAL'

        if context.edit_object:

            UseSeparator(self, context)
            props = layout.operator("transform.mirror", text="X Local")
            props.constraint_axis = (True, False, False)
            props.constraint_orientation = 'LOCAL'
            props = layout.operator("transform.mirror", text="Y Local")
            props.constraint_axis = (False, True, False)
            props.constraint_orientation = 'LOCAL'
            props = layout.operator("transform.mirror", text="Z Local")
            props.constraint_axis = (False, False, True)
            props.constraint_orientation = 'LOCAL'
            UseSeparator(self, context)
            layout.operator("object.vertex_group_mirror")


# ********** Object Snap Cursor **********
class VIEW3D_MT_Pivot(Menu):
    bl_label = "Pivot"

    def draw(self, context):
        layout = self.layout
        layout.prop(context.space_data, "pivot_point", expand=True)
        if context.active_object.mode == 'OBJECT':
            UseSeparator(self, context)
            layout.prop(context.space_data, "use_pivot_point_align", text="Center Points")


class VIEW3D_Snap_Context(Menu):
    bl_label = "Snapping"

    def draw(self, context):
        layout = self.layout
        toolsettings = context.tool_settings
        layout.prop(toolsettings, "snap_element", expand=True)
        layout.prop(toolsettings, "use_snap")


class VIEW3D_Snap_Origin(Menu):
    bl_label = "Snap  "

    def draw(self, context):
        layout = self.layout
        layout.operator_context = 'EXEC_AREA'
        layout.operator("object.origin_set",
                        text="Geometry to Origin").type = 'GEOMETRY_ORIGIN'
        UseSeparator(self, context)
        layout.operator("object.origin_set",
                        text="Origin to Geometry").type = 'ORIGIN_GEOMETRY'
        layout.operator("object.origin_set",
                        text="Origin to 3D Cursor").type = 'ORIGIN_CURSOR'
        layout.operator("object.origin_set",
                        text="Origin to Center of Mass").type = 'ORIGIN_CENTER_OF_MASS'


class VIEW3D_MT_CursorMenu(Menu):
    bl_label = "Snap Cursor"

    def draw(self, context):
        layout = self.layout
        layout.operator_context = 'INVOKE_REGION_WIN'
        layout.menu("VIEW3D_Snap_Origin")
        layout.menu("VIEW3D_Snap_Context")
        UseSeparator(self, context)
        layout.operator("view3d.snap_cursor_to_selected",
                        text="Cursor to Selected")
        layout.operator("view3d.snap_cursor_to_center",
                        text="Cursor to Center")
        layout.operator("view3d.snap_cursor_to_grid",
                        text="Cursor to Grid")
        layout.operator("view3d.snap_cursor_to_active",
                        text="Cursor to Active")
        UseSeparator(self, context)
        layout.operator("view3d.snap_selected_to_cursor", text="Selection to Cursor").use_offset = False
        layout.operator("view3d.snap_selected_to_cursor", text="Selection to Cursor (Offset)").use_offset = True
        layout.operator("view3d.snap_selected_to_grid",
                        text="Selection to Grid")
        layout.operator("view3d.snap_cursor_selected_to_center",
                        text="Selection and Cursor to Center")
        UseSeparator(self, context)
        layout.menu("VIEW3D_MT_Pivot")
        layout.operator("view3d.pivot_cursor",
                        text="Set Cursor as Pivot Point")
        layout.operator("view3d.revert_pivot",
                        text="Revert Pivot Point")


class VIEW3D_MT_CursorMenuLite(Menu):
    bl_label = "Snap Cursor"

    def draw(self, context):
        layout = self.layout
        layout.operator_context = 'INVOKE_REGION_WIN'
        layout.menu("VIEW3D_Snap_Origin")
        UseSeparator(self, context)
        layout.operator("view3d.snap_cursor_to_selected",
                        text="Cursor to Selected")
        layout.operator("view3d.snap_cursor_to_center",
                        text="Cursor to Center")
        layout.operator("view3d.snap_cursor_to_grid",
                        text="Cursor to Grid")
        layout.operator("view3d.snap_cursor_to_active",
                        text="Cursor to Active")
        UseSeparator(self, context)
        layout.operator("view3d.snap_selected_to_cursor", text="Selection to Cursor").use_offset = False
        layout.operator("view3d.snap_selected_to_cursor", text="Selection to Cursor (Offset)").use_offset = True
        layout.operator("view3d.snap_selected_to_grid",
                        text="Selection to Grid")
        layout.operator("view3d.snap_cursor_selected_to_center",
                        text="Selection and Cursor to Center")
        UseSeparator(self, context)
        layout.menu("VIEW3D_MT_Pivot")
        layout.operator("view3d.pivot_cursor",
                        text="Set Cursor as Pivot Point")
        layout.operator("view3d.revert_pivot",
                        text="Revert Pivot Point")


# ********** Object Interactive Mode **********
class InteractiveMode(Menu):
    bl_idname = "VIEW3D_MT_Object_Interactive_Mode"
    bl_label = "Interactive Mode"
    bl_description = "Menu of objects' interactive modes (Window Types)"

    def draw(self, context):
        layout = self.layout
        obj = context.active_object
        psys = hasattr(obj, "particle_systems")
        psys_items = len(obj.particle_systems.items()) > 0 if psys else False

        layout.operator(SetObjectMode.bl_idname, text="Object", icon="OBJECT_DATAMODE").mode = "OBJECT"
        layout.operator(SetObjectMode.bl_idname, text="Edit", icon="EDITMODE_HLT").mode = "EDIT"
        layout.operator(SetObjectMode.bl_idname, text="Sculpt", icon="SCULPTMODE_HLT").mode = "SCULPT"
        layout.operator(SetObjectMode.bl_idname, text="Vertex Paint", icon="VPAINT_HLT").mode = "VERTEX_PAINT"
        layout.operator(SetObjectMode.bl_idname, text="Weight Paint", icon="WPAINT_HLT").mode = "WEIGHT_PAINT"
        layout.operator(SetObjectMode.bl_idname, text="Texture Paint", icon="TPAINT_HLT").mode = "TEXTURE_PAINT"
        if obj and psys_items:
            layout.operator(SetObjectMode.bl_idname, text="Particle Edit",
                            icon="PARTICLEMODE").mode = "PARTICLE_EDIT"
        if context.gpencil_data:
            layout.operator("view3d.interactive_mode_grease_pencil", icon="GREASEPENCIL")


# ********** Object Armature Interactive Mode **********
class InteractiveModeArmature(Menu):
    bl_idname = "VIEW3D_MT_Object_Interactive_Armature"
    bl_label = "Interactive Mode"
    bl_description = "Menu of objects interactive mode"

    def draw(self, context):
        layout = self.layout

        layout.operator(SetObjectMode.bl_idname, text="Object", icon="OBJECT_DATAMODE").mode = "OBJECT"
        layout.operator(SetObjectMode.bl_idname, text="Edit", icon="EDITMODE_HLT").mode = "EDIT"
        layout.operator(SetObjectMode.bl_idname, text="Pose", icon="POSE_HLT").mode = "POSE"
        if context.gpencil_data:
            layout.operator("view3d.interactive_mode_grease_pencil", icon="GREASEPENCIL")


# ********** Interactive Mode Other **********
class InteractiveModeOther(Menu):
    bl_idname = "VIEW3D_MT_Object_Interactive_Other"
    bl_label = "Interactive Mode"
    bl_description = "Menu of objects interactive mode"

    def draw(self, context):
        layout = self.layout
        layout.operator("object.editmode_toggle", text="Edit/Object Toggle",
                        icon='OBJECT_DATA')
        if context.gpencil_data:
            layout.operator("view3d.interactive_mode_grease_pencil", icon="GREASEPENCIL")


# ********** Grease Pencil Interactive Mode **********
class VIEW3D_OT_Interactive_Mode_Grease_Pencil(Operator):
    bl_idname = "view3d.interactive_mode_grease_pencil"
    bl_label = "Edit Strokes"
    bl_description = "Toggle Edit Strokes for Grease Pencil"

    @classmethod
    def poll(cls, context):
        return (context.gpencil_data is not None)

    def execute(self, context):
        try:
            bpy.ops.gpencil.editmode_toggle()
        except:
            self.report({'WARNING'}, "It is not possible to enter into the interactive mode")
        return {'FINISHED'}


class VIEW3D_MT_Edit_Gpencil(Menu):
    bl_label = "GPencil"

    def draw(self, context):
        toolsettings = context.tool_settings
        layout = self.layout

        layout.operator("gpencil.brush_paint", text="Sculpt Strokes").wait_for_input = True
        layout.prop_menu_enum(toolsettings.gpencil_sculpt, "tool", text="Sculpt Brush")
        UseSeparator(self, context)

        layout.menu("VIEW3D_MT_edit_gpencil_transform")
        layout.operator("transform.mirror", text="Mirror")
        layout.menu("GPENCIL_MT_snap")
        UseSeparator(self, context)

        layout.menu("VIEW3D_MT_object_animation")   # NOTE: provides keyingset access...
        UseSeparator(self, context)

        layout.menu("VIEW3D_MT_edit_gpencil_delete")
        layout.operator("gpencil.duplicate_move", text="Duplicate")
        UseSeparator(self, context)

        layout.menu("VIEW3D_MT_select_gpencil")
        UseSeparator(self, context)

        layout.operator("gpencil.copy", text="Copy")
        layout.operator("gpencil.paste", text="Paste")
        UseSeparator(self, context)

        layout.prop_menu_enum(toolsettings, "proportional_edit")
        layout.prop_menu_enum(toolsettings, "proportional_edit_falloff")
        UseSeparator(self, context)

        layout.operator("gpencil.reveal")
        layout.operator("gpencil.hide", text="Show Active Layer Only").unselected = True
        layout.operator("gpencil.hide", text="Hide Active Layer").unselected = False
        UseSeparator(self, context)

        layout.operator_menu_enum("gpencil.move_to_layer", "layer", text="Move to Layer")
        layout.operator_menu_enum("gpencil.convert", "type", text="Convert to Geometry...")


# ********** Text Interactive Mode **********
class VIEW3D_OT_Interactive_Mode_Text(Operator):
    bl_idname = "view3d.interactive_mode_text"
    bl_label = "Enter Edit Mode"
    bl_description = "Toggle object's editmode"

    @classmethod
    def poll(cls, context):
        return (context.active_object is not None)

    def execute(self, context):
        bpy.ops.object.editmode_toggle()
        self.report({'INFO'}, "Spacebar shortcut won't work in the Text Edit mode")
        return {'FINISHED'}


# ********** Object Parent **********
class VIEW3D_MT_ParentMenu(Menu):
    bl_label = "Parent"

    def draw(self, context):
        layout = self.layout

        layout.operator("object.parent_set", text="Set")
        layout.operator("object.parent_clear", text="Clear")


# ********** Object Group **********
class VIEW3D_MT_GroupMenu(Menu):
    bl_label = "Group"

    def draw(self, context):
        layout = self.layout
        layout.operator("group.create")
        layout.operator("group.objects_add_active")
        UseSeparator(self, context)
        layout.operator("group.objects_remove")
        layout.operator("group.objects_remove_all")
        layout.operator("group.objects_remove_active")


# ********** Object Camera Options **********
class VIEW3D_MT_Camera_Options(Menu):
    bl_label = "Camera"

    def draw(self, context):
        layout = self.layout
        layout.operator_context = 'EXEC_REGION_WIN'
        layout.operator("object.camera_add", text="Add Camera", icon='OUTLINER_OB_CAMERA')
        self.layout.operator("view3d.object_as_camera", text="Object As Camera", icon='OUTLINER_OB_CAMERA')
        self.layout.operator("view3d.viewnumpad", text="View Active Camera",
                              icon='OUTLINER_OB_CAMERA').type = 'CAMERA'


class VIEW3D_MT_Object_Data_Link(Menu):
    bl_label = "Object Data"

    def draw(self, context):
        layout = self.layout

        layout.operator_menu_enum("object.make_local", "type", text="Make Local...")
        layout.menu("VIEW3D_MT_make_single_user")
        layout.operator("object.proxy_make", text="Make Proxy...")
        layout.operator("object.make_dupli_face")
        UseSeparator(self, context)
        layout.operator("object.data_transfer")
        layout.operator("object.datalayout_transfer")


class VIEW3D_MT_Duplicate(Menu):
    bl_label = "Duplicate"

    def draw(self, context):
        layout = self.layout

        layout.operator("object.duplicate_move")
        layout.operator("object.duplicate_move_linked")


class VIEW3D_MT_KeyframeMenu(Menu):
    bl_label = "Keyframe"

    def draw(self, context):
        layout = self.layout
        layout.operator("anim.keyframe_insert_menu",
                        text="Insert Keyframe...")
        layout.operator("anim.keyframe_delete_v3d",
                        text="Delete Keyframe...")
        layout.operator("anim.keying_set_active_set",
                        text="Change Keying Set...")


class VIEW3D_MT_UndoS(Menu):
    bl_label = "Undo/Redo"

    def draw(self, context):
        layout = self.layout

        layout.operator("ed.undo")
        layout.operator("ed.redo")
        UseSeparator(self, context)
        layout.operator("ed.undo_history")


# ********** Normals / Auto Smooth Menu **********
# Thanks to marvin.k.breuer for the Autosmooth part of the menu
class VIEW3D_MT_AutoSmooth(Menu):
    bl_label = "Normals / Auto Smooth"

    def draw(self, context):
        layout = self.layout
        obj = context.object
        obj_data = context.active_object.data

        # moved the VIEW3D_MT_edit_mesh_normals contents here under an Edit mode check
        if obj and obj.type == 'MESH' and obj.mode in {'EDIT'}:
            layout.operator("mesh.normals_make_consistent",
                            text="Recalculate Outside").inside = False
            layout.operator("mesh.normals_make_consistent",
                            text="Recalculate Inside").inside = True
            layout.operator("mesh.flip_normals")
            UseSeparator(self, context)

        layout.prop(obj_data, "show_double_sided", text="Normals: Double Sided")
        UseSeparator(self, context)
        layout.prop(obj_data, "use_auto_smooth", text="Normals: Auto Smooth")

        # Auto Smooth Angle - two tab spaces to align it with the rest of the menu
        layout.prop(obj_data, "auto_smooth_angle",
                    text="       Auto Smooth Angle")


# Edit Mode Menu's #

# ********** Edit Mesh **********
class VIEW3D_MT_Edit_Mesh(Menu):
    bl_label = "Mesh"

    def draw(self, context):
        layout = self.layout
        toolsettings = context.tool_settings
        view = context.space_data

        layout.menu("VIEW3D_MT_edit_mesh_vertices", icon='VERTEXSEL')
        layout.menu("VIEW3D_MT_edit_mesh_edges", icon='EDGESEL')
        layout.menu("VIEW3D_MT_edit_mesh_faces", icon='FACESEL')
        UseSeparator(self, context)
        layout.operator("mesh.duplicate_move")
        UseSeparator(self, context)
        layout.menu("VIEW3D_MT_edit_mesh_clean", icon='AUTO')
        layout.prop(view, "use_occlude_geometry")
        UseSeparator(self, context)
        layout.menu("VIEW3D_MT_AutoSmooth", icon='META_DATA')
        layout.operator("mesh.loopcut_slide",
                        text="Loopcut", icon='UV_EDGESEL')
        UseSeparator(self, context)
        layout.operator("mesh.symmetrize")
        layout.operator("mesh.symmetry_snap")
        UseSeparator(self, context)
        layout.operator("mesh.bisect")
        layout.operator_menu_enum("mesh.sort_elements", "type", text="Sort Elements...")
        UseSeparator(self, context)
        layout.prop_menu_enum(toolsettings, "proportional_edit")
        layout.prop_menu_enum(toolsettings, "proportional_edit_falloff")
        UseSeparator(self, context)

        layout.prop(toolsettings, "use_mesh_automerge")
        # Double Threshold - two tab spaces to align it with the rest of the menu
        layout.prop(toolsettings, "double_threshold", text="       Double Threshold")

        UseSeparator(self, context)
        layout.menu("VIEW3D_MT_edit_mesh_showhide")


# ********** Edit Multiselect **********
class VIEW3D_MT_Edit_Multi(Menu):
    bl_label = "Multi Select"

    def draw(self, context):
        layout = self.layout
        layout.operator_context = 'INVOKE_REGION_WIN'

        prop = layout.operator("wm.context_set_value", text="Vertex Select",
                               icon='VERTEXSEL')
        prop.value = "(True, False, False)"
        prop.data_path = "tool_settings.mesh_select_mode"

        prop = layout.operator("wm.context_set_value", text="Edge Select",
                               icon='EDGESEL')
        prop.value = "(False, True, False)"
        prop.data_path = "tool_settings.mesh_select_mode"

        prop = layout.operator("wm.context_set_value", text="Face Select",
                               icon='FACESEL')
        prop.value = "(False, False, True)"
        prop.data_path = "tool_settings.mesh_select_mode"
        UseSeparator(self, context)

        prop = layout.operator("wm.context_set_value",
                               text="Vertex & Edge Select",
                               icon='EDITMODE_HLT')
        prop.value = "(True, True, False)"
        prop.data_path = "tool_settings.mesh_select_mode"

        prop = layout.operator("wm.context_set_value",
                               text="Vertex & Face Select",
                               icon='ORTHO')
        prop.value = "(True, False, True)"
        prop.data_path = "tool_settings.mesh_select_mode"

        prop = layout.operator("wm.context_set_value",
                               text="Edge & Face Select",
                               icon='SNAP_FACE')
        prop.value = "(False, True, True)"
        prop.data_path = "tool_settings.mesh_select_mode"
        UseSeparator(self, context)

        prop = layout.operator("wm.context_set_value",
                               text="Vertex & Edge & Face Select",
                               icon='SNAP_VOLUME')
        prop.value = "(True, True, True)"
        prop.data_path = "tool_settings.mesh_select_mode"


# ********** Edit Mesh Edge **********
class VIEW3D_MT_EditM_Edge(Menu):
    bl_label = "Edges"

    def draw(self, context):
        layout = self.layout
        layout.operator_context = 'INVOKE_REGION_WIN'

        layout.operator("mesh.mark_seam")
        layout.operator("mesh.mark_seam", text="Clear Seam").clear = True
        UseSeparator(self, context)

        layout.operator("mesh.mark_sharp")
        layout.operator("mesh.mark_sharp", text="Clear Sharp").clear = True
        layout.operator("mesh.extrude_move_along_normals", text="Extrude")
        UseSeparator(self, context)

        layout.operator("mesh.edge_rotate",
                        text="Rotate Edge CW").direction = 'CW'
        layout.operator("mesh.edge_rotate",
                        text="Rotate Edge CCW").direction = 'CCW'
        UseSeparator(self, context)

        layout.operator("TFM_OT_edge_slide", text="Edge Slide")
        layout.operator("mesh.loop_multi_select", text="Edge Loop")
        layout.operator("mesh.loop_multi_select", text="Edge Ring").ring = True
        layout.operator("mesh.loop_to_region")
        layout.operator("mesh.region_to_loop")


# ********** Edit Mesh Cursor **********
class VIEW3D_MT_EditCursorMenu(Menu):
    bl_label = "Snap Cursor"

    def draw(self, context):
        layout = self.layout
        layout.operator_context = 'INVOKE_REGION_WIN'
        layout.operator("object.setorigintoselected",
                        text="Origin to Selected V/F/E")
        UseSeparator(self, context)
        layout.menu("VIEW3D_Snap_Origin")
        layout.menu("VIEW3D_Snap_Context")
        UseSeparator(self, context)
        layout.operator("view3d.snap_cursor_to_selected",
                        text="Cursor to Selected")
        layout.operator("view3d.snap_cursor_to_center",
                        text="Cursor to Center")
        layout.operator("view3d.snap_cursor_to_grid",
                        text="Cursor to Grid")
        layout.operator("view3d.snap_cursor_to_active",
                        text="Cursor to Active")
        layout.operator("view3d.snap_cursor_to_edge_intersection",
                        text="Cursor to Edge Intersection")
        UseSeparator(self, context)
        layout.operator("view3d.snap_selected_to_cursor", text="Selection to Cursor").use_offset = False
        layout.operator("view3d.snap_selected_to_cursor", text="Selection to Cursor (Offset)").use_offset = True
        layout.operator("view3d.snap_selected_to_grid",
                        text="Selection to Grid")
        UseSeparator(self, context)
        layout.menu("VIEW3D_MT_Pivot")
        layout.operator("view3d.pivot_cursor",
                        text="Set Cursor as Pivot Point")
        layout.operator("view3d.revert_pivot",
                        text="Revert Pivot Point")


# ********** Edit Mesh UV **********
class VIEW3D_MT_UV_Map(Menu):
    bl_label = "UV Mapping"

    def draw(self, context):
        layout = self.layout
        layout.operator("uv.unwrap")
        UseSeparator(self, context)
        layout.operator_context = 'INVOKE_DEFAULT'
        layout.operator("uv.smart_project")
        layout.operator("uv.lightmap_pack")
        layout.operator("uv.follow_active_quads")
        layout.operator_context = 'EXEC_REGION_WIN'
        layout.operator("uv.cube_project")
        layout.operator("uv.cylinder_project")
        layout.operator("uv.sphere_project")
        layout.operator_context = 'INVOKE_REGION_WIN'
        UseSeparator(self, context)
        layout.operator("uv.project_from_view").scale_to_bounds = False
        layout.operator("uv.project_from_view", text="Project from View (Bounds)").scale_to_bounds = True
        UseSeparator(self, context)
        layout.operator("uv.reset")


# ********** Edit Curve **********
class VIEW3D_MT_Edit_Curve(Menu):
    bl_label = "Curve"

    def draw(self, context):
        layout = self.layout

        toolsettings = context.tool_settings

        layout.operator("curve.extrude_move")
        layout.operator("curve.spin")
        layout.operator("curve.duplicate_move")
        layout.operator("curve.split")
        layout.operator("curve.separate")
        layout.operator("curve.make_segment")
        layout.operator("curve.cyclic_toggle")
        UseSeparator(self, context)
        layout.operator("curve.delete", text="Delete...")
        UseSeparator(self, context)
        layout.menu("VIEW3D_MT_edit_curve_segments")
        layout.prop_menu_enum(toolsettings, "proportional_edit",
                              icon="PROP_CON")
        layout.prop_menu_enum(toolsettings, "proportional_edit_falloff",
                              icon="SMOOTHCURVE")
        layout.menu("VIEW3D_MT_edit_curve_showhide")


class VIEW3D_MT_EditCurveCtrlpoints(Menu):
    bl_label = "Control Points"

    def draw(self, context):
        layout = self.layout

        edit_object = context.edit_object

        if edit_object.type == 'CURVE':
            layout.operator("transform.transform").mode = 'TILT'
            layout.operator("curve.tilt_clear")
            layout.operator("curve.separate")
            layout.operator_menu_enum("curve.handle_type_set", "type")
            layout.menu("VIEW3D_MT_hook")


class VIEW3D_MT_EditCurveSegments(Menu):
    bl_label = "Curve Segments"

    def draw(self, context):
        layout = self.layout
        layout.operator("curve.subdivide")
        layout.operator("curve.switch_direction")


class VIEW3D_MT_EditCurveSpecials(Menu):
    bl_label = "Specials"

    def draw(self, context):
        layout = self.layout
        layout.operator("curve.subdivide")
        UseSeparator(self, context)
        layout.operator("curve.switch_direction")
        layout.operator("curve.spline_weight_set")
        layout.operator("curve.radius_set")
        UseSeparator(self, context)
        layout.operator("curve.smooth")
        layout.operator("curve.smooth_weight")
        layout.operator("curve.smooth_radius")
        layout.operator("curve.smooth_tilt")


# Brushes Menu's #
# Thanks to CoDEmanX for the code
class VIEW3D_MT_Brush_Selection(Menu):
    bl_label = "Brush Tool"

    def draw(self, context):
        layout = self.layout
        settings = UnifiedPaintPanel.paint_settings(context)

        # check if brush exists (for instance, in paint mode before adding a slot)
        if hasattr(settings, 'brush'):
            brush = settings.brush
        else:
            brush = None

        if not brush:
            layout.label(text="No Brushes currently available", icon="INFO")
            return

        if not context.particle_edit_object:
            if UseBrushesLists():
                flow = layout.column_flow(columns=3)

                for brsh in bpy.data.brushes:
                    if (context.sculpt_object and brsh.use_paint_sculpt):
                        props = flow.operator("wm.context_set_id", text=brsh.name,
                                              icon_value=layout.icon(brsh))
                        props.data_path = "tool_settings.sculpt.brush"
                        props.value = brsh.name
                    elif (context.image_paint_object and brsh.use_paint_image):
                        props = flow.operator("wm.context_set_id", text=brsh.name,
                                              icon_value=layout.icon(brsh))
                        props.data_path = "tool_settings.image_paint.brush"
                        props.value = brsh.name
                    elif (context.vertex_paint_object and brsh.use_paint_vertex):
                        props = flow.operator("wm.context_set_id", text=brsh.name,
                                              icon_value=layout.icon(brsh))
                        props.data_path = "tool_settings.vertex_paint.brush"
                        props.value = brsh.name
                    elif (context.weight_paint_object and brsh.use_paint_weight):
                        props = flow.operator("wm.context_set_id", text=brsh.name,
                                              icon_value=layout.icon(brsh))
                        props.data_path = "tool_settings.weight_paint.brush"
                        props.value = brsh.name
            else:
                layout.template_ID_preview(settings, "brush", new="brush.add", rows=3, cols=8)


class VIEW3D_MT_Brush_Settings(Menu):
    bl_label = "Brush Settings"

    def draw(self, context):
        layout = self.layout
        settings = UnifiedPaintPanel.paint_settings(context)
        brush = getattr(settings, "brush", None)

        ups = context.tool_settings.unified_paint_settings
        layout.prop(ups, "use_unified_size", text="Unified Size")
        layout.prop(ups, "use_unified_strength", text="Unified Strength")
        if context.image_paint_object or context.vertex_paint_object:
            layout.prop(ups, "use_unified_color", text="Unified Color")
        UseSeparator(self, context)

        if not brush:
            layout.label(text="No Brushes currently available", icon="INFO")
            return

        layout.menu("VIEW3D_MT_brush_paint_modes")

        if context.sculpt_object:
            sculpt_tool = brush.sculpt_tool

            UseSeparator(self, context)
            layout.operator_menu_enum("brush.curve_preset", "shape", text="Curve Preset")
            UseSeparator(self, context)

            if sculpt_tool != 'GRAB':
                layout.prop_menu_enum(brush, "stroke_method")

                if sculpt_tool in {'DRAW', 'PINCH', 'INFLATE', 'LAYER', 'CLAY'}:
                    layout.prop_menu_enum(brush, "direction")

                if sculpt_tool == 'LAYER':
                    layout.prop(brush, "use_persistent")
                    layout.operator("sculpt.set_persistent_base")


# Sculpt Menu's #
class VIEW3D_MT_Sculpts(Menu):
    bl_label = "Sculpt"

    def draw(self, context):
        layout = self.layout
        toolsettings = context.tool_settings
        sculpt = toolsettings.sculpt

        layout.prop(sculpt, "use_symmetry_x")
        layout.prop(sculpt, "use_symmetry_y")
        layout.prop(sculpt, "use_symmetry_z")

        UseSeparator(self, context)
        layout.prop(sculpt, "lock_x")
        layout.prop(sculpt, "lock_y")
        layout.prop(sculpt, "lock_z")

        UseSeparator(self, context)
        layout.prop(sculpt, "use_threaded", text="Threaded Sculpt")
        layout.prop(sculpt, "show_low_resolution")
        layout.prop(sculpt, "use_deform_only")

        UseSeparator(self, context)
        layout.prop(sculpt, "show_brush")
        layout.prop(sculpt, "show_diffuse_color")


class VIEW3D_MT_Hide_Masks(Menu):
    bl_label = "Hide/Mask"

    def draw(self, context):
        layout = self.layout

        props = layout.operator("paint.mask_lasso_gesture", text="Lasso Mask")
        UseSeparator(self, context)
        props = layout.operator("view3d.select_border", text="Box Mask", icon="BORDER_RECT")
        props = layout.operator("paint.hide_show", text="Box Hide")
        props.action = 'HIDE'
        props.area = 'INSIDE'

        props = layout.operator("paint.hide_show", text="Box Show")
        props.action = 'SHOW'
        props.area = 'INSIDE'
        UseSeparator(self, context)

        props = layout.operator("paint.mask_flood_fill", text="Fill Mask", icon="BORDER_RECT")
        props.mode = 'VALUE'
        props.value = 1

        props = layout.operator("paint.mask_flood_fill", text="Clear Mask")
        props.mode = 'VALUE'
        props.value = 0

        layout.operator("paint.mask_flood_fill", text="Invert Mask").mode = 'INVERT'
        UseSeparator(self, context)

        props = layout.operator("paint.hide_show", text="Show All", icon="RESTRICT_VIEW_OFF")
        props.action = 'SHOW'
        props.area = 'ALL'

        props = layout.operator("paint.hide_show", text="Hide Masked", icon="RESTRICT_VIEW_ON")
        props.area = 'MASKED'
        props.action = 'HIDE'


# Sculpt Specials Menu (Thanks to marvin.k.breuer) #
class VIEW3D_MT_Sculpt_Specials(Menu):
    bl_label = "Sculpt Specials"

    def draw(self, context):
        layout = self.layout
        settings = context.tool_settings

        if context.sculpt_object.use_dynamic_topology_sculpting:
            layout.operator("sculpt.dynamic_topology_toggle",
                            icon='X', text="Disable Dyntopo")
            UseSeparator(self, context)

            if (settings.sculpt.detail_type_method == 'CONSTANT'):
                layout.prop(settings.sculpt, "constant_detail", text="Const.")
                layout.operator("sculpt.sample_detail_size", text="", icon='EYEDROPPER')
            else:
                layout.prop(settings.sculpt, "detail_size", text="Detail")
            UseSeparator(self, context)

            layout.operator("sculpt.symmetrize", icon='ARROW_LEFTRIGHT')
            layout.prop(settings.sculpt, "symmetrize_direction", "")
            UseSeparator(self, context)

            layout.operator("sculpt.optimize")
            if (settings.sculpt.detail_type_method == 'CONSTANT'):
                layout.operator("sculpt.detail_flood_fill")
            UseSeparator(self, context)

            layout.prop(settings.sculpt, "detail_refine_method", text="")
            layout.prop(settings.sculpt, "detail_type_method", text="")
            UseSeparator(self, context)
            layout.prop(settings.sculpt, "use_smooth_shading", "Smooth")
        else:
            layout.operator("sculpt.dynamic_topology_toggle",
                            icon='SCULPT_DYNTOPO', text="Enable Dyntopo")


# Display Wire (Thanks to marvin.k.breuer) #
class VIEW3D_OT_Display_Wire_All(Operator):
    bl_label = "Wire on All Objects"
    bl_idname = "view3d.display_wire_all"
    bl_description = "Enable/Disable Display Wire on All Objects"

    @classmethod
    def poll(cls, context):
        return context.active_object is not None

    def execute(self, context):
        is_error = False
        for obj in bpy.data.objects:
            try:
                if obj.show_wire:
                    obj.show_all_edges = False
                    obj.show_wire = False
                else:
                    obj.show_all_edges = True
                    obj.show_wire = True
            except:
                is_error = True
                pass

        if is_error:
            self.report({'WARNING'},
                        "Wire on All Objects could not be completed for some objects")

        return {'FINISHED'}


# Vertex Color Menu #
class VIEW3D_MT_Vertex_Colors(Menu):
    bl_label = "Vertex Colors"

    def draw(self, context):
        layout = self.layout
        layout.operator("paint.vertex_color_set")
        UseSeparator(self, context)

        layout.operator("paint.vertex_color_smooth")
        layout.operator("paint.vertex_color_dirt")


# Weight Paint Menu #
class VIEW3D_MT_Paint_Weights(Menu):
    bl_label = "Weights"

    def draw(self, context):
        layout = self.layout

        layout.operator("paint.weight_from_bones",
                        text="Assign Automatic From Bones").type = 'AUTOMATIC'
        layout.operator("paint.weight_from_bones",
                        text="Assign From Bone Envelopes").type = 'ENVELOPES'
        UseSeparator(self, context)

        layout.operator("object.vertex_group_normalize_all", text="Normalize All")
        layout.operator("object.vertex_group_normalize", text="Normalize")
        UseSeparator(self, context)

        layout.operator("object.vertex_group_mirror", text="Mirror")
        layout.operator("object.vertex_group_invert", text="Invert")
        UseSeparator(self, context)

        layout.operator("object.vertex_group_clean", text="Clean")
        layout.operator("object.vertex_group_quantize", text="Quantize")
        UseSeparator(self, context)

        layout.operator("object.vertex_group_levels", text="Levels")
        layout.operator("object.vertex_group_smooth", text="Smooth")
        UseSeparator(self, context)

        props = layout.operator("object.data_transfer", text="Transfer Weights")
        props.use_reverse_transfer = True
        props.data_type = 'VGROUP_WEIGHTS'
        UseSeparator(self, context)

        layout.operator("object.vertex_group_limit_total", text="Limit Total")
        layout.operator("object.vertex_group_fix", text="Fix Deforms")
        UseSeparator(self, context)

        layout.operator("paint.weight_set")


# Armature Menu's #

class VIEW3D_MT_Edit_Armature(Menu):
    bl_label = "Armature"

    def draw(self, context):
        layout = self.layout
        toolsettings = context.tool_settings

        layout.prop_menu_enum(toolsettings, "proportional_edit", icon="PROP_CON")
        layout.prop_menu_enum(toolsettings, "proportional_edit_falloff", icon="SMOOTHCURVE")
        UseSeparator(self, context)

        layout.menu("VIEW3D_MT_bone_options_toggle", text="Bone Settings")
        layout.operator("armature.merge")
        layout.operator("armature.fill")
        layout.operator("armature.split")
        layout.operator("armature.separate")
        layout.operator("armature.switch_direction", text="Switch Direction")

        layout.operator_context = 'EXEC_AREA'
        layout.operator("armature.symmetrize")
        UseSeparator(self, context)

        layout.operator("armature.delete")
        UseSeparator(self, context)

        layout.operator_context = 'INVOKE_DEFAULT'
        layout.operator("armature.armature_layers")
        layout.operator("armature.bone_layers")


class VIEW3D_MT_EditArmatureTK(Menu):
    bl_label = "Armature Tools"

    def draw(self, context):
        layout = self.layout
        layout.operator("armature.subdivide", text="Subdivide")
        layout.operator("armature.extrude_move")
        layout.operator("armature.extrude_forked")
        layout.operator("armature.duplicate_move")
        UseSeparator(self, context)
        layout.menu("VIEW3D_MT_edit_armature_delete")
        UseSeparator(self, context)
        layout.operator("transform.transform",
                        text="Scale Envelope Distance").mode = 'BONE_SIZE'
        layout.operator("transform.transform",
                        text="Scale B-Bone Width").mode = 'BONE_SIZE'


# Armature Pose Menu's #

class VIEW3D_MT_Pose(Menu):
    bl_label = "Pose"

    def draw(self, context):
        layout = self.layout

        layout.menu("VIEW3D_MT_object_animation")
        layout.menu("VIEW3D_MT_pose_slide")
        layout.menu("VIEW3D_MT_pose_propagate")
        layout.menu("VIEW3D_MT_pose_library")
        layout.menu("VIEW3D_MT_pose_motion")
        UseSeparator(self, context)
        layout.menu("VIEW3D_MT_pose_group")
        layout.menu("VIEW3D_MT_object_parent")
        UseSeparator(self, context)
        layout.menu("VIEW3D_MT_pose_ik")
        layout.menu("VIEW3D_MT_pose_constraints")
        layout.menu("VIEW3D_MT_PoseNames")
        layout.operator("pose.quaternions_flip")
        layout.operator_context = 'INVOKE_AREA'
        UseSeparator(self, context)
        layout.operator("armature.armature_layers", text="Change Armature Layers...")
        layout.operator("pose.bone_layers", text="Change Bone Layers...")
        UseSeparator(self, context)
        layout.menu("VIEW3D_MT_pose_showhide")
        layout.menu("VIEW3D_MT_bone_options_toggle", text="Bone Settings")


# Transform Menu's #

class VIEW3D_MT_TransformMenu(Menu):
    bl_label = "Transform"

    def draw(self, context):
        layout = self.layout
        layout.menu("VIEW3D_MT_ManipulatorMenu1")
        UseSeparator(self, context)
        layout.operator("transform.translate", text="Grab/Move")
        layout.operator("transform.rotate", text="Rotate")
        layout.operator("transform.resize", text="Scale")
        UseSeparator(self, context)
        layout.menu("VIEW3D_MT_object_clear")
        layout.menu("VIEW3D_MT_object_apply")
        UseSeparator(self, context)
        layout.operator("transform.translate", text="Move Texture Space").texture_space = True
        layout.operator("transform.resize", text="Scale Texture Space").texture_space = True
        UseSeparator(self, context)
        layout.operator("object.randomize_transform")
        layout.operator("transform.tosphere", text="To Sphere")
        layout.operator("transform.shear", text="Shear")
        layout.operator("transform.bend", text="Bend")
        layout.operator("transform.push_pull", text="Push/Pull")
        UseSeparator(self, context)
        layout.operator("object.align")
        layout.operator_context = 'EXEC_REGION_WIN'
        layout.operator("transform.transform",
                        text="Align to Transform Orientation").mode = 'ALIGN'


# ********** Edit Mesh Transform **********
class VIEW3D_MT_TransformMenuEdit(Menu):
    bl_label = "Transform"

    def draw(self, context):
        layout = self.layout
        layout.menu("VIEW3D_MT_ManipulatorMenu1")
        UseSeparator(self, context)
        layout.operator("transform.translate", text="Grab/Move")
        layout.operator("transform.rotate", text="Rotate")
        layout.operator("transform.resize", text="Scale")
        UseSeparator(self, context)
        layout.operator("transform.tosphere", text="To Sphere")
        layout.operator("transform.shear", text="Shear")
        layout.operator("transform.bend", text="Bend")
        layout.operator("transform.push_pull", text="Push/Pull")
        layout.operator("transform.vertex_warp", text="Warp")
        layout.operator("transform.vertex_random", text="Randomize")
        UseSeparator(self, context)
        layout.operator("transform.translate", text="Move Texture Space").texture_space = True
        layout.operator("transform.resize", text="Scale Texture Space").texture_space = True
        UseSeparator(self, context)
        layout.operator_context = 'EXEC_REGION_WIN'
        layout.operator("transform.transform",
                        text="Align to Transform Orientation").mode = 'ALIGN'
        layout.operator_context = 'EXEC_AREA'
        layout.operator("object.origin_set",
                        text="Geometry to Origin").type = 'GEOMETRY_ORIGIN'


# ********** Transform Lite/Short **********
class VIEW3D_MT_TransformMenuLite(Menu):
    bl_label = "Transform"

    def draw(self, context):
        layout = self.layout
        layout.menu("VIEW3D_MT_ManipulatorMenu1")
        UseSeparator(self, context)
        layout.operator("transform.translate", text="Grab/Move")
        layout.operator("transform.rotate", text="Rotate")
        layout.operator("transform.resize", text="Scale")
        UseSeparator(self, context)
        layout.menu("VIEW3D_MT_object_clear")
        layout.menu("VIEW3D_MT_object_apply")
        UseSeparator(self, context)
        layout.operator("transform.transform",
                        text="Align to Transform Orientation").mode = 'ALIGN'


# ********** Transform Camera **********
class VIEW3D_MT_TransformMenuCamera(Menu):
    bl_label = "Transform"

    def draw(self, context):
        layout = self.layout

        layout.menu("VIEW3D_MT_ManipulatorMenu1")
        layout.menu("VIEW3D_MT_object_clear")
        layout.menu("VIEW3D_MT_object_apply")
        layout.operator("transform.translate", text="Grab/Move")
        layout.operator("transform.rotate", text="Rotate")
        layout.operator("transform.resize", text="Scale")
        layout.operator("object.align")
        layout.operator_context = 'EXEC_REGION_WIN'
        UseSeparator(self, context)
        layout.operator("transform.transform",
                        text="Align to Transform Orientation").mode = 'ALIGN'


# ********** Transform Armature  **********
class VIEW3D_MT_TransformMenuArmature(Menu):
    bl_label = "Transform"

    def draw(self, context):
        layout = self.layout

        layout.menu("VIEW3D_MT_ManipulatorMenu1")
        UseSeparator(self, context)
        layout.operator("transform.translate", text="Grab/Move")
        layout.operator("transform.rotate", text="Rotate")
        layout.operator("transform.resize", text="Scale")
        UseSeparator(self, context)
        layout.operator("armature.align")
        layout.operator("object.align")
        layout.operator_context = 'EXEC_AREA'
        UseSeparator(self, context)
        layout.operator("object.origin_set",
                        text="Geometry to Origin").type = 'GEOMETRY_ORIGIN'
        layout.operator("object.origin_set",
                        text="Origin to Geometry").type = 'ORIGIN_GEOMETRY'
        layout.operator("object.origin_set",
                        text="Origin to 3D Cursor").type = 'ORIGIN_CURSOR'
        layout.operator("object.origin_set",
                        text="Origin to Center of Mass").type = 'ORIGIN_CENTER_OF_MASS'


# ********** Transform Armature Edit **********
class VIEW3D_MT_TransformMenuArmatureEdit(Menu):
    bl_label = "Transform"

    def draw(self, context):
        layout = self.layout
        layout.menu("VIEW3D_MT_ManipulatorMenu1")
        UseSeparator(self, context)
        layout.operator("transform.translate", text="Grab/Move")
        layout.operator("transform.rotate", text="Rotate")
        layout.operator("transform.resize", text="Scale")
        UseSeparator(self, context)
        layout.operator("transform.tosphere", text="To Sphere")
        layout.operator("transform.shear", text="Shear")
        layout.operator("transform.bend", text="Bend")
        layout.operator("transform.push_pull", text="Push/Pull")
        layout.operator("transform.vertex_warp", text="Warp")
        UseSeparator(self, context)
        layout.operator("transform.vertex_random", text="Randomize")
        layout.operator("armature.align")
        layout.operator_context = 'EXEC_AREA'


# ********** Transform Armature Pose **********
class VIEW3D_MT_TransformMenuArmaturePose(Menu):
    bl_label = "Transform"

    def draw(self, context):
        layout = self.layout
        layout.menu("VIEW3D_MT_ManipulatorMenu1")
        layout.operator("transform.translate", text="Grab/Move")
        layout.operator("transform.rotate", text="Rotate")
        layout.operator("transform.resize", text="Scale")
        UseSeparator(self, context)
        layout.operator("pose.transforms_clear", text="Clear All")
        layout.operator("pose.loc_clear", text="Location")
        layout.operator("pose.rot_clear", text="Rotation")
        layout.operator("pose.scale_clear", text="Scale")

        UseSeparator(self, context)

        layout.operator("pose.user_transforms_clear", text="Reset unkeyed")
        obj = context.object
        if obj.type == 'ARMATURE' and obj.mode in {'EDIT', 'POSE'}:
            if obj.data.draw_type == 'BBONE':
                layout.operator("transform.transform", text="Scale BBone").mode = 'BONE_SIZE'
            elif obj.data.draw_type == 'ENVELOPE':
                layout.operator("transform.transform", text="Scale Envelope Distance").mode = 'BONE_SIZE'
                layout.operator("transform.transform", text="Scale Radius").mode = 'BONE_ENVELOPE'


# View Menu's #

class VIEW3D_MT_View_Directions(Menu):
    bl_label = "Directions"

    def draw(self, context):
        layout = self.layout
        layout.operator("view3d.viewnumpad", text="Camera").type = 'CAMERA'
        UseSeparator(self, context)
        layout.operator("view3d.viewnumpad", text="Top").type = 'TOP'
        layout.operator("view3d.viewnumpad", text="Bottom").type = 'BOTTOM'
        UseSeparator(self, context)
        layout.operator("view3d.viewnumpad", text="Front").type = 'FRONT'
        layout.operator("view3d.viewnumpad", text="Back").type = 'BACK'
        UseSeparator(self, context)
        layout.operator("view3d.viewnumpad", text="Right").type = 'RIGHT'
        layout.operator("view3d.viewnumpad", text="Left").type = 'LEFT'


class VIEW3D_MT_View_Border(Menu):
    bl_label = "Set Border"

    def draw(self, context):
        layout = self.layout
        layout.operator_context = 'INVOKE_REGION_WIN'
        layout.operator("view3d.clip_border", text="Clipping Border...")
        layout.operator("view3d.zoom_border", text="Zoom Border...")
        layout.operator("view3d.render_border", text="Render Border...").camera_only = False


class VIEW3D_MT_View_Toggle(Menu):
    bl_label = "View Toggle"

    def draw(self, context):
        layout = self.layout
        layout.operator_context = 'INVOKE_REGION_WIN'
        layout.operator("screen.area_dupli")
        UseSeparator(self, context)
        layout.operator("screen.region_quadview")
        layout.operator("screen.screen_full_area", text="Toggle Maximize Area")
        layout.operator("screen.screen_full_area").use_hide_panels = True


class VIEW3D_MT_View_Menu(Menu):
    bl_label = "View"

    def draw(self, context):
        layout = self.layout
        layout.menu("VIEW3D_MT_Shade")
        UseSeparator(self, context)
        layout.menu("VIEW3D_MT_view_cameras", text="Cameras")
        layout.menu("VIEW3D_MT_View_Directions")
        layout.menu("VIEW3D_MT_View_Navigation")
        UseSeparator(self, context)
        layout.menu("VIEW3D_MT_View_Align")
        layout.menu("VIEW3D_MT_View_Toggle")
        layout.operator("view3d.view_persportho")
        layout.operator("view3d.localview", text="View Global/Local")
        layout.operator("view3d.view_selected").use_all_regions = False
        layout.operator("view3d.view_all").center = False
        UseSeparator(self, context)
        layout.menu("VIEW3D_MT_View_Border")
        layout.operator("view3d.layers", text="Show All Layers").nr = 0
        UseSeparator(self, context)
        # New menu entry for Animation player
        layout.menu("VIEW3D_MT_Animation_Player",
                    text="Playback Animation", icon='PLAY')


class VIEW3D_MT_View_Navigation(Menu):
    bl_label = "Navigation"

    def draw(self, context):
        from math import pi
        layout = self.layout
        layout.operator_enum("view3d.view_orbit", "type")
        props = layout.operator("view3d.view_orbit", "Orbit Opposite")
        props.type = 'ORBITRIGHT'
        props.angle = pi

        UseSeparator(self, context)
        layout.operator("view3d.view_roll", text="Roll Left").type = 'LEFT'
        layout.operator("view3d.view_roll", text="Roll Right").type = 'RIGHT'
        UseSeparator(self, context)
        layout.operator_enum("view3d.view_pan", "type")
        UseSeparator(self, context)
        layout.operator("view3d.zoom", text="Zoom In").delta = 1
        layout.operator("view3d.zoom", text="Zoom Out").delta = -1
        UseSeparator(self, context)
        layout.operator("view3d.zoom_camera_1_to_1", text="Zoom Camera 1:1")
        UseSeparator(self, context)
        layout.operator("view3d.fly")
        layout.operator("view3d.walk")


class VIEW3D_MT_View_Align(Menu):
    bl_label = "Align View"

    def draw(self, context):
        layout = self.layout
        layout.operator("view3d.view_all", text="Center Cursor and View All").center = True
        layout.operator("view3d.view_center_cursor")
        UseSeparator(self, context)
        layout.operator("view3d.camera_to_view", text="Align Active Camera to View")
        layout.operator("view3d.camera_to_view_selected", text="Align Active Camera to Selected")
        UseSeparator(self, context)
        layout.operator("view3d.view_selected")
        layout.operator("view3d.view_lock_to_active")
        layout.operator("view3d.view_lock_clear")


class VIEW3D_MT_View_Align_Selected(Menu):
    bl_label = "Align View to Active"

    def draw(self, context):
        layout = self.layout
        props = layout.operator("view3d.viewnumpad", text="Top")
        props.align_active = True
        props.type = 'TOP'
        props = layout.operator("view3d.viewnumpad", text="Bottom")
        props.align_active = True
        props.type = 'BOTTOM'
        props = layout.operator("view3d.viewnumpad", text="Front")
        props.align_active = True
        props.type = 'FRONT'
        props = layout.operator("view3d.viewnumpad", text="Back")
        props.align_active = True
        props.type = 'BACK'
        props = layout.operator("view3d.viewnumpad", text="Right")
        props.align_active = True
        props.type = 'RIGHT'
        props = layout.operator("view3d.viewnumpad", text="Left")
        props.align_active = True
        props.type = 'LEFT'


class VIEW3D_MT_View_Cameras(Menu):
    bl_label = "Cameras"

    def draw(self, context):
        layout = self.layout
        layout.operator("view3d.object_as_camera")
        layout.operator("view3d.viewnumpad", text="Active Camera").type = 'CAMERA'


# Matcap and AO, Wire all and X-Ray entries thanks to marvin.k.breuer
class VIEW3D_MT_Shade(Menu):
    bl_label = "Shade"

    def draw(self, context):
        layout = self.layout

        layout.prop(context.space_data, "viewport_shade", expand=True)
        UseSeparator(self, context)

        if context.active_object:
            if(context.mode == 'EDIT_MESH'):
                layout.operator("MESH_OT_faces_shade_smooth")
                layout.operator("MESH_OT_faces_shade_flat")
            else:
                layout.operator("OBJECT_OT_shade_smooth")
                layout.operator("OBJECT_OT_shade_flat")

        UseSeparator(self, context)
        layout.operator("view3d.display_wire_all", text="Wire all", icon='WIRE')
        layout.prop(context.object, "show_x_ray", text="X-Ray", icon="META_CUBE")

        UseSeparator(self, context)
        layout.prop(context.space_data.fx_settings, "use_ssao",
                    text="Ambient Occlusion", icon="GROUP")
        layout.prop(context.space_data, "use_matcap", icon="MATCAP_01")

        if context.space_data.use_matcap:
            row = layout.column(1)
            row.scale_y = 0.3
            row.scale_x = 0.5
            row.template_icon_view(context.space_data, "matcap_icon")


# Animation Player (Thanks to marvin.k.breuer) #
class VIEW3D_MT_Animation_Player(Menu):
    bl_label = "Animation Player"

    def draw(self, context):
        layout = self.layout

        layout.operator("screen.frame_jump", text="Jump REW", icon='REW').end = False
        layout.operator("screen.keyframe_jump", text="Previous FR", icon='PREV_KEYFRAME').next = False

        UseSeparator(self, context)
        layout.operator("screen.animation_play", text="Reverse", icon='PLAY_REVERSE').reverse = True
        layout.operator("screen.animation_play", text="PLAY", icon='PLAY')
        layout.operator("screen.animation_play", text="Stop", icon='PAUSE')
        UseSeparator(self, context)

        layout.operator("screen.keyframe_jump", text="Next FR", icon='NEXT_KEYFRAME').next = True
        layout.operator("screen.frame_jump", text="Jump FF", icon='FF').end = True


# Select Menu's #

# Object Select #
class VIEW3D_MT_Select_Object(Menu):
    bl_label = "Select"

    def draw(self, context):
        layout = self.layout
        layout.operator_context = 'INVOKE_REGION_WIN'
        layout.operator("view3d.select_border")
        layout.operator("view3d.select_circle")
        UseSeparator(self, context)
        layout.operator("object.select_all").action = 'TOGGLE'
        layout.operator("object.select_all", text="Inverse").action = 'INVERT'
        layout.operator("object.select_random", text="Random")
        layout.operator("object.select_mirror", text="Mirror")
        UseSeparator(self, context)
        layout.operator("object.select_by_layer", text="Select All by Layer")
        layout.operator_menu_enum("object.select_by_type", "type",
                                  text="Select All by Type...")
        layout.operator_menu_enum("object.select_grouped", "type",
                                  text="Grouped")
        layout.operator_menu_enum("object.select_linked", "type",
                                  text="Linked")
        layout.operator("object.select_camera", text="Select Camera")
        UseSeparator(self, context)
        layout.menu("VIEW3D_MT_Select_Object_More_Less", text="More/Less")
        layout.operator("object.select_pattern", text="Select Pattern...")


class VIEW3D_MT_Select_Object_More_Less(Menu):
    bl_label = "Select More/Less"

    def draw(self, context):
        layout = self.layout
        layout.operator("object.select_more", text="More")
        layout.operator("object.select_less", text="Less")
        UseSeparator(self, context)
        props = layout.operator("object.select_hierarchy", text="Parent")
        props.extend = False
        props.direction = 'PARENT'
        props = layout.operator("object.select_hierarchy", text="Child")
        props.extend = False
        props.direction = 'CHILD'
        UseSeparator(self, context)
        props = layout.operator("object.select_hierarchy", text="Extend Parent")
        props.extend = True
        props.direction = 'PARENT'
        props = layout.operator("object.select_hierarchy", text="Extend Child")
        props.extend = True
        props.direction = 'CHILD'


# Edit Select #
class VIEW3D_MT_Select_Edit_Mesh(Menu):
    bl_label = "Select"

    def draw(self, context):
        layout = self.layout
        layout.operator("view3d.select_border")
        layout.operator("view3d.select_circle")
        UseSeparator(self, context)
        layout.operator("mesh.select_all").action = 'TOGGLE'
        layout.operator("mesh.select_all", text="Inverse").action = 'INVERT'
        layout.operator("mesh.select_linked", text="Linked")
        layout.operator("mesh.faces_select_linked_flat",
                        text="Linked Flat Faces")
        layout.operator("mesh.select_random", text="Random")
        layout.operator("mesh.select_nth", text="Every N Number of Verts")
        UseSeparator(self, context)
        layout.menu("VIEW3D_MT_Edit_Mesh_Select_Trait")
        layout.menu("VIEW3D_MT_Edit_Mesh_Select_Similar")
        layout.menu("VIEW3D_MT_Edit_Mesh_Select_More_Less")
        UseSeparator(self, context)
        layout.operator("mesh.select_mirror", text="Mirror")
        layout.operator("mesh.edges_select_sharp", text="Sharp Edges")
        layout.operator("mesh.select_axis", text="Side of Active")
        layout.operator("mesh.shortest_path_select", text="Shortest Path")
        UseSeparator(self, context)
        layout.operator("mesh.loop_multi_select", text="Edge Loops").ring = False
        layout.operator("mesh.loop_multi_select", text="Edge Rings").ring = True
        layout.operator("mesh.loop_to_region")
        layout.operator("mesh.region_to_loop")


class VIEW3D_MT_Edit_Mesh_Select_Similar(Menu):
    bl_label = "Select Similar"

    def draw(self, context):
        layout = self.layout
        layout.operator_enum("mesh.select_similar", "type")
        layout.operator("mesh.select_similar_region", text="Face Regions")


class VIEW3D_MT_Edit_Mesh_Select_Trait(Menu):
    bl_label = "Select All by Trait"

    def draw(self, context):
        layout = self.layout
        if context.scene.tool_settings.mesh_select_mode[2] is False:
            layout.operator("mesh.select_non_manifold", text="Non Manifold")
        layout.operator("mesh.select_loose", text="Loose Geometry")
        layout.operator("mesh.select_interior_faces", text="Interior Faces")
        layout.operator("mesh.select_face_by_sides", text="By Number of Verts")
        layout.operator("mesh.select_ungrouped", text="Ungrouped Verts")


class VIEW3D_MT_Edit_Mesh_Select_More_Less(Menu):
    bl_label = "Select More/Less"

    def draw(self, context):
        layout = self.layout
        layout.operator("mesh.select_more", text="More")
        layout.operator("mesh.select_less", text="Less")
        UseSeparator(self, context)
        layout.operator("mesh.select_next_item", text="Next Active")
        layout.operator("mesh.select_prev_item", text="Previous Active")


# Edit Curve Select #
class VIEW3D_MT_Select_Edit_Curve(Menu):
    bl_label = "Select"

    def draw(self, context):
        layout = self.layout
        layout.operator("view3d.select_border")
        layout.operator("view3d.select_circle")
        UseSeparator(self, context)
        layout.operator("curve.select_all").action = 'TOGGLE'
        layout.operator("curve.select_all", text="Inverse").action = 'INVERT'
        layout.operator("curve.select_nth")
        UseSeparator(self, context)
        layout.operator("curve.select_random")
        layout.operator("curve.select_linked", text="Select Linked")
        layout.operator("curve.select_similar", text="Select Similar")
        layout.operator("curve.de_select_first")
        layout.operator("curve.de_select_last")
        layout.operator("curve.select_next")
        layout.operator("curve.select_previous")
        UseSeparator(self, context)
        layout.operator("curve.select_more")
        layout.operator("curve.select_less")


# Armature Select #
class VIEW3D_MT_SelectArmatureMenu(Menu):
    bl_label = "Select"

    def draw(self, context):
        layout = self.layout
        layout.operator("view3d.select_border")
        layout.operator("armature.select_all")
        layout.operator("armature.select_inverse", text="Inverse")
        layout.operator("armature.select_hierarchy",
                        text="Parent").direction = 'PARENT'
        layout.operator("armature.select_hierarchy",
                        text="Child").direction = 'CHILD'
        props = layout.operator("armature.select_hierarchy",
                                text="Extend Parent")
        props.extend = True
        props.direction = 'PARENT'
        props = layout.operator("armature.select_hierarchy",
                                text="Extend Child")
        props.extend = True
        props.direction = 'CHILD'
        layout.operator("object.select_pattern", text="Select Pattern...")


class VIEW3D_MT_Select_Edit_Armature(Menu):
    bl_label = "Select"

    def draw(self, context):
        layout = self.layout

        layout.operator("view3d.select_border")
        layout.operator("view3d.select_circle")

        UseSeparator(self, context)

        layout.operator("armature.select_all").action = 'TOGGLE'
        layout.operator("armature.select_all", text="Inverse").action = 'INVERT'
        layout.operator("armature.select_mirror", text="Mirror").extend = False

        UseSeparator(self, context)

        layout.operator("armature.select_more", text="More")
        layout.operator("armature.select_less", text="Less")

        UseSeparator(self, context)

        props = layout.operator("armature.select_hierarchy", text="Parent")
        props.extend = False
        props.direction = 'PARENT'

        props = layout.operator("armature.select_hierarchy", text="Child")
        props.extend = False
        props.direction = 'CHILD'

        UseSeparator(self, context)

        props = layout.operator("armature.select_hierarchy", text="Extend Parent")
        props.extend = True
        props.direction = 'PARENT'

        props = layout.operator("armature.select_hierarchy", text="Extend Child")
        props.extend = True
        props.direction = 'CHILD'

        layout.operator_menu_enum("armature.select_similar", "type", text="Similar")
        layout.operator("object.select_pattern", text="Select Pattern...")


class VIEW3D_MT_Select_Pose(Menu):
    bl_label = "Select"

    def draw(self, context):
        layout = self.layout
        layout.operator("view3d.select_border")
        layout.operator("view3d.select_circle")
        UseSeparator(self, context)
        layout.operator("pose.select_all").action = 'TOGGLE'
        layout.operator("pose.select_all", text="Inverse").action = 'INVERT'
        layout.operator("pose.select_mirror", text="Flip Active")
        layout.operator("pose.select_constraint_target",
                        text="Constraint Target")
        UseSeparator(self, context)
        layout.operator("pose.select_linked", text="Linked")
        layout.operator("pose.select_hierarchy",
                        text="Parent").direction = 'PARENT'
        layout.operator("pose.select_hierarchy",
                        text="Child").direction = 'CHILD'
        props = layout.operator("pose.select_hierarchy", text="Extend Parent")
        props.extend = True
        props.direction = 'PARENT'
        props = layout.operator("pose.select_hierarchy", text="Extend Child")
        props.extend = True
        props.direction = 'CHILD'
        layout.operator_menu_enum("pose.select_grouped", "type",
                                  text="Grouped")
        UseSeparator(self, context)
        layout.operator("object.select_pattern", text="Select Pattern...")
        layout.menu("VIEW3D_MT_select_pose_more_less")


class VIEW3D_MT_Select_Pose_More_Less(Menu):
    bl_label = "Select More/Less"

    def draw(self, context):
        layout = self.layout
        props = layout.operator("pose.select_hierarchy", text="Parent")
        props.extend = False
        props.direction = 'PARENT'

        props = layout.operator("pose.select_hierarchy", text="Child")
        props.extend = False
        props.direction = 'CHILD'

        props = layout.operator("pose.select_hierarchy", text="Extend Parent")
        props.extend = True
        props.direction = 'PARENT'

        props = layout.operator("pose.select_hierarchy", text="Extend Child")
        props.extend = True
        props.direction = 'CHILD'


class VIEW3D_MT_PoseCopy(Menu):
    bl_label = "Pose Copy"

    def draw(self, context):
        layout = self.layout
        layout.operator("pose.copy")
        layout.operator("pose.paste")
        layout.operator("pose.paste",
                        text="Paste X-Flipped Pose").flipped = True


class VIEW3D_MT_PoseNames(Menu):
    bl_label = "Pose Names"

    def draw(self, context):
        layout = self.layout
        layout.operator_context = 'EXEC_AREA'
        layout.operator("pose.autoside_names",
                        text="AutoName Left/Right").axis = 'XAXIS'
        layout.operator("pose.autoside_names",
                        text="AutoName Front/Back").axis = 'YAXIS'
        layout.operator("pose.autoside_names",
                        text="AutoName Top/Bottom").axis = 'ZAXIS'
        layout.operator("pose.flip_names")


# Surface Select #
class VIEW3D_MT_Select_Edit_Surface(Menu):
    bl_label = "Select"

    def draw(self, context):
        layout = self.layout
        layout.operator("view3d.select_border")
        layout.operator("view3d.select_circle")
        UseSeparator(self, context)
        layout.operator("curve.select_all").action = 'TOGGLE'
        layout.operator("curve.select_all", text="Inverse").action = 'INVERT'
        layout.operator("curve.select_random")
        layout.operator("curve.select_nth")
        layout.operator("curve.select_linked", text="Select Linked")
        layout.operator("curve.select_similar", text="Select Similar")
        layout.operator("curve.select_row")
        UseSeparator(self, context)
        layout.operator("curve.select_more")
        layout.operator("curve.select_less")


# Metaball Select #
class VIEW3D_MT_SelectMetaball(Menu):
    bl_label = "Select"

    def draw(self, context):
        layout = self.layout
        layout.operator("view3d.select_border")
        layout.operator("view3d.select_circle")
        UseSeparator(self, context)
        layout.operator("mball.select_all").action = 'TOGGLE'
        layout.operator("mball.select_all").action = 'INVERT'
        layout.operator("mball.select_random_metaelems")


class VIEW3D_MT_Select_Edit_Metaball(Menu):
    bl_label = "Select"

    def draw(self, context):
        layout = self.layout
        layout.operator("view3d.select_border")
        layout.operator("view3d.select_circle")
        layout.operator("mball.select_all").action = 'TOGGLE'
        layout.operator("mball.select_all", text="Inverse").action = 'INVERT'
        layout.operator("mball.select_random_metaelems")
        layout.operator_menu_enum("mball.select_similar", "type", text="Similar")


# Particle Select #
class VIEW3D_MT_Selection_Mode_Particle(Menu):
    bl_label = "Particle Select and Display Mode"

    def draw(self, context):
        layout = self.layout
        toolsettings = context.tool_settings

        layout.prop(toolsettings.particle_edit, "select_mode", expand=True)


class VIEW3D_MT_Select_Particle(Menu):
    bl_label = "Select"

    def draw(self, context):
        layout = self.layout

        layout.operator("view3d.select_border")
        layout.operator("view3d.select_circle")
        UseSeparator(self, context)

        layout.operator("particle.select_all").action = 'TOGGLE'
        layout.operator("particle.select_linked")
        layout.operator("particle.select_all", text="Inverse").action = 'INVERT'

        UseSeparator(self, context)
        layout.operator("particle.select_more")
        layout.operator("particle.select_less")

        UseSeparator(self, context)
        layout.operator("particle.select_random")

        UseSeparator(self, context)
        layout.operator("particle.select_roots", text="Roots")
        layout.operator("particle.select_tips", text="Tips")


# Lattice Edit Select #
class VIEW3D_MT_Select_Edit_Lattice(Menu):
    bl_label = "Select"

    def draw(self, context):
        layout = self.layout

        layout.operator("view3d.select_border")
        layout.operator("view3d.select_circle")
        UseSeparator(self, context)
        layout.operator("lattice.select_mirror")
        layout.operator("lattice.select_random")
        layout.operator("lattice.select_all").action = 'TOGGLE'
        layout.operator("lattice.select_all", text="Inverse").action = 'INVERT'
        UseSeparator(self, context)
        layout.operator("lattice.select_ungrouped", text="Ungrouped Verts")


# Grease Pencil Select #
class VIEW3D_MT_Select_Gpencil(Menu):
    # To Do: used in 3dview header might work if mapped to mouse
    # Not in Class List yet
    bl_label = "Select"

    def draw(self, context):
        layout = self.layout

        layout.operator("gpencil.select_border")
        layout.operator("gpencil.select_circle")

        UseSeparator(self, context)

        layout.operator("gpencil.select_all", text="(De)select All").action = 'TOGGLE'
        layout.operator("gpencil.select_all", text="Inverse").action = 'INVERT'
        layout.operator("gpencil.select_linked", text="Linked")
        # layout.operator_menu_enum("gpencil.select_grouped", "type", text="Grouped")
        layout.operator("gpencil.select_grouped", text="Grouped")

        UseSeparator(self, context)

        layout.operator("gpencil.select_more")
        layout.operator("gpencil.select_less")


# Text Select #
class VIEW3D_MT_Select_Edit_Text(Menu):
    # To Do: used in 3dview header might work if mapped to mouse
    # Not in Class List yet
    bl_label = "Edit"

    def draw(self, context):
        layout = self.layout
        layout.operator("font.text_copy", text="Copy")
        layout.operator("font.text_cut", text="Cut")
        layout.operator("font.text_paste", text="Paste")
        layout.operator("font.text_paste_from_file")
        layout.operator("font.select_all")


# Paint Mode Menus #
class VIEW3D_MT_Select_Paint_Mask(Menu):
    bl_label = "Select"

    def draw(self, context):
        layout = self.layout
        layout.operator("view3d.select_border")
        layout.operator("view3d.select_circle")
        layout.operator("paint.face_select_all").action = 'TOGGLE'
        layout.operator("paint.face_select_all", text="Inverse").action = 'INVERT'
        layout.operator("paint.face_select_linked", text="Linked")


class VIEW3D_MT_Select_Paint_Mask_Vertex(Menu):
    bl_label = "Select"

    def draw(self, context):
        layout = self.layout
        layout.operator("view3d.select_border")
        layout.operator("view3d.select_circle")
        layout.operator("paint.vert_select_all").action = 'TOGGLE'
        layout.operator("paint.vert_select_all", text="Inverse").action = 'INVERT'
        layout.operator("paint.vert_select_ungrouped", text="Ungrouped Verts")


class VIEW3D_MT_Angle_Control(Menu):
    bl_label = "Angle Control"

    @classmethod
    def poll(cls, context):
        settings = UnifiedPaintPanel.paint_settings(context)
        if not settings:
            return False

        brush = settings.brush
        tex_slot = brush.texture_slot

        return tex_slot.has_texture_angle and tex_slot.has_texture_angle_source

    def draw(self, context):
        layout = self.layout

        settings = UnifiedPaintPanel.paint_settings(context)
        brush = settings.brush

        sculpt = (context.sculpt_object is not None)

        tex_slot = brush.texture_slot

        layout.prop(tex_slot, "use_rake", text="Rake")

        if brush.brush_capabilities.has_random_texture_angle and tex_slot.has_random_texture_angle:
            if sculpt:
                if brush.sculpt_capabilities.has_random_texture_angle:
                    layout.prop(tex_slot, "use_random", text="Random")
            else:
                layout.prop(tex_slot, "use_random", text="Random")


# Cursor Menu Operators #
class VIEW3D_OT_Pivot_Cursor(Operator):
    bl_idname = "view3d.pivot_cursor"
    bl_label = "Cursor as Pivot Point"
    bl_description = "Set Pivot Point back to Cursor"

    @classmethod
    def poll(cls, context):
        space = context.space_data
        return (hasattr(space, "pivot_point") and space.pivot_point != 'CURSOR')

    def execute(self, context):
        bpy.context.space_data.pivot_point = 'CURSOR'
        return {'FINISHED'}


class VIEW3D_OT_Revert_Pivot(Operator):
    bl_idname = "view3d.revert_pivot"
    bl_label = "Revert Pivot Point to Median"
    bl_description = "Set Pivot Point back to Median"

    @classmethod
    def poll(cls, context):
        space = context.space_data
        return (hasattr(space, "pivot_point") and space.pivot_point != 'MEDIAN_POINT')

    def execute(self, context):
        bpy.context.space_data.pivot_point = 'MEDIAN_POINT'
        return{'FINISHED'}


# Cursor Edge Intersection Defs #

def abs(val):
    if val > 0:
        return val
    return -val


def edgeIntersect(context, operator):
    from mathutils.geometry import intersect_line_line

    obj = context.active_object

    if (obj.type != "MESH"):
        operator.report({'ERROR'}, "Object must be a mesh")
        return None

    edges = []
    mesh = obj.data
    verts = mesh.vertices

    is_editmode = (obj.mode == 'EDIT')
    if is_editmode:
        bpy.ops.object.mode_set(mode='OBJECT')

    for e in mesh.edges:
        if e.select:
            edges.append(e)

            if len(edges) > 2:
                break

    if is_editmode:
        bpy.ops.object.mode_set(mode='EDIT')

    if len(edges) != 2:
        operator.report({'ERROR'},
                        "Operator requires exactly 2 edges to be selected")
        return

    line = intersect_line_line(verts[edges[0].vertices[0]].co,
                               verts[edges[0].vertices[1]].co,
                               verts[edges[1].vertices[0]].co,
                               verts[edges[1].vertices[1]].co)

    if line is None:
        operator.report({'ERROR'}, "Selected edges do not intersect")
        return

    point = line[0].lerp(line[1], 0.5)
    context.scene.cursor_location = obj.matrix_world * point


# Cursor Edge Intersection Operator #
class VIEW3D_OT_CursorToEdgeIntersection(Operator):
    bl_idname = "view3d.snap_cursor_to_edge_intersection"
    bl_label = "Cursor to Edge Intersection"
    bl_description = "Finds the mid-point of the shortest distance between two edges"

    @classmethod
    def poll(cls, context):
        obj = context.active_object
        return (obj is not None and obj.type == 'MESH')

    def execute(self, context):
        # Prevent unsupported Execution in Local View modes
        space_data = bpy.context.space_data
        if True in space_data.layers_local_view:
            self.report({'INFO'}, 'Global Perspective modes only unable to continue.')
            return {'FINISHED'}
        edgeIntersect(context, self)
        return {'FINISHED'}


# Set Mode Operator #
class SetObjectMode(Operator):
    bl_idname = "object.set_object_mode"
    bl_label = "Set the object interactive mode"
    bl_description = "I set the interactive mode of object"
    bl_options = {'REGISTER'}

    mode = StringProperty(
                    name="Interactive mode",
                    default="OBJECT"
                    )

    def execute(self, context):
        if (context.active_object):
            try:
                bpy.ops.object.mode_set(mode=self.mode)
            except TypeError:
                msg = context.active_object.name + ": It is not possible to enter into the interactive mode"
                self.report(type={"WARNING"}, message=msg)
        else:
            self.report(type={"WARNING"}, message="There is no active object")
        return {'FINISHED'}


# Origin To Selected Edit Mode #
def vfeOrigin(context):
    try:
        cursorPositionX = context.scene.cursor_location[0]
        cursorPositionY = context.scene.cursor_location[1]
        cursorPositionZ = context.scene.cursor_location[2]
        bpy.ops.view3d.snap_cursor_to_selected()
        bpy.ops.object.mode_set()
        bpy.ops.object.origin_set(type='ORIGIN_CURSOR', center='MEDIAN')
        bpy.ops.object.mode_set(mode='EDIT')
        context.scene.cursor_location[0] = cursorPositionX
        context.scene.cursor_location[1] = cursorPositionY
        context.scene.cursor_location[2] = cursorPositionZ
        return True
    except:
        return False


class SetOriginToSelected(Operator):
    bl_idname = "object.setorigintoselected"
    bl_label = "Set Origin to Selected"
    bl_description = "Set Origin to Selected"

    @classmethod
    def poll(cls, context):
        return (context.area.type == "VIEW_3D" and context.active_object is not None)

    def execute(self, context):
        check = vfeOrigin(context)
        if not check:
            self.report({"ERROR"}, "Set Origin to Selected could not be performed")
            return {'CANCELLED'}

        return {'FINISHED'}


# Code thanks to Isaac Weaver (wisaac) D1963
class SnapCursSelToCenter(Operator):
    bl_idname = "view3d.snap_cursor_selected_to_center"
    bl_label = "Snap Cursor & Selection to Center"
    bl_description = ("Snap 3D cursor and selected objects to the center \n"
                      "Works only in Object Mode")

    @classmethod
    def poll(cls, context):
        return (context.area.type == "VIEW_3D" and context.mode == "OBJECT")

    def execute(self, context):
        context.space_data.cursor_location = (0, 0, 0)
        for obj in context.selected_objects:
            obj.location = (0, 0, 0)
        return {'FINISHED'}


# Preferences utility functions

# Draw Separator #
def UseSeparator(operator, context):
    useSep = bpy.context.user_preferences.addons[__name__].preferences.use_separators
    if useSep:
        operator.layout.separator()


# Use compact brushes menus #
def UseBrushesLists():
    # separate function just for more convience
    useLists = bpy.context.user_preferences.addons[__name__].preferences.use_brushes_lists

    return bool(useLists)


# Addon Preferences #
class VIEW3D_MT_Space_Dynamic_Menu_Pref(AddonPreferences):
    bl_idname = __name__

    use_separators = BoolProperty(
                    name="Use Separators in the menus",
                    default=True,
                    description=("Use separators in the menus, a trade-off between \n"
                                 "readability vs. using more space for displaying items")
                    )
    use_brushes_lists = BoolProperty(
                    name="Use compact menus for brushes",
                    default=False,
                    description=("Use more compact menus instead  \n"
                                 "of thumbnails for displaying brushes")
                    )

    def draw(self, context):
        layout = self.layout
        row = layout.row(align=True)
        row.prop(self, "use_separators", toggle=True)
        row.prop(self, "use_brushes_lists", toggle=True)


# List The Classes #

classes = (
    VIEW3D_MT_Space_Dynamic_Menu,
    VIEW3D_MT_AddMenu,
    VIEW3D_MT_Object,
    VIEW3D_MT_Edit_Mesh,
    VIEW3D_MT_TransformMenu,
    VIEW3D_MT_TransformMenuEdit,
    VIEW3D_MT_TransformMenuArmature,
    VIEW3D_MT_TransformMenuArmatureEdit,
    VIEW3D_MT_TransformMenuArmaturePose,
    VIEW3D_MT_TransformMenuLite,
    VIEW3D_MT_TransformMenuCamera,
    VIEW3D_MT_MirrorMenu,
    VIEW3D_MT_ParentMenu,
    VIEW3D_MT_GroupMenu,
    VIEW3D_MT_Select_Object,
    VIEW3D_MT_Select_Object_More_Less,
    VIEW3D_MT_Select_Edit_Mesh,
    VIEW3D_MT_Edit_Mesh_Select_Similar,
    VIEW3D_MT_Edit_Mesh_Select_Trait,
    VIEW3D_MT_Edit_Mesh_Select_More_Less,
    VIEW3D_MT_Select_Edit_Curve,
    VIEW3D_MT_SelectArmatureMenu,
    VIEW3D_MT_Select_Pose,
    VIEW3D_MT_Select_Pose_More_Less,
    VIEW3D_MT_Pose,
    VIEW3D_MT_PoseCopy,
    VIEW3D_MT_PoseNames,
    VIEW3D_MT_Select_Edit_Surface,
    VIEW3D_MT_SelectMetaball,
    VIEW3D_MT_Select_Edit_Metaball,
    VIEW3D_MT_Select_Particle,
    VIEW3D_MT_Select_Edit_Lattice,
    VIEW3D_MT_Select_Edit_Armature,
    VIEW3D_MT_Select_Paint_Mask,
    VIEW3D_MT_Select_Paint_Mask_Vertex,
    VIEW3D_MT_Angle_Control,
    VIEW3D_MT_Edit_Multi,
    VIEW3D_MT_EditM_Edge,
    VIEW3D_MT_Edit_Curve,
    VIEW3D_MT_EditCurveCtrlpoints,
    VIEW3D_MT_EditCurveSegments,
    VIEW3D_MT_EditCurveSpecials,
    VIEW3D_MT_Edit_Armature,
    VIEW3D_MT_EditArmatureTK,
    VIEW3D_MT_KeyframeMenu,
    VIEW3D_OT_Pivot_Cursor,
    VIEW3D_OT_Revert_Pivot,
    VIEW3D_MT_CursorMenu,
    VIEW3D_MT_CursorMenuLite,
    VIEW3D_MT_EditCursorMenu,
    VIEW3D_OT_CursorToEdgeIntersection,
    VIEW3D_MT_UndoS,
    VIEW3D_MT_Camera_Options,
    InteractiveMode,
    InteractiveModeArmature,
    SetObjectMode,
    VIEW3D_MT_View_Directions,
    VIEW3D_MT_View_Border,
    VIEW3D_MT_View_Toggle,
    VIEW3D_MT_View_Menu,
    VIEW3D_MT_View_Navigation,
    VIEW3D_MT_View_Align,
    VIEW3D_MT_View_Align_Selected,
    VIEW3D_MT_View_Cameras,
    VIEW3D_MT_UV_Map,
    VIEW3D_MT_Pivot,
    VIEW3D_Snap_Context,
    VIEW3D_Snap_Origin,
    VIEW3D_MT_Shade,
    VIEW3D_MT_ManipulatorMenu1,
    SetOriginToSelected,
    VIEW3D_MT_Object_Data_Link,
    VIEW3D_MT_Duplicate,
    VIEW3D_MT_Space_Dynamic_Menu_Pref,
    VIEW3D_MT_Selection_Mode_Particle,
    VIEW3D_MT_AutoSmooth,
    VIEW3D_MT_Animation_Player,
    VIEW3D_OT_Interactive_Mode_Text,
    SnapCursSelToCenter,
    VIEW3D_MT_Sculpt_Specials,
    VIEW3D_MT_Brush_Settings,
    VIEW3D_MT_Brush_Selection,
    VIEW3D_MT_Sculpts,
    VIEW3D_MT_Hide_Masks,
    VIEW3D_OT_Display_Wire_All,
    VIEW3D_MT_Vertex_Colors,
    VIEW3D_MT_Paint_Weights,
    VIEW3D_OT_Interactive_Mode_Grease_Pencil,
    VIEW3D_MT_Edit_Gpencil,
    InteractiveModeOther,
)


# Register Classes & Hotkeys #
def register():
    for cls in classes:
        bpy.utils.register_class(cls)

    wm = bpy.context.window_manager
    kc = wm.keyconfigs.addon
    if kc:
        km = kc.keymaps.new(name='3D View', space_type='VIEW_3D')
        kmi = km.keymap_items.new('wm.call_menu', 'SPACE', 'PRESS')
        kmi.properties.name = "VIEW3D_MT_Space_Dynamic_Menu"


# Unregister Classes & Hotkeys #
def unregister():
    wm = bpy.context.window_manager
    kc = wm.keyconfigs.addon
    if kc:
        km = kc.keymaps['3D View']
        for kmi in km.keymap_items:
            if kmi.idname == 'wm.call_menu':
                if kmi.properties.name == "VIEW3D_MT_Space_Dynamic_Menu":
                    km.keymap_items.remove(kmi)
                    break
    for cls in classes:
        bpy.utils.unregister_class(cls)


if __name__ == "__main__":
    register()