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

properties_freestyle.py « bl_ui « startup « scripts « release - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e74e1725aa221328ec63db83c084187e6b766c6e (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
# SPDX-License-Identifier: GPL-2.0-or-later
import bpy
from bpy.types import Menu, Panel, UIList


# Render properties
class RenderFreestyleButtonsPanel:
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "render"
    # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here

    @classmethod
    def poll(cls, context):
        scene = context.scene
        with_freestyle = bpy.app.build_options.freestyle
        return scene and with_freestyle and (context.engine in cls.COMPAT_ENGINES)


class RENDER_PT_freestyle(RenderFreestyleButtonsPanel, Panel):
    bl_label = "Freestyle"
    bl_options = {'DEFAULT_CLOSED'}
    bl_order = 10
    COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}

    def draw_header(self, context):
        rd = context.scene.render
        self.layout.prop(rd, "use_freestyle", text="")

    def draw(self, context):
        layout = self.layout
        layout.use_property_split = True
        layout.use_property_decorate = False
        rd = context.scene.render
        layout.active = rd.use_freestyle
        layout.row().prop(rd, "line_thickness_mode", expand=True, text="Line Thickness Mode")
        if rd.line_thickness_mode == 'ABSOLUTE':
            layout.prop(rd, "line_thickness")


# Render layer properties


class ViewLayerFreestyleButtonsPanel:
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "view_layer"
    bl_order = 10
    # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here

    @classmethod
    def poll(cls, context):
        scene = context.scene
        rd = scene.render
        with_freestyle = bpy.app.build_options.freestyle

        return (
            scene
            and with_freestyle
            and rd.use_freestyle
            and (context.engine in cls.COMPAT_ENGINES)
        )


class ViewLayerFreestyleEditorButtonsPanel(ViewLayerFreestyleButtonsPanel):
    # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here

    @classmethod
    def poll(cls, context):
        if not super().poll(context):
            return False
        view_layer = context.view_layer
        return (
            view_layer
            and view_layer.use_freestyle
            and view_layer.freestyle_settings.mode == 'EDITOR'
        )


class ViewLayerFreestyleLineStyle(ViewLayerFreestyleEditorButtonsPanel):
    # Freestyle Linestyle Panels
    COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}

    @classmethod
    def poll(cls, context):
        if not super().poll(context):
            return False
        view_layer = context.view_layer
        lineset = view_layer.freestyle_settings.linesets.active
        if lineset is None:
            return False
        linestyle = lineset.linestyle
        if linestyle is None:
            return False

        return True


class ViewLayerFreestyleLinestyleStrokesSubPanel(ViewLayerFreestyleLineStyle):
    # Freestyle Linestyle Strokes sub panels
    bl_parent_id = "VIEWLAYER_PT_freestyle_linestyle_strokes"


class VIEWLAYER_UL_linesets(UIList):
    def draw_item(self, _context, layout, _data, item, icon, _active_data, _active_propname, index):
        lineset = item
        if self.layout_type in {'DEFAULT', 'COMPACT'}:
            layout.prop(lineset, "name", text="", emboss=False, icon_value=icon)
            layout.prop(lineset, "show_render", text="", index=index)
        elif self.layout_type == 'GRID':
            layout.alignment = 'CENTER'
            layout.label(text="", icon_value=icon)


class RENDER_MT_lineset_context_menu(Menu):
    bl_label = "Lineset Specials"

    def draw(self, _context):
        layout = self.layout
        layout.operator("scene.freestyle_lineset_copy", icon='COPYDOWN')
        layout.operator("scene.freestyle_lineset_paste", icon='PASTEDOWN')


class VIEWLAYER_PT_freestyle(ViewLayerFreestyleButtonsPanel, Panel):
    bl_label = "Freestyle"
    COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}

    def draw_header(self, context):
        view_layer = context.view_layer
        rd = context.scene.render

        layout = self.layout

        layout.active = rd.use_freestyle
        layout.prop(view_layer, "use_freestyle", text="")

    def draw(self, context):
        layout = self.layout
        layout.use_property_split = True
        layout.use_property_decorate = False

        view_layer = context.view_layer
        freestyle = view_layer.freestyle_settings

        layout.active = view_layer.use_freestyle

        col = layout.column(align=True)
        col.prop(freestyle, "mode", text="Control Mode")
        col.prop(freestyle, "use_view_map_cache", text="View Map Cache")
        col.prop(freestyle, "as_render_pass", text="As Render Pass")


class VIEWLAYER_PT_freestyle_edge_detection(ViewLayerFreestyleButtonsPanel, Panel):
    bl_label = "Edge Detection"
    bl_parent_id = "VIEWLAYER_PT_freestyle"
    COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}

    def draw(self, context):
        layout = self.layout
        layout.use_property_split = True
        layout.use_property_decorate = False

        view_layer = context.view_layer
        freestyle = view_layer.freestyle_settings

        layout.active = view_layer.use_freestyle

        col = layout.column()
        col.prop(freestyle, "crease_angle")
        col.prop(freestyle, "use_culling")
        col.prop(freestyle, "use_smoothness")

        if freestyle.mode == 'SCRIPT':
            col.prop(freestyle, "use_material_boundaries")

        if freestyle.mode == 'SCRIPT':
            col.prop(freestyle, "use_ridges_and_valleys")
            col.prop(freestyle, "use_suggestive_contours")
        col.prop(freestyle, "sphere_radius")
        col.prop(freestyle, "kr_derivative_epsilon")


