2025-12-01
This commit is contained in:
@@ -31,31 +31,6 @@ def build_mode(url, action, id_notice):
|
||||
return "notify@{}@{}@{}".format(url, action, id_notice)
|
||||
|
||||
|
||||
def _draw_notification_open_url_single_row(cTB, notice, first_row, icon) -> None:
|
||||
# Single row with text + button.
|
||||
# TODO: generalize this for notification message and length,
|
||||
# and if dismiss is included.
|
||||
# During SOFT-780 this has been changed for POPUP_MESSAGE in a
|
||||
# very simplistic way
|
||||
# (commit: https://github.com/poliigon/poliigon-addon-blender/pull/278/commits/00296ab70288893a023a6705d52eb4505ce36897).
|
||||
# When addressing this properly,
|
||||
# make sure to address it for all notification types.
|
||||
first_row.alert = True
|
||||
first_row.label(text=notice.title)
|
||||
first_row.alert = False
|
||||
op = first_row.operator(
|
||||
"poliigon.poliigon_link",
|
||||
icon=icon,
|
||||
text=notice.label,
|
||||
)
|
||||
if notice.tooltip != "":
|
||||
op.tooltip = notice.tooltip
|
||||
op.mode = build_mode(
|
||||
notice.url,
|
||||
notice.label,
|
||||
notice.id_notice)
|
||||
|
||||
|
||||
def _draw_notification_open_url_two_rows(
|
||||
cTB, notice, first_row, main_col, icon) -> None:
|
||||
# Two rows (or more, if text wrapping).
|
||||
@@ -88,13 +63,7 @@ def _draw_notification_open_url_two_rows(
|
||||
|
||||
def _draw_notification_open_url(
|
||||
cTB, notice, first_row, main_col, panel_width, icon) -> None:
|
||||
# Empirical for width for "Beta addon: [Take survey]" specifically.
|
||||
single_row_width = 250
|
||||
if panel_width > single_row_width:
|
||||
_draw_notification_open_url_single_row(cTB, notice, first_row, icon)
|
||||
else:
|
||||
_draw_notification_open_url_two_rows(
|
||||
cTB, notice, first_row, main_col, icon)
|
||||
_draw_notification_open_url_two_rows(cTB, notice, first_row, main_col, icon)
|
||||
|
||||
|
||||
def _draw_notification_update_ready_single_row(cTB, notice, first_row, icon) -> None:
|
||||
@@ -231,6 +200,25 @@ def _draw_notification_run_operator(cTB, notice, first_row, icon) -> None:
|
||||
op.tooltip = notice.tooltip
|
||||
|
||||
|
||||
def _draw_notification_none_action(cTB, notice, first_row, icon) -> None:
|
||||
"""Draws a notification with no clickable action - just text with dismiss button."""
|
||||
# Create a row with icon on the left and text in center (X button handled by main function)
|
||||
row = first_row.row(align=True)
|
||||
|
||||
# Icon column on the left - single row for compact height
|
||||
icon_col = row.column(align=True)
|
||||
icon_col.alignment = "CENTER"
|
||||
icon_col.label(text="", icon=icon)
|
||||
|
||||
# Text column in center - fills remaining space
|
||||
text_col = row.column()
|
||||
text_col.alignment = "CENTER"
|
||||
# Using full available width for text
|
||||
wrapped_label(
|
||||
cTB, cTB.width_draw_ui, notice.title, text_col)
|
||||
text_col.alert = False
|
||||
|
||||
|
||||
# TODO(Andreas): deactivated reporting here, as I needed a third parameter and
|
||||
# was not able to quickly make handle_draw() work
|
||||
# @reporting.handle_draw()
|
||||
@@ -270,6 +258,8 @@ def notification_banner(cTB, layout):
|
||||
cTB, notice, first_row, main_col, panel_width, icon)
|
||||
elif notice.action == ActionType.RUN_OPERATOR:
|
||||
_draw_notification_run_operator(cTB, notice, first_row, icon)
|
||||
elif notice.action == ActionType.NONE:
|
||||
_draw_notification_none_action(cTB, notice, first_row, icon)
|
||||
else:
|
||||
main_col.label(text=notice.title)
|
||||
cTB.logger_ui.error("Invalid notifcation type")
|
||||
|
||||
Reference in New Issue
Block a user