[Bf-blender-cvs] [2d8702b] soc-2013-paint: merge with master a930fb154f47a7473848254ad0b0b83c9edd1850
Antony Riakiotakis
noreply at git.blender.org
Mon Dec 9 19:02:18 CET 2013
Commit: 2d8702b84a912b5588860d412f8e9d31d53eff47
Author: Antony Riakiotakis
Date: Mon Dec 9 20:00:56 2013 +0200
http://developer.blender.org/rB2d8702b84a912b5588860d412f8e9d31d53eff47
merge with master a930fb154f47a7473848254ad0b0b83c9edd1850
===================================================================
===================================================================
diff --cc release/scripts/startup/bl_ui/space_view3d_toolbar.py
index 59e6aa1,bdf7b8e..fd7d271
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@@ -18,10 -18,12 +18,12 @@@
# <pep8 compliant>
import bpy
-from bpy.types import Menu, Panel
+from bpy.types import Menu, Panel, UIList
- from bl_ui.properties_paint_common import UnifiedPaintPanel
- from bl_ui.properties_paint_common import brush_texture_settings
- from bl_ui.properties_paint_common import brush_mask_texture_settings
+ from bl_ui.properties_paint_common import (
+ UnifiedPaintPanel,
+ brush_texture_settings,
+ brush_mask_texture_settings,
+ )
class View3DPanel():
diff --cc source/blender/editors/include/UI_interface.h
index 721b1fd,e931aad..2ba04fb
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@@ -430,8 -432,6 +437,8 @@@ void uiButSetDragValue(uiBut *but)
void uiButSetDragImage(uiBut *but, const char *path, int icon, struct ImBuf *ima, float scale);
int UI_but_active_drop_name(struct bContext *C);
+int UI_but_active_drop_color(struct bContext *C);
- struct uiBut *ui_but_find_mouse_over(struct ARegion *ar, int x, int y);
++struct uiBut *ui_but_find_mouse_over(struct ARegion *ar, const struct wmEvent *event);
void uiButSetFlag(uiBut *but, int flag);
void uiButClearFlag(uiBut *but, int flag);
diff --cc source/blender/editors/interface/interface_handlers.c
index 26b48d6,5e17831..45d59c3
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@@ -236,9 -236,15 +237,14 @@@ typedef struct uiAfterFunc
+ static bool ui_is_but_interactive(uiBut *but, const bool labeledit);
static bool ui_but_contains_pt(uiBut *but, int mx, int my);
static bool ui_mouse_inside_button(ARegion *ar, uiBut *but, int x, int y);
+ static uiBut *ui_but_find_mouse_over_ex(ARegion *ar, int x, int y, bool ctrl);
-static uiBut *ui_but_find_mouse_over(ARegion *ar, const wmEvent *event);
+ static void button_activate_init(bContext *C, ARegion *ar, uiBut *but, uiButtonActivateType type);
static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState state);
+ static void button_activate_exit(bContext *C, uiBut *but, uiHandleButtonData *data,
+ const bool mousemove, const bool onfree);
static int ui_handler_region_menu(bContext *C, const wmEvent *event, void *userdata);
static void ui_handle_button_activate(bContext *C, ARegion *ar, uiBut *but, uiButtonActivateType type);
static void button_timers_tooltip_remove(bContext *C, uiBut *but);
@@@ -872,10 -887,10 +887,10 @@@ static bool ui_but_mouse_inside_icon(ui
BLI_rcti_rctf_copy(&rect, &but->rect);
- if (but->imb) {
+ if (but->imb || but->type == COLOR) {
/* use button size itself */
}
- else if (but->flag & UI_ICON_LEFT) {
+ else if (but->drawflag & UI_BUT_ICON_LEFT) {
rect.xmax = rect.xmin + (BLI_rcti_size_y(&rect));
}
else {
@@@ -3653,9 -3693,7 +3722,9 @@@ static int ui_do_but_BLOCK(bContext *C
}
}
#ifdef USE_DRAG_TOGGLE
- if (event->type == LEFTMOUSE && ui_is_but_drag_toggle(but)) {
+ if (event->type == LEFTMOUSE && event->val == KM_PRESS
- && (ui_is_but_bool(but)))
++ && (ui_is_but_drag_toggle(but)))
+ {
button_activate_state(C, but, BUTTON_STATE_WAIT_DRAG);
data->dragstartx = event->x;
data->dragstarty = event->y;
@@@ -6072,6 -6022,12 +6146,12 @@@ static uiBut *ui_but_find_mouse_over_ex
return butover;
}
-static uiBut *ui_but_find_mouse_over(ARegion *ar, const wmEvent *event)
++uiBut *ui_but_find_mouse_over(ARegion *ar, const wmEvent *event)
+ {
+ return ui_but_find_mouse_over_ex(ar, event->x, event->y, event->ctrl != 0);
+ }
+
+
static uiBut *ui_list_find_mouse_over(ARegion *ar, int x, int y)
{
uiBlock *block;
diff --cc source/blender/editors/sculpt_paint/paint_image.c
index 8427fe5,6ffa54c..c6d4dc5
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@@ -279,34 -238,7 +279,34 @@@ void image_undo_remove_masks(void
}
}
+static void image_undo_restore_runtime(ListBase *lb)
+{
+ ImBuf *ibuf, *tmpibuf;
+ UndoImageTile *tile;
+
+ tmpibuf = IMB_allocImBuf(IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE, 32,
+ IB_rectfloat | IB_rect);
+
+ for (tile = lb->first; tile; tile = tile->next) {
+ Image *ima = tile->ima;
+ ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL);
+
+ undo_copy_tile(tile, tmpibuf, ibuf, RESTORE);
+
+ GPU_free_image(ima); /* force OpenGL reload (maybe partial update will operate better?) */
+ if (ibuf->rect_float)
+ ibuf->userflags |= IB_RECT_INVALID; /* force recreate of char rect */
+ if (ibuf->mipmap[0])
+ ibuf->userflags |= IB_MIPMAP_INVALID; /* force mipmap recreatiom */
+ ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;
+
+ BKE_image_release_ibuf(ima, ibuf, NULL);
+ }
+
+ IMB_freeImBuf(tmpibuf);
+}
+
- void image_undo_restore(bContext *C, ListBase *lb)
+ void ED_image_undo_restore(bContext *C, ListBase *lb)
{
Main *bmain = CTX_data_main(C);
Image *ima = NULL;
@@@ -380,45 -312,9 +380,45 @@@ void ED_image_undo_free(ListBase *lb
MEM_freeN(tile->rect.pt);
}
+static void image_undo_end(void)
+{
+ ListBase *lb = undo_paint_push_get_list(UNDO_PAINT_IMAGE);
+ UndoImageTile *tile;
+ int deallocsize = 0;
+ int allocsize = IMAPAINT_TILE_SIZE * IMAPAINT_TILE_SIZE * 4;
+
+ /* first dispose of invalid tiles (may happen due to drag dot for instance) */
+ for (tile = lb->first; tile;) {
+ if (!tile->valid) {
+ UndoImageTile *tmp_tile = tile->next;
+ deallocsize += allocsize * ((tile->use_float) ? sizeof(float) : sizeof(char));
+ MEM_freeN(tile->rect.pt);
+ BLI_freelinkN (lb, tile);
+ tile = tmp_tile;
+ }
+ else {
+ tile = tile->next;
+ }
+ }
+
+ /* don't forget to remove the size of deallocated tiles */
+ undo_paint_push_count_alloc(UNDO_PAINT_IMAGE, -deallocsize);
+
- undo_paint_push_end(UNDO_PAINT_IMAGE);
++ ED_undo_paint_push_end(UNDO_PAINT_IMAGE);
+}
+
- void image_undo_invalidate(void)
++static void image_undo_invalidate(void)
+{
+ UndoImageTile *tile;
+ ListBase *lb = undo_paint_push_get_list(UNDO_PAINT_IMAGE);
+
+ for (tile = lb->first; tile; tile = tile->next)
+ tile->valid = false;
+}
+
/* Imagepaint Partial Redraw & Dirty Region */
- void imapaint_clear_partial_redraw(void)
+ void ED_imapaint_clear_partial_redraw(void)
{
memset(&imapaintpartial, 0, sizeof(imapaintpartial));
}
@@@ -664,33 -478,12 +664,33 @@@ void paint_brush_exit_tex(Brush *brush
}
}
+static void gradient_draw_line(bContext *UNUSED(C), int x, int y, void *customdata) {
+ PaintOperation *pop = (PaintOperation *)customdata;
+
+ if (pop) {
+ glEnable(GL_LINE_SMOOTH);
+ glEnable(GL_BLEND);
+
+ glLineWidth(4.0);
+ glColor4ub(0, 0, 0, 255);
+ sdrawline(x, y, pop->startmouse[0], pop->startmouse[1]);
+ glLineWidth(2.0);
+ glColor4ub(255, 255, 255, 255);
+ sdrawline(x, y, pop->startmouse[0], pop->startmouse[1]);
+ glLineWidth(1.0);
+
+ glDisable(GL_BLEND);
+ glDisable(GL_LINE_SMOOTH);
+ }
+}
+
-static PaintOperation *texture_paint_init(bContext *C, wmOperator *op, float mouse[2])
+static PaintOperation *texture_paint_init(bContext *C, wmOperator *op, const float mouse[2])
{
Scene *scene = CTX_data_scene(C);
- ToolSettings *toolsettings = scene->toolsettings;
+ ToolSettings *settings = scene->toolsettings;
PaintOperation *pop = MEM_callocN(sizeof(PaintOperation), "PaintOperation"); /* caller frees */
- Brush *brush = BKE_paint_brush(&toolsettings->imapaint.paint);
++ Brush *brush = BKE_paint_brush(&settings->imapaint.paint);
int mode = RNA_enum_get(op->ptr, "mode");
view3d_set_viewcontext(C, &pop->vc);
@@@ -716,10 -505,15 +716,10 @@@
return NULL;
}
- toolsettings->imapaint.flag |= IMAGEPAINT_DRAWING;
- undo_paint_push_begin(UNDO_PAINT_IMAGE, op->type->name,
- image_undo_restore, image_undo_free);
+ settings->imapaint.flag |= IMAGEPAINT_DRAWING;
+ ED_undo_paint_push_begin(UNDO_PAINT_IMAGE, op->type->name,
+ ED_image_undo_restore, ED_image_undo_free);
- {
- UnifiedPaintSettings *ups = &settings->unified_paint_settings;
- ups->draw_pressure = true;
- }
-
return pop;
}
@@@ -1427,55 -1112,6 +1427,55 @@@ void PAINT_OT_texture_paint_toggle(wmOp
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
+
+static int brush_colors_flip_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ Brush *br = image_paint_brush(C);
+ swap_v3_v3(br->rgb, br->secondary_rgb);
+
+ WM_event_add_notifier(C, NC_BRUSH | NA_EDITED, br);
+
+ return OPERATOR_FINISHED;
+}
+
+static int brush_colors_flip_poll(bContext *C)
+{
+ if (image_paint_poll(C)) {
+ Brush *br = image_paint_brush(C);
+ if(br->imagepaint_tool == PAINT_TOOL_DRAW)
+ return 1;
+ }
+
+ return 0;
+}
+
+void PAINT_OT_brush_colors_flip(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Brush Colors Flip";
+ ot->idname = "PAINT_OT_brush_colors_flip";
+ ot->description = "Toggle foreground and background brush colors";
+
+ /* api callbacks */
+ ot->exec = brush_colors_flip_exec;
+ ot->poll = brush_colors_flip_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
+
+void paint_bucket_fill(struct bContext *C, float color[3], wmOperator *op)
+{
- undo_paint_push_begin(UNDO_PAINT_IMAGE, op->type->name,
- image_undo_restore, image_undo_free);
++ ED_undo_paint_push_begin(UNDO_PAINT_IMAGE, op->type->name,
++ ED_image_undo_restore, ED_image_undo_free);
+
+ paint_2d_bucket_fill(C, color, NULL, NULL, NULL);
+
- undo_paint_push_end(UNDO_PAINT_IMAGE);
++ ED_undo_paint_push_end(UNDO_PAINT_IMAGE);
+}
+
+
static int texture_paint_poll(bContext *C)
{
if (texture_paint_toggle_poll(C))
diff --cc source/blender/editors/sculpt_paint/paint_image_2d.c
index 20a0a09,b2f429c..b0d2d09
--- a/source/blender/editors/scu
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list