Tool System: remove duplicate gpencil draw UI

Tool properties showed options twice.
This commit is contained in:
Campbell Barton 2018-11-14 19:19:04 +11:00
parent 477407bd3b
commit f91b797b2b
2 changed files with 17 additions and 55 deletions

View File

@ -1214,50 +1214,8 @@ class _defs_gpencil_paint:
),
)
@staticmethod
def draw_color_selector(context, layout, gp_settings):
ma = gp_settings.material
row = layout.row(align=True)
icon_id = 0
if ma:
icon_id = ma.id_data.preview.icon_id
txt_ma = ma.name
maxw = 25
if len(txt_ma) > maxw:
txt_ma = txt_ma[:maxw - 5] + '..' + txt_ma[-3:]
else:
txt_ma = ""
row.label(text="Material:")
sub = row.row()
sub.ui_units_x = 8
sub.popover(
panel="TOPBAR_PT_gpencil_materials",
text=txt_ma,
icon_value=icon_id,
)
row.prop(gp_settings, "use_material_pin", text="")
def draw_settings_common(context, layout, tool):
row = layout.row(align=True)
ts = context.scene.tool_settings
gp_settings = ts.gpencil_paint
brush = gp_settings.brush
gp_brush = brush.gpencil_settings
row.template_ID_preview(gp_settings, "brush", rows=3, cols=8, hide_buttons=True)
if brush and brush.gpencil_tool == 'DRAW':
row = layout.row(align=True)
row.prop(brush, "size", text="Radius")
row = layout.row(align=True)
row.prop(gp_brush, "pen_strength", slider=True)
_defs_gpencil_paint.draw_color_selector(context, layout, gp_brush)
@ToolDef.from_fn.with_args(draw_settings=draw_settings_common)
def line(*, draw_settings):
@ToolDef.from_fn
def line():
return dict(
text="Line",
icon="ops.gpencil.primitive_line",
@ -1267,11 +1225,10 @@ class _defs_gpencil_paint:
dict(type='LINE', wait_for_input=False),
dict(type='EVT_TWEAK_A', value='ANY')),
),
draw_settings=draw_settings,
)
@ToolDef.from_fn.with_args(draw_settings=draw_settings_common)
def box(*, draw_settings):
@ToolDef.from_fn
def box():
return dict(
text="Box",
icon="ops.gpencil.primitive_box",
@ -1281,11 +1238,10 @@ class _defs_gpencil_paint:
dict(type='BOX', wait_for_input=False),
dict(type='EVT_TWEAK_A', value='ANY')),
),
draw_settings=draw_settings,
)
@ToolDef.from_fn.with_args(draw_settings=draw_settings_common)
def circle(*, draw_settings):
@ToolDef.from_fn
def circle():
return dict(
text="Circle",
icon="ops.gpencil.primitive_circle",
@ -1295,7 +1251,6 @@ class _defs_gpencil_paint:
dict(type='CIRCLE', wait_for_input=False),
dict(type='EVT_TWEAK_A', value='ANY')),
),
draw_settings=draw_settings,
)

View File

@ -297,8 +297,13 @@ class _draw_left_context_mode:
@staticmethod
def GPENCIL_PAINT(context, layout, tool):
if tool is None:
return
if (tool is None) or (not tool.has_datablock):
is_paint = True
if (tool.name in {"Line", "Box", "Circle"}):
is_paint = False
elif (not tool.has_datablock):
return
paint = context.tool_settings.gpencil_paint
@ -358,13 +363,15 @@ class _draw_left_context_mode:
row.prop(gp_settings, "fill_draw_mode", text="")
row.prop(gp_settings, "show_fill_boundary", text="", icon='GRID')
else: # bgpsettings.tool == 'DRAW':
else: # brush.gpencil_tool == 'DRAW':
row = layout.row(align=True)
row.prop(brush, "size", text="Radius")
row.prop(gp_settings, "use_pressure", text="", icon='STYLUS_PRESSURE')
if is_paint:
row.prop(gp_settings, "use_pressure", text="", icon='STYLUS_PRESSURE')
row = layout.row(align=True)
row.prop(gp_settings, "pen_strength", slider=True)
row.prop(gp_settings, "use_strength_pressure", text="", icon='STYLUS_PRESSURE')
if is_paint:
row.prop(gp_settings, "use_strength_pressure", text="", icon='STYLUS_PRESSURE')
draw_color_selector()