class VIEWLAYER_PT_freestyle_style_modules(ViewLayerFreestyleButtonsPanel, Panel):
    bl_label = "Style Modules"
    bl_parent_id = "VIEWLAYER_PT_freestyle"
    COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}

    @classmethod
    def poll(cls, context):
        view_layer = context.view_layer
        freestyle = view_layer.freestyle_settings
        return freestyle.mode == 'SCRIPT'

    def draw(self, context):
        layout = self.layout
        layout.use_property_split = True
        layout.use_property_decorate = False

        view_layer = context.view_layer
        freestyle = view_layer.freestyle_settings

        layout.active = view_layer.use_freestyle

        col = layout.column()
        col.use_property_split = False
        row = col.row()
        row.operator("scene.freestyle_module_add", text="Add")
        for module in freestyle.modules:
            box = col.box()
            box.context_pointer_set("freestyle_module", module)
            row = box.row(align=True)
            row.prop(module, "use", text="")
            row.prop(module, "script", text="")
            row.operator("scene.freestyle_module_open", icon='FILEBROWSER', text="")
            row.operator("scene.freestyle_module_remove", icon='X', text="")
            row.operator("scene.freestyle_module_move", icon='TRIA_UP', text="").direction = 'UP'
            row.operator("scene.freestyle_module_move", icon='TRIA_DOWN', text="").direction = 'DOWN'


class VIEWLAYER_PT_freestyle_lineset(ViewLayerFreestyleEditorButtonsPanel, Panel):
    bl_label = "Freestyle Line Set"
    COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}

    def draw_edge_type_buttons(self, box, lineset, edge_type):
        # property names
        select_edge_type = "select_" + edge_type
        exclude_edge_type = "exclude_" + edge_type
        # draw edge type buttons
        row = box.row(align=True)
        row.prop(lineset, select_edge_type)
        sub = row.column(align=True)
        sub.prop(lineset, exclude_edge_type, text="")
        sub.active = getattr(lineset, select_edge_type)

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

        view_layer = context.view_layer
        freestyle = view_layer.freestyle_settings
        lineset = freestyle.linesets.active

        row = layout.row()

        is_sortable = len(freestyle.linesets) > 1
        rows = 3
        if is_sortable:
            rows = 5

        row.template_list(
            "VIEWLAYER_UL_linesets",
            "",
            freestyle,
            "linesets",
            freestyle.linesets,
            "active_index",
            rows=rows,
        )

        col = row.column(align=True)
        col.operator("scene.freestyle_lineset_add", icon='ADD', text="")
        col.operator("scene.freestyle_lineset_remove", icon='REMOVE', text="")

        col.separator()

        col.menu("RENDER_MT_lineset_context_menu", icon='DOWNARROW_HLT', text="")

        if is_sortable:
            col.separator()
            col.operator("scene.freestyle_lineset_move", icon='TRIA_UP', text="").direction = 'UP'
            col.operator("scene.freestyle_lineset_move", icon='TRIA_DOWN', text="").direction = 'DOWN'

        if lineset:
            layout.template_ID(lineset, "linestyle", new="scene.freestyle_linestyle_new")
            layout.separator()
            col = layout.column(heading="Select by")
            col.use_property_split = True
            col.use_property_decorate = False
            col.prop(lineset, "select_by_image_border", text="Image Border")


# Freestyle Lineset Sub Panels
class VIEWLAYER_PT_freestyle_lineset_visibilty(ViewLayerFreestyleLineStyle, Panel):
    bl_label = "Visibility"
    bl_parent_id = "VIEWLAYER_PT_freestyle_lineset"
    COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}

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

        view_layer = context.view_layer
        freestyle = view_layer.freestyle_settings
        lineset = freestyle.linesets.active

        layout.prop(lineset, "select_by_visibility", text="")

    def draw(self, context):
        layout = self.layout
        layout.use_property_split = True
        layout.use_property_decorate = False

        view_layer = context.view_layer
        freestyle = view_layer.freestyle_settings
        lineset = freestyle.linesets.active

        layout.active = lineset.select_by_visibility
        col = layout.column(align=True, heading="Type")
        col.prop(lineset, "visibility", text="Type", expand=False)

        if lineset.visibility == 'RANGE':
            col = layout.column(align=True)
            col.use_property_split = True
            col.prop(lineset, "qi_start")
            col.prop(lineset, "qi_end")


class VIEWLAYER_PT_freestyle_lineset_edgetype(ViewLayerFreestyleLineStyle, Panel):
    bl_label = "Edge Type"
    bl_parent_id = "VIEWLAYER_PT_freestyle_lineset"
    COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}

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

        view_layer = context.view_layer
        freestyle = view_layer.freestyle_settings
        lineset = freestyle.linesets.active

        layout.prop(lineset, "select_by_edge_types", text="")

    def draw_edge_type_buttons(self, box, lineset, edge_type):
        # property names
        select_edge_type = "select_" + edge_type
        exclude_edge_type = "exclude_" + edge_type
        # draw edge type buttons
        row = box.row(align=True)
        row.prop(lineset, select_edge_type)
        sub = row.column(align=True)
        sub.prop(lineset, exclude_edge_type, text="")
        sub.active = getattr(lineset, select_edge_type)

    def draw(self, context):
        layout = self.layout
        layout.use_property_split = True
        layout.use_property_decorate = False

        view_layer = context.view_layer
        freestyle = view_layer.freestyle_settings
        lineset = freestyle.linesets.active

        layout.active = lineset.select_by_edge_types
        layout.row().prop(lineset, "edge_type_negation", expand=True, text="Negation")
        layout.row().prop(lineset, "edge_type_combination", expand=True, text="Combination")

        col = layout.column(heading="Type")
        self.draw_edge_type_buttons(col, lineset, "silhouette")
        self.draw_edge_type_buttons(col, lineset, "crease")
        self.draw_edge_type_buttons(col, lineset, "border")
        self.draw_edge_type_buttons(col, lineset, "edge_mark")
        self.draw_edge_type_buttons(col, lineset, "contour")
        self.draw_edge_type_buttons(col, lineset, "external_contour")
        self.draw_edge_type_buttons(col, lineset, "material_boundary")
        self.draw_edge_type_buttons(col, lineset, "suggestive_contour")
        self.draw_edge_type_buttons(col, lineset, "ridge_valley")


