Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Oversized shorthand #4069

Merged
merged 4 commits into from
May 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions node_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,16 @@ def migrate_from(self, old_node):
"""
pass

@property
def prefs_over_sized_buttons(self):
try:
addon = bpy.context.preferences.addons.get(sverchok.__name__)
prefs = addon.preferences
except Exception as err:
print('failed to access addon preferences for button size', err)
return False
return prefs.over_sized_buttons

# Methods for OpenGL viewers

def get_and_set_gl_scale_info(self, origin=None): # todo, probably openGL viewers should have its own mixin class
Expand Down
10 changes: 3 additions & 7 deletions nodes/exchange/bezier_in.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,9 @@ def draw_buttons(self, context, layout):
row = col.row()
op_text = "Get selection" # fallback

try:
addon = context.preferences.addons.get(sverchok.__name__)
if addon.preferences.over_sized_buttons:
row.scale_y = 4.0
op_text = "G E T"
except:
pass
if self.prefs_over_sized_buttons:
row.scale_y = 4.0
op_text = "G E T"

self.wrapper_tracked_ui_draw_op(row, SvBezierInCallbackOp.bl_idname, text=op_text)

Expand Down
7 changes: 4 additions & 3 deletions nodes/exchange/gcode_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,10 @@ def sv_init(self, context):
self.outputs.new('SvStringsSocket', 'Travel Edges',)

def draw_buttons(self, context, layout):
with sv_preferences() as prefs:
#addon = context.user_preferences.addons.get(sverchok.__name__)
over_sized_buttons = prefs.over_sized_buttons #addon.preferences.over_sized_buttons

# over_sized_buttons = self.prefs_over_sized_buttons
# unused property.

col = layout.column(align=True)
row = col.row()
row.prop(self, 'folder', toggle=True, text='')
Expand Down
15 changes: 5 additions & 10 deletions nodes/exchange/nurbs_in.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,21 +121,16 @@ def draw_buttons_ext(self, context, layout):

def draw_buttons(self, context, layout):
self.draw_animatable_buttons(layout, icon_only=True)
layout.prop(self, 'implementation', text='')

layout.prop(self, 'implementation', text='')
col = layout.column(align=True)
row = col.row(align=True)

row = col.row()
op_text = "Get selection" # fallback

try:
addon = context.preferences.addons.get(sverchok.__name__)
if addon.preferences.over_sized_buttons:
row.scale_y = 4.0
op_text = "G E T"
except:
pass
op_text = "Get selection" # fallback
if self.prefs_over_sized_buttons:
row.scale_y = 4.0
op_text = "G E T"

callback = 'node.sv_ex_nurbs_in_callback'
self.wrapper_tracked_ui_draw_op(row, callback, text=op_text).fn_name = 'get_objects_from_scene'
Expand Down
12 changes: 6 additions & 6 deletions nodes/scene/obj_edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class SvObjEditCallback(bpy.types.Operator):
bl_label = "Sverchok object in lite callback"
bl_options = {'REGISTER', 'UNDO', 'INTERNAL'}


cmd: StringProperty()
mode: StringProperty()

Expand All @@ -52,10 +51,13 @@ class SvObjEdit(bpy.types.Node, SverchCustomTreeNode):
def set_edit(self, ops, mode):
try:
obj_name = self.obj_passed_in or self.inputs[0].object_ref
bpy.context.scene.objects.active = bpy.data.objects.get(obj_name)

bpy.context.view_layer.objects.active = bpy.data.objects.get(obj_name)
bpy.ops.object.mode_set(mode=mode)
except:

except Exception as err:
ops.report({'WARNING'}, 'No object selected / active')
print(err)


def sv_init(self, context):
Expand All @@ -67,13 +69,11 @@ def draw_buttons(self, context, layout):
if not (self.inputs and self.inputs[0]):
return

addon = context.preferences.addons.get(sverchok.__name__)
prefs = addon.preferences
callback = 'node.sverchok_objectedit_cb'

col = layout.column(align=True)
row = col.row(align=True)
row.scale_y = 4.0 if prefs.over_sized_buttons else 1
row.scale_y = 4.0 if self.prefs_over_sized_buttons else 1

objects = bpy.data.objects
if self.obj_passed_in or self.inputs[0].object_ref:
Expand Down
5 changes: 2 additions & 3 deletions nodes/scene/objects_in_lite.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,12 @@ def sv_init(self, context):
out('SvMatrixSocket', 'Matrix')

def draw_buttons(self, context, layout):
addon = context.preferences.addons.get(sverchok.__name__)
prefs = addon.preferences
callback = 'node.sverchok_objectinlite_cb'
scale_y = 4.0 if self.prefs_over_sized_buttons else 1

col = layout.column(align=True)
row = col.row(align=True)
row.scale_y = 4.0 if prefs.over_sized_buttons else 1
row.scale_y = scale_y

cb_text, cmd, display_text = [
("G E T", "dget", "--None--"),
Expand Down
12 changes: 4 additions & 8 deletions nodes/scene/objects_mk3.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,10 @@ def draw_buttons(self, context, layout):
op_text = "Get selection" # fallback
callback = 'node.ob3_callback'

try:
addon = context.preferences.addons.get(sverchok.__name__)
if addon.preferences.over_sized_buttons:
row.scale_y = 4.0
op_text = "G E T"
except:
pass

if self.prefs_over_sized_buttons:
row.scale_y = 4.0
op_text = "G E T"

self.wrapper_tracked_ui_draw_op(row, callback, text=op_text).fn_name = 'get_objects_from_scene'

col = layout.column(align=True)
Expand Down
5 changes: 1 addition & 4 deletions nodes/text/text_in_mk2.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,17 +183,14 @@ def draw_buttons_ext(self, context, layout):

def draw_buttons(self, context, layout):

addon = context.preferences.addons.get(sverchok.__name__)
over_sized_buttons = addon.preferences.over_sized_buttons

col = layout.column(align=True)
col.prop(self, 'autoreload', toggle=True) # reload() not work properly somehow 2016.10.07 | really? 2017.12.21
if self.current_text:
col.label(text="File: {0} loaded".format(self.current_text))
row = col.row(align=True)

if not self.autoreload:
row.scale_y = 4.0 if over_sized_buttons else 1
row.scale_y = 4.0 if self.prefs_over_sized_buttons else 1
row.operator(TEXT_IO_CALLBACK, text='R E L O A D').fn_name = 'reload'
col.operator(TEXT_IO_CALLBACK, text='R E S E T').fn_name = 'reset'

Expand Down
5 changes: 1 addition & 4 deletions nodes/text/text_out_mk2.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,6 @@ def sv_init(self, context):

def draw_buttons(self, context, layout):

addon = context.preferences.addons.get(sverchok.__name__)
over_sized_buttons = addon.preferences.over_sized_buttons

col = layout.column(align=True)
col.prop(self, 'autodump', toggle=True)
row = col.row(align=True)
Expand All @@ -211,7 +208,7 @@ def draw_buttons(self, context, layout):
if not self.autodump:
col2 = col.column(align=True)
row = col2.row(align=True)
row.scale_y = 4.0 if over_sized_buttons else 1
row.scale_y = 4.0 if self.prefs_over_sized_buttons else 1
row.operator(TEXT_IO_CALLBACK, text='D U M P').fn_name = 'dump'
col2.prop(self, 'append', text="Append")

Expand Down
5 changes: 2 additions & 3 deletions nodes/viz/viewer_draw_mk4.py
Original file line number Diff line number Diff line change
Expand Up @@ -676,8 +676,7 @@ def configureAttrSocket(self, context):
node_ui_show_attrs_socket: BoolProperty(default=False, name='Show attributes socket', update=configureAttrSocket)

def draw_buttons(self, context, layout):
addon = context.preferences.addons.get(sverchok.__name__)
over_sized_buttons = addon.preferences.over_sized_buttons

r0 = layout.row()
r0.prop(self, "activate", text="", icon="HIDE_" + ("OFF" if self.activate else "ON"))
r0.separator()
Expand All @@ -689,7 +688,7 @@ def draw_buttons(self, context, layout):
row.prop(self, "point_size")
row.prop(self, "line_width")
row = layout.row(align=True)
row.scale_y = 4.0 if over_sized_buttons else 1
row.scale_y = 4.0 if self.prefs_over_sized_buttons else 1
self.wrapper_tracked_ui_draw_op(row, "node.sverchok_mesh_baker_mk3", icon='OUTLINER_OB_MESH', text="B A K E")
row.separator()
self.wrapper_tracked_ui_draw_op(row, "node.view3d_align_from", icon='CURSOR', text='')
Expand Down
3 changes: 1 addition & 2 deletions settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ def general_tab(self, layout):
col1 = col_split.column()
col1.label(text="UI:")
col1.prop(self, "show_icons")
col1.prop(self, "over_sized_buttons")

toolbar_box = col1.box()
toolbar_box.label(text="Node toolbars")
Expand All @@ -430,8 +431,6 @@ def general_tab(self, layout):
toolbar_box.prop(self, "node_panels_columns")

col1.prop(self, 'show_input_menus')

col1.prop(self, "over_sized_buttons")
col1.prop(self, "external_editor", text="Ext Editor")
col1.prop(self, "real_sverchok_path", text="Src Directory")

Expand Down