Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Inch <mythologylover75@gmail.com>2020-07-24 06:15:35 +0300
committerRyan Inch <mythologylover75@gmail.com>2020-07-24 06:15:35 +0300
commit2c9bc1e642bc77470921968b4890fc53a038f408 (patch)
tree8f3d81133394b098b72b652ee9893158f2bd1ec2
parent089cfd12a5511829aafad3790417a5218955a3ad (diff)
Collection Manager: QCD Move Widget fixes. Task: T69577
Fix QCD Move Widget not accounting for the 3D View bounds when first called and not appearing at all when called from the menu if the mouse is outside the 3D View.
-rw-r--r--object_collection_manager/__init__.py2
-rw-r--r--object_collection_manager/qcd_move_widget.py43
2 files changed, 27 insertions, 18 deletions
diff --git a/object_collection_manager/__init__.py b/object_collection_manager/__init__.py
index 7fe71187..ad67c29b 100644
--- a/object_collection_manager/__init__.py
+++ b/object_collection_manager/__init__.py
@@ -22,7 +22,7 @@ bl_info = {
"name": "Collection Manager",
"description": "Manage collections and their objects",
"author": "Ryan Inch",
- "version": (2, 12, 1),
+ "version": (2, 12, 2),
"blender": (2, 80, 0),
"location": "View3D - Object Mode (Shortcut - M)",
"warning": '', # used for warning icon and text in addons panel
diff --git a/object_collection_manager/qcd_move_widget.py b/object_collection_manager/qcd_move_widget.py
index 85f63f58..28ed9c01 100644
--- a/object_collection_manager/qcd_move_widget.py
+++ b/object_collection_manager/qcd_move_widget.py
@@ -27,10 +27,12 @@ import gpu
from gpu_extras.batch import batch_for_shader
from bpy.types import Operator
+
from .internals import (
layer_collections,
qcd_slots,
)
+
from . import qcd_operators
def spacer():
@@ -338,13 +340,7 @@ def mouse_in_area(mouse_pos, area, buf = 0):
return True
def account_for_view_bounds(area):
- # make sure it renders in the 3d view
- # left
- if area["vert"][0] < 0:
- x = 0
- y = area["vert"][1]
-
- area["vert"] = (x, y)
+ # make sure it renders in the 3d view - prioritize top left
# right
if area["vert"][0] + area["width"] > bpy.context.region.width:
@@ -353,10 +349,10 @@ def account_for_view_bounds(area):
area["vert"] = (x, y)
- # top
- if area["vert"][1] > bpy.context.region.height:
- x = area["vert"][0]
- y = bpy.context.region.height
+ # left
+ if area["vert"][0] < 0:
+ x = 0
+ y = area["vert"][1]
area["vert"] = (x, y)
@@ -367,6 +363,13 @@ def account_for_view_bounds(area):
area["vert"] = (x, y)
+ # top
+ if area["vert"][1] > bpy.context.region.height:
+ x = area["vert"][0]
+ y = bpy.context.region.height
+
+ area["vert"] = (x, y)
+
def update_area_dimensions(area, w=0, h=0):
area["width"] += w
area["height"] += h
@@ -390,6 +393,7 @@ class QCDMoveWidget(Operator):
}
last_type = ''
+ initialized = False
moved = False
def modal(self, context, event):
@@ -424,12 +428,16 @@ class QCDMoveWidget(Operator):
self.mouse_pos = (event.mouse_region_x, event.mouse_region_y)
if not mouse_in_area(self.mouse_pos, self.areas["Main Window"], 50 * scale_factor()):
- bpy.types.SpaceView3D.draw_handler_remove(self._handle, 'WINDOW')
+ if self.initialized:
+ bpy.types.SpaceView3D.draw_handler_remove(self._handle, 'WINDOW')
- if self.moved:
- bpy.ops.ed.undo_push()
+ if self.moved:
+ bpy.ops.ed.undo_push()
- return {'FINISHED'}
+ return {'FINISHED'}
+
+ else:
+ self.initialized = True
elif event.value == 'PRESS' and event.type == 'LEFTMOUSE':
if not mouse_in_area(self.mouse_pos, self.areas["Main Window"], 10 * scale_factor()):
@@ -498,13 +506,14 @@ class QCDMoveWidget(Operator):
"height": 0,
"value": None
}
- account_for_view_bounds(main_window)
- # add main window background to areas
self.areas["Main Window"] = main_window
+ allocate_main_ui(self, context)
+ account_for_view_bounds(main_window)
context.window_manager.modal_handler_add(self)
return {'RUNNING_MODAL'}
+
else:
self.report({'WARNING'}, "View3D not found, cannot run operator")
return {'CANCELLED'}