class VIEWLAYER_PT_freestyle_lineset_facemarks(ViewLayerFreestyleLineStyle, Panel):
    bl_label = "Face Marks"
    bl_parent_id = "VIEWLAYER_PT_freestyle_lineset"
    COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
    bl_options = {'DEFAULT_CLOSED'}

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

        view_layer = context.view_layer
        freestyle = view_layer.freestyle_settings
        lineset = freestyle.linesets.active

        layout.prop(lineset, "select_by_face_marks", text="")

    def draw(self, context):
        layout = self.layout
        layout.use_property_split = True
        layout.use_property_decorate = False

        view_layer = context.view_layer
        freestyle = view_layer.freestyle_settings
        lineset = freestyle.linesets.active

        layout.active = lineset.select_by_face_marks
        layout.row().prop(lineset, "face_mark_negation", expand=True, text="Negation")
        layout.row().prop(lineset, "face_mark_condition", expand=True, text="Condition")


class VIEWLAYER_PT_freestyle_lineset_collection(ViewLayerFreestyleLineStyle, Panel):
    bl_label = "Collection"
    bl_parent_id = "VIEWLAYER_PT_freestyle_lineset"
    COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
    bl_options = {'DEFAULT_CLOSED'}

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

        view_layer = context.view_layer
        freestyle = view_layer.freestyle_settings
        lineset = freestyle.linesets.active

        layout.prop(lineset, "select_by_collection", text="")

    def draw(self, context):
        layout = self.layout
        layout.use_property_split = True
        layout.use_property_decorate = False

        view_layer = context.view_layer
        freestyle = view_layer.freestyle_settings
        lineset = freestyle.linesets.active

        layout.active = lineset.select_by_collection
        layout.row().prop(lineset, "collection", text="Line Set Collection")
        layout.row().prop(lineset, "collection_negation", expand=True, text="Negation")


# Linestyle Modifier Drawing code
def draw_modifier_box_header(box, modifier):
    row = box.row()
    row.use_property_split = False
    row.context_pointer_set("modifier", modifier)
    if modifier.expanded:
        icon = 'TRIA_DOWN'
    else:
        icon = 'TRIA_RIGHT'
    row.prop(modifier, "expanded", text="", icon=icon, emboss=False)

    sub = row.row(align=True)
    sub.prop(modifier, "name", text="")
    if modifier.use:
        icon = 'RESTRICT_RENDER_OFF'
    else:
        icon = 'RESTRICT_RENDER_ON'
    sub.prop(modifier, "use", text="", icon=icon)
    sub.operator("scene.freestyle_modifier_copy", icon='DUPLICATE', text="")

    sub = row.row(align=True)
    sub.operator("scene.freestyle_modifier_move", icon='TRIA_UP', text="").direction = 'UP'
    sub.operator("scene.freestyle_modifier_move", icon='TRIA_DOWN', text="").direction = 'DOWN'

    row.operator("scene.freestyle_modifier_remove", icon='X', text="", emboss=False)


def draw_modifier_box_error(box, _modifier, message):
    row = box.row()
    row.label(text=message, icon='ERROR')


def draw_modifier_common(box, modifier):
    col = box.column()
    col.prop(modifier, "blend", text="Blend Mode")
    col.prop(modifier, "influence")


def draw_modifier_color_ramp_common(box, modifier, has_range):
    box.template_color_ramp(modifier, "color_ramp", expand=True)
    if has_range:
        col = box.column(align=True)
        col.prop(modifier, "range_min", text="Range Min")
        col.prop(modifier, "range_max", text="Max")


def draw_modifier_curve_common(box, modifier, has_range, has_value):
    row = box.row()
    row.prop(modifier, "mapping", text="Mapping")
    if modifier.mapping == 'LINEAR':
        box.prop(modifier, "invert")
    if has_range:
        col = box.column(align=True)
        col.prop(modifier, "range_min", text="Range Min")
        col.prop(modifier, "range_max", text="Max")
    if has_value:
        col = box.column(align=True)
        col.prop(modifier, "value_min", text="Value Min")
        col.prop(modifier, "value_max", text="Max")
    if modifier.mapping == 'CURVE':
        box.template_curve_mapping(modifier, "curve")


