def show_ui(parent: bpy.types.UILayout, bone: str, icon: str) -> None: parent.prop_search(data, f'["{bone}"]', data, "bones", text=bone, icon=icon)
def draw_version_panel( layout: bpy.types.UILayout, context: bpy.types.Context, actual_version: str, latest_version: str, ) -> None: """Draws the panel to connect to Tresorio""" user_props = context.window_manager.tresorio_user_props report_props = bpy.context.window_manager.tresorio_report_props title = layout.row() title.label(text=f"{TRADUCTOR['desc']['new_version'][CONFIG_LANG]}") title = layout.row() title.label( text= f"{TRADUCTOR['desc']['actual_version'][CONFIG_LANG]} : {actual_version}" ) title = layout.row() title.label( text= f"{TRADUCTOR['desc']['latest_version'][CONFIG_LANG]} : {latest_version}" ) layout.operator( 'tresorio.download_addon', text=f"{TRADUCTOR['desc']['download_latest'][CONFIG_LANG]}", icon_value=til.icon('TRESORIO_LEAF'))
def draw_advanced_settings_ui(layout: bpy.types.UILayout): mixer_prefs = get_mixer_prefs() layout.prop(mixer_prefs, "data_directory", text="Data Directory") layout.prop(mixer_prefs, "ignore_version_check") layout.prop(mixer_prefs, "log_level") layout.prop(mixer_prefs, "show_server_console") layout.prop(mixer_prefs, "vrtist_protocol")
def draw_socket_layout(socket: bpy.types.NodeSocket, layout: bpy.types.UILayout, prop_name='default_value_raw'): if not socket.is_output and not socket.is_linked: layout.prop(socket, prop_name, text=socket.name) else: layout.label(text=socket.name)
def draw(cls, context, layout: bpy.types.UILayout, data, effect, richstrip): metastrip = cls.getEffectStrip(richstrip, effect, "mask") imgstrip = metastrip.sequences.get( cls.genRegularStripName(data.RichStripID, effect.EffectId, "img")) white = metastrip.sequences.get( cls.genRegularStripName(data.RichStripID, effect.EffectId, "white")) layout.label(text="Gradient:") layout.prop(metastrip, "mute", toggle=0, invert_checkbox=True, text="Only Mate") # layout.prop(white, cls.genbinderName(effect, "offsetFactor", True), text="Offset") exportbox.draw(layout, richstrip, cls.getBoolProperty(effect, "offset_export"), white, cls.genbinderName(effect, "offsetFactor", True), "Offset") exportbox.draw(layout, richstrip, cls.getBoolProperty(effect, "scale_export"), imgstrip, cls.genbinderName(effect, "scaleFactor", True), "Scale") return
def panel_tex_image_draw(layout: bpy.types.UILayout, ntree: bpy.types.NodeTree, node_name: str) -> None: # Look for needed image node if node_name in ntree.nodes: node = ntree.nodes[node_name] layout.template_image(node, "image", node.image_user) else: layout.label(text="Incompatible image node")
def draw_filter(self, layout: bpy.types.UILayout, sel_props: LocalProps) -> None: row = layout.row() split = compat.layout_split(row, factor=0.75) split.prop(sel_props, 'key', icon='NONE') split.operator(BUTL_OT_ArmSelectNameOprator.bl_idname, icon='NONE', text='Select') row = layout.row() row.alignment = 'RIGHT' row.prop(sel_props, 'ignore_case', icon='NONE')
def draw_expand_handle(parent: bpy.types.UILayout, text: str, object_with_property, expand_property_field: str): parent.prop( object_with_property, expand_property_field, text=text, icon="TRIA_DOWN" if getattr( object_with_property, expand_property_field) else "TRIA_RIGHT", icon_only=True, emboss=False)
def _show_data(layout: bpy.types.UILayout, context, data=[]): is_overflowing = True max_i = 21 if max_i > len(data): max_i = len(data) is_overflowing = False for i in range(0, max_i): layout.label(text=data[i].debug) if is_overflowing: layout.label(text="...")
def draw_socket_layout_split(socket: bpy.types.NodeSocket, layout: bpy.types.UILayout, prop_name='default_value_raw'): if not socket.is_output and not socket.is_linked: # Blender layouts use 0.4 splits layout = layout.split(factor=0.4, align=True) layout.label(text=socket.name) if not socket.is_output and not socket.is_linked: layout.prop(socket, prop_name, text='')
def draw_expand_handle(parent: bpy.types.UILayout, text: str, object_with_expand_property, expand_property_field: str): """ :param parent: the parent layout :param text: the text for the expand handle :param object_with_expand_property: object with the expand/collapse property :param expand_property_field: expand/collapse field on the object :return: None """ parent.prop(object_with_expand_property, expand_property_field, text=text, icon="TRIA_DOWN" if getattr(object_with_expand_property, expand_property_field) else "TRIA_RIGHT", icon_only=True, emboss=False)
def _emit_operator(self, layout: bpy.types.UILayout, op: Optional[Union[str, Tuple[str, Dict[str, Any]]]], icon: str): if isinstance(op, str): layout.operator(op, text="", icon=icon) else: op_name = op[0] op_args = op[1] op_instance = layout.operator(op_name, text="", icon=icon) for key, value in op_args.items(): setattr(op_instance, key, value)
def draw_collapsible_box(parent: bpy.types.UILayout, text: str, object_with_expand_property, expand_property_field: str, remove_operator_id: str = None): """ :param parent: the parent layout :param text: the text for the expand handle :param object_with_expand_property: object with the expand/collapse property :param expand_property_field: expand/collapse field on the object :param remove_operator_id: id of the remove operator (may be None for no remove operator) :return: (the collapsible box, remove operator) """ box = parent.box() row = box.row() draw_expand_handle(row, text, object_with_expand_property, expand_property_field) if remove_operator_id is not None: remove_operator = row.operator(remove_operator_id, icon='CANCEL', text='') else: remove_operator = None return box, remove_operator
def draw(layout: bpy.types.UILayout, effect: RichStripEffect, data: RichStripData, mask_modifier: bpy.types.SequenceModifier, mask_through: BoolProperty = None): box = layout.box() box.label(text="Mask", icon="MOD_MASK") row = box.row(align=True) row.prop(mask_modifier, "input_mask_id", text="") maskName = "" if mask_modifier.input_mask_id is not None: maskName = mask_modifier.input_mask_id.name row.operator( "icetb.richstrip_annotation2mask", text="", icon="GREASEPENCIL").effectName_plusmaskId = "%s$$%d_%d$$%s" % ( effect.EffectType, data.RichStripID, effect.EffectId, "true" if maskName == "" else "false") row.operator("icetb.richstrip_openmaskeditor", text="", icon="EDITMODE_HLT").maskName = maskName if maskName != "": mask = mask_modifier.input_mask_id row.prop(mask.layers[mask.active_layer_index], "invert", toggle=1, icon="LOOP_FORWARDS", text="") if mask_through: box.prop(mask_through, "value", toggle=0, text="Mask through")
def __draw_description_properties(self, layout: bpy.types.UILayout, description_properties: WorkpieceDescription): description_box = layout.box() description_box.label(text="Type", icon="OOPS") description_box.prop(description_properties, "cutting_list_type", text="") description_box.label(text="Piece name", icon="SORTALPHA") description_box.prop(description_properties, "piece_name", text="") description_box.label(text="Comments", icon="TEXT") description_box.prop(description_properties, "comments", text="") description_box.prop(description_properties, "is_in_group") if description_properties.is_in_group: if not description_properties.create_new_group: if len(self.group_items) > 0: description_box.template_list( "GroupUIList", "", self, "group_items", description_properties, "active_group_index", rows=4, maxrows=4) description_box.prop(description_properties, "create_new_group", emboss=True) else: description_box.prop(description_properties, "create_new_group", emboss=True) description_box.prop(description_properties, "group_name")
def draw_setting_shader_node_properties(self, layout: bpy.types.UILayout, nodes: Iterable[GeometryNode]): for node in nodes: if isinstance(node, GeometryNodeGroup): pass elif self.check_setting_node(node): pass else: continue col = layout.box().column(align=True) col.label(text=node.label) if isinstance(node, ShaderNodeValue): for node_output in node.outputs: col.prop(node_output, 'default_value', text=node_output.name) else: for node_input in node.inputs: if node_input.is_linked: continue if isinstance(node_input, NodeSocketGeometry): continue col.prop(node_input, 'default_value', text=node_input.name)
def draw_filter(unused_self, context: bpy.types.Context, layout: bpy.types.UILayout) -> None: """Draw the filter part of the ui list""" del unused_self user_settings = context.window_manager.tresorio_user_settings_props layout.separator() # layout.prop(user_settings, # 'decompress_results', # text=TRADUCTOR['field']['decompress_results'][CONFIG_LANG]) row = layout.row() if user_settings.decompress_results is False: row.enabled = False row.prop( user_settings, 'open_image_on_download', text=TRADUCTOR['field']['open_image_on_download'][CONFIG_LANG])
def draw_transpose_operator(instrument, steps: int, text: str, row: bpy.types.UILayout): col = row.column(align=True) transpose_operator = col.operator(TransposeInstrument.bl_idname, text=text) transpose_operator.transpose_steps = steps col.enabled = MidiInstrumentPanel.can_transpose(instrument, steps)
def draw_server_users_ui(layout: bpy.types.UILayout): mixer_props = get_mixer_props() def is_user_displayed(user: UserItem): if mixer_props.display_users_filter == "all": return True if mixer_props.display_users_filter == "no_room": return user.room == "" if mixer_props.display_users_filter == "current_room": return user.room == share_data.client.current_room or ( share_data.client.current_room is None and user.room == "") if mixer_props.display_users_filter == "selected_room": if mixer_props.room_index >= 0 and mixer_props.room_index < len( mixer_props.rooms): return user.room == mixer_props.rooms[ mixer_props.room_index].name return user.room == "" collapsable_panel(layout, mixer_props, "display_users", text="Server Users") if mixer_props.display_users: box = layout.box() box.row().prop(mixer_props, "display_users_details") box.row().prop(mixer_props, "display_users_filter", expand=True) for user in (user for user in mixer_props.users if is_user_displayed(user)): user_layout = box if mixer_props.display_users_details: user_layout = box.box() row = user_layout.split() row.label(text=f"{user.name}", icon="HOME" if user.is_me else "NONE") row.label(text=f"{user.room}") row.prop(user, "color", text="") if mixer_props.display_users_details: row.label(text=f"{user.ip_port}") window_count = len(user.windows) row.label( text= f"{window_count} window{'s' if window_count > 1 else ''}") frame_of_scene = {} for scene in user.scenes: frame_of_scene[scene.scene] = scene.frame for window in user.windows: split = user_layout.split(align=True) split.label(text=" ") split.label(text=window.scene, icon="SCENE_DATA") split.label(text=str(frame_of_scene[window.scene]), icon="TIME") split.label(text=window.view_layer, icon="RENDERLAYERS") split.label(text=window.screen, icon="SCREEN_BACK") split.label(text=f"{window.areas_3d_count}", icon="VIEW_CAMERA") split.scale_y = 0.5 user_layout.separator(factor=0.2)
def draw(cls, context, layout:bpy.types.UILayout, data, effect, richstrip): blurlayer = cls.getEffectStrip(richstrip, effect, "blur") mask_modifier = blurlayer.modifiers.get(cls.genRegularStripName(data.RichStripID, effect.EffectId, "mask")) box = layout.box() box.label(text="Blur", icon="MATFLUID") xylock.drawWithExportBox(box, richstrip, blurlayer, "size_x", "strongX", blurlayer, cls.genbinderName(effect, "size_y", True), "strongY", cls.getBoolProperty(effect, "union_size_lock"), "value") layout.separator() mask_through = cls.getBoolProperty(effect, "mask_through") cropbox.draw(layout, blurlayer, mask_through) layout.separator() maskbox.draw(layout, effect, data, mask_modifier, mask_through=mask_through)
def draw_connection_panel(layout: bpy.types.UILayout, context: bpy.types.Context ) -> None: """Draws the panel to connect to Tresorio""" user_props = context.window_manager.tresorio_user_props report_props = bpy.context.window_manager.tresorio_report_props case = layout.row().split(factor=0.5) case.label(text=TRADUCTOR['field']['connection'][CONFIG_LANG]) align_case = case.column().row().split(factor=0.8) align_case.column().prop(user_props, 'langs') align_case.column().operator('tresorio.advanced_settings_navigation_in', icon_value=til.icon('TRESORIO_SETTINGS'), text='') box = layout.box() box.label(text=TRADUCTOR['field']['mail'][CONFIG_LANG] + ':') box.prop(user_props, 'email', text='') box.label(text=TRADUCTOR['field']['password'][CONFIG_LANG] + ':') row = box.row().split(factor=0.9) if user_props.show_password: row.prop(user_props, 'clear_password', text='') else: row.prop(user_props, 'hidden_password', text='') row.prop(user_props, 'show_password', icon_only=True, icon='HIDE_OFF') row = layout.row().split(factor=0.5) row.column().prop(user_props, 'remember_email', text=TRADUCTOR['field']['remember_email'][CONFIG_LANG]) col = row.column() if not report_props.login_in: col.operator('tresorio.login', icon_value=til.icon('TRESORIO_LOGIN'), text=TRADUCTOR['field']['login'][CONFIG_LANG]) else: col.label(text=TRADUCTOR['notif']['login_in'][CONFIG_LANG]) layout.separator(factor=2.0) layout.operator('tresorio.redirect_forgot_password', text=TRADUCTOR['field']['forgot_password'][CONFIG_LANG], icon_value=til.icon('TRESORIO_KEY')) layout.operator('tresorio.redirect_register', text=TRADUCTOR['field']['create_account'][CONFIG_LANG], icon_value=til.icon('TRESORIO_PROFILE'))
def draw_stat_label(layout: bpy.types.UILayout, label: str, value: str): """Add a label-value pair to Blender's UI, aligned as a split property""" split = layout.split(factor=0.4, align=True) split.alignment = 'RIGHT' split.label(text=label) split.alignment = 'LEFT' split.label(text=value)
def draw_symmetry(self, layout: bpy.types.UILayout, sel_props: LocalProps) -> None: row = layout.row() split = compat.layout_split(row, factor=0.18, align=True) split.label(text=' ') label = bpy.app.translations.pgettext('selutl.SymmetryLTB') split.operator(BUTL_OT_MeshSelectSymOperator.bl_idname, icon='NONE', text=label).target = 'lt' label = bpy.app.translations.pgettext('selutl.SymmetryGTB') split.operator(BUTL_OT_MeshSelectSymOperator.bl_idname, icon='NONE', text=label).target = 'gt'
def draw_prop_row(data, layout: bpy.types.UILayout, label: str, prop_names: [], align=True): row = layout.row(align=align) row.label(text=label) for prop_name in prop_names: row.prop(data, prop_name, text="")
def wrapped_label(context: bpy.types.Context, layout: bpy.types.UILayout, text: str): lines = wrap_text_in_region(context, text) col = layout.column(align=True) col.scale_y = .7 # bring text lines a little closer together for line in lines: col.label(text=line)
def draw_prop_array(data, layout: bpy.types.UILayout, label: str, prop_array_name: str, prop_indices: [], align=True): row = layout.row(align=align) row.label(text=label) for index in prop_indices: row.prop(data, prop_array_name, index=index, text="")
def __draw_size_properties(layout: bpy.types.UILayout, size_properties: WorkpieceSize): size_box = layout.box() size_box.label(text="Thickness", icon="SETTINGS") size_box.prop(size_properties, "thickness", text="") size_box.label(text="Length", icon="SETTINGS") size_box.prop(size_properties, "length", text="") size_box.label(text="Width", icon="SETTINGS") size_box.prop(size_properties, "width", text="")
def draw_shared_folders_settings_ui(layout: bpy.types.UILayout): mixer_props = get_mixer_props() mixer_prefs = get_mixer_prefs() row = layout.row() row.template_list( "SHAREDFOLDER_UL_ItemRenderer", "", mixer_prefs, "shared_folders", mixer_props, "shared_folder_index", rows=4 ) col = row.column(align=True) col.operator(bl_operators.SharedFoldersAddFolderOperator.bl_idname, text="", icon="ADD") col.operator(bl_operators.SharedFoldersRemoveFolderOperator.bl_idname, text="", icon="REMOVE")
def draw_user_settings_ui(layout: bpy.types.UILayout): mixer_prefs = get_mixer_prefs() split = layout.split(factor=0.258, align=False) split.label(text="User:"******"user", text="") sub_row = row.row() sub_row.scale_x = 0.4 sub_row.prop(mixer_prefs, "color", text="")
def collapsable_panel( layout: bpy.types.UILayout, data: bpy.types.AnyType, property: str, alert: bool = False, **kwargs ): row = layout.row() row.prop( data, property, icon="TRIA_DOWN" if getattr(data, property) else "TRIA_RIGHT", icon_only=True, emboss=False, ) if alert: row.alert = True row.label(**kwargs) return getattr(data, property)
def draw_frame_prop(layout: bpy.types.UILayout, prop_label: str, prop_value: int): """Add a property to Blender's UI, showing timestamp and number of frames""" split = layout.split(factor=0.4, align=True) split.alignment = 'RIGHT' split.label(text=prop_label) split = split.split(factor=0.75, align=True) split.label(text=timestamp_str(prop_value)) split.alignment = 'RIGHT' split.label(text=f"{prop_value} ")
def __draw_position_properties(layout: bpy.types.UILayout, position_properties: WorkpiecePosition): position_box = layout.box() position_box.label(text="Visible face", icon="SNAP_FACE") position_box.prop(position_properties, "visible_surface", text="") position_box.label(text="Orientation", icon="FILE_REFRESH") position_box.prop(position_properties, "orientation", text="") position_box.label(text="View", icon="RESTRICT_VIEW_OFF") position_box.prop(position_properties, "view", text="") WorkpieceOperator.__draw_location_properties(position_box, position_properties)
def draw_item(self, context: bpy.types.Context, layout: bpy.types.UILayout, data: 'AddonPreferences', item: CustomPipelineProperty, icon: int, active_data: 'AddonPreferences', active_propname: str) -> None: """Defines the layout of a {sfm_flow.prefs.CustomPipelineProperty} list item.""" if self.layout_type in {'DEFAULT', 'COMPACT'}: split = layout.split(factor=0.3) split.label(text=item.name) split.label(text=item.command) elif self.layout_type in {'GRID'}: raise NotImplementedError( "`GRID` mode is not supported custom pipeline list items.")
def __draw_count_properties(layout: bpy.types.UILayout, count_properties: WorkpieceCount): count_box = layout.box() count_box.label(text="Count", icon="ORTHO") count_box.prop(count_properties, "count", text="") if count_properties.count > 1: count_box.prop(count_properties, "use_same_mesh", text="Use same mesh", icon="LINKED", toggle=True) count_box.label(text="Distance", icon='ARROW_LEFTRIGHT') count_box.prop(count_properties, "distance", text="")
def draw_connection_settings_ui(layout: bpy.types.UILayout): mixer_prefs = get_mixer_prefs() row = layout.row() split = row.split(factor=0.233, align=False) split.label(text="Host:") sub_row = split.row() sub_row.prop(mixer_prefs, "host", text="") sub_row.prop(mixer_prefs, "port") layout.separator() row = layout.row() split = row.split(factor=0.233, align=False) split.label(text="Session Log:") sub_row = split.row() icon = icons.icons_col["General_Explorer_32"] user_data_path = os.environ.get("MIXER_DATA_DIR", get_data_directory()) # from pathlib import Path # user_data_path = Path(user_data_path).parent sub_row.operator("mixer.open_explorer", text="Open Log Folder", icon_value=icon.icon_id).path = str(user_data_path)
def __draw_location_properties(position_box: bpy.types.UILayout, position_properties: WorkpiecePosition): position_box.label(text="Origin type") position_box.prop(position_properties, "origin_type", text="") if position_properties.origin_type == "corner": position_box.label(text="Selected corner (local)") position_box.prop(position_properties, "origin_corner", text="") elif position_properties.origin_type == "edge-centered": position_box.label(text="Selected edge") position_box.prop(position_properties, "origin_edge", text="") elif position_properties.origin_type == "face-centered": position_box.label(text="Selected face") position_box.prop(position_properties, "origin_face", text="") position_box.label(text="Origin location") position_box.prop(position_properties, "origin_location", text="") if position_properties.origin_location == "position": position_box.label(text="Coordinates") position_box.prop(position_properties, "location_coordinates", text="") elif position_properties.origin_location == "selected": position_box.label(text="Distance", icon='ARROW_LEFTRIGHT') position_box.prop(position_properties, "distance", text="")