Changeset View
Changeset View
Standalone View
Standalone View
release/scripts/startup/bl_ui/space_topbar.py
| Show First 20 Lines • Show All 1,061 Lines • ▼ Show 20 Lines | def draw(self, context): | ||||
| row.prop(gp_settings, "fill_factor", text="Resolution") | row.prop(gp_settings, "fill_factor", text="Resolution") | ||||
| if gp_settings.fill_draw_mode != 'STROKE': | if gp_settings.fill_draw_mode != 'STROKE': | ||||
| row = layout.row(align=True) | row = layout.row(align=True) | ||||
| row.prop(gp_settings, "show_fill", text="Ignore Transparent Strokes") | row.prop(gp_settings, "show_fill", text="Ignore Transparent Strokes") | ||||
| row = layout.row(align=True) | row = layout.row(align=True) | ||||
| row.prop(gp_settings, "fill_threshold", text="Threshold") | row.prop(gp_settings, "fill_threshold", text="Threshold") | ||||
| # Only a popover | |||||
| class TOPBAR_PT_name(Panel): | |||||
| bl_space_type = 'TOPBAR' # dummy | |||||
| bl_region_type = 'HEADER' | |||||
| bl_label = "Rename" | |||||
| bl_ui_units_x = 14 | |||||
| @classmethod | |||||
| def poll(cls, context): | |||||
| return True | |||||
| def draw(self, context): | |||||
| layout = self.layout | |||||
| # Edit first editable button in popup | |||||
| layout.activate_init = True | |||||
| mode = context.mode | |||||
| scene = context.scene | |||||
| space = context.space_data | |||||
| space_type = 'PROPERTIES' if (space is None) else space.type | |||||
| found = False | |||||
| if space_type == 'SEQUENCE_EDITOR': | |||||
| layout.label(text="Sequence Strip Name") | |||||
| item = getattr(scene.sequence_editor, "active_strip") | |||||
| if item: | |||||
| layout.prop(item, "name", text="") | |||||
| found = True | |||||
| elif space_type == 'NODE_EDITOR': | |||||
| layout.label(text="Node Name") | |||||
| item = context.active_node | |||||
| if item: | |||||
| layout.prop(item, "name", text="") | |||||
| layout.label(text="Node Label") | |||||
| layout.prop(item, "label", text="") | |||||
| found = True | |||||
| else: | |||||
| if mode == 'POSE' or (mode == 'WEIGHT_PAINT' and context.pose_object): | |||||
| layout.label(text="Bone Name") | |||||
| item = getattr(getattr(getattr(context.pose_object, "data", None), "bones", None), "active", None) | |||||
| if item: | |||||
| layout.prop(item, "name", text="") | |||||
| found = True | |||||
| elif mode == 'EDIT_ARMATURE': | |||||
| layout.label(text="Bone Name") | |||||
| item = getattr(getattr(getattr(context.active_object, "data", None), "edit_bones", None), "active", None) | |||||
| if item: | |||||
| layout.prop(item, "name", text="") | |||||
| found = True | |||||
| else: | |||||
| layout.label(text="Object Name") | |||||
| item = context.object | |||||
| if item: | |||||
| layout.prop(item, "name", text="") | |||||
| found = True | |||||
| if not found: | |||||
| layout.label(text="No active item") | |||||
| classes = ( | classes = ( | ||||
| TOPBAR_HT_upper_bar, | TOPBAR_HT_upper_bar, | ||||
| TOPBAR_HT_lower_bar, | TOPBAR_HT_lower_bar, | ||||
| TOPBAR_MT_file_context_menu, | TOPBAR_MT_file_context_menu, | ||||
| TOPBAR_MT_window_context_menu, | TOPBAR_MT_window_context_menu, | ||||
| TOPBAR_MT_workspace_menu, | TOPBAR_MT_workspace_menu, | ||||
| TOPBAR_MT_editor_menus, | TOPBAR_MT_editor_menus, | ||||
| TOPBAR_MT_file, | TOPBAR_MT_file, | ||||
| TOPBAR_MT_file_new, | TOPBAR_MT_file_new, | ||||
| TOPBAR_MT_templates_more, | TOPBAR_MT_templates_more, | ||||
| TOPBAR_MT_file_import, | TOPBAR_MT_file_import, | ||||
| TOPBAR_MT_file_export, | TOPBAR_MT_file_export, | ||||
| TOPBAR_MT_file_external_data, | TOPBAR_MT_file_external_data, | ||||
| TOPBAR_MT_file_previews, | TOPBAR_MT_file_previews, | ||||
| TOPBAR_MT_edit, | TOPBAR_MT_edit, | ||||
| TOPBAR_MT_render, | TOPBAR_MT_render, | ||||
| TOPBAR_MT_window, | TOPBAR_MT_window, | ||||
| TOPBAR_MT_help, | TOPBAR_MT_help, | ||||
| TOPBAR_PT_active_tool, | TOPBAR_PT_active_tool, | ||||
| TOPBAR_PT_gpencil_layers, | TOPBAR_PT_gpencil_layers, | ||||
| TOPBAR_PT_gpencil_primitive, | TOPBAR_PT_gpencil_primitive, | ||||
| TOPBAR_PT_gpencil_fill, | TOPBAR_PT_gpencil_fill, | ||||
| TOPBAR_PT_name, | |||||
| ) | ) | ||||
| if __name__ == "__main__": # only for live edit. | if __name__ == "__main__": # only for live edit. | ||||
| from bpy.utils import register_class | from bpy.utils import register_class | ||||
| for cls in classes: | for cls in classes: | ||||
| register_class(cls) | register_class(cls) | ||||