Skip to content

Commit

Permalink
Rename messages offset to scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
AlpenAalAlex committed Feb 7, 2024
1 parent e1d8ea8 commit 13847b7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
19 changes: 10 additions & 9 deletions phobos/blender/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,31 +206,32 @@ def draw_textbox(
draw_text(text, position=origin, size=textsize, color=textcolor)


def draw_message(text, msgtype, slot, opacity=1.0, offset=0):
def draw_message(text, msgtype, slot, opacity=1.0, scroll=0):
"""
Args:
text:
msgtype:
slot:
opacity: (Default value = 1.0)
offset: (Default value = 0)
scroll: (Default value = 0)
Returns:
"""
blf.size(0, 6, 150)
margin = 4
start = 20
if slot == 0 and scroll > 0:
start = start + get_text_width('+' + str(scroll), size=6) + margin
blocksize = 10
left, top = start, slotlower[slot] + 4
width, height = blocksize, blocksize
draw_2dpolygon(left, top, width, height, fillcolor=(*colors[msgtype], 0.2 * opacity))
draw_text(text, (start + margin + blocksize - 1, slotlower[slot] + 4 - 1), size=6, color=(0, 0, 0, opacity))
draw_text(text, (start + margin + blocksize, slotlower[slot] + 4), size=6, color=(1, 1, 1, opacity))
if slot == 0 and offset > 0:
# draw_text(str(offset) + ' \u25bc', (start - 30, slotlower[0] + 4), size=6, color=(1, 1, 1, opacity))
draw_text('+' + str(offset), (start - 30, slotlower[0] + 4), size=6, color=(1, 1, 1, 1))
if slot == 0 and scroll > 0:
draw_text('+' + str(scroll), (10, slotlower[0] + 4), size=6, color=(1, 1, 1, 1))


def draw_progressbar(value):
Expand Down Expand Up @@ -445,13 +446,13 @@ def draw_callback_2d(self, context):
if wm.draw_messages:
for m in range(wm.phobos_msg_count):
opacity = 1.0
if 1 >= m <= wm.phobos_msg_offset - 1 or m >= wm.phobos_msg_count - 2:
if 1 >= m <= wm.phobos_msg_scroll - 1 or m >= wm.phobos_msg_count - 2:
opacity = 0.5
if wm.phobos_msg_offset > 1 > m or m >= wm.phobos_msg_count - 1:
if wm.phobos_msg_scroll > 1 > m or m >= wm.phobos_msg_count - 1:
opacity = 0.1
try:
msg = messages[m + wm.phobos_msg_offset]
draw_message(msg['text'], msg['type'], m, opacity, offset=wm.phobos_msg_offset)
msg = messages[m + wm.phobos_msg_scroll]
draw_message(msg['text'], msg['type'], m, opacity, scroll=wm.phobos_msg_scroll)
except IndexError:
pass

Expand Down
8 changes: 4 additions & 4 deletions phobos/blender/phobosgui.py
Original file line number Diff line number Diff line change
Expand Up @@ -1662,7 +1662,7 @@ def draw(self, context):
dc1.prop(wm, "draw_progress")
dc2.prop(wm, "draw_messages")
dc2.prop(wm, 'phobos_msg_count')
dc2.prop(wm, 'phobos_msg_offset')
dc2.prop(wm, 'phobos_msg_scroll')

layout.separator()

Expand Down Expand Up @@ -1812,12 +1812,12 @@ def register():
description="How many Phobos log messages to show on screen",
)

bpy.types.WindowManager.phobos_msg_offset = IntProperty(
name='offset',
bpy.types.WindowManager.phobos_msg_scroll = IntProperty(
name='scroll',
default=0,
min=0,
max=50,
description="The Phobos log message index to start with",
description="Use this to scroll through the messages",
)

bpy.types.WindowManager.draw_progress = BoolProperty(name='Progress', default=True)
Expand Down

0 comments on commit 13847b7

Please sign in to comment.