Collection Manager: Update tooltips. Task: T69577

Make tooltips for QCD slots show the slot number and its
collection's name in both the OpenGL widget and
the 3D View header widget.
This commit is contained in:
Ryan Inch 2020-03-26 23:28:02 -04:00
parent 6c3fbd669d
commit 928d6a2e0a
3 changed files with 33 additions and 9 deletions

View File

@ -22,7 +22,7 @@ bl_info = {
"name": "Collection Manager",
"description": "Manage collections and their objects",
"author": "Ryan Inch",
"version": (2,4,3),
"version": (2,4,4),
"blender": (2, 80, 0),
"location": "View3D - Object Mode (Shortcut - M)",
"warning": '', # used for warning icon and text in addons panel

View File

@ -774,12 +774,13 @@ def draw_callback_px(self, context):
shader.bind()
in_tooltip_area = False
tooltip_slot_idx = None
for num in range(20):
slot_num = num + 1
qcd_slot = qcd_slots.get_name(f"{slot_num}")
if qcd_slot:
qcd_laycol = layer_collections[qcd_slot]["ptr"]
qcd_slot_name = qcd_slots.get_name(f"{slot_num}")
if qcd_slot_name:
qcd_laycol = layer_collections[qcd_slot_name]["ptr"]
collection_objects = qcd_laycol.collection.objects
selected_objects = qcd_operators.get_move_selection()
active_object = qcd_operators.get_move_active()
@ -794,6 +795,7 @@ def draw_callback_px(self, context):
if mouse_in_area(self.mouse_pos, button_area):
in_tooltip_area = True
tooltip_slot_idx = slot_num
mod = 0.1
@ -908,7 +910,12 @@ def draw_callback_px(self, context):
if in_tooltip_area:
if self.draw_tooltip:
draw_tooltip(self, context, shader,"Move Object To QCD Slot\n * Shift-Click to toggle objects\' slot")
slot_name = qcd_slots.get_name(f"{tooltip_slot_idx}")
slot_string = f"QCD Slot {tooltip_slot_idx}: \"{slot_name}\"\n"
hotkey_string = " * Shift-Click to toggle objects\' slot."
draw_tooltip(self, context, shader, f"{slot_string}{hotkey_string}")
self.hover_time = None
else:
@ -930,8 +937,10 @@ def draw_tooltip(self, context, shader, message):
num_lines = len(lines)
for line in lines:
if len(line) > longest[0]:
longest[0] = len(line)
w, _ = blf.dimensions(font_id, line)
if w > longest[0]:
longest[0] = w
longest[1] = line
w, h = blf.dimensions(font_id, longest[1])

View File

@ -154,13 +154,28 @@ class MoveToQCDSlot(Operator):
class ViewMoveQCDSlot(Operator):
''' * Shift-Click to toggle QCD slots\n * Ctrl-Click to move objects to QCD slot\n * Ctrl-Shift-Click to toggle objects\' slot'''
bl_label = "View QCD Slot"
bl_label = ""
bl_idname = "view3d.view_move_qcd_slot"
bl_options = {'REGISTER', 'UNDO'}
slot: StringProperty()
@classmethod
def description(cls, context, properties):
global qcd_slots
slot_name = qcd_slots.get_name(properties.slot)
slot_string = f"QCD Slot {properties.slot}: \"{slot_name}\"\n"
hotkey_string = (
" * Shift-Click to toggle QCD slot.\n"
" * Ctrl-Click to move objects to QCD slot.\n"
" * Ctrl-Shift-Click to toggle objects' slot"
)
return f"{slot_string}{hotkey_string}"
def invoke(self, context, event):
global layer_collections
global qcd_history