diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-01-25 04:33:47 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-01-25 04:33:59 +0300 |
commit | 425a3f6a705beab849cab36d2ca2ae43726d700f (patch) | |
tree | 00802f0b1efac9d9fc8b7b4062ab5349ca90722d /blenderkit | |
parent | 3c6e9c26bc6b35399dfbc38c3116b1375fa6f53c (diff) |
Cleanup: strip trailing space
Diffstat (limited to 'blenderkit')
-rw-r--r-- | blenderkit/__init__.py | 8 | ||||
-rw-r--r-- | blenderkit/asset_pack_bg.py | 2 | ||||
-rw-r--r-- | blenderkit/bl_ui_widgets/__init__.py | 6 | ||||
-rw-r--r-- | blenderkit/bl_ui_widgets/bl_ui_button.py | 66 | ||||
-rw-r--r-- | blenderkit/bl_ui_widgets/bl_ui_drag_panel.py | 24 | ||||
-rw-r--r-- | blenderkit/bl_ui_widgets/bl_ui_draw_op.py | 38 | ||||
-rw-r--r-- | blenderkit/bl_ui_widgets/bl_ui_label.py | 14 | ||||
-rw-r--r-- | blenderkit/bl_ui_widgets/bl_ui_widget.py | 44 | ||||
-rw-r--r-- | blenderkit/image_utils.py | 2 | ||||
-rw-r--r-- | blenderkit/resolutions.py | 2 | ||||
-rw-r--r-- | blenderkit/resolutions_bg.py | 2 |
11 files changed, 103 insertions, 105 deletions
diff --git a/blenderkit/__init__.py b/blenderkit/__init__.py index d3cd5a72..4a4ae4ba 100644 --- a/blenderkit/__init__.py +++ b/blenderkit/__init__.py @@ -91,13 +91,13 @@ else: from blenderkit import upload from blenderkit import utils - from blenderkit.bl_ui_widgets import bl_ui_label - from blenderkit.bl_ui_widgets import bl_ui_button + from blenderkit.bl_ui_widgets import bl_ui_label + from blenderkit.bl_ui_widgets import bl_ui_button # from blenderkit.bl_ui_widgets import bl_ui_checkbox # from blenderkit.bl_ui_widgets import bl_ui_slider # from blenderkit.bl_ui_widgets import bl_ui_up_down - from blenderkit.bl_ui_widgets import bl_ui_drag_panel - from blenderkit.bl_ui_widgets import bl_ui_draw_op + from blenderkit.bl_ui_widgets import bl_ui_drag_panel + from blenderkit.bl_ui_widgets import bl_ui_draw_op # from blenderkit.bl_ui_widgets import bl_ui_textbox diff --git a/blenderkit/asset_pack_bg.py b/blenderkit/asset_pack_bg.py index adde9515..c59ca08d 100644 --- a/blenderkit/asset_pack_bg.py +++ b/blenderkit/asset_pack_bg.py @@ -5,4 +5,4 @@ from blenderkit import resolutions BLENDERKIT_EXPORT_DATA = sys.argv[-1] if __name__ == "__main__": - resolutions.run_bg(sys.argv[-1])
\ No newline at end of file + resolutions.run_bg(sys.argv[-1]) diff --git a/blenderkit/bl_ui_widgets/__init__.py b/blenderkit/bl_ui_widgets/__init__.py index 745f59c9..a1db444d 100644 --- a/blenderkit/bl_ui_widgets/__init__.py +++ b/blenderkit/bl_ui_widgets/__init__.py @@ -16,7 +16,7 @@ from bpy.props import * addon_keymaps = [] def register(): - + bpy.utils.register_class(DP_OT_draw_operator) kcfg = bpy.context.window_manager.keyconfigs.addon if kcfg: @@ -29,8 +29,8 @@ def unregister(): for km, kmi in addon_keymaps: km.keymap_items.remove(kmi) addon_keymaps.clear() - + bpy.utils.unregister_class(DP_OT_draw_operator) - + if __name__ == "__main__": register() diff --git a/blenderkit/bl_ui_widgets/bl_ui_button.py b/blenderkit/bl_ui_widgets/bl_ui_button.py index ce26c54e..f3902c4b 100644 --- a/blenderkit/bl_ui_widgets/bl_ui_button.py +++ b/blenderkit/bl_ui_widgets/bl_ui_button.py @@ -4,13 +4,13 @@ import blf import bpy class BL_UI_Button(BL_UI_Widget): - + def __init__(self, x, y, width, height): super().__init__(x, y, width, height) self._text_color = (1.0, 1.0, 1.0, 1.0) self._hover_bg_color = (0.5, 0.5, 0.5, 1.0) self._select_bg_color = (0.7, 0.7, 0.7, 1.0) - + self._text = "Button" self._text_size = 16 self._textpos = (x, y) @@ -35,7 +35,7 @@ class BL_UI_Button(BL_UI_Widget): @text.setter def text(self, value): self._text = value - + @property def text_size(self): return self._text_size @@ -58,8 +58,8 @@ class BL_UI_Button(BL_UI_Widget): @select_bg_color.setter def select_bg_color(self, value): - self._select_bg_color = value - + self._select_bg_color = value + def set_image_size(self, imgage_size): self.__image_size = imgage_size @@ -68,30 +68,30 @@ class BL_UI_Button(BL_UI_Widget): def set_image(self, rel_filepath): try: - self.__image = bpy.data.images.load(rel_filepath, check_existing=True) + self.__image = bpy.data.images.load(rel_filepath, check_existing=True) self.__image.gl_load() except: pass - def update(self, x, y): + def update(self, x, y): super().update(x, y) self._textpos = [x, y] - + def draw(self): if not self.visible: return - + area_height = self.get_area_height() self.shader.bind() - + self.set_colors() - + bgl.glEnable(bgl.GL_BLEND) - self.batch_panel.draw(self.shader) + self.batch_panel.draw(self.shader) - self.draw_image() + self.draw_image() bgl.glDisable(bgl.GL_BLEND) @@ -128,21 +128,21 @@ class BL_UI_Button(BL_UI_Widget): if self.__image is not None: try: y_screen_flip = self.get_area_height() - self.y_screen - + off_x, off_y = self.__image_position sx, sy = self.__image_size - + # bottom left, top left, top right, bottom right vertices = ( - (self.x_screen + off_x, y_screen_flip - off_y), - (self.x_screen + off_x, y_screen_flip - sy - off_y), + (self.x_screen + off_x, y_screen_flip - off_y), + (self.x_screen + off_x, y_screen_flip - sy - off_y), (self.x_screen + off_x + sx, y_screen_flip - sy - off_y), (self.x_screen + off_x + sx, y_screen_flip - off_y)) - + self.shader_img = gpu.shader.from_builtin('2D_IMAGE') - self.batch_img = batch_for_shader(self.shader_img, 'TRI_FAN', - { "pos" : vertices, - "texCoord": ((0, 1), (0, 0), (1, 0), (1, 1)) + self.batch_img = batch_for_shader(self.shader_img, 'TRI_FAN', + { "pos" : vertices, + "texCoord": ((0, 1), (0, 0), (1, 0), (1, 1)) },) # send image to gpu if it isn't there already @@ -154,39 +154,39 @@ class BL_UI_Button(BL_UI_Widget): self.shader_img.bind() self.shader_img.uniform_int("image", 0) - self.batch_img.draw(self.shader_img) + self.batch_img.draw(self.shader_img) return True except: pass - return False - + return False + def set_mouse_down(self, mouse_down_func): - self.mouse_down_func = mouse_down_func - - def mouse_down(self, x, y): + self.mouse_down_func = mouse_down_func + + def mouse_down(self, x, y): if self.is_in_rect(x,y): self.__state = 1 try: self.mouse_down_func(self) except Exception as e: print(e) - + return True - + return False - + def mouse_move(self, x, y): if self.is_in_rect(x,y): if(self.__state != 1): - + # hover state self.__state = 2 else: self.__state = 0 - + def mouse_up(self, x, y): if self.is_in_rect(x,y): self.__state = 2 else: - self.__state = 0
\ No newline at end of file + self.__state = 0 diff --git a/blenderkit/bl_ui_widgets/bl_ui_drag_panel.py b/blenderkit/bl_ui_widgets/bl_ui_drag_panel.py index e07aa784..44a5b1b9 100644 --- a/blenderkit/bl_ui_widgets/bl_ui_drag_panel.py +++ b/blenderkit/bl_ui_widgets/bl_ui_drag_panel.py @@ -1,7 +1,7 @@ -from . bl_ui_widget import * +from . bl_ui_widget import * class BL_UI_Drag_Panel(BL_UI_Widget): - + def __init__(self, x, y, width, height): super().__init__(x,y, width, height) self.drag_offset_x = 0 @@ -15,35 +15,35 @@ class BL_UI_Drag_Panel(BL_UI_Widget): def add_widget(self, widget): self.widgets.append(widget) - + def add_widgets(self, widgets): self.widgets = widgets self.layout_widgets() - + def layout_widgets(self): for widget in self.widgets: - widget.update(self.x_screen + widget.x, self.y_screen + widget.y) - + widget.update(self.x_screen + widget.x, self.y_screen + widget.y) + def update(self, x, y): super().update(x - self.drag_offset_x, y + self.drag_offset_y) - + def child_widget_focused(self, x, y): for widget in self.widgets: if widget.is_in_rect(x, y): - return True + return True return False - + def mouse_down(self, x, y): if self.child_widget_focused(x, y): return False - + if self.is_in_rect(x,y): height = self.get_area_height() self.is_drag = True self.drag_offset_x = x - self.x_screen self.drag_offset_y = y - (height - self.y_screen) return True - + return False def mouse_move(self, x, y): @@ -55,4 +55,4 @@ class BL_UI_Drag_Panel(BL_UI_Widget): def mouse_up(self, x, y): self.is_drag = False self.drag_offset_x = 0 - self.drag_offset_y = 0
\ No newline at end of file + self.drag_offset_y = 0 diff --git a/blenderkit/bl_ui_widgets/bl_ui_draw_op.py b/blenderkit/bl_ui_widgets/bl_ui_draw_op.py index 2f534479..ab407f47 100644 --- a/blenderkit/bl_ui_widgets/bl_ui_draw_op.py +++ b/blenderkit/bl_ui_widgets/bl_ui_draw_op.py @@ -5,14 +5,14 @@ from bpy.types import Operator class BL_UI_OT_draw_operator(Operator): bl_idname = "object.bl_ui_ot_draw_operator" bl_label = "bl ui widgets operator" - bl_description = "Operator for bl ui widgets" + bl_description = "Operator for bl ui widgets" bl_options = {'REGISTER'} - + def __init__(self): self.draw_handle = None self.draw_event = None self._finished = False - + self.widgets = [] def init_widgets(self, context, widgets): @@ -31,32 +31,32 @@ class BL_UI_OT_draw_operator(Operator): self.on_invoke(context, event) args = (self, context) - + self.register_handlers(args, context) - + context.window_manager.modal_handler_add(self) return {"RUNNING_MODAL"} - + def register_handlers(self, args, context): self.draw_handle = bpy.types.SpaceView3D.draw_handler_add(self.draw_callback_px, args, "WINDOW", "POST_PIXEL") self.draw_event = context.window_manager.event_timer_add(0.1, window=context.window) - + def unregister_handlers(self, context): - + context.window_manager.event_timer_remove(self.draw_event) - + bpy.types.SpaceView3D.draw_handler_remove(self.draw_handle, "WINDOW") - + self.draw_handle = None self.draw_event = None - + def handle_widget_events(self, event): result = False for widget in self.widgets: if widget.handle_event(event): result = True return result - + def modal(self, context, event): if self._finished: @@ -64,20 +64,20 @@ class BL_UI_OT_draw_operator(Operator): if context.area: context.area.tag_redraw() - + if self.handle_widget_events(event): - return {'RUNNING_MODAL'} - + return {'RUNNING_MODAL'} + if event.type in {"ESC"}: self.finish() - + return {"PASS_THROUGH"} - + def finish(self): self.unregister_handlers(bpy.context) self.on_finish(bpy.context) - + # Draw handler to paint onto the screen def draw_callback_px(self, op, context): for widget in self.widgets: - widget.draw()
\ No newline at end of file + widget.draw() diff --git a/blenderkit/bl_ui_widgets/bl_ui_label.py b/blenderkit/bl_ui_widgets/bl_ui_label.py index 11743b41..b008a17b 100644 --- a/blenderkit/bl_ui_widgets/bl_ui_label.py +++ b/blenderkit/bl_ui_widgets/bl_ui_label.py @@ -3,7 +3,7 @@ from . bl_ui_widget import * import blf class BL_UI_Label(BL_UI_Widget): - + def __init__(self, x, y, width, height): super().__init__(x, y, width, height) @@ -34,24 +34,24 @@ class BL_UI_Label(BL_UI_Widget): @text_size.setter def text_size(self, value): self._text_size = value - + def is_in_rect(self, x, y): return False - + def draw(self): if not self.visible: return - + area_height = self.get_area_height() blf.size(0, self._text_size, 72) size = blf.dimensions(0, self._text) - + textpos_y = area_height - self.y_screen - self.height blf.position(0, self.x_screen, textpos_y, 0) r, g, b, a = self._text_color blf.color(0, r, g, b, a) - - blf.draw(0, self._text)
\ No newline at end of file + + blf.draw(0, self._text) diff --git a/blenderkit/bl_ui_widgets/bl_ui_widget.py b/blenderkit/bl_ui_widgets/bl_ui_widget.py index 2ae529fa..c13bb33d 100644 --- a/blenderkit/bl_ui_widgets/bl_ui_widget.py +++ b/blenderkit/bl_ui_widgets/bl_ui_widget.py @@ -4,7 +4,7 @@ import bgl from gpu_extras.batch import batch_for_shader class BL_UI_Widget: - + def __init__(self, x, y, width, height): self.x = x self.y = y @@ -50,40 +50,40 @@ class BL_UI_Widget: @tag.setter def tag(self, value): self._tag = value - + def draw(self): if not self.visible: return - + self.shader.bind() self.shader.uniform_float("color", self._bg_color) - + bgl.glEnable(bgl.GL_BLEND) - self.batch_panel.draw(self.shader) + self.batch_panel.draw(self.shader) bgl.glDisable(bgl.GL_BLEND) def init(self, context): self.context = context self.update(self.x, self.y) - + def update(self, x, y): - + area_height = self.get_area_height() - + self.x_screen = x self.y_screen = y - + indices = ((0, 1, 2), (0, 2, 3)) y_screen_flip = area_height - self.y_screen # bottom left, top left, top right, bottom right vertices = ( - (self.x_screen, y_screen_flip), - (self.x_screen, y_screen_flip - self.height), + (self.x_screen, y_screen_flip), + (self.x_screen, y_screen_flip - self.height), (self.x_screen + self.width, y_screen_flip - self.height), (self.x_screen + self.width, y_screen_flip)) - + self.shader = gpu.shader.from_builtin('2D_UNIFORM_COLOR') self.batch_panel = batch_for_shader(self.shader, 'TRIS', {"pos" : vertices}, indices=indices) @@ -140,17 +140,17 @@ class BL_UI_Widget: widget_y = area_height - self.y_screen if ( - (self.x_screen <= x <= (self.x_screen + self.width)) and + (self.x_screen <= x <= (self.x_screen + self.width)) and (widget_y >= y >= (widget_y - self.height)) ): return True - - return False - def text_input(self, event): return False - def mouse_down(self, x, y): + def text_input(self, event): + return False + + def mouse_down(self, x, y): return self.is_in_rect(x,y) def mouse_down_right(self, x, y): @@ -160,8 +160,8 @@ class BL_UI_Widget: pass def set_mouse_enter(self, mouse_enter_func): - self.mouse_enter_func = mouse_enter_func - + self.mouse_enter_func = mouse_enter_func + def call_mouse_enter(self): try: if self.mouse_enter_func: @@ -173,8 +173,8 @@ class BL_UI_Widget: self.call_mouse_enter() def set_mouse_exit(self, mouse_exit_func): - self.mouse_exit_func = mouse_exit_func - + self.mouse_exit_func = mouse_exit_func + def call_mouse_exit(self): try: if self.mouse_exit_func: @@ -186,4 +186,4 @@ class BL_UI_Widget: self.call_mouse_exit() def mouse_move(self, x, y): - pass
\ No newline at end of file + pass diff --git a/blenderkit/image_utils.py b/blenderkit/image_utils.py index e0b49b10..96bad204 100644 --- a/blenderkit/image_utils.py +++ b/blenderkit/image_utils.py @@ -87,5 +87,3 @@ def generate_hdr_thumbnail(): inew.scale(thumbnailWidth, thumbnailHeight) img_save_as(inew, filepath=inew.filepath) - - diff --git a/blenderkit/resolutions.py b/blenderkit/resolutions.py index 03026c68..6d66d55b 100644 --- a/blenderkit/resolutions.py +++ b/blenderkit/resolutions.py @@ -209,7 +209,7 @@ def make_possible_reductions_on_image(teximage, input_filepath, do_reductions=Fa - it finds it's usages and replaces the inputs where the image is used with zero/black color. currently implemented file type conversions: - PNG->JPG + PNG->JPG ''' colorspace = teximage.colorspace_settings.name teximage.colorspace_settings.name = 'Non-Color' diff --git a/blenderkit/resolutions_bg.py b/blenderkit/resolutions_bg.py index adde9515..c59ca08d 100644 --- a/blenderkit/resolutions_bg.py +++ b/blenderkit/resolutions_bg.py @@ -5,4 +5,4 @@ from blenderkit import resolutions BLENDERKIT_EXPORT_DATA = sys.argv[-1] if __name__ == "__main__": - resolutions.run_bg(sys.argv[-1])
\ No newline at end of file + resolutions.run_bg(sys.argv[-1]) |