class VIEWLAYER_PT_freestyle_linestyle_strokes(ViewLayerFreestyleLineStyle, Panel):
    bl_label = "Freestyle Strokes"
    bl_options = {'DEFAULT_CLOSED'}

    def draw(self, context):
        layout = self.layout
        layout.use_property_split = True
        layout.use_property_decorate = False

        view_layer = context.view_layer
        lineset = view_layer.freestyle_settings.linesets.active

        layout.active = view_layer.use_freestyle

        if lineset is None:
            return
        linestyle = lineset.linestyle

        if linestyle is None:
            return

        row = layout.row(align=True)
        row.alignment = 'LEFT'
        row.label(text=lineset.name, icon='LINE_DATA')
        row.label(text="", icon='RIGHTARROW')
        row.label(text=linestyle.name)

        col = layout.column(align=True)
        col.prop(linestyle, "caps", expand=False)


class VIEWLAYER_PT_freestyle_linestyle_strokes_chaining(ViewLayerFreestyleLinestyleStrokesSubPanel, Panel):
    bl_label = "Chaining"

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

        view_layer = context.view_layer
        freestyle = view_layer.freestyle_settings
        lineset = freestyle.linesets.active

        linestyle = lineset.linestyle
        layout.prop(linestyle, "use_chaining", text="")

    def draw(self, context):
        layout = self.layout
        layout.use_property_split = True
        layout.use_property_decorate = False

        view_layer = context.view_layer
        lineset = view_layer.freestyle_settings.linesets.active
        linestyle = lineset.linestyle

        layout.active = linestyle.use_chaining
        layout.row().prop(linestyle, "chaining", expand=True, text="Method")
        if linestyle.chaining == 'SKETCHY':
            layout.prop(linestyle, "rounds")
        layout.prop(linestyle, "use_same_object")


class VIEWLAYER_PT_freestyle_linestyle_strokes_splitting(ViewLayerFreestyleLinestyleStrokesSubPanel, Panel):
    bl_label = "Splitting"
    bl_options = {'DEFAULT_CLOSED'}

    def draw(self, context):
        layout = self.layout
        layout.use_property_split = True
        layout.use_property_decorate = False

        view_layer = context.view_layer
        lineset = view_layer.freestyle_settings.linesets.active
        linestyle = lineset.linestyle

        row = layout.row(align=False, heading="Min 2D Angle")
        row.prop(linestyle, "use_angle_min", text="")
        sub = row.row()
        sub.active = linestyle.use_angle_min
        sub.prop(linestyle, "angle_min", text="")

        row = layout.row(align=False, heading="Max 2D Angle")
        row.prop(linestyle, "use_angle_max", text="")
        sub = row.row()
        sub.active = linestyle.use_angle_max
        sub.prop(linestyle, "angle_max", text="")

        row = layout.row(align=False, heading="2D Length")
        row.prop(linestyle, "use_split_length", text="")
        sub = row.row()
        sub.active = linestyle.use_split_length
        sub.prop(linestyle, "split_length", text="")

        layout.prop(linestyle, "material_boundary")


class VIEWLAYER_PT_freestyle_linestyle_strokes_splitting_pattern(ViewLayerFreestyleLinestyleStrokesSubPanel, Panel):
    bl_label = "Split Pattern"
    bl_parent_id = "VIEWLAYER_PT_freestyle_linestyle_strokes_splitting"
    bl_options = {'DEFAULT_CLOSED'}

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

        view_layer = context.view_layer
        freestyle = view_layer.freestyle_settings
        lineset = freestyle.linesets.active

        linestyle = lineset.linestyle
        layout.prop(linestyle, "use_split_pattern", text="")

    def draw(self, context):
        layout = self.layout
        layout.use_property_split = True
        layout.use_property_decorate = False

        view_layer = context.view_layer
        lineset = view_layer.freestyle_settings.linesets.active
        linestyle = lineset.linestyle

        layout.active = linestyle.use_split_pattern

        col = layout.column(align=True)
        col.prop(linestyle, "split_dash1", text="Dash 1")
        col.prop(linestyle, "split_dash2", text="2")
        col.prop(linestyle, "split_dash3", text="3")
        col = layout.column(align=True)
        col.prop(linestyle, "split_gap1", text="Gap 1")
        col.prop(linestyle, "split_gap2", text="2")
        col.prop(linestyle, "split_gap3", text="3")


class VIEWLAYER_PT_freestyle_linestyle_strokes_sorting(ViewLayerFreestyleLinestyleStrokesSubPanel, Panel):
    bl_label = "Sorting"
    bl_options = {'DEFAULT_CLOSED'}

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

        view_layer = context.view_layer
        freestyle = view_layer.freestyle_settings
        lineset = freestyle.linesets.active

        linestyle = lineset.linestyle
        layout.prop(linestyle, "use_sorting", text="")

    def draw(self, context):
        layout = self.layout
        layout.use_property_split = True
        layout.use_property_decorate = False

        view_layer = context.view_layer
        freestyle = view_layer.freestyle_settings
        lineset = freestyle.linesets.active

        linestyle = lineset.linestyle

        layout.active = linestyle.use_sorting

        layout.prop(linestyle, "sort_key")

        row = layout.row()
        row.active = linestyle.sort_key in {
            'DISTANCE_FROM_CAMERA',
            'PROJECTED_X',
            'PROJECTED_Y',
        }
        row.prop(linestyle, "integration_type")
        layout.row().prop(linestyle, "sort_order", expand=True, text="Sort Order")


