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:
authorHans Goudey <h.goudey@me.com>2020-08-14 04:00:54 +0300
committerHans Goudey <h.goudey@me.com>2020-08-14 04:00:54 +0300
commit570044e9f412d37fbf1523652034afe5d87a3d4e (patch)
tree0ed5697e4de4e87704862d72e158206dbc4b4864 /source/blender
parent275f1039d22cb0de4862eb3b7bae859cdddce777 (diff)
UI Code Quality: Use derived struct for curve profile buttons
Continuing the work from rB49f088e2d093. Differential Revision: https://developer.blender.org/D8561
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/editors/interface/interface.c4
-rw-r--r--source/blender/editors/interface/interface_draw.c11
-rw-r--r--source/blender/editors/interface/interface_handlers.c24
-rw-r--r--source/blender/editors/interface/interface_intern.h11
4 files changed, 36 insertions, 14 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 22fbffa9030..d7e33a37204 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -3797,6 +3797,10 @@ static void ui_but_alloc_info(const eButType type,
alloc_size = sizeof(uiButHSVCube);
alloc_str = "uiButHSVCube";
break;
+ case UI_BTYPE_CURVEPROFILE:
+ alloc_size = sizeof(uiButCurveProfile);
+ alloc_str = "uiButCurveProfile";
+ break;
default:
alloc_size = sizeof(uiBut);
alloc_str = "uiBut";
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index 44c3ccccda8..aad3b4d15a1 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -2179,13 +2179,10 @@ void ui_draw_but_CURVEPROFILE(ARegion *region,
{
uint i;
float fx, fy;
- CurveProfile *profile;
- if (but->editprofile) {
- profile = but->editprofile;
- }
- else {
- profile = (CurveProfile *)but->poin;
- }
+
+ uiButCurveProfile *but_profile = (uiButCurveProfile *)but;
+ CurveProfile *profile = (but_profile->edit_profile == NULL) ? (CurveProfile *)but->poin :
+ but_profile->edit_profile;
/* Calculate offset and zoom. */
float zoomx = (BLI_rcti_size_x(rect) - 2.0f) / BLI_rctf_size_x(&profile->view_rect);
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 2d3a6181f09..63cd30ba1ff 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -2088,13 +2088,19 @@ static void ui_apply_but(
editvec = but->editvec;
editcoba = but->editcoba;
editcumap = but->editcumap;
- editprofile = but->editprofile;
+ if (but->type == UI_BTYPE_CURVEPROFILE) {
+ uiButCurveProfile *but_profile = (uiButCurveProfile *)but;
+ editprofile = but_profile->edit_profile;
+ }
but->editstr = NULL;
but->editval = NULL;
but->editvec = NULL;
but->editcoba = NULL;
but->editcumap = NULL;
- but->editprofile = NULL;
+ if (but->type == UI_BTYPE_CURVEPROFILE) {
+ uiButCurveProfile *but_profile = (uiButCurveProfile *)but;
+ but_profile->edit_profile = NULL;
+ }
/* handle different types */
switch (but->type) {
@@ -2205,7 +2211,10 @@ static void ui_apply_but(
but->editvec = editvec;
but->editcoba = editcoba;
but->editcumap = editcumap;
- but->editprofile = editprofile;
+ if (but->type == UI_BTYPE_CURVEPROFILE) {
+ uiButCurveProfile *but_profile = (uiButCurveProfile *)but;
+ but_profile->edit_profile = editprofile;
+ }
}
/** \} */
@@ -3851,7 +3860,8 @@ static void ui_numedit_begin(uiBut *but, uiHandleButtonData *data)
but->editcumap = (CurveMapping *)but->poin;
}
if (but->type == UI_BTYPE_CURVEPROFILE) {
- but->editprofile = (CurveProfile *)but->poin;
+ uiButCurveProfile *but_profile = (uiButCurveProfile *)but;
+ but_profile->edit_profile = (CurveProfile *)but->poin;
}
else if (but->type == UI_BTYPE_COLORBAND) {
data->coba = (ColorBand *)but->poin;
@@ -3943,8 +3953,10 @@ static void ui_numedit_end(uiBut *but, uiHandleButtonData *data)
but->editvec = NULL;
but->editcoba = NULL;
but->editcumap = NULL;
- but->editprofile = NULL;
-
+ if (but->type == UI_BTYPE_CURVEPROFILE) {
+ uiButCurveProfile *but_profile = (uiButCurveProfile *)but;
+ but_profile->edit_profile = NULL;
+ }
data->dragstartx = 0;
data->draglastx = 0;
data->dragchange = false;
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index 6718db39e61..ad34649a5ec 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -33,6 +33,7 @@
struct AnimationEvalContext;
struct ARegion;
+struct CurveProfile;
struct ID;
struct ImBuf;
struct Scene;
@@ -268,7 +269,6 @@ struct uiBut {
float *editvec;
void *editcoba;
void *editcumap;
- void *editprofile;
uiButPushedStateFunc pushed_state_func;
void *pushed_state_arg;
@@ -320,6 +320,7 @@ typedef struct uiButDecorator {
int rnaindex;
} uiButDecorator;
+/** Derived struct for #UI_BTYPE_PROGRESS_BAR. */
typedef struct uiButProgressbar {
uiBut but;
@@ -327,12 +328,20 @@ typedef struct uiButProgressbar {
float progress;
} uiButProgressbar;
+/** Derived struct for #UI_BTYPE_HSVCUBE. */
typedef struct uiButHSVCube {
uiBut but;
eButGradientType gradient_type;
} uiButHSVCube;
+/** Derived struct for #UI_BTYPE_CURVEPROFILE. */
+typedef struct uiButCurveProfile {
+ uiBut but;
+
+ struct CurveProfile *edit_profile;
+} uiButCurveProfile;
+
/**
* Additional, superimposed icon for a button, invoking an operator.
*/