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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Eisel <julian@blender.org>2020-07-03 17:31:29 +0300
committerJulian Eisel <julian@blender.org>2020-07-03 17:31:29 +0300
commit89dbb12c29b62759d82b62d3e197598b6b973a04 (patch)
treeec7f7e2946fafb225ae548972e3f461658f8ed39 /source/blender
parent4de632b48b3ca2bbfcd1a649c6512f7bdc741074 (diff)
Add own button type for progress-bar, don't using uiBut.a1 for progress
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/editors/interface/interface.c12
-rw-r--r--source/blender/editors/interface/interface_intern.h8
-rw-r--r--source/blender/editors/interface/interface_templates.c34
-rw-r--r--source/blender/editors/interface/interface_widgets.c3
4 files changed, 35 insertions, 22 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 5964aece875..e6ac4631bd9 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -820,10 +820,10 @@ static bool ui_but_update_from_old_block(const bContext *C,
oldbut->hardmax = but->hardmax;
}
- /* Selectively copy a1, a2 since their use differs across all button types
- * (and we'll probably split these out later) */
- if (ELEM(oldbut->type, UI_BTYPE_PROGRESS_BAR)) {
- oldbut->a1 = but->a1;
+ if (oldbut->type == UI_BTYPE_PROGRESS_BAR) {
+ uiButProgressbar *progress_oldbut = (uiButProgressbar *)oldbut;
+ uiButProgressbar *progress_but = (uiButProgressbar *)but;
+ progress_oldbut->progress = progress_but->progress;
}
if (!BLI_listbase_is_empty(&block->butstore)) {
@@ -3731,6 +3731,10 @@ static void ui_but_alloc_info(const eButType type,
alloc_size = sizeof(uiButSearch);
alloc_str = "uiButSearch";
break;
+ case UI_BTYPE_PROGRESS_BAR:
+ alloc_size = sizeof(uiButProgressbar);
+ alloc_str = "uiButProgressbar";
+ break;
default:
alloc_size = sizeof(uiBut);
alloc_str = "uiBut";
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index 5696feaee03..97a929fedca 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -178,7 +178,6 @@ struct uiBut {
* - UI_BTYPE_SCROLL: Use as scroll size.
* - UI_BTYPE_SEARCH_MENU: Use as number or rows.
* - UI_BTYPE_COLOR: Use as indication of color palette.
- * - UI_BTYPE_PROGRESS_BAR: Use to store progress (0..1).
*/
float a1;
@@ -316,6 +315,13 @@ typedef struct uiButDecorator {
int rnaindex;
} uiButDecorator;
+typedef struct uiButProgressbar {
+ uiBut but;
+
+ /* 0..1 range */
+ float progress;
+} uiButProgressbar;
+
/**
* Additional, superimposed icon for a button, invoking an operator.
*/
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 7a6a40f5553..a4d02cc4617 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -6741,22 +6741,24 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C)
struct ProgressTooltip_Store *tip_arg = MEM_mallocN(sizeof(*tip_arg), __func__);
tip_arg->wm = wm;
tip_arg->owner = owner;
- uiBut *but_progress = uiDefIconTextBut(block,
- UI_BTYPE_PROGRESS_BAR,
- 0,
- 0,
- text,
- UI_UNIT_X,
- 0,
- UI_UNIT_X * 6.0f,
- UI_UNIT_Y,
- NULL,
- 0.0f,
- 0.0f,
- progress,
- 0,
- NULL);
- UI_but_func_tooltip_set(but_progress, progress_tooltip_func, tip_arg);
+ uiButProgressbar *but_progress = (uiButProgressbar *)uiDefIconTextBut(block,
+ UI_BTYPE_PROGRESS_BAR,
+ 0,
+ 0,
+ text,
+ UI_UNIT_X,
+ 0,
+ UI_UNIT_X * 6.0f,
+ UI_UNIT_Y,
+ NULL,
+ 0.0f,
+ 0.0f,
+ 0.0f,
+ 0,
+ NULL);
+
+ but_progress->progress = progress;
+ UI_but_func_tooltip_set(&but_progress->but, progress_tooltip_func, tip_arg);
}
if (!wm->is_interface_locked) {
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index ba88d4ccf9b..b8ee11d7439 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -3587,6 +3587,7 @@ static void widget_scroll(
static void widget_progressbar(
uiBut *but, uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign)
{
+ uiButProgressbar *but_progressbar = (uiButProgressbar *)but;
uiWidgetBase wtb, wtb_bar;
rcti rect_prog = *rect, rect_bar = *rect;
@@ -3594,7 +3595,7 @@ static void widget_progressbar(
widget_init(&wtb_bar);
/* round corners */
- float value = but->a1;
+ float value = but_progressbar->progress;
float offs = wcol->roundness * BLI_rcti_size_y(&rect_prog);
float w = value * BLI_rcti_size_x(&rect_prog);