class VIEWLAYER_PT_freestyle_linestyle_strokes_selection(ViewLayerFreestyleLinestyleStrokesSubPanel, Panel):
    bl_label = "Selection"
    bl_options = {'DEFAULT_CLOSED'}

    def draw(self, context):
        layout = self.layout
        layout.use_property_split = True
        layout.use_property_decorate = False

        view_layer = context.view_layer
        lineset = view_layer.freestyle_settings.linesets.active
        linestyle = lineset.linestyle

        row = layout.row(align=False, heading="Min 2D Length")
        row.prop(linestyle, "use_length_min", text="")
        sub = row.row()
        sub.active = linestyle.use_length_min
        sub.prop(linestyle, "length_min", text="")

        row = layout.row(align=False, heading="Max 2D Length")
        row.prop(linestyle, "use_length_max", text="")
        sub = row.row()
        sub.active = linestyle.use_length_max
        sub.prop(linestyle, "length_max", text="")

        row = layout.row(align=False, heading="Chain Count")
        row.prop(linestyle, "use_chain_count", text="")
        sub = row.row()
        sub.active = linestyle.use_chain_count
        sub.prop(linestyle, "chain_count", text="")


class VIEWLAYER_PT_freestyle_linestyle_strokes_dashedline(ViewLayerFreestyleLinestyleStrokesSubPanel, Panel):
    bl_label = "Dashed Line"
    bl_options = {'DEFAULT_CLOSED'}

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

        view_layer = context.view_layer
        freestyle = view_layer.freestyle_settings
        lineset = freestyle.linesets.active

        linestyle = lineset.linestyle
        layout.prop(linestyle, "use_dashed_line", text="")

    def draw(self, context):
        layout = self.layout
        layout.use_property_split = True
        layout.use_property_decorate = False

        view_layer = context.view_layer
        lineset = view_layer.freestyle_settings.linesets.active
        linestyle = lineset.linestyle

        layout.active = linestyle.use_dashed_line

        col = layout.column(align=True)
        col.prop(linestyle, "dash1", text="Dash 1")
        col.prop(linestyle, "dash2", text="2")
        col.prop(linestyle, "dash3", text="3")
        col = layout.column(align=True)
        col.prop(linestyle, "gap1", text="Gap 1")
        col.prop(linestyle, "gap2", text="2")
        col.prop(linestyle, "gap3", text="3")


class VIEWLAYER_PT_freestyle_linestyle_color(ViewLayerFreestyleLineStyle, Panel):
    bl_label = "Freestyle Color"
    bl_options = {'DEFAULT_CLOSED'}

    def draw_color_modifier(self, context, modifier):
        layout = self.layout

        col = layout.column(align=True)
        draw_modifier_box_header(col.box(), modifier)
        if modifier.expanded:
            box = col.box()
            draw_modifier_common(box, modifier)

            if modifier.type == 'ALONG_STROKE':
                draw_modifier_color_ramp_common(box, modifier, False)

            elif modifier.type == 'DISTANCE_FROM_OBJECT':
                box.prop(modifier, "target")
                draw_modifier_color_ramp_common(box, modifier, True)
                prop = box.operator("scene.freestyle_fill_range_by_selection")
                prop.type = 'COLOR'
                prop.name = modifier.name

            elif modifier.type == 'DISTANCE_FROM_CAMERA':
                draw_modifier_color_ramp_common(box, modifier, True)
                prop = box.operator("scene.freestyle_fill_range_by_selection")
                prop.type = 'COLOR'
                prop.name = modifier.name

            elif modifier.type == 'MATERIAL':
                row = box.row()
                row.prop(modifier, "material_attribute",
                         text="Material Attribute")
                sub = box.column()
                sub.prop(modifier, "use_ramp")
                if modifier.material_attribute in {'LINE', 'DIFF', 'SPEC'}:
                    sub.active = True
                    show_ramp = modifier.use_ramp
                else:
                    sub.active = False
                    show_ramp = True
                if show_ramp:
                    draw_modifier_color_ramp_common(box, modifier, False)

            elif modifier.type == 'TANGENT':
                draw_modifier_color_ramp_common(box, modifier, False)

            elif modifier.type == 'NOISE':
                subcol = box.column(align=True)
                subcol.prop(modifier, "amplitude")
                subcol.prop(modifier, "period")
                subcol.prop(modifier, "seed")
                draw_modifier_color_ramp_common(box, modifier, False)

            elif modifier.type == 'CREASE_ANGLE':
                subcol = box.column(align=True)
                subcol.prop(modifier, "angle_min", text="Angle Min")
                subcol.prop(modifier, "angle_max", text="Max")
                draw_modifier_color_ramp_common(box, modifier, False)

            elif modifier.type == 'CURVATURE_3D':
                subcol = box.column(align=True)
                subcol.prop(modifier, "curvature_min", text="Curvature Min")
                subcol.prop(modifier, "curvature_max", text="Max")

                draw_modifier_color_ramp_common(box, modifier, False)

                freestyle = context.view_layer.freestyle_settings
                if not freestyle.use_smoothness:
                    message = "Enable Face Smoothness to use this modifier"
                    draw_modifier_box_error(col.box(), modifier, message)

    def draw(self, context):
        layout = self.layout
        layout.use_property_split = True
        layout.use_property_decorate = False

        view_layer = context.view_layer
        lineset = view_layer.freestyle_settings.linesets.active

        layout.active = view_layer.use_freestyle

        if lineset is None:
            return
        linestyle = lineset.linestyle

        if linestyle is None:
            return

        row = layout.row(align=True)
        row.alignment = 'LEFT'
        row.label(text=lineset.name, icon='LINE_DATA')
        row.label(text="", icon='RIGHTARROW')
        row.label(text=linestyle.name)

        col = layout.column()
        row = col.row()
        row.prop(linestyle, "color", text="Base Color")
        col.operator_menu_enum("scene.freestyle_color_modifier_add", "type", text="Add Modifier")
        for modifier in linestyle.color_modifiers:
            self.draw_color_modifier(context, modifier)


