UI: Text Editor header cleanup

- Register toggle is in the Text menu
  - Run Script and Refresh OSL become an icon buttons next to ID block

Differential Revision: https://developer.blender.org/D5686

Reviewed by Campbell Barton
This commit is contained in:
William Reynish 2020-01-23 14:53:19 +01:00
parent 24ebed4d84
commit 8482ba6d2e
1 changed files with 13 additions and 20 deletions

View File

@ -30,7 +30,7 @@ class TEXT_HT_header(Header):
st = context.space_data
text = st.text
is_syntax_highlight_supported = st.is_syntax_highlight_supported()
layout.template_header()
TEXT_MT_editor_menus.draw_collapsible(context, layout)
@ -43,7 +43,18 @@ class TEXT_HT_header(Header):
layout.separator_spacer()
row = layout.row(align=True)
row.template_ID(st, "text", new="text.new", unlink="text.unlink", open="text.open")
row.template_ID(st, "text", new="text.new",
unlink="text.unlink", open="text.open")
if text:
is_osl = text.name.endswith((".osl", ".osl"))
if is_osl:
row.operator("node.shader_script_update",
text="", icon='FILE_REFRESH')
else:
row = layout.row()
row.active = is_syntax_highlight_supported
row.operator("text.run_script", text="", icon='PLAY')
layout.separator_spacer()
@ -51,28 +62,10 @@ class TEXT_HT_header(Header):
row.prop(st, "show_line_numbers", text="")
row.prop(st, "show_word_wrap", text="")
is_syntax_highlight_supported = st.is_syntax_highlight_supported()
syntax = row.row(align=True)
syntax.active = is_syntax_highlight_supported
syntax.prop(st, "show_syntax_highlight", text="")
if text:
text_name = text.name
is_osl = text_name.endswith((".osl", ".oso"))
row = layout.row()
if is_osl:
row = layout.row()
row.operator("node.shader_script_update")
else:
row = layout.row()
row.active = text_name.endswith(".py")
row.prop(text, "use_module")
row = layout.row()
row.active = is_syntax_highlight_supported
row.operator("text.run_script")
class TEXT_HT_footer(Header):
bl_space_type = 'TEXT_EDITOR'