-
Notifications
You must be signed in to change notification settings - Fork 78
/
ui.py
140 lines (113 loc) · 5.4 KB
/
ui.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####
import bpy
from bpy.types import Operator
from bpy.app.translations import pgettext_iface as iface_
from . import geometry, utils, gob_import
icons = None
preview_collections = {}
def draw_goz_buttons(self, context):
if context.region.alignment == 'RIGHT':
layout = self.layout
row = layout.row(align=True)
icons = preview_collections["main"]
if utils.prefs().show_button_text:
row.operator(operator="scene.gob_export_button",
text="Export",
emboss=True,
icon_value=icons["GOZ_SEND"].icon_id)
if gob_import.run_background_update:
row.operator(operator="scene.gob_import",
text=iface_("Import", None),
emboss=True,
depress=True,
icon_value=icons["GOZ_SYNC_ENABLED"].icon_id).action = 'AUTO'
else:
row.operator(operator="scene.gob_import",
text=iface_("Import", None),
emboss=True,
depress=False,
icon_value=icons["GOZ_SYNC_DISABLED"].icon_id).action = 'AUTO'
row.operator(operator="scene.gob_import",
text="Manual",
emboss=True,
depress=False,
icon='IMPORT').action = 'MANUAL'
else:
row.operator(operator="scene.gob_export_button",
text="",
emboss=True,
icon_value=icons["GOZ_SEND"].icon_id)
if gob_import.run_background_update:
row.operator(operator="scene.gob_import",
text="",
emboss=True,
depress=True,
icon_value=icons["GOZ_SYNC_ENABLED"].icon_id).action = 'AUTO'
else:
row.operator(operator="scene.gob_import",
text="",
emboss=True,
depress=False,
icon_value=icons["GOZ_SYNC_DISABLED"].icon_id).action = 'AUTO'
row.operator(operator="scene.gob_import",
text="",
emboss=True,
depress=False,
icon='IMPORT').action = 'MANUAL'
class GoB_OT_export_button(Operator):
bl_idname = "scene.gob_export_button"
bl_label = "Export to ZBrush"
bl_description = "Export selected Objects to ZBrush\n"\
"LeftMouse: as Subtool\n"\
"SHIFT/CTRL/ALT + LeftMouse: as Tool"
bl_options = {'INTERNAL'}
@classmethod
def poll(cls, context):
return geometry.export_poll(cls, context)
#return bpy.context.selected_objects
def invoke(self, context, event):
as_tool = event.shift or event.ctrl or event.alt
bpy.ops.scene.gob_export(as_tool=as_tool)
return {'FINISHED'}
class GOB_OT_Popup(Operator):
bl_label = "GoB: Zbrush Path not found!"
bl_description ="look for zbrush in specified path or in default installation"\
"directories and if its not found prompt the user to input the path manually"
bl_idname = "gob.search_zbrush"
def draw(self, context):
self.layout.label(text='Please set your ZBrush path', icon='COLORSET_01_VEC')
self.layout.label(text=' in the Add-ons Preferences')
def open_addon_prefs(self, context):
context.window_manager.addon_support = {'OFFICIAL', 'COMMUNITY', 'TESTING'}
bpy.ops.preferences.addon_show(module=__package__)
def invoke(self, context, event):
wm = context.window_manager
if bpy.app.version < (4,3,0):
font_size_correction = bpy.context.preferences.ui_styles[0].widget_label.points / 10
else:
font_size_correction = bpy.context.preferences.ui_styles[0].tooltip.points / 10
return wm.invoke_props_dialog(self, width = int(200 * font_size_correction))
def execute(self, context):
self.open_addon_prefs(context)
return {'FINISHED'}
def ShowReport(self, message = [], title = "Message Box", icon = 'INFO'):
def draw(self, context):
for i in message:
self.layout.label(text=i)
bpy.context.window_manager.popup_menu(draw, title = title, icon = icon)