class VIEWLAYER_PT_freestyle_linestyle_alpha(ViewLayerFreestyleLineStyle, Panel):
    bl_label = "Freestyle Alpha"
    bl_options = {'DEFAULT_CLOSED'}

    def draw_alpha_modifier(self, context, modifier):
        layout = self.layout

        col = layout.column(align=True)
        draw_modifier_box_header(col.box(), modifier)
        if modifier.expanded:
            box = col.box()
            draw_modifier_common(box, modifier)

            if modifier.type == 'ALONG_STROKE':
                draw_modifier_curve_common(box, modifier, False, False)

            elif modifier.type == 'DISTANCE_FROM_OBJECT':
                box.prop(modifier, "target")
                draw_modifier_curve_common(box, modifier, True, False)
                prop = box.operator("scene.freestyle_fill_range_by_selection")
                prop.type = 'ALPHA'
                prop.name = modifier.name

            elif modifier.type == 'DISTANCE_FROM_CAMERA':
                draw_modifier_curve_common(box, modifier, True, False)
                prop = box.operator("scene.freestyle_fill_range_by_selection")
                prop.type = 'ALPHA'
                prop.name = modifier.name

            elif modifier.type == 'MATERIAL':
                box.prop(modifier, "material_attribute", text="Material Attribute")
                draw_modifier_curve_common(box, modifier, False, False)

            elif modifier.type == 'TANGENT':
                draw_modifier_curve_common(box, modifier, False, False)

            elif modifier.type == 'NOISE':
                col = box.column(align=True)
                col.prop(modifier, "amplitude")
                col.prop(modifier, "period")
                col.prop(modifier, "seed")
                draw_modifier_curve_common(box, modifier, False, False)

            elif modifier.type == 'CREASE_ANGLE':
                col = box.column(align=True)
                col.prop(modifier, "angle_min", text="Angle Min")
                col.prop(modifier, "angle_max", text="Max")
                draw_modifier_curve_common(box, modifier, False, False)

            elif modifier.type == 'CURVATURE_3D':
                draw_modifier_curve_common(box, modifier, False, False)

                subcol = box.column(align=True)
                subcol.prop(modifier, "curvature_min", text="Curvature Min")
                subcol.prop(modifier, "curvature_max", text="Max")

                freestyle = context.view_layer.freestyle_settings
                if not freestyle.use_smoothness:
                    message = "Enable Face Smoothness to use this modifier"
                    draw_modifier_box_error(col.box(), modifier, message)

    def draw(self, context):
        layout = self.layout
        layout.use_property_split = True
        layout.use_property_decorate = False

        view_layer = context.view_layer
        lineset = view_layer.freestyle_settings.linesets.active

        layout.active = view_layer.use_freestyle

        if lineset is None:
            return
        linestyle = lineset.linestyle

        if linestyle is None:
            return

        row = layout.row(align=True)
        row.alignment = 'LEFT'
        row.label(text=lineset.name, icon='LINE_DATA')
        row.label(text="", icon='RIGHTARROW')
        row.label(text=linestyle.name)

        col = layout.column()
        row = col.row()
        row.prop(linestyle, "alpha", text="Base Transparency")
        col.operator_menu_enum("scene.freestyle_alpha_modifier_add", "type", text="Add Modifier")
        for modifier in linestyle.alpha_modifiers:
            self.draw_alpha_modifier(context, modifier)


