mirror of
https://github.com/blender/blender-addons-contrib.git
synced 2025-07-25 16:09:05 +00:00
Amaranth: Fix "Current Blend's Folder" button missing in file browser.
This commit is contained in:
@ -87,8 +87,8 @@ from amaranth.misc import (
|
|||||||
bl_info = {
|
bl_info = {
|
||||||
"name": "Amaranth Toolset",
|
"name": "Amaranth Toolset",
|
||||||
"author": "Pablo Vazquez, Bassam Kurdali, Sergey Sharybin, Lukas Tönne, Cesar Saez, CansecoGPC",
|
"author": "Pablo Vazquez, Bassam Kurdali, Sergey Sharybin, Lukas Tönne, Cesar Saez, CansecoGPC",
|
||||||
"version": (1, 0, 7),
|
"version": (1, 0, 8),
|
||||||
"blender": (2, 80, 0),
|
"blender": (2, 81, 0),
|
||||||
"location": "Everywhere!",
|
"location": "Everywhere!",
|
||||||
"description": "A collection of tools and settings to improve productivity",
|
"description": "A collection of tools and settings to improve productivity",
|
||||||
"warning": "",
|
"warning": "",
|
||||||
|
@ -21,6 +21,12 @@ shows up if the file is saved.
|
|||||||
|
|
||||||
import bpy
|
import bpy
|
||||||
|
|
||||||
|
# From space_filebrowser.py
|
||||||
|
def panel_poll_is_upper_region(region):
|
||||||
|
# The upper region is left-aligned, the lower is split into it then.
|
||||||
|
# Note that after "Flip Regions" it's right-aligned.
|
||||||
|
return region.alignment in {'LEFT', 'RIGHT'}
|
||||||
|
|
||||||
|
|
||||||
class AMTH_FILE_OT_directory_current_blend(bpy.types.Operator):
|
class AMTH_FILE_OT_directory_current_blend(bpy.types.Operator):
|
||||||
|
|
||||||
@ -33,19 +39,42 @@ class AMTH_FILE_OT_directory_current_blend(bpy.types.Operator):
|
|||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
def button_directory_current_blend(self, context):
|
class FILEBROWSER_PT_amaranth(bpy.types.Panel):
|
||||||
if bpy.data.filepath:
|
bl_space_type = 'FILE_BROWSER'
|
||||||
self.layout.operator(
|
bl_region_type = 'TOOLS'
|
||||||
AMTH_FILE_OT_directory_current_blend.bl_idname,
|
bl_category = "Bookmarks"
|
||||||
text="Current Blend's Folder",
|
bl_label = "Amaranth"
|
||||||
icon="APPEND_BLEND")
|
bl_options = {'HIDE_HEADER'}
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def poll(cls, context):
|
||||||
|
return panel_poll_is_upper_region(context.region)
|
||||||
|
|
||||||
|
def draw(self, context):
|
||||||
|
layout = self.layout
|
||||||
|
layout.scale_x = 1.3
|
||||||
|
layout.scale_y = 1.3
|
||||||
|
|
||||||
|
if bpy.data.filepath:
|
||||||
|
row = layout.row()
|
||||||
|
flow = row.grid_flow(row_major=False, columns=0, even_columns=False, even_rows=False, align=True)
|
||||||
|
|
||||||
|
subrow = flow.row()
|
||||||
|
subsubrow = subrow.row(align=True)
|
||||||
|
subsubrow.operator(
|
||||||
|
AMTH_FILE_OT_directory_current_blend.bl_idname,
|
||||||
|
icon="DESKTOP")
|
||||||
|
|
||||||
|
|
||||||
|
classes = (
|
||||||
|
AMTH_FILE_OT_directory_current_blend,
|
||||||
|
FILEBROWSER_PT_amaranth
|
||||||
|
)
|
||||||
|
|
||||||
def register():
|
def register():
|
||||||
bpy.utils.register_class(AMTH_FILE_OT_directory_current_blend)
|
for cls in classes:
|
||||||
bpy.types.FILEBROWSER_HT_header.append(button_directory_current_blend)
|
bpy.utils.register_class(cls)
|
||||||
|
|
||||||
|
|
||||||
def unregister():
|
def unregister():
|
||||||
bpy.utils.unregister_class(AMTH_FILE_OT_directory_current_blend)
|
for cls in classes:
|
||||||
bpy.types.FILEBROWSER_HT_header.remove(button_directory_current_blend)
|
bpy.utils.unregister_class(cls)
|
||||||
|
Reference in New Issue
Block a user