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:
authorAntony Riakiotakis <kalast@gmail.com>2014-09-18 13:16:31 +0400
committerAntony Riakiotakis <kalast@gmail.com>2014-09-18 13:16:31 +0400
commite6271d236752b8551d8d401ff6aff8e92efde18e (patch)
tree82e76b140c3d8c123ce469c0c2277fdea3c4e881 /source/blender
parent90f75b8ce034068f0f8192e32d4b9a6d9261393f (diff)
Palettes:
Avoid having an invalid active index if user deletes a color. Also attempt to set active color on clicking (Not working yet but fix coming soon)
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/intern/paint.c6
-rw-r--r--source/blender/editors/interface/interface_handlers.c19
-rw-r--r--source/blender/makesdna/DNA_brush_types.h2
3 files changed, 19 insertions, 8 deletions
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index 4382d74f34e..296ca09a901 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -315,8 +315,14 @@ void BKE_paint_curve_set(Brush *br, PaintCurve *pc)
/* remove colour from palette. Must be certain color is inside the palette! */
void BKE_palette_color_remove(Palette *palette, PaletteColor *color)
{
+ int num_items;
BLI_remlink(&palette->colors, color);
+
+ num_items = BLI_countlist(&palette->colors);
+
BLI_addhead(&palette->deleted, color);
+ if (palette->active_color == num_items && num_items > 0)
+ palette->active_color--;
}
void BKE_palette_cleanup(Palette *palette)
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 33bb46ced7f..17f898b5ba3 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -4255,11 +4255,21 @@ static bool ui_numedit_but_NORMAL(uiBut *but, uiHandleButtonData *data,
return changed;
}
+static void ui_palette_set_active(uiBut *but)
+{
+ if ((int)(but->a1) == UI_PALETTE_COLOR) {
+ Palette *palette = but->rnapoin.id.data;
+ PaletteColor *color = but->rnapoin.data;
+ palette->active_color = BLI_findindex(&palette->colors, color);
+ }
+}
+
static int ui_do_but_COLOR(bContext *C, uiBut *but, uiHandleButtonData *data, const wmEvent *event)
{
if (data->state == BUTTON_STATE_HIGHLIGHT) {
/* first handle click on icondrag type button */
if (event->type == LEFTMOUSE && but->dragpoin && event->val == KM_PRESS) {
+ ui_palette_set_active(but);
if (ui_but_mouse_inside_icon(but, data->region, event)) {
button_activate_state(C, but, BUTTON_STATE_WAIT_DRAG);
data->dragstartx = event->x;
@@ -4269,6 +4279,7 @@ static int ui_do_but_COLOR(bContext *C, uiBut *but, uiHandleButtonData *data, co
}
#ifdef USE_DRAG_TOGGLE
if (event->type == LEFTMOUSE && event->val == KM_PRESS) {
+ ui_palette_set_active(but);
button_activate_state(C, but, BUTTON_STATE_WAIT_DRAG);
data->dragstartx = event->x;
data->dragstarty = event->y;
@@ -4277,6 +4288,7 @@ static int ui_do_but_COLOR(bContext *C, uiBut *but, uiHandleButtonData *data, co
#endif
/* regular open menu */
if (ELEM(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val == KM_PRESS) {
+ ui_palette_set_active(but);
button_activate_state(C, but, BUTTON_STATE_MENU_OPEN);
return WM_UI_HANDLER_BREAK;
}
@@ -4333,13 +4345,6 @@ static int ui_do_but_COLOR(bContext *C, uiBut *but, uiHandleButtonData *data, co
if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
if ((int)(but->a1) == UI_PALETTE_COLOR) {
- Palette *palette = but->rnapoin.id.data;
- PaletteColor *color = but->rnapoin.data;
- palette->active_color = BLI_findindex(&palette->colors, color);
-
- /* enforce redraw, sometimes state here can already be exit */
- ED_region_tag_redraw(data->region);
-
if (!event->ctrl) {
float color[3];
Scene *scene = CTX_data_scene(C);
diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h
index 9fbd70419f4..b14861fcf47 100644
--- a/source/blender/makesdna/DNA_brush_types.h
+++ b/source/blender/makesdna/DNA_brush_types.h
@@ -153,8 +153,8 @@ typedef struct Palette
ListBase colors;
ListBase deleted;
- int num_of_colours;
int active_color;
+ int pad;
} Palette;
typedef struct PaintCurvePoint