class VIEWLAYER_PT_freestyle_linestyle_thickness(ViewLayerFreestyleLineStyle, Panel):
    bl_label = "Freestyle Thickness"
    bl_options = {'DEFAULT_CLOSED'}

    def draw_thickness_modifier(self, context, modifier):
        layout = self.layout

        col = layout.column(align=True)
        draw_modifier_box_header(col.box(), modifier)
        if modifier.expanded:
            box = col.box()
            draw_modifier_common(box, modifier)

            if modifier.type == 'ALONG_STROKE':
                draw_modifier_curve_common(box, modifier, False, True)

            elif modifier.type == 'DISTANCE_FROM_OBJECT':
                box.prop(modifier, "target")
                draw_modifier_curve_common(box, modifier, True, True)
                prop = box.operator("scene.freestyle_fill_range_by_selection")
                prop.type = 'THICKNESS'
                prop.name = modifier.name

            elif modifier.type == 'DISTANCE_FROM_CAMERA':
                draw_modifier_curve_common(box, modifier, True, True)
                prop = box.operator("scene.freestyle_fill_range_by_selection")
                prop.type = 'THICKNESS'
                prop.name = modifier.name

            elif modifier.type == 'MATERIAL':
                box.prop(modifier, "material_attribute", text="Material Attribute")
                draw_modifier_curve_common(box, modifier, False, True)

            elif modifier.type == 'CALLIGRAPHY':
                box.prop(modifier, "orientation")
                subcol = box.column(align=True)
                subcol.prop(modifier, "thickness_min", text="Thickness Min")
                subcol.prop(modifier, "thickness_max", text="Max")

            elif modifier.type == 'TANGENT':
                self.mapping = 'CURVE'
                subcol = box.column(align=True)
                subcol.prop(modifier, "thickness_min", text="Thickness Min")
                subcol.prop(modifier, "thickness_max", text="Max")

                draw_modifier_curve_common(box, modifier, False, False)

            elif modifier.type == 'NOISE':
                col = box.column(align=True)
                col.prop(modifier, "amplitude")
                col.prop(modifier, "period")

                col = box.column(align=True)
                col.prop(modifier, "seed")
                col.prop(modifier, "use_asymmetric")

            elif modifier.type == 'CREASE_ANGLE':
                col = box.column(align=True)
                col.prop(modifier, "thickness_min", text="Thickness Min")
                col.prop(modifier, "thickness_max", text="Max")

                col = box.column(align=True)
                col.prop(modifier, "angle_min", text="Angle Min")
                col.prop(modifier, "angle_max", text="Max")

                draw_modifier_curve_common(box, modifier, False, False)

            elif modifier.type == 'CURVATURE_3D':
                subcol = box.column(align=True)
                subcol.prop(modifier, "thickness_min", text="Thickness Min")
                subcol.prop(modifier, "thickness_max", text="Max")

                subcol = box.column(align=True)
                subcol.prop(modifier, "curvature_min")
                subcol.prop(modifier, "curvature_max")

                draw_modifier_curve_common(box, modifier, False, False)

                freestyle = context.view_layer.freestyle_settings
                if not freestyle.use_smoothness:
                    message = "Enable Face Smoothness to use this modifier"
                    draw_modifier_box_error(col.box(), modifier, message)

    def draw(self, context):
        layout = self.layout
        layout.use_property_split = True
        layout.use_property_decorate = False

        view_layer = context.view_layer
        lineset = view_layer.freestyle_settings.linesets.active

        layout.active = view_layer.use_freestyle

        if lineset is None:
            return
        linestyle = lineset.linestyle

        if linestyle is None:
            return

        row = layout.row(align=True)
        row.alignment = 'LEFT'
        row.label(text=lineset.name, icon='LINE_DATA')
        row.label(text="", icon='RIGHTARROW')
        row.label(text=linestyle.name)

        col = layout.column()
        row = col.row()
        row.prop(linestyle, "thickness", text="Base Thickness")
        subcol = col.column()
        subcol.active = linestyle.chaining == 'PLAIN' and linestyle.use_same_object
        row = subcol.row()
        row.prop(linestyle, "thickness_position", expand=False)

        if linestyle.thickness_position == 'RELATIVE':
            row = subcol.row()
            row.prop(linestyle, "thickness_ratio")

        col = layout.column()
        col.operator_menu_enum("scene.freestyle_thickness_modifier_add", "type", text="Add Modifier")
        for modifier in linestyle.thickness_modifiers:
            self.draw_thickness_modifier(context, modifier)


class VIEWLAYER_PT_freestyle_linestyle_geometry(ViewLayerFreestyleLineStyle, Panel):
    bl_label = "Freestyle Geometry"
    bl_options = {'DEFAULT_CLOSED'}

    def draw_geometry_modifier(self, _context, modifier):
        layout = self.layout

        col = layout.column(align=True)
        draw_modifier_box_header(col.box(), modifier)
        if modifier.expanded:
            box = col.box()

            if modifier.type == 'SAMPLING':
                box.prop(modifier, "sampling")

            elif modifier.type == 'BEZIER_CURVE':
                box.prop(modifier, "error")

            elif modifier.type == 'SINUS_DISPLACEMENT':
                col = box.column(align=True)
                col.prop(modifier, "wavelength")
                col.prop(modifier, "amplitude")

                col = box.column(align=True)
                col.prop(modifier, "phase")

            elif modifier.type == 'SPATIAL_NOISE':
                col = box.column(align=True)
                col.prop(modifier, "amplitude")
                col.prop(modifier, "scale")
                col.prop(modifier, "octaves")

                col = box.column(align=True)
                col.prop(modifier, "smooth")
                col.prop(modifier, "use_pure_random")

            elif modifier.type == 'PERLIN_NOISE_1D':
                col = box.column(align=True)
                col.prop(modifier, "frequency")
                col.prop(modifier, "amplitude")
                col.prop(modifier, "seed")

                col = box.column(align=True)
                col.prop(modifier, "octaves")
                col.prop(modifier, "angle")

            elif modifier.type == 'PERLIN_NOISE_2D':
                col = box.column(align=True)
                col.prop(modifier, "frequency")
                col.prop(modifier, "amplitude")
                col.prop(modifier, "seed")

                col = box.column(align=True)
                col.prop(modifier, "octaves")
                col.prop(modifier, "angle")

            elif modifier.type == 'BACKBONE_STRETCHER':
                box.prop(modifier, "backbone_length")

            elif modifier.type == 'TIP_REMOVER':
                box.prop(modifier, "tip_length")

            elif modifier.type == 'POLYGONIZATION':
                box.prop(modifier, "error")

            elif modifier.type == 'GUIDING_LINES':
                box.prop(modifier, "offset")

            elif modifier.type == 'BLUEPRINT':
                row = box.row()
                row.prop(modifier, "shape", expand=True)
                box.prop(modifier, "rounds")
                subcol = box.column(align=True)
                if modifier.shape in {'CIRCLES', 'ELLIPSES'}:
                    subcol.prop(modifier, "random_radius", text="Random Radius")
                    subcol.prop(modifier, "random_center", text="Center")
                elif modifier.shape == 'SQUARES':
                    subcol.prop(modifier, "backbone_length", text="Backbone Length")
                    subcol.prop(modifier, "random_backbone", text="Randomness")

            elif modifier.type == '2D_OFFSET':
                subcol = box.column(align=True)
                subcol.prop(modifier, "start")
                subcol.prop(modifier, "end")

                subcol = box.column(align=True)
                subcol.prop(modifier, "x")
                subcol.prop(modifier, "y")

            elif modifier.type == '2D_TRANSFORM':
                box.prop(modifier, "pivot")
                if modifier.pivot == 'PARAM':
                    box.prop(modifier, "pivot_u")
                elif modifier.pivot == 'ABSOLUTE':
                    subcol = box.column(align=True)
                    subcol.prop(modifier, "pivot_x", text="Pivot X")
                    subcol.prop(modifier, "pivot_y", text="Y")
                subcol = box.column(align=True)
                subcol.prop(modifier, "scale_x", text="Scale X")
                subcol.prop(modifier, "scale_y", text="Y")
                box.prop(modifier, "angle")

            elif modifier.type == 'SIMPLIFICATION':
                box.prop(modifier, "tolerance")

    def draw(self, context):
        layout = self.layout
        layout.use_property_split = True
        layout.use_property_decorate = False

        view_layer = context.view_layer
        lineset = view_layer.freestyle_settings.linesets.active

        layout.active = view_layer.use_freestyle

        if lineset is None:
            return
        linestyle = lineset.linestyle

        if linestyle is None:
            return

        row = layout.row(align=True)
        row.alignment = 'LEFT'
        row.label(text=lineset.name, icon='LINE_DATA')
        row.label(text="", icon='RIGHTARROW')
        row.label(text=linestyle.name)

        col = layout.column()
        col.operator_menu_enum("scene.freestyle_geometry_modifier_add", "type", text="Add Modifier")
        for modifier in linestyle.geometry_modifiers:
            self.draw_geometry_modifier(context, modifier)


