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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2012-02-02 18:07:24 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2012-02-02 18:07:24 +0400
commit4aaf59324e0ea5fecf28c1e9d54b1aed9b135dc5 (patch)
treea15460ae3188ccf5b31019ff472507af3f4dbc65 /source/blender/editors/interface
parent8f01ad9bf884f15c9cd6d19971f8ab3a1e1e176c (diff)
Fix #27213: editing color ramp "Pos:" number value did not update the ramp
properly, when moving the current point before another.
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r--source/blender/editors/interface/interface_handlers.c27
-rw-r--r--source/blender/editors/interface/interface_templates.c14
2 files changed, 15 insertions, 26 deletions
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index cfb375c2558..cadc57c9881 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -3607,31 +3607,6 @@ static int ui_do_but_HSVCIRCLE(bContext *C, uiBlock *block, uiBut *but, uiHandle
}
-static int verg_colorband(const void *a1, const void *a2)
-{
- const CBData *x1=a1, *x2=a2;
-
- if( x1->pos > x2->pos ) return 1;
- else if( x1->pos < x2->pos) return -1;
- return WM_UI_HANDLER_CONTINUE;
-}
-
-static void ui_colorband_update(ColorBand *coba)
-{
- int a;
-
- if(coba->tot<2) return;
-
- for(a=0; a<coba->tot; a++) coba->data[a].cur= a;
- qsort(coba->data, coba->tot, sizeof(CBData), verg_colorband);
- for(a=0; a<coba->tot; a++) {
- if(coba->data[a].cur==coba->cur) {
- coba->cur= a;
- break;
- }
- }
-}
-
static int ui_numedit_but_COLORBAND(uiBut *but, uiHandleButtonData *data, int mx)
{
float dx;
@@ -3644,7 +3619,7 @@ static int ui_numedit_but_COLORBAND(uiBut *but, uiHandleButtonData *data, int mx
data->dragcbd->pos += dx;
CLAMP(data->dragcbd->pos, 0.0f, 1.0f);
- ui_colorband_update(data->coba);
+ colorband_update_sort(data->coba);
data->dragcbd= data->coba->data + data->coba->cur; /* because qsort */
data->draglastx= mx;
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 1f6165852d7..4a797b0e960 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -1305,6 +1305,16 @@ static void colorband_flip_cb(bContext *C, void *cb_v, void *coba_v)
rna_update_cb(C, cb_v, NULL);
}
+static void colorband_update_cb(bContext *UNUSED(C), void *bt_v, void *coba_v)
+{
+ uiBut *bt= bt_v;
+ ColorBand *coba= coba_v;
+
+ /* sneaky update here, we need to sort the colorband points to be in order,
+ however the RNA pointer then is wrong, so we update it */
+ colorband_update_sort(coba);
+ bt->rnapoin.data = coba->data + coba->cur;
+}
/* offset aligns from bottom, standard width 300, height 115 */
static void colorband_buttons_large(uiLayout *layout, uiBlock *block, ColorBand *coba, int xoffs, int yoffs, RNAUpdateCb *cb)
@@ -1348,7 +1358,11 @@ static void colorband_buttons_large(uiLayout *layout, uiBlock *block, ColorBand
PointerRNA ptr;
RNA_pointer_create(cb->ptr.id.data, &RNA_ColorRampElement, cbd, &ptr);
row= uiLayoutRow(layout, 0);
+
uiItemR(row, &ptr, "position", 0, "Pos", ICON_NONE);
+ bt= block->buttons.last;
+ uiButSetFunc(bt, colorband_update_cb, bt, coba);
+
uiItemR(row, &ptr, "color", 0, "", ICON_NONE);
}