2d91c99800715395844a0625d67474f8903a18f3
[blender-staging.git] / release / scripts / startup / bl_ui / properties_freestyle.py
1 # ##### BEGIN GPL LICENSE BLOCK #####
2 #
3 #  This program is free software; you can redistribute it and/or
4 #  modify it under the terms of the GNU General Public License
5 #  as published by the Free Software Foundation; either version 2
6 #  of the License, or (at your option) any later version.
7 #
8 #  This program is distributed in the hope that it will be useful,
9 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 #  GNU General Public License for more details.
12 #
13 #  You should have received a copy of the GNU General Public License
14 #  along with this program; if not, write to the Free Software Foundation,
15 #  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 #
17 # ##### END GPL LICENSE BLOCK #####
18
19 # <pep8 compliant>
20 import bpy
21 from bpy.types import Menu, Panel, UIList
22
23
24 # Render properties
25
26 class RenderFreestyleButtonsPanel:
27     bl_space_type = 'PROPERTIES'
28     bl_region_type = 'WINDOW'
29     bl_context = "render"
30     # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here
31
32     @classmethod
33     def poll(cls, context):
34         scene = context.scene
35         with_freestyle = bpy.app.build_options.freestyle
36         return scene and with_freestyle and(scene.render.engine in cls.COMPAT_ENGINES)
37
38
39 class RENDER_PT_freestyle(RenderFreestyleButtonsPanel, Panel):
40     bl_label = "Freestyle"
41     bl_options = {'DEFAULT_CLOSED'}
42     COMPAT_ENGINES = {'BLENDER_RENDER'}
43
44     def draw_header(self, context):
45         rd = context.scene.render
46         self.layout.prop(rd, "use_freestyle", text="")
47
48     def draw(self, context):
49         layout = self.layout
50
51         rd = context.scene.render
52
53         layout.active = rd.use_freestyle
54
55         row = layout.row()
56         row.label(text="Line Thickness:")
57         row.prop(rd, "line_thickness_mode", expand=True)
58
59         if (rd.line_thickness_mode == 'ABSOLUTE'):
60             layout.prop(rd, "line_thickness")
61
62
63 # Render layer properties
64
65 class RenderLayerFreestyleButtonsPanel:
66     bl_space_type = 'PROPERTIES'
67     bl_region_type = 'WINDOW'
68     bl_context = "render_layer"
69     # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here
70
71     @classmethod
72     def poll(cls, context):
73         scene = context.scene
74         rd = context.scene.render
75         with_freestyle = bpy.app.build_options.freestyle
76
77         return (scene and with_freestyle and rd.use_freestyle
78             and rd.layers.active and(scene.render.engine in cls.COMPAT_ENGINES))
79
80
81 class RenderLayerFreestyleEditorButtonsPanel(RenderLayerFreestyleButtonsPanel):
82     # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here
83
84     @classmethod
85     def poll(cls, context):
86         if not super().poll(context):
87             return False
88         rl = context.scene.render.layers.active
89         return rl and rl.freestyle_settings.mode == 'EDITOR'
90
91
92 class RENDERLAYER_UL_linesets(UIList):
93     def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
94         lineset = item
95         if self.layout_type in {'DEFAULT', 'COMPACT'}:
96             layout.prop(lineset, "name", text="", emboss=False, icon_value=icon)
97             layout.prop(lineset, "show_render", text="", index=index)
98         elif self.layout_type in {'GRID'}:
99             layout.alignment = 'CENTER'
100             layout.label("", icon_value=icon)
101
102
103 class RENDER_MT_lineset_specials(Menu):
104     bl_label = "Lineset Specials"
105
106     def draw(self, context):
107         layout = self.layout
108         layout.operator("scene.freestyle_lineset_copy", icon='COPYDOWN')
109         layout.operator("scene.freestyle_lineset_paste", icon='PASTEDOWN')
110
111
112 class RENDERLAYER_PT_freestyle(RenderLayerFreestyleButtonsPanel, Panel):
113     bl_label = "Freestyle"
114     COMPAT_ENGINES = {'BLENDER_RENDER'}
115
116     def draw(self, context):
117         layout = self.layout
118
119         rd = context.scene.render
120         rl = rd.layers.active
121         freestyle = rl.freestyle_settings
122
123         layout.active = rl.use_freestyle
124
125         row = layout.row()
126         layout.prop(freestyle, "mode", text="Control mode")
127         layout.prop(freestyle, "use_view_map_cache", text="View Map Cache")
128         layout.label(text="Edge Detection Options:")
129
130         split = layout.split()
131
132         col = split.column()
133         col.prop(freestyle, "crease_angle")
134         col.prop(freestyle, "use_culling")
135         col.prop(freestyle, "use_advanced_options")
136
137         col = split.column()
138         col.prop(freestyle, "use_smoothness")
139         if freestyle.mode == 'SCRIPT':
140             col.prop(freestyle, "use_material_boundaries")
141
142         # Advanced options are hidden by default to warn new users
143         if freestyle.use_advanced_options:
144             if freestyle.mode == 'SCRIPT':
145                 row = layout.row()
146                 row.prop(freestyle, "use_ridges_and_valleys")
147                 row.prop(freestyle, "use_suggestive_contours")
148             row = layout.row()
149             row.prop(freestyle, "sphere_radius")
150             row.prop(freestyle, "kr_derivative_epsilon")
151
152         if freestyle.mode == 'SCRIPT':
153             row = layout.row()
154             row.label("Style modules:")
155             row.operator("scene.freestyle_module_add", text="Add")
156             for i, module in enumerate(freestyle.modules):
157                 box = layout.box()
158                 box.context_pointer_set("freestyle_module", module)
159                 row = box.row(align=True)
160                 row.prop(module, "use", text="")
161                 row.prop(module, "script", text="")
162                 row.operator("scene.freestyle_module_open", icon='FILESEL', text="")
163                 row.operator("scene.freestyle_module_remove", icon='X', text="")
164                 row.operator("scene.freestyle_module_move", icon='TRIA_UP', text="").direction = 'UP'
165                 row.operator("scene.freestyle_module_move", icon='TRIA_DOWN', text="").direction = 'DOWN'
166
167
168 class RENDERLAYER_PT_freestyle_lineset(RenderLayerFreestyleEditorButtonsPanel, Panel):
169     bl_label = "Freestyle Line Set"
170     COMPAT_ENGINES = {'BLENDER_RENDER'}
171
172     def draw_edge_type_buttons(self, box, lineset, edge_type):
173         # property names
174         select_edge_type = "select_" + edge_type
175         exclude_edge_type = "exclude_" + edge_type
176         # draw edge type buttons
177         row = box.row(align=True)
178         row.prop(lineset, select_edge_type)
179         sub = row.column(align=True)
180         sub.prop(lineset, exclude_edge_type, text="")
181         sub.active = getattr(lineset, select_edge_type)
182
183     def draw(self, context):
184         layout = self.layout
185
186         rd = context.scene.render
187         rl = rd.layers.active
188         freestyle = rl.freestyle_settings
189         lineset = freestyle.linesets.active
190
191         layout.active = rl.use_freestyle
192
193         row = layout.row()
194         rows = 4 if lineset else 2
195         row.template_list("RENDERLAYER_UL_linesets", "", freestyle, "linesets", freestyle.linesets, "active_index", rows=rows)
196
197         sub = row.column(align=True)
198         sub.operator("scene.freestyle_lineset_add", icon='ZOOMIN', text="")
199         sub.operator("scene.freestyle_lineset_remove", icon='ZOOMOUT', text="")
200         sub.menu("RENDER_MT_lineset_specials", icon='DOWNARROW_HLT', text="")
201         if lineset:
202             sub.separator()
203             sub.separator()
204             sub.operator("scene.freestyle_lineset_move", icon='TRIA_UP', text="").direction = 'UP'
205             sub.operator("scene.freestyle_lineset_move", icon='TRIA_DOWN', text="").direction = 'DOWN'
206
207             col = layout.column()
208             col.label(text="Selection By:")
209             row = col.row(align=True)
210             row.prop(lineset, "select_by_visibility", text="Visibility", toggle=True)
211             row.prop(lineset, "select_by_edge_types", text="Edge Types", toggle=True)
212             row.prop(lineset, "select_by_face_marks", text="Face Marks", toggle=True)
213             row.prop(lineset, "select_by_group", text="Group", toggle=True)
214             row.prop(lineset, "select_by_image_border", text="Image Border", toggle=True)
215
216             if lineset.select_by_visibility:
217                 col.label(text="Visibility:")
218                 row = col.row(align=True)
219                 row.prop(lineset, "visibility", expand=True)
220                 if lineset.visibility == 'RANGE':
221                     row = col.row(align=True)
222                     row.prop(lineset, "qi_start")
223                     row.prop(lineset, "qi_end")
224
225             if lineset.select_by_edge_types:
226                 col.label(text="Edge Types:")
227                 row = col.row()
228                 row.prop(lineset, "edge_type_negation", expand=True)
229                 row.prop(lineset, "edge_type_combination", expand=True)
230
231                 split = col.split()
232
233                 sub = split.column()
234                 self.draw_edge_type_buttons(sub, lineset, "silhouette")
235                 self.draw_edge_type_buttons(sub, lineset, "border")
236                 self.draw_edge_type_buttons(sub, lineset, "contour")
237                 self.draw_edge_type_buttons(sub, lineset, "suggestive_contour")
238                 self.draw_edge_type_buttons(sub, lineset, "ridge_valley")
239
240                 sub = split.column()
241                 self.draw_edge_type_buttons(sub, lineset, "crease")
242                 self.draw_edge_type_buttons(sub, lineset, "edge_mark")
243                 self.draw_edge_type_buttons(sub, lineset, "external_contour")
244                 self.draw_edge_type_buttons(sub, lineset, "material_boundary")
245
246             if lineset.select_by_face_marks:
247                 col.label(text="Face Marks:")
248                 row = col.row()
249                 row.prop(lineset, "face_mark_negation", expand=True)
250                 row.prop(lineset, "face_mark_condition", expand=True)
251
252             if lineset.select_by_group:
253                 col.label(text="Group:")
254                 row = col.row()
255                 row.prop(lineset, "group", text="")
256                 row.prop(lineset, "group_negation", expand=True)
257
258
259 class RENDERLAYER_PT_freestyle_linestyle(RenderLayerFreestyleEditorButtonsPanel, Panel):
260     bl_label = "Freestyle Line Style"
261     bl_options = {'DEFAULT_CLOSED'}
262     COMPAT_ENGINES = {'BLENDER_RENDER'}
263
264     def draw_modifier_box_header(self, box, modifier):
265         row = box.row()
266         row.context_pointer_set("modifier", modifier)
267         if modifier.expanded:
268             icon = 'TRIA_DOWN'
269         else:
270             icon = 'TRIA_RIGHT'
271         row.prop(modifier, "expanded", text="", icon=icon, emboss=False)
272         # TODO: Use icons rather than text label, would save some room!
273         row.label(text=modifier.rna_type.name)
274         row.prop(modifier, "name", text="")
275         if modifier.use:
276             icon = 'RESTRICT_RENDER_OFF'
277         else:
278             icon = 'RESTRICT_RENDER_ON'
279         row.prop(modifier, "use", text="", icon=icon)
280         sub = row.row(align=True)
281         sub.operator("scene.freestyle_modifier_copy", icon='NONE', text="Copy")
282         sub.operator("scene.freestyle_modifier_move", icon='TRIA_UP', text="").direction = 'UP'
283         sub.operator("scene.freestyle_modifier_move", icon='TRIA_DOWN', text="").direction = 'DOWN'
284         sub.operator("scene.freestyle_modifier_remove", icon='X', text="")
285
286     def draw_modifier_common(self, box, modifier):
287         row = box.row()
288         row.prop(modifier, "blend", text="")
289         row.prop(modifier, "influence")
290
291     def draw_modifier_color_ramp_common(self, box, modifier, has_range):
292         box.template_color_ramp(modifier, "color_ramp", expand=True)
293         if has_range:
294             row = box.row(align=True)
295             row.prop(modifier, "range_min")
296             row.prop(modifier, "range_max")
297
298     def draw_modifier_curve_common(self, box, modifier, has_range, has_value):
299         row = box.row()
300         row.prop(modifier, "mapping", text="")
301         sub = row.column()
302         sub.prop(modifier, "invert")
303         if modifier.mapping == 'CURVE':
304             sub.active = False
305             box.template_curve_mapping(modifier, "curve")
306         if has_range:
307             row = box.row(align=True)
308             row.prop(modifier, "range_min")
309             row.prop(modifier, "range_max")
310         if has_value:
311             row = box.row(align=True)
312             row.prop(modifier, "value_min")
313             row.prop(modifier, "value_max")
314
315     def draw_color_modifier(self, context, modifier):
316         layout = self.layout
317
318         col = layout.column(align=True)
319         self.draw_modifier_box_header(col.box(), modifier)
320         if modifier.expanded:
321             box = col.box()
322             self.draw_modifier_common(box, modifier)
323
324             if modifier.type == 'ALONG_STROKE':
325                 self.draw_modifier_color_ramp_common(box, modifier, False)
326
327             elif modifier.type == 'DISTANCE_FROM_OBJECT':
328                 box.prop(modifier, "target")
329                 self.draw_modifier_color_ramp_common(box, modifier, True)
330                 prop = box.operator("scene.freestyle_fill_range_by_selection")
331                 prop.type = 'COLOR'
332                 prop.name = modifier.name
333
334             elif modifier.type == 'DISTANCE_FROM_CAMERA':
335                 self.draw_modifier_color_ramp_common(box, modifier, True)
336                 prop = box.operator("scene.freestyle_fill_range_by_selection")
337                 prop.type = 'COLOR'
338                 prop.name = modifier.name
339
340             elif modifier.type == 'MATERIAL':
341                 row = box.row()
342                 row.prop(modifier, "material_attribute", text="")
343                 sub = row.column()
344                 sub.prop(modifier, "use_ramp")
345                 if modifier.material_attribute in {'LINE', 'DIFF', 'SPEC'}:
346                     sub.active = True
347                     show_ramp = modifier.use_ramp
348                 else:
349                     sub.active = False
350                     show_ramp = True
351                 if show_ramp:
352                     self.draw_modifier_color_ramp_common(box, modifier, False)
353
354     def draw_alpha_modifier(self, context, modifier):
355         layout = self.layout
356
357         col = layout.column(align=True)
358         self.draw_modifier_box_header(col.box(), modifier)
359         if modifier.expanded:
360             box = col.box()
361             self.draw_modifier_common(box, modifier)
362
363             if modifier.type == 'ALONG_STROKE':
364                 self.draw_modifier_curve_common(box, modifier, False, False)
365
366             elif modifier.type == 'DISTANCE_FROM_OBJECT':
367                 box.prop(modifier, "target")
368                 self.draw_modifier_curve_common(box, modifier, True, False)
369                 prop = box.operator("scene.freestyle_fill_range_by_selection")
370                 prop.type = 'ALPHA'
371                 prop.name = modifier.name
372
373             elif modifier.type == 'DISTANCE_FROM_CAMERA':
374                 self.draw_modifier_curve_common(box, modifier, True, False)
375                 prop = box.operator("scene.freestyle_fill_range_by_selection")
376                 prop.type = 'ALPHA'
377                 prop.name = modifier.name
378
379             elif modifier.type == 'MATERIAL':
380                 box.prop(modifier, "material_attribute", text="")
381                 self.draw_modifier_curve_common(box, modifier, False, False)
382
383     def draw_thickness_modifier(self, context, modifier):
384         layout = self.layout
385
386         col = layout.column(align=True)
387         self.draw_modifier_box_header(col.box(), modifier)
388         if modifier.expanded:
389             box = col.box()
390             self.draw_modifier_common(box, modifier)
391
392             if modifier.type == 'ALONG_STROKE':
393                 self.draw_modifier_curve_common(box, modifier, False, True)
394
395             elif modifier.type == 'DISTANCE_FROM_OBJECT':
396                 box.prop(modifier, "target")
397                 self.draw_modifier_curve_common(box, modifier, True, True)
398                 prop = box.operator("scene.freestyle_fill_range_by_selection")
399                 prop.type = 'THICKNESS'
400                 prop.name = modifier.name
401
402             elif modifier.type == 'DISTANCE_FROM_CAMERA':
403                 self.draw_modifier_curve_common(box, modifier, True, True)
404                 prop = box.operator("scene.freestyle_fill_range_by_selection")
405                 prop.type = 'THICKNESS'
406                 prop.name = modifier.name
407
408             elif modifier.type == 'MATERIAL':
409                 box.prop(modifier, "material_attribute", text="")
410                 self.draw_modifier_curve_common(box, modifier, False, True)
411
412             elif modifier.type == 'CALLIGRAPHY':
413                 box.prop(modifier, "orientation")
414                 row = box.row(align=True)
415                 row.prop(modifier, "thickness_min")
416                 row.prop(modifier, "thickness_max")
417
418     def draw_geometry_modifier(self, context, modifier):
419         layout = self.layout
420
421         col = layout.column(align=True)
422         self.draw_modifier_box_header(col.box(), modifier)
423         if modifier.expanded:
424             box = col.box()
425
426             if modifier.type == 'SAMPLING':
427                 box.prop(modifier, "sampling")
428
429             elif modifier.type == 'BEZIER_CURVE':
430                 box.prop(modifier, "error")
431
432             elif modifier.type == 'SINUS_DISPLACEMENT':
433                 split = box.split()
434                 col = split.column()
435                 col.prop(modifier, "wavelength")
436                 col.prop(modifier, "amplitude")
437                 col = split.column()
438                 col.prop(modifier, "phase")
439
440             elif modifier.type == 'SPATIAL_NOISE':
441                 split = box.split()
442                 col = split.column()
443                 col.prop(modifier, "amplitude")
444                 col.prop(modifier, "scale")
445                 col.prop(modifier, "octaves")
446                 col = split.column()
447                 col.prop(modifier, "smooth")
448                 col.prop(modifier, "use_pure_random")
449
450             elif modifier.type == 'PERLIN_NOISE_1D':
451                 split = box.split()
452                 col = split.column()
453                 col.prop(modifier, "frequency")
454                 col.prop(modifier, "amplitude")
455                 col.prop(modifier, "seed")
456                 col = split.column()
457                 col.prop(modifier, "octaves")
458                 col.prop(modifier, "angle")
459
460             elif modifier.type == 'PERLIN_NOISE_2D':
461                 split = box.split()
462                 col = split.column()
463                 col.prop(modifier, "frequency")
464                 col.prop(modifier, "amplitude")
465                 col.prop(modifier, "seed")
466                 col = split.column()
467                 col.prop(modifier, "octaves")
468                 col.prop(modifier, "angle")
469
470             elif modifier.type == 'BACKBONE_STRETCHER':
471                 box.prop(modifier, "backbone_length")
472
473             elif modifier.type == 'TIP_REMOVER':
474                 box.prop(modifier, "tip_length")
475
476             elif modifier.type == 'POLYGONIZATION':
477                 box.prop(modifier, "error")
478
479             elif modifier.type == 'GUIDING_LINES':
480                 box.prop(modifier, "offset")
481
482             elif modifier.type == 'BLUEPRINT':
483                 row = box.row()
484                 row.prop(modifier, "shape", expand=True)
485                 box.prop(modifier, "rounds")
486                 row = box.row()
487                 if modifier.shape in {'CIRCLES', 'ELLIPSES'}:
488                     row.prop(modifier, "random_radius")
489                     row.prop(modifier, "random_center")
490                 elif modifier.shape == 'SQUARES':
491                     row.prop(modifier, "backbone_length")
492                     row.prop(modifier, "random_backbone")
493
494             elif modifier.type == '2D_OFFSET':
495                 row = box.row(align=True)
496                 row.prop(modifier, "start")
497                 row.prop(modifier, "end")
498                 row = box.row(align=True)
499                 row.prop(modifier, "x")
500                 row.prop(modifier, "y")
501
502             elif modifier.type == '2D_TRANSFORM':
503                 box.prop(modifier, "pivot")
504                 if modifier.pivot == 'PARAM':
505                     box.prop(modifier, "pivot_u")
506                 elif modifier.pivot == 'ABSOLUTE':
507                     row = box.row(align=True)
508                     row.prop(modifier, "pivot_x")
509                     row.prop(modifier, "pivot_y")
510                 row = box.row(align=True)
511                 row.prop(modifier, "scale_x")
512                 row.prop(modifier, "scale_y")
513                 box.prop(modifier, "angle")
514
515     def draw(self, context):
516         layout = self.layout
517
518         rd = context.scene.render
519         rl = rd.layers.active
520         lineset = rl.freestyle_settings.linesets.active
521
522         layout.active = rl.use_freestyle
523
524         if lineset is None:
525             return
526         linestyle = lineset.linestyle
527
528         layout.template_ID(lineset, "linestyle", new="scene.freestyle_linestyle_new")
529         if linestyle is None:
530             return
531         row = layout.row(align=True)
532         row.prop(linestyle, "panel", expand=True)
533         if linestyle.panel == 'STROKES':
534             ## Chaining
535             layout.prop(linestyle, "use_chaining", text="Chaining:")
536             split = layout.split(align=True)
537             split.active = linestyle.use_chaining
538             # First column
539             col = split.column()
540             col.active = linestyle.use_chaining
541             col.prop(linestyle, "chaining", text="")
542             if linestyle.chaining == 'SKETCHY':
543                 col.prop(linestyle, "rounds")
544             # Second column
545             col = split.column()
546             col.prop(linestyle, "use_same_object")
547
548             ## Splitting
549             layout.label(text="Splitting:")
550             split = layout.split(align=True)
551             # First column
552             col = split.column()
553             row = col.row(align=True)
554             row.prop(linestyle, "use_angle_min", text="")
555             sub = row.row()
556             sub.active = linestyle.use_angle_min
557             sub.prop(linestyle, "angle_min")
558             row = col.row(align=True)
559             row.prop(linestyle, "use_angle_max", text="")
560             sub = row.row()
561             sub.active = linestyle.use_angle_max
562             sub.prop(linestyle, "angle_max")
563             # Second column
564             col = split.column()
565             row = col.row(align=True)
566             row.prop(linestyle, "use_split_length", text="")
567             sub = row.row()
568             sub.active = linestyle.use_split_length
569             sub.prop(linestyle, "split_length", text="2D Length")
570             row = col.row(align=True)
571             row.prop(linestyle, "material_boundary")
572             # End of columns
573             row = layout.row(align=True)
574             row.prop(linestyle, "use_split_pattern", text="")
575             sub = row.row(align=True)
576             sub.active = linestyle.use_split_pattern
577             sub.prop(linestyle, "split_dash1", text="D1")
578             sub.prop(linestyle, "split_gap1", text="G1")
579             sub.prop(linestyle, "split_dash2", text="D2")
580             sub.prop(linestyle, "split_gap2", text="G2")
581             sub.prop(linestyle, "split_dash3", text="D3")
582             sub.prop(linestyle, "split_gap3", text="G3")
583
584             ## Sorting
585             layout.prop(linestyle, "use_sorting", text="Sorting:")
586             col = layout.column()
587             col.active = linestyle.use_sorting
588             row = col.row(align=True)
589             row.prop(linestyle, "sort_key", text="")
590             sub = row.row()
591             sub.active = linestyle.sort_key in {'DISTANCE_FROM_CAMERA',
592                                                 'PROJECTED_X',
593                                                 'PROJECTED_Y'}
594             sub.prop(linestyle, "integration_type", text="")
595             row = col.row(align=True)
596             row.prop(linestyle, "sort_order", expand=True)
597
598             ## Selection
599             layout.label(text="Selection:")
600             split = layout.split(align=True)
601             # First column
602             col = split.column()
603             row = col.row(align=True)
604             row.prop(linestyle, "use_length_min", text="")
605             sub = row.row()
606             sub.active = linestyle.use_length_min
607             sub.prop(linestyle, "length_min")
608             row = col.row(align=True)
609             row.prop(linestyle, "use_length_max", text="")
610             sub = row.row()
611             sub.active = linestyle.use_length_max
612             sub.prop(linestyle, "length_max")
613             # Second column
614             col = split.column()
615             row = col.row(align=True)
616             row.prop(linestyle, "use_chain_count", text="")
617             sub = row.row()
618             sub.active = linestyle.use_chain_count
619             sub.prop(linestyle, "chain_count")
620
621             ## Caps
622             layout.label(text="Caps:")
623             row = layout.row(align=True)
624             row.prop(linestyle, "caps", expand=True)
625
626             ## Dashed lines
627             layout.prop(linestyle, "use_dashed_line", text="Dashed Line:")
628             row = layout.row(align=True)
629             row.active = linestyle.use_dashed_line
630             row.prop(linestyle, "dash1", text="D1")
631             row.prop(linestyle, "gap1", text="G1")
632             row.prop(linestyle, "dash2", text="D2")
633             row.prop(linestyle, "gap2", text="G2")
634             row.prop(linestyle, "dash3", text="D3")
635             row.prop(linestyle, "gap3", text="G3")
636
637         elif linestyle.panel == 'COLOR':
638             col = layout.column()
639             row = col.row()
640             row.label(text="Base Color:")
641             row.prop(linestyle, "color", text="")
642             col.label(text="Modifiers:")
643             col.operator_menu_enum("scene.freestyle_color_modifier_add", "type", text="Add Modifier")
644             for modifier in linestyle.color_modifiers:
645                 self.draw_color_modifier(context, modifier)
646
647         elif linestyle.panel == 'ALPHA':
648             col = layout.column()
649             row = col.row()
650             row.label(text="Base Transparency:")
651             row.prop(linestyle, "alpha")
652             col.label(text="Modifiers:")
653             col.operator_menu_enum("scene.freestyle_alpha_modifier_add", "type", text="Add Modifier")
654             for modifier in linestyle.alpha_modifiers:
655                 self.draw_alpha_modifier(context, modifier)
656
657         elif linestyle.panel == 'THICKNESS':
658             col = layout.column()
659             row = col.row()
660             row.label(text="Base Thickness:")
661             row.prop(linestyle, "thickness")
662             subcol = col.column()
663             subcol.active = linestyle.chaining == 'PLAIN' and linestyle.use_same_object
664             row = subcol.row()
665             row.prop(linestyle, "thickness_position", expand=True)
666             row = subcol.row()
667             row.prop(linestyle, "thickness_ratio")
668             row.active = (linestyle.thickness_position == 'RELATIVE')
669             col = layout.column()
670             col.label(text="Modifiers:")
671             col.operator_menu_enum("scene.freestyle_thickness_modifier_add", "type", text="Add Modifier")
672             for modifier in linestyle.thickness_modifiers:
673                 self.draw_thickness_modifier(context, modifier)
674
675         elif linestyle.panel == 'GEOMETRY':
676             col = layout.column()
677             col.label(text="Modifiers:")
678             col.operator_menu_enum("scene.freestyle_geometry_modifier_add", "type", text="Add Modifier")
679             for modifier in linestyle.geometry_modifiers:
680                 self.draw_geometry_modifier(context, modifier)
681
682         elif linestyle.panel == 'TEXTURE':
683             layout.separator()
684
685             row = layout.row()
686             if rd.use_shading_nodes:
687                 row.prop(linestyle, "use_nodes")
688             else:
689                 row.prop(linestyle, "use_texture")
690             row.prop(linestyle, "texture_spacing", text="Spacing Along Stroke")
691
692             row = layout.row()
693             op = row.operator("wm.properties_context_change",
694                          text="Go to Linestyle Textures Properties",
695                          icon='TEXTURE')
696             op.context = 'TEXTURE'
697
698         elif linestyle.panel == 'MISC':
699             pass
700
701
702 # Material properties
703
704 class MaterialFreestyleButtonsPanel:
705     bl_space_type = 'PROPERTIES'
706     bl_region_type = 'WINDOW'
707     bl_context = "material"
708     # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here
709
710     @classmethod
711     def poll(cls, context):
712         scene = context.scene
713         material = context.material
714         with_freestyle = bpy.app.build_options.freestyle
715         return with_freestyle and material and scene and scene.render.use_freestyle and \
716             (scene.render.engine in cls.COMPAT_ENGINES)
717
718
719 class MATERIAL_PT_freestyle_line(MaterialFreestyleButtonsPanel, Panel):
720     bl_label = "Freestyle Line"
721     bl_options = {'DEFAULT_CLOSED'}
722     COMPAT_ENGINES = {'BLENDER_RENDER'}
723
724     def draw(self, context):
725         layout = self.layout
726
727         mat = context.material
728
729         row = layout.row()
730         row.prop(mat, "line_color", text="")
731         row.prop(mat, "line_priority", text="Priority")
732
733
734 if __name__ == "__main__":  # only for live edit.
735     bpy.utils.register_module(__name__)