class VIEWLAYER_PT_freestyle_linestyle_texture(ViewLayerFreestyleLineStyle, Panel):
    bl_label = "Freestyle Texture"
    bl_options = {'DEFAULT_CLOSED'}

    def draw(self, context):
        layout = self.layout
        layout.use_property_split = True
        layout.use_property_decorate = False

        view_layer = context.view_layer
        lineset = view_layer.freestyle_settings.linesets.active

        layout.active = view_layer.use_freestyle

        if lineset is None:
            return
        linestyle = lineset.linestyle

        if linestyle is None:
            return

        row = layout.row(align=True)
        row.alignment = 'LEFT'
        row.label(text=lineset.name, icon='LINE_DATA')
        row.label(text="", icon='RIGHTARROW')
        row.label(text=linestyle.name)

        layout.prop(linestyle, "use_nodes")
        layout.prop(linestyle, "texture_spacing", text="Spacing Along Stroke")

        row = layout.row()
        props = row.operator(
            "wm.properties_context_change",
            text="Go to Linestyle Textures Properties",
            icon='TEXTURE',
        )
        props.context = 'TEXTURE'


# Material properties
class MaterialFreestyleButtonsPanel:
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "material"
    # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here

    @classmethod
    def poll(cls, context):
        scene = context.scene
        material = context.material
        with_freestyle = bpy.app.build_options.freestyle
        return (
            with_freestyle
            and material
            and scene
            and scene.render.use_freestyle
            and (context.engine in cls.COMPAT_ENGINES)
        )


class MATERIAL_PT_freestyle_line(MaterialFreestyleButtonsPanel, Panel):
    bl_label = "Freestyle Line"
    bl_options = {'DEFAULT_CLOSED'}
    COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}

    def draw(self, context):
        layout = self.layout
        layout.use_property_split = True
        layout.use_property_decorate = False

        mat = context.material

        col = layout.column()
        col.prop(mat, "line_color")
        col.prop(mat, "line_priority", text="Priority")


classes = (
    RENDER_PT_freestyle,
    VIEWLAYER_UL_linesets,
    RENDER_MT_lineset_context_menu,
    VIEWLAYER_PT_freestyle,
    VIEWLAYER_PT_freestyle_edge_detection,
    VIEWLAYER_PT_freestyle_style_modules,
    VIEWLAYER_PT_freestyle_lineset,
    VIEWLAYER_PT_freestyle_lineset_visibilty,
    VIEWLAYER_PT_freestyle_lineset_edgetype,
    VIEWLAYER_PT_freestyle_lineset_facemarks,
    VIEWLAYER_PT_freestyle_lineset_collection,
    VIEWLAYER_PT_freestyle_linestyle_strokes,
    VIEWLAYER_PT_freestyle_linestyle_strokes_chaining,
    VIEWLAYER_PT_freestyle_linestyle_strokes_splitting,
    VIEWLAYER_PT_freestyle_linestyle_strokes_splitting_pattern,
    VIEWLAYER_PT_freestyle_linestyle_strokes_sorting,
    VIEWLAYER_PT_freestyle_linestyle_strokes_selection,
    VIEWLAYER_PT_freestyle_linestyle_strokes_dashedline,
    VIEWLAYER_PT_freestyle_linestyle_color,
    VIEWLAYER_PT_freestyle_linestyle_alpha,
    VIEWLAYER_PT_freestyle_linestyle_thickness,
    VIEWLAYER_PT_freestyle_linestyle_geometry,
    VIEWLAYER_PT_freestyle_linestyle_texture,
    MATERIAL_PT_freestyle_line,
)

if __name__ == "__main__":  # only for live edit.
    from bpy.utils import register_class

    for cls in classes:
        register_class(cls)