[Bf-extensions-cvs] [2c9bc1e6] blender-v2.90-release: Collection Manager: QCD Move Widget fixes. Task: T69577

Ryan Inch noreply at git.blender.org
Fri Jul 24 05:19:46 CEST 2020


Commit: 2c9bc1e642bc77470921968b4890fc53a038f408
Author: Ryan Inch
Date:   Thu Jul 23 23:15:35 2020 -0400
Branches: blender-v2.90-release
https://developer.blender.org/rBA2c9bc1e642bc77470921968b4890fc53a038f408

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.

===================================================================

M	object_collection_manager/__init__.py
M	object_collection_manager/qcd_move_widget.py

===================================================================

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'}



More information about the Bf-extensions-cvs mailing list