diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2013-02-10 14:17:59 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2013-02-10 14:17:59 +0400 |
commit | ac9ec06ec121589fedbfeaa10137140b45bfd668 (patch) | |
tree | ab08f9528136f0b8813593b78621f869d98d655e /source/blender/editors | |
parent | 3c064f4553e4be988fe4fcec450b59b935fa3c80 (diff) | |
parent | 63af7068ad17f30a526ccb81fbe74253b064bc89 (diff) |
Merged changes in the trunk up to revision 54421.
Conflicts resolved:
release/datafiles/startup.blend
release/scripts/startup/bl_ui/properties_render.py
source/blender/SConscript
source/blender/blenloader/intern/readfile.c
Diffstat (limited to 'source/blender/editors')
78 files changed, 854 insertions, 505 deletions
diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index ef1b73fc58f..62725cb6c70 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -41,6 +41,7 @@ #include "RNA_enum_types.h" #include "BLI_blenlib.h" +#include "BLI_math_base.h" #include "BLI_utildefines.h" #include "BKE_context.h" @@ -146,16 +147,15 @@ int ED_markers_post_apply_transform(ListBase *markers, Scene *scene, int mode, f marker->frame += (int)floorf(value + 0.5f); changed++; } + break; } - break; - case TFM_TIME_SCALE: { /* rescale the distance between the marker and the current frame */ marker->frame = cfra + (int)floorf(((float)(marker->frame - cfra) * value) + 0.5f); changed++; + break; } - break; } } } @@ -402,17 +402,22 @@ static void draw_marker(View2D *v2d, TimeMarker *marker, int cfra, int flag) /* and the marker name too, shifted slightly to the top-right */ if (marker->name && marker->name[0]) { float x, y; + + /* minimal y coordinate which wouldn't be occluded by scroll */ + int min_y = 17.0f * UI_DPI_FAC; if (marker->flag & SELECT) { UI_ThemeColor(TH_TEXT_HI); x = xpos * xscale + 4.0f * UI_DPI_FAC; y = (ypixels <= 39.0f * UI_DPI_FAC) ? (ypixels - 10.0f * UI_DPI_FAC) : 29.0f * UI_DPI_FAC; + y = max_ii(y, min_y); } else { UI_ThemeColor(TH_TEXT); if ((marker->frame <= cfra) && (marker->frame + 5 > cfra)) { x = xpos * xscale + 8.0f * UI_DPI_FAC; y = (ypixels <= 39.0f * UI_DPI_FAC) ? (ypixels - 10.0f * UI_DPI_FAC) : 29.0f * UI_DPI_FAC; + y = max_ii(y, min_y); } else { x = xpos * xscale + 8.0f * UI_DPI_FAC; diff --git a/source/blender/editors/animation/fmodifier_ui.c b/source/blender/editors/animation/fmodifier_ui.c index 6bd774e084a..cc2366affe6 100644 --- a/source/blender/editors/animation/fmodifier_ui.c +++ b/source/blender/editors/animation/fmodifier_ui.c @@ -327,88 +327,7 @@ static void draw_modifier__noise(uiLayout *layout, ID *id, FModifier *fcm, short uiItemR(col, &ptr, "depth", 0, NULL, ICON_NONE); } -/* --------------- */ - -#define BINARYSEARCH_FRAMEEQ_THRESH 0.0001f - -/* Binary search algorithm for finding where to insert Envelope Data Point. - * Returns the index to insert at (data already at that index will be offset if replace is 0) - */ -static int binarysearch_fcm_envelopedata_index(FCM_EnvelopeData array[], float frame, int arraylen, short *exists) -{ - int start = 0, end = arraylen; - int loopbreaker = 0, maxloop = arraylen * 2; - - /* initialize exists-flag first */ - *exists = 0; - - /* sneaky optimizations (don't go through searching process if...): - * - keyframe to be added is to be added out of current bounds - * - keyframe to be added would replace one of the existing ones on bounds - */ - if ((arraylen <= 0) || (array == NULL)) { - printf("Warning: binarysearch_fcm_envelopedata_index() encountered invalid array\n"); - return 0; - } - else { - /* check whether to add before/after/on */ - float framenum; - - /* 'First' Point (when only one point, this case is used) */ - framenum = array[0].time; - if (IS_EQT(frame, framenum, BINARYSEARCH_FRAMEEQ_THRESH)) { - *exists = 1; - return 0; - } - else if (frame < framenum) - return 0; - - /* 'Last' Point */ - framenum = array[(arraylen - 1)].time; - if (IS_EQT(frame, framenum, BINARYSEARCH_FRAMEEQ_THRESH)) { - *exists = 1; - return (arraylen - 1); - } - else if (frame > framenum) - return arraylen; - } - - - /* most of the time, this loop is just to find where to put it - * - 'loopbreaker' is just here to prevent infinite loops - */ - for (loopbreaker = 0; (start <= end) && (loopbreaker < maxloop); loopbreaker++) { - /* compute and get midpoint */ - int mid = start + ((end - start) / 2); /* we calculate the midpoint this way to avoid int overflows... */ - float midfra = array[mid].time; - - /* check if exactly equal to midpoint */ - if (IS_EQT(frame, midfra, BINARYSEARCH_FRAMEEQ_THRESH)) { - *exists = 1; - return mid; - } - - /* repeat in upper/lower half */ - if (frame > midfra) - start = mid + 1; - else if (frame < midfra) - end = mid - 1; - } - - /* print error if loop-limit exceeded */ - if (loopbreaker == (maxloop - 1)) { - printf("Error: binarysearch_fcm_envelopedata_index() was taking too long\n"); - - // include debug info - printf("\tround = %d: start = %d, end = %d, arraylen = %d\n", loopbreaker, start, end, arraylen); - } - - /* not found, so return where to place it */ - return start; -} - /* callback to add new envelope data point */ -// TODO: should we have a separate file for things like this? static void fmod_envelope_addpoint_cb(bContext *C, void *fcm_dv, void *UNUSED(arg)) { Scene *scene = CTX_data_scene(C); @@ -425,7 +344,7 @@ static void fmod_envelope_addpoint_cb(bContext *C, void *fcm_dv, void *UNUSED(ar /* check that no data exists for the current frame... */ if (env->data) { short exists = -1; - int i = binarysearch_fcm_envelopedata_index(env->data, (float)(scene->r.cfra), env->totvert, &exists); + int i = BKE_fcm_envelope_find_index(env->data, (float)(scene->r.cfra), env->totvert, &exists); /* binarysearch_...() will set exists by default to 0, so if it is non-zero, that means that the point exists already */ if (exists) diff --git a/source/blender/editors/animation/keyframes_edit.c b/source/blender/editors/animation/keyframes_edit.c index 015c2667a93..decbc351cad 100644 --- a/source/blender/editors/animation/keyframes_edit.c +++ b/source/blender/editors/animation/keyframes_edit.c @@ -300,7 +300,14 @@ static short summary_keyframes_loop(KeyframeEditData *ked, bAnimContext *ac, Key /* loop through each F-Curve, working on the keyframes until the first curve aborts */ for (ale = anim_data.first; ale; ale = ale->next) { - ret_code = ANIM_fcurve_keyframes_loop(ked, ale->data, key_ok, key_cb, fcu_cb); + switch (ale->datatype) { + case ALE_MASKLAY: + case ALE_GPFRAME: + break; + default: + ret_code = ANIM_fcurve_keyframes_loop(ked, ale->data, key_ok, key_cb, fcu_cb); + break; + } if (ret_code) break; diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index 64832a1311f..c99f939300e 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -143,7 +143,7 @@ bAction *verify_adt_action(ID *id, short add) if ((adt->action == NULL) && (add)) { char actname[sizeof(id->name) - 2]; BLI_snprintf(actname, sizeof(actname), "%sAction", id->name + 2); - adt->action = add_empty_action(actname); + adt->action = add_empty_action(G.main, actname); } /* return the action */ diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index ca2fe48543a..3bcb4002ece 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -563,7 +563,9 @@ void docenter_armature(Scene *scene, Object *ob, float cursor[3], int centermode add_v3_v3(cent, ebone->head); add_v3_v3(cent, ebone->tail); } - mul_v3_fl(cent, 1.0f / (float)total); + if (total) { + mul_v3_fl(cent, 1.0f / (float)total); + } } else { float min[3], max[3]; @@ -3658,6 +3660,16 @@ void ARMATURE_OT_subdivide(wmOperatorType *ot) * easy to retrieve any hierarchical/chain relationships which are necessary for * this to be done easily. */ + +/* helper to clear BONE_TRANSFORM flags */ +static void armature_clear_swap_done_flags(bArmature *arm) +{ + EditBone *ebone; + + for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { + ebone->flag &= ~BONE_TRANSFORM; + } +} static int armature_switch_direction_exec(bContext *C, wmOperator *UNUSED(op)) { @@ -3669,9 +3681,16 @@ static int armature_switch_direction_exec(bContext *C, wmOperator *UNUSED(op)) /* get chains of bones (ends on chains) */ chains_find_tips(arm->edbo, &chains); if (chains.first == NULL) return OPERATOR_CANCELLED; - + + /* ensure that mirror bones will also be operated on */ armature_tag_select_mirrored(arm); - + + /* clear BONE_TRANSFORM flags + * - used to prevent duplicate/cancelling operations from occurring [#34123] + * - BONE_DONE cannot be used here as that's already used for mirroring + */ + armature_clear_swap_done_flags(arm); + /* loop over chains, only considering selected and visible bones */ for (chain = chains.first; chain; chain = chain->next) { EditBone *ebo, *child = NULL, *parent = NULL; @@ -3684,51 +3703,59 @@ static int armature_switch_direction_exec(bContext *C, wmOperator *UNUSED(op)) */ parent = ebo->parent; - /* only if selected and editable */ - if (EBONE_VISIBLE(arm, ebo) && EBONE_EDITABLE(ebo)) { - /* swap head and tail coordinates */ - SWAP(float, ebo->head[0], ebo->tail[0]); - SWAP(float, ebo->head[1], ebo->tail[1]); - SWAP(float, ebo->head[2], ebo->tail[2]); - - /* do parent swapping: - * - use 'child' as new parent - * - connected flag is only set if points are coincidental - */ - ebo->parent = child; - if ((child) && equals_v3v3(ebo->head, child->tail)) - ebo->flag |= BONE_CONNECTED; - else - ebo->flag &= ~BONE_CONNECTED; - - /* get next bones - * - child will become the new parent of next bone - */ - child = ebo; - } - else { - /* not swapping this bone, however, if its 'parent' got swapped, unparent us from it - * as it will be facing in opposite direction - */ - if ((parent) && (EBONE_VISIBLE(arm, parent) && EBONE_EDITABLE(parent))) { - ebo->parent = NULL; - ebo->flag &= ~BONE_CONNECTED; + /* skip bone if already handled... [#34123] */ + if ((ebo->flag & BONE_TRANSFORM) == 0) { + /* only if selected and editable */ + if (EBONE_VISIBLE(arm, ebo) && EBONE_EDITABLE(ebo)) { + /* swap head and tail coordinates */ + SWAP(float, ebo->head[0], ebo->tail[0]); + SWAP(float, ebo->head[1], ebo->tail[1]); + SWAP(float, ebo->head[2], ebo->tail[2]); + + /* do parent swapping: + * - use 'child' as new parent + * - connected flag is only set if points are coincidental + */ + ebo->parent = child; + if ((child) && equals_v3v3(ebo->head, child->tail)) + ebo->flag |= BONE_CONNECTED; + else + ebo->flag &= ~BONE_CONNECTED; + + /* get next bones + * - child will become the new parent of next bone + */ + child = ebo; + } + else { + /* not swapping this bone, however, if its 'parent' got swapped, unparent us from it + * as it will be facing in opposite direction + */ + if ((parent) && (EBONE_VISIBLE(arm, parent) && EBONE_EDITABLE(parent))) { + ebo->parent = NULL; + ebo->flag &= ~BONE_CONNECTED; + } + + /* get next bones + * - child will become new parent of next bone (not swapping occurred, + * so set to NULL to prevent infinite-loop) + */ + child = NULL; } - /* get next bones - * - child will become new parent of next bone (not swapping occurred, - * so set to NULL to prevent infinite-loop) - */ - child = NULL; + /* tag as done (to prevent double-swaps) */ + ebo->flag |= BONE_TRANSFORM; } } } /* free chains */ BLI_freelistN(&chains); - + + /* clear temp flags */ + armature_clear_swap_done_flags(arm); armature_tag_unselect(arm); - + /* note, notifier might evolve */ WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); diff --git a/source/blender/editors/armature/poselib.c b/source/blender/editors/armature/poselib.c index 04815b9c33c..b2c1b7fdcd0 100644 --- a/source/blender/editors/armature/poselib.c +++ b/source/blender/editors/armature/poselib.c @@ -54,6 +54,7 @@ #include "BKE_action.h" #include "BKE_armature.h" #include "BKE_depsgraph.h" +#include "BKE_global.h" #include "BKE_idprop.h" #include "BKE_library.h" #include "BKE_object.h" @@ -196,7 +197,7 @@ static bAction *poselib_init_new(Object *ob) /* init object's poselib action (unlink old one if there) */ if (ob->poselib) id_us_min(&ob->poselib->id); - ob->poselib = add_empty_action("PoseLib"); + ob->poselib = add_empty_action(G.main, "PoseLib"); return ob->poselib; } diff --git a/source/blender/editors/datafiles/CMakeLists.txt b/source/blender/editors/datafiles/CMakeLists.txt index ed3088696b1..8d108644470 100644 --- a/source/blender/editors/datafiles/CMakeLists.txt +++ b/source/blender/editors/datafiles/CMakeLists.txt @@ -100,6 +100,14 @@ if(WITH_BLENDER) data_to_c_simple(../../../../release/datafiles/matcaps/mc14.jpg SRC) data_to_c_simple(../../../../release/datafiles/matcaps/mc15.jpg SRC) data_to_c_simple(../../../../release/datafiles/matcaps/mc16.jpg SRC) + data_to_c_simple(../../../../release/datafiles/matcaps/mc17.jpg SRC) + data_to_c_simple(../../../../release/datafiles/matcaps/mc18.jpg SRC) + data_to_c_simple(../../../../release/datafiles/matcaps/mc19.jpg SRC) + data_to_c_simple(../../../../release/datafiles/matcaps/mc20.jpg SRC) + data_to_c_simple(../../../../release/datafiles/matcaps/mc21.jpg SRC) + data_to_c_simple(../../../../release/datafiles/matcaps/mc22.jpg SRC) + data_to_c_simple(../../../../release/datafiles/matcaps/mc23.jpg SRC) + data_to_c_simple(../../../../release/datafiles/matcaps/mc24.jpg SRC) endif() diff --git a/source/blender/editors/datafiles/SConscript b/source/blender/editors/datafiles/SConscript index fb1f9f37975..c17ab386fe6 100644 --- a/source/blender/editors/datafiles/SConscript +++ b/source/blender/editors/datafiles/SConscript @@ -95,6 +95,14 @@ sources.extend(( os.path.join(env['DATA_SOURCES'], "mc14.jpg.c"), os.path.join(env['DATA_SOURCES'], "mc15.jpg.c"), os.path.join(env['DATA_SOURCES'], "mc16.jpg.c"), + os.path.join(env['DATA_SOURCES'], "mc17.jpg.c"), + os.path.join(env['DATA_SOURCES'], "mc18.jpg.c"), + os.path.join(env['DATA_SOURCES'], "mc19.jpg.c"), + os.path.join(env['DATA_SOURCES'], "mc20.jpg.c"), + os.path.join(env['DATA_SOURCES'], "mc21.jpg.c"), + os.path.join(env['DATA_SOURCES'], "mc22.jpg.c"), + os.path.join(env['DATA_SOURCES'], "mc23.jpg.c"), + os.path.join(env['DATA_SOURCES'], "mc24.jpg.c"), )) diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c index 3e092ed8c5b..09a7890a539 100644 --- a/source/blender/editors/gpencil/drawgpencil.c +++ b/source/blender/editors/gpencil/drawgpencil.c @@ -27,7 +27,6 @@ * \ingroup edgpencil */ - #include <stdio.h> #include <string.h> #include <stdlib.h> diff --git a/source/blender/editors/include/ED_datafiles.h b/source/blender/editors/include/ED_datafiles.h index 19552d60387..81dbb8e9aa5 100644 --- a/source/blender/editors/include/ED_datafiles.h +++ b/source/blender/editors/include/ED_datafiles.h @@ -206,6 +206,30 @@ extern char datatoc_mc15_jpg[]; extern int datatoc_mc16_jpg_size; extern char datatoc_mc16_jpg[]; +extern int datatoc_mc17_jpg_size; +extern char datatoc_mc17_jpg[]; + +extern int datatoc_mc18_jpg_size; +extern char datatoc_mc18_jpg[]; + +extern int datatoc_mc19_jpg_size; +extern char datatoc_mc19_jpg[]; + +extern int datatoc_mc20_jpg_size; +extern char datatoc_mc20_jpg[]; + +extern int datatoc_mc21_jpg_size; +extern char datatoc_mc21_jpg[]; + +extern int datatoc_mc22_jpg_size; +extern char datatoc_mc22_jpg[]; + +extern int datatoc_mc23_jpg_size; +extern char datatoc_mc23_jpg[]; + +extern int datatoc_mc24_jpg_size; +extern char datatoc_mc24_jpg[]; + #endif /* __ED_DATAFILES_H__ */ diff --git a/source/blender/editors/include/UI_icons.h b/source/blender/editors/include/UI_icons.h index f5ac3f19b5b..0560cbd69cc 100644 --- a/source/blender/editors/include/UI_icons.h +++ b/source/blender/editors/include/UI_icons.h @@ -1007,6 +1007,14 @@ DEF_ICON(MATCAP_13) DEF_ICON(MATCAP_14) DEF_ICON(MATCAP_15) DEF_ICON(MATCAP_16) +DEF_ICON(MATCAP_17) +DEF_ICON(MATCAP_18) +DEF_ICON(MATCAP_19) +DEF_ICON(MATCAP_20) +DEF_ICON(MATCAP_21) +DEF_ICON(MATCAP_22) +DEF_ICON(MATCAP_23) +DEF_ICON(MATCAP_24) /* vector icons, VICO_ prefix added */ DEF_VICO(VIEW3D_VEC) diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index e9cb2eff7e3..434fb58184f 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -85,6 +85,9 @@ typedef struct uiLayout uiLayout; #define UI_MAX_DRAW_STR 400 #define UI_MAX_NAME_STR 128 +/* use for clamping popups within the screen */ +#define UI_SCREEN_MARGIN 10 + /* uiBlock->dt */ #define UI_EMBOSS 0 /* use widget style for drawing */ #define UI_EMBOSSN 1 /* Nothing, only icon and/or text */ @@ -219,7 +222,7 @@ typedef enum { NUMSLI = (14 << 9), COLOR = (15 << 9), IDPOIN = (16 << 9), - HSVSLI = (17 << 9), + HSVSLI = (17 << 9), /* UNUSED, but code still references */ SCROLL = (18 << 9), BLOCK = (19 << 9), BUTM = (20 << 9), diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 1dee497ff11..4a5f3acad4f 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -319,6 +319,7 @@ static void ui_popup_bounds_block(const bContext *C, uiBlock *block, eBlockBound wmWindow *window = CTX_wm_window(C); int startx, starty, endx, endy, width, height, oldwidth, oldheight; int oldbounds, xmax, ymax; + const int margin = UI_SCREEN_MARGIN; oldbounds = block->bounds; @@ -356,20 +357,20 @@ static void ui_popup_bounds_block(const bContext *C, uiBlock *block, eBlockBound startx = window->eventstate->x + block->rect.xmin + (block->mx * width) / oldwidth; starty = window->eventstate->y + block->rect.ymin + (block->my * height) / oldheight; - if (startx < 10) - startx = 10; - if (starty < 10) - starty = 10; + if (startx < margin) + startx = margin; + if (starty < margin) + starty = margin; endx = startx + width; endy = starty + height; if (endx > xmax) { - endx = xmax - 10; + endx = xmax - margin; startx = endx - width; } - if (endy > ymax - 20) { - endy = ymax - 20; + if (endy > ymax - margin) { + endy = ymax - margin; starty = endy - height; } @@ -927,6 +928,8 @@ void uiEndBlock(const bContext *C, uiBlock *block) block->auto_open = block->oldblock->auto_open; block->auto_open_last = block->oldblock->auto_open_last; block->tooltipdisabled = block->oldblock->tooltipdisabled; + copy_v3_v3(ui_block_hsv_get(block), + ui_block_hsv_get(block->oldblock)); block->oldblock = NULL; } @@ -997,7 +1000,7 @@ void ui_fontscale(short *points, float aspect) /* project button or block (but==NULL) to pixels in regionspace */ static void ui_but_to_pixelrect(rcti *rect, const ARegion *ar, uiBlock *block, uiBut *but) { - rctf rectf = (but)? but->rect: block->rect; + rctf rectf = (but) ? but->rect : block->rect; ui_block_to_window_fl(ar, block, &rectf.xmin, &rectf.ymin); ui_block_to_window_fl(ar, block, &rectf.xmax, &rectf.ymax); diff --git a/source/blender/editors/interface/interface_anim.c b/source/blender/editors/interface/interface_anim.c index 5d62ef768d2..e4c163e9162 100644 --- a/source/blender/editors/interface/interface_anim.c +++ b/source/blender/editors/interface/interface_anim.c @@ -57,7 +57,11 @@ static FCurve *ui_but_get_fcurve(uiBut *but, bAction **action, int *driven) { - return rna_get_fcurve(&but->rnapoin, but->rnaprop, but->rnaindex, action, driven); + /* for entire array buttons we check the first component, it's not perfect + * but works well enough in typical cases */ + int rnaindex = (but->rnaindex == -1) ? 0 : but->rnaindex; + + return rna_get_fcurve(&but->rnapoin, but->rnaprop, rnaindex, action, driven); } void ui_but_anim_flag(uiBut *but, float cfra) @@ -131,7 +135,7 @@ int ui_but_anim_expression_create(uiBut *but, const char *str) ID *id; FCurve *fcu; char *path; - short ok = 0; + bool ok = false; /* button must have RNA-pointer to a numeric-capable property */ if (ELEM(NULL, but->rnapoin.data, but->rnaprop)) { @@ -140,6 +144,14 @@ int ui_but_anim_expression_create(uiBut *but, const char *str) return 0; } + if (RNA_property_array_length(&but->rnapoin, but->rnaprop) != 0) { + if (but->rnaindex == -1) { + if (G.debug & G_DEBUG) + printf("ERROR: create expression failed - can't create expression for entire array\n"); + return 0; + } + } + /* make sure we have animdata for this */ /* FIXME: until materials can be handled by depsgraph, don't allow drivers to be created for them */ id = (ID *)but->rnapoin.id.data; @@ -168,6 +180,7 @@ int ui_but_anim_expression_create(uiBut *but, const char *str) /* updates */ driver->flag |= DRIVER_FLAG_RECOMPILE; WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME, NULL); + ok = true; } } diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index 792553f842c..e19e89af5da 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -373,7 +373,7 @@ void uiRoundRect(float minx, float miny, float maxx, float maxy, float rad) glEnable(GL_BLEND); uiDrawBox(GL_LINE_LOOP, minx, miny, maxx, maxy, rad); - + glDisable(GL_BLEND); glDisable(GL_LINE_SMOOTH); } diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 0d65cd19034..edd5b901ca1 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -214,18 +214,22 @@ typedef struct uiAfterFunc { static int ui_but_contains_pt(uiBut *but, int mx, int my); static int ui_mouse_inside_button(ARegion *ar, uiBut *but, int x, int y); static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState state); -static int ui_handler_region_menu(bContext *C, wmEvent *event, void *userdata); +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); /* ******************** menu navigation helpers ************** */ /* assumes event type is MOUSEPAN */ -void ui_pan_to_scroll(wmEvent *event, int *type, int *val) +void ui_pan_to_scroll(const wmEvent *event, int *type, int *val) { static int lastdy = 0; int dy = event->prevy - event->y; - + + /* This event should be originally from event->type, + * converting wrong event into wheel is bad, see [#33803] */ + BLI_assert(*type == MOUSEPAN); + /* sign differs, reset */ if ((dy > 0 && lastdy < 0) || (dy < 0 && lastdy > 0)) lastdy = dy; @@ -233,8 +237,14 @@ void ui_pan_to_scroll(wmEvent *event, int *type, int *val) lastdy += dy; if (ABS(lastdy) > (int)UI_UNIT_Y) { + int dy = event->prevy - event->y; + + if (U.uiflag2 & USER_TRACKPAD_NATURAL) + dy = -dy; + *val = KM_PRESS; - if (event->prevy - event->y > 0) + + if (dy > 0) *type = WHEELUPMOUSE; else *type = WHEELDOWNMOUSE; @@ -291,15 +301,15 @@ static uiBut *ui_but_last(uiBlock *block) return NULL; } -static int ui_is_a_warp_but(uiBut *but) +static bool ui_is_a_warp_but(uiBut *but) { if (U.uiflag & USER_CONTINUOUS_MOUSE) { - if (ELEM6(but->type, NUM, NUMABS, HSVCIRCLE, TRACKPREVIEW, HSVCUBE, BUT_CURVE)) { - return TRUE; + if (ELEM7(but->type, NUM, NUMSLI, NUMABS, HSVCIRCLE, TRACKPREVIEW, HSVCUBE, BUT_CURVE)) { + return true; } } - return FALSE; + return false; } static float ui_mouse_scale_warp_factor(const short shift) @@ -721,7 +731,7 @@ static void ui_apply_but_CHARTAB(bContext *C, uiBut *but, uiHandleButtonData *da /* ****************** drag drop code *********************** */ -static int ui_but_mouse_inside_icon(uiBut *but, ARegion *ar, wmEvent *event) +static int ui_but_mouse_inside_icon(uiBut *but, ARegion *ar, const wmEvent *event) { rcti rect; int x = event->x, y = event->y; @@ -745,7 +755,7 @@ static int ui_but_mouse_inside_icon(uiBut *but, ARegion *ar, wmEvent *event) return BLI_rcti_isect_pt(&rect, x, y); } -static int ui_but_start_drag(bContext *C, uiBut *but, uiHandleButtonData *data, wmEvent *event) +static int ui_but_start_drag(bContext *C, uiBut *but, uiHandleButtonData *data, const wmEvent *event) { /* prevent other WM gestures to start while we try to drag */ WM_gestures_remove(C); @@ -1162,7 +1172,7 @@ static void ui_apply_button(bContext *C, uiBlock *block, uiBut *but, uiHandleBut /* ******************* drop event ******************** */ /* only call if event type is EVT_DROP */ -static void ui_but_drop(bContext *C, wmEvent *event, uiBut *but, uiHandleButtonData *data) +static void ui_but_drop(bContext *C, const wmEvent *event, uiBut *but, uiHandleButtonData *data) { wmDrag *wmd; ListBase *drags = event->customdata; /* drop event type has listbase customdata by default */ @@ -1911,7 +1921,7 @@ static void ui_textedit_prev_but(uiBlock *block, uiBut *actbut, uiHandleButtonDa } -static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, wmEvent *event) +static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, const wmEvent *event) { int mx, my, changed = 0, inbox = 0, update = 0, retval = WM_UI_HANDLER_CONTINUE; @@ -2103,7 +2113,7 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle ED_region_tag_redraw(data->region); } -static void ui_do_but_textedit_select(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, wmEvent *event) +static void ui_do_but_textedit_select(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, const wmEvent *event) { int mx, my, retval = WM_UI_HANDLER_CONTINUE; @@ -2292,7 +2302,7 @@ int ui_button_open_menu_direction(uiBut *but) /* ***************** events for different button types *************** */ -static int ui_do_but_BUT(bContext *C, uiBut *but, uiHandleButtonData *data, wmEvent *event) +static int ui_do_but_BUT(bContext *C, uiBut *but, uiHandleButtonData *data, const wmEvent *event) { if (data->state == BUTTON_STATE_HIGHLIGHT) { if (event->type == LEFTMOUSE && event->val == KM_PRESS) { @@ -2320,7 +2330,7 @@ static int ui_do_but_BUT(bContext *C, uiBut *but, uiHandleButtonData *data, wmEv return WM_UI_HANDLER_CONTINUE; } -static int ui_do_but_HOTKEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data, wmEvent *event) +static int ui_do_but_HOTKEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data, const wmEvent *event) { if (data->state == BUTTON_STATE_HIGHLIGHT) { if (ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val == KM_PRESS) { @@ -2381,7 +2391,7 @@ static int ui_do_but_HOTKEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data return WM_UI_HANDLER_CONTINUE; } -static int ui_do_but_KEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data, wmEvent *event) +static int ui_do_but_KEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data, const wmEvent *event) { if (data->state == BUTTON_STATE_HIGHLIGHT) { if (ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val == KM_PRESS) { @@ -2406,7 +2416,7 @@ static int ui_do_but_KEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data, w return WM_UI_HANDLER_CONTINUE; } -static int ui_do_but_TEX(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, wmEvent *event) +static int ui_do_but_TEX(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, const wmEvent *event) { if (data->state == BUTTON_STATE_HIGHLIGHT) { if (ELEM(event->type, LEFTMOUSE, EVT_BUT_OPEN) && event->val == KM_PRESS) { @@ -2431,7 +2441,7 @@ static int ui_do_but_TEX(bContext *C, uiBlock *block, uiBut *but, uiHandleButton return WM_UI_HANDLER_CONTINUE; } -static int ui_do_but_SEARCH_UNLINK(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, wmEvent *event) +static int ui_do_but_SEARCH_UNLINK(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, const wmEvent *event) { /* unlink icon is on right */ if (ELEM(event->type, LEFTMOUSE, EVT_BUT_OPEN) && event->val == KM_PRESS) { @@ -2459,7 +2469,7 @@ static int ui_do_but_SEARCH_UNLINK(bContext *C, uiBlock *block, uiBut *but, uiHa return ui_do_but_TEX(C, block, but, data, event); } -static int ui_do_but_TOG(bContext *C, uiBut *but, uiHandleButtonData *data, wmEvent *event) +static int ui_do_but_TOG(bContext *C, uiBut *but, uiHandleButtonData *data, const wmEvent *event) { if (data->state == BUTTON_STATE_HIGHLIGHT) { if (ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val == KM_PRESS) { @@ -2472,7 +2482,7 @@ static int ui_do_but_TOG(bContext *C, uiBut *but, uiHandleButtonData *data, wmEv return WM_UI_HANDLER_CONTINUE; } -static int ui_do_but_EXIT(bContext *C, uiBut *but, uiHandleButtonData *data, wmEvent *event) +static int ui_do_but_EXIT(bContext *C, uiBut *but, uiHandleButtonData *data, const wmEvent *event) { if (data->state == BUTTON_STATE_HIGHLIGHT) { @@ -2730,7 +2740,7 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i return changed; } -static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, wmEvent *event) +static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, const wmEvent *event) { int mx, my; /* mouse location scaled to fit the UI */ int screen_mx, screen_my; /* mouse location kept at screen pixel coords */ @@ -2745,7 +2755,9 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton if (data->state == BUTTON_STATE_HIGHLIGHT) { int type = event->type, val = event->val; - ui_pan_to_scroll(event, &type, &val); + if (type == MOUSEPAN) { + ui_pan_to_scroll(event, &type, &val); + } /* XXX hardcoded keymap check.... */ if (type == MOUSEPAN && event->alt) @@ -2882,36 +2894,66 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton return retval; } -static int ui_numedit_but_SLI(uiBut *but, uiHandleButtonData *data, const short shift, const short ctrl, int mx) +static bool ui_numedit_but_SLI(uiBut *but, uiHandleButtonData *data, + const bool is_horizontal, const bool shift, const bool ctrl, int mx) { float deler, f, tempf, softmin, softmax, softrange; - int temp, lvalue, changed = 0; + int temp, lvalue; + bool changed = false; + float mx_fl, my_fl; + /* note, 'offs' is really from the widget drawing rounded corners see 'widget_numslider' */ + float offs; softmin = but->softmin; softmax = but->softmax; softrange = softmax - softmin; + /* yes, 'mx' as both x/y is intentional */ + ui_mouse_scale_warp(data, mx, mx, &mx_fl, &my_fl, shift); + if (but->type == NUMSLI) { - deler = (BLI_rctf_size_x(&but->rect) - 5.0f * but->aspect); + offs = (BLI_rctf_size_y(&but->rect) / 2.0f) * but->aspect; + deler = BLI_rctf_size_x(&but->rect) - offs; } else if (but->type == HSVSLI) { - deler = (BLI_rctf_size_x(&but->rect) / 2.0f - 5.0f * but->aspect); + offs = (BLI_rctf_size_y(&but->rect) / 2.0f) * but->aspect; + deler = (BLI_rctf_size_x(&but->rect) / 2.0f) - offs; } else if (but->type == SCROLL) { - int horizontal = (BLI_rctf_size_x(&but->rect) > BLI_rctf_size_y(&but->rect)); - float size = (horizontal) ? BLI_rctf_size_x(&but->rect) : -BLI_rctf_size_y(&but->rect); + const float size = (is_horizontal) ? BLI_rctf_size_x(&but->rect) : -BLI_rctf_size_y(&but->rect); deler = size * (but->softmax - but->softmin) / (but->softmax - but->softmin + but->a1); + offs = 0.0; } else { - deler = (BLI_rctf_size_x(&but->rect) - 5.0f * but->aspect); + offs = (BLI_rctf_size_y(&but->rect) / 2.0f) * but->aspect; + deler = (BLI_rctf_size_x(&but->rect) - offs); } - f = (float)(mx - data->dragstartx) / deler + data->dragfstart; - - if (shift) - f = (f - data->dragfstart) / 10.0f + data->dragfstart; - + f = (mx_fl - data->dragstartx) / deler + data->dragfstart; CLAMP(f, 0.0f, 1.0f); + + + /* deal with mouse correction */ +#ifdef USE_CONT_MOUSE_CORRECT + if (ui_is_a_warp_but(but)) { + /* OK but can go outside bounds */ + if (is_horizontal) { + data->ungrab_mval[0] = (but->rect.xmin + offs / but->aspect) + (f * deler); + data->ungrab_mval[1] = BLI_rctf_cent_y(&but->rect); + } + else { + data->ungrab_mval[1] = (but->rect.ymin + offs / but->aspect) + (f * deler); + data->ungrab_mval[0] = BLI_rctf_cent_x(&but->rect); + } + BLI_rctf_clamp_pt_v(&but->rect, data->ungrab_mval); + } +#endif + if (is_horizontal == false) { + mx_fl = my_fl; + } + /* done correcting mouse */ + + tempf = softmin + f * softrange; temp = floorf(tempf + 0.5f); @@ -2947,7 +2989,7 @@ static int ui_numedit_but_SLI(uiBut *but, uiHandleButtonData *data, const short if (temp != lvalue) { data->value = temp; data->dragchange = 1; - changed = 1; + changed = true; } } else { @@ -2956,14 +2998,14 @@ static int ui_numedit_but_SLI(uiBut *but, uiHandleButtonData *data, const short if (tempf != (float)data->value) { data->value = tempf; data->dragchange = 1; - changed = 1; + changed = true; } } return changed; } -static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, wmEvent *event) +static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, const wmEvent *event) { int mx, my, click = 0; int retval = WM_UI_HANDLER_CONTINUE; @@ -2974,8 +3016,10 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton if (data->state == BUTTON_STATE_HIGHLIGHT) { int type = event->type, val = event->val; - - ui_pan_to_scroll(event, &type, &val); + + if (type == MOUSEPAN) { + ui_pan_to_scroll(event, &type, &val); + } /* XXX hardcoded keymap check.... */ if (type == MOUSEPAN && event->alt) @@ -3032,7 +3076,7 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton click = 1; } else if (event->type == MOUSEMOVE) { - if (ui_numedit_but_SLI(but, data, event->shift, event->ctrl, mx)) + if (ui_numedit_but_SLI(but, data, true, event->shift, event->ctrl, mx)) ui_numedit_apply(C, block, but, data); } retval = WM_UI_HANDLER_BREAK; @@ -3105,11 +3149,11 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton return retval; } -static int ui_do_but_SCROLL(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, wmEvent *event) +static int ui_do_but_SCROLL(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, const wmEvent *event) { int mx, my /*, click = 0 */; int retval = WM_UI_HANDLER_CONTINUE; - int horizontal = (BLI_rctf_size_x(&but->rect) > BLI_rctf_size_y(&but->rect)); + bool horizontal = (BLI_rctf_size_x(&but->rect) > BLI_rctf_size_y(&but->rect)); mx = event->x; my = event->y; @@ -3146,7 +3190,7 @@ static int ui_do_but_SCROLL(bContext *C, uiBlock *block, uiBut *but, uiHandleBut button_activate_state(C, but, BUTTON_STATE_EXIT); } else if (event->type == MOUSEMOVE) { - if (ui_numedit_but_SLI(but, data, 0, 0, (horizontal) ? mx : my)) + if (ui_numedit_but_SLI(but, data, horizontal, false, false, (horizontal) ? mx : my)) ui_numedit_apply(C, block, but, data); } @@ -3157,7 +3201,7 @@ static int ui_do_but_SCROLL(bContext *C, uiBlock *block, uiBut *but, uiHandleBut } -static int ui_do_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data, wmEvent *event) +static int ui_do_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data, const wmEvent *event) { if (data->state == BUTTON_STATE_HIGHLIGHT) { @@ -3320,7 +3364,7 @@ static int ui_numedit_but_NORMAL(uiBut *but, uiHandleButtonData *data, int mx, i return changed; } -static int ui_do_but_NORMAL(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, wmEvent *event) +static int ui_do_but_NORMAL(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, const wmEvent *event) { int mx, my; @@ -3506,7 +3550,7 @@ static void ui_ndofedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, wmNDOF ui_set_but_vectorf(but, data->vec); } -static int ui_do_but_HSVCUBE(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, wmEvent *event) +static int ui_do_but_HSVCUBE(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, const wmEvent *event) { int mx, my; @@ -3706,7 +3750,7 @@ static void ui_ndofedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, wmND } -static int ui_do_but_HSVCIRCLE(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, wmEvent *event) +static int ui_do_but_HSVCIRCLE(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, const wmEvent *event) { int mx, my; mx = event->x; @@ -3825,7 +3869,7 @@ static int ui_numedit_but_COLORBAND(uiBut *but, uiHandleButtonData *data, int mx return changed; } -static int ui_do_but_COLORBAND(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, wmEvent *event) +static int ui_do_but_COLORBAND(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, const wmEvent *event) { ColorBand *coba; CBData *cbd; @@ -3989,7 +4033,7 @@ static int ui_numedit_but_CURVE(uiBut *but, uiHandleButtonData *data, int snap, return changed; } -static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, wmEvent *event) +static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, const wmEvent *event) { int mx, my, a, changed = 0; @@ -4171,7 +4215,7 @@ static int ui_numedit_but_HISTOGRAM(uiBut *but, uiHandleButtonData *data, int mx return changed; } -static int ui_do_but_HISTOGRAM(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, wmEvent *event) +static int ui_do_but_HISTOGRAM(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, const wmEvent *event) { int mx, my; @@ -4254,7 +4298,7 @@ static int ui_numedit_but_WAVEFORM(uiBut *but, uiHandleButtonData *data, int mx, return changed; } -static int ui_do_but_WAVEFORM(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, wmEvent *event) +static int ui_do_but_WAVEFORM(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, const wmEvent *event) { int mx, my; @@ -4329,7 +4373,7 @@ static int ui_numedit_but_VECTORSCOPE(uiBut *but, uiHandleButtonData *data, int return changed; } -static int ui_do_but_VECTORSCOPE(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, wmEvent *event) +static int ui_do_but_VECTORSCOPE(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, const wmEvent *event) { int mx, my; @@ -4374,7 +4418,7 @@ static int ui_do_but_VECTORSCOPE(bContext *C, uiBlock *block, uiBut *but, uiHand } #ifdef WITH_INTERNATIONAL -static int ui_do_but_CHARTAB(bContext *UNUSED(C), uiBlock *UNUSED(block), uiBut *UNUSED(but), uiHandleButtonData *UNUSED(data), wmEvent *UNUSED(event)) +static int ui_do_but_CHARTAB(bContext *UNUSED(C), uiBlock *UNUSED(block), uiBut *UNUSED(but), uiHandleButtonData *UNUSED(data), const wmEvent *UNUSED(event)) { /* XXX 2.50 bad global and state access */ #if 0 @@ -4479,7 +4523,7 @@ static int ui_do_but_CHARTAB(bContext *UNUSED(C), uiBlock *UNUSED(block), uiBut #endif -static int ui_do_but_LINK(bContext *C, uiBut *but, uiHandleButtonData *data, wmEvent *event) +static int ui_do_but_LINK(bContext *C, uiBut *but, uiHandleButtonData *data, const wmEvent *event) { VECCOPY2D(but->linkto, event->mval); @@ -4546,7 +4590,7 @@ static int ui_numedit_but_TRACKPREVIEW(bContext *C, uiBut *but, uiHandleButtonDa return changed; } -static int ui_do_but_TRACKPREVIEW(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, wmEvent *event) +static int ui_do_but_TRACKPREVIEW(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, const wmEvent *event) { int mx, my; @@ -4722,7 +4766,7 @@ static int ui_but_menu(bContext *C, uiBut *but) { uiPopupMenu *pup; uiLayout *layout; - int length; + bool is_array, is_array_component; const char *name; uiStringInfo label = {BUT_GET_LABEL, NULL}; @@ -4749,12 +4793,14 @@ static int ui_but_menu(bContext *C, uiBut *but) if (is_anim) is_anim = RNA_property_path_from_ID_check(&but->rnapoin, but->rnaprop); - length = RNA_property_array_length(&but->rnapoin, but->rnaprop); + /* determine if we can key a single component of an array */ + is_array = RNA_property_array_length(&but->rnapoin, but->rnaprop) != 0; + is_array_component = (is_array && but->rnaindex != -1); /* Keyframes */ if (but->flag & UI_BUT_ANIMATED_KEY) { /* replace/delete keyfraemes */ - if (length) { + if (is_array_component) { uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Replace Keyframes"), ICON_NONE, "ANIM_OT_keyframe_insert_button", "all", 1); uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Replace Single Keyframe"), @@ -4766,9 +4812,9 @@ static int ui_but_menu(bContext *C, uiBut *but) } else { uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Replace Keyframe"), - ICON_NONE, "ANIM_OT_keyframe_insert_button", "all", 0); + ICON_NONE, "ANIM_OT_keyframe_insert_button", "all", 1); uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Delete Keyframe"), - ICON_NONE, "ANIM_OT_keyframe_delete_button", "all", 0); + ICON_NONE, "ANIM_OT_keyframe_delete_button", "all", 1); } /* keyframe settings */ @@ -4780,7 +4826,7 @@ static int ui_but_menu(bContext *C, uiBut *but) /* pass */ } else if (is_anim) { - if (length) { + if (is_array_component) { uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Insert Keyframes"), ICON_NONE, "ANIM_OT_keyframe_insert_button", "all", 1); uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Insert Single Keyframe"), @@ -4788,12 +4834,12 @@ static int ui_but_menu(bContext *C, uiBut *but) } else { uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Insert Keyframe"), - ICON_NONE, "ANIM_OT_keyframe_insert_button", "all", 0); + ICON_NONE, "ANIM_OT_keyframe_insert_button", "all", 1); } } if (but->flag & UI_BUT_ANIMATED) { - if (length) { + if (is_array_component) { uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Clear Keyframes"), ICON_NONE, "ANIM_OT_keyframe_clear_button", "all", 1); uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Clear Single Keyframes"), @@ -4801,7 +4847,7 @@ static int ui_but_menu(bContext *C, uiBut *but) } else { uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Clear Keyframes"), - ICON_NONE, "ANIM_OT_keyframe_clear_button", "all", 0); + ICON_NONE, "ANIM_OT_keyframe_clear_button", "all", 1); } } @@ -4809,7 +4855,7 @@ static int ui_but_menu(bContext *C, uiBut *but) if (but->flag & UI_BUT_DRIVEN) { uiItemS(layout); - if (length) { + if (is_array_component) { uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Delete Drivers"), ICON_NONE, "ANIM_OT_driver_button_remove", "all", 1); uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Delete Single Driver"), @@ -4817,7 +4863,7 @@ static int ui_but_menu(bContext *C, uiBut *but) } else { uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Delete Driver"), - ICON_NONE, "ANIM_OT_driver_button_remove", "all", 0); + ICON_NONE, "ANIM_OT_driver_button_remove", "all", 1); } uiItemO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Copy Driver"), @@ -4833,7 +4879,7 @@ static int ui_but_menu(bContext *C, uiBut *but) else if (is_anim) { uiItemS(layout); - if (length) { + if (is_array_component) { uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Add Drivers"), ICON_NONE, "ANIM_OT_driver_button_add", "all", 1); uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Add Single Driver"), @@ -4841,7 +4887,7 @@ static int ui_but_menu(bContext *C, uiBut *but) } else { uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Add Driver"), - ICON_NONE, "ANIM_OT_driver_button_add", "all", 0); + ICON_NONE, "ANIM_OT_driver_button_add", "all", 1); } if (ANIM_driver_can_paste()) { @@ -4855,7 +4901,7 @@ static int ui_but_menu(bContext *C, uiBut *but) if (is_anim) { uiItemS(layout); - if (length) { + if (is_array_component) { uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Add All to Keying Set"), ICON_NONE, "ANIM_OT_keyingset_button_add", "all", 1); uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Add Single to Keying Set"), @@ -4865,7 +4911,7 @@ static int ui_but_menu(bContext *C, uiBut *but) } else { uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Add to Keying Set"), - ICON_NONE, "ANIM_OT_keyingset_button_add", "all", 0); + ICON_NONE, "ANIM_OT_keyingset_button_add", "all", 1); uiItemO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Remove from Keying Set"), ICON_NONE, "ANIM_OT_keyingset_button_remove"); } @@ -4878,15 +4924,15 @@ static int ui_but_menu(bContext *C, uiBut *but) /* Copy Property Value * Paste Property Value */ - if (length) { + if (is_array_component) { uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Reset All to Default Values"), ICON_NONE, "UI_OT_reset_default_button", "all", 1); uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Reset Single to Default Value"), ICON_NONE, "UI_OT_reset_default_button", "all", 0); } else { - uiItemO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Reset to Default Value"), - ICON_NONE, "UI_OT_reset_default_button"); + uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Reset to Default Value"), + ICON_NONE, "UI_OT_reset_default_button", "all", 1); } uiItemO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Copy Data Path"), @@ -5006,7 +5052,7 @@ static int ui_but_menu(bContext *C, uiBut *but) return 1; } -static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event) +static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent *event) { uiHandleButtonData *data; int retval; @@ -5919,7 +5965,7 @@ void uiContextAnimUpdate(const bContext *C) /************** handle activating a button *************/ -static uiBut *uit_but_find_open_event(ARegion *ar, wmEvent *event) +static uiBut *uit_but_find_open_event(ARegion *ar, const wmEvent *event) { uiBlock *block; uiBut *but; @@ -5932,7 +5978,7 @@ static uiBut *uit_but_find_open_event(ARegion *ar, wmEvent *event) return NULL; } -static int ui_handle_button_over(bContext *C, wmEvent *event, ARegion *ar) +static int ui_handle_button_over(bContext *C, const wmEvent *event, ARegion *ar) { uiBut *but; @@ -5987,7 +6033,7 @@ static void ui_handle_button_activate(bContext *C, ARegion *ar, uiBut *but, uiBu /************ handle events for an activated button ***********/ -static int ui_handle_button_event(bContext *C, wmEvent *event, uiBut *but) +static int ui_handle_button_event(bContext *C, const wmEvent *event, uiBut *but) { uiHandleButtonData *data; uiBlock *block; @@ -6161,7 +6207,7 @@ static int ui_handle_button_event(bContext *C, wmEvent *event, uiBut *but) return retval; } -static int ui_handle_list_event(bContext *C, wmEvent *event, ARegion *ar) +static int ui_handle_list_event(bContext *C, const wmEvent *event, ARegion *ar) { uiBut *but = ui_list_find_mouse_over(ar, event->x, event->y); int retval = WM_UI_HANDLER_CONTINUE; @@ -6248,7 +6294,7 @@ static int ui_handle_list_event(bContext *C, wmEvent *event, ARegion *ar) return retval; } -static void ui_handle_button_return_submenu(bContext *C, wmEvent *event, uiBut *but) +static void ui_handle_button_return_submenu(bContext *C, const wmEvent *event, uiBut *but) { uiHandleButtonData *data; uiPopupBlockHandle *menu; @@ -6451,7 +6497,7 @@ static int ui_menu_scroll(ARegion *ar, uiBlock *block, int my, uiBut *to_bt) return 0; } -static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle *menu, int level) +static int ui_handle_menu_event(bContext *C, const wmEvent *event, uiPopupBlockHandle *menu, int level) { ARegion *ar; uiBlock *block; @@ -6862,7 +6908,7 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle return retval; } -static int ui_handle_menu_return_submenu(bContext *C, wmEvent *event, uiPopupBlockHandle *menu) +static int ui_handle_menu_return_submenu(bContext *C, const wmEvent *event, uiPopupBlockHandle *menu) { ARegion *ar; uiBut *but; @@ -6911,7 +6957,7 @@ static int ui_handle_menu_return_submenu(bContext *C, wmEvent *event, uiPopupBlo return WM_UI_HANDLER_BREAK; } -static int ui_handle_menus_recursive(bContext *C, wmEvent *event, uiPopupBlockHandle *menu, int level) +static int ui_handle_menus_recursive(bContext *C, const wmEvent *event, uiPopupBlockHandle *menu, int level) { uiBut *but; uiHandleButtonData *data; @@ -6933,7 +6979,7 @@ static int ui_handle_menus_recursive(bContext *C, wmEvent *event, uiPopupBlockHa retval = ui_handle_menu_return_submenu(C, event, menu); submenu = NULL; /* hint not to use this, it may be freed by call above */ (void)submenu; - /* we may wan't to quit the submenu and handle the even in this menu, + /* we may want to quit the submenu and handle the even in this menu, * if its important to use it, check 'data->menu' first */ if ((retval == WM_UI_HANDLER_BREAK) && do_ret_out_parent) { retval = ui_handle_menu_event(C, event, menu, level); @@ -6949,7 +6995,7 @@ static int ui_handle_menus_recursive(bContext *C, wmEvent *event, uiPopupBlockHa /* *************** UI event handlers **************** */ -static int ui_handler_region(bContext *C, wmEvent *event, void *UNUSED(userdata)) +static int ui_handler_region(bContext *C, const wmEvent *event, void *UNUSED(userdata)) { ARegion *ar; uiBut *but; @@ -7007,7 +7053,7 @@ static void ui_handler_remove_region(bContext *C, void *UNUSED(userdata)) ui_apply_but_funcs_after(C); } -static int ui_handler_region_menu(bContext *C, wmEvent *event, void *UNUSED(userdata)) +static int ui_handler_region_menu(bContext *C, const wmEvent *event, void *UNUSED(userdata)) { ARegion *ar; uiBut *but; @@ -7062,7 +7108,7 @@ static int ui_handler_region_menu(bContext *C, wmEvent *event, void *UNUSED(user } /* two types of popups, one with operator + enum, other with regular callbacks */ -static int ui_handler_popup(bContext *C, wmEvent *event, void *userdata) +static int ui_handler_popup(bContext *C, const wmEvent *event, void *userdata) { uiPopupBlockHandle *menu = userdata; diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 619fb18cd7a..086e9dad895 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -130,6 +130,7 @@ static IconTexture icongltex = {0, 0, 0, 0.0f, 0.0f}; /* **************************************************** */ +#ifndef WITH_HEADLESS static DrawInfo *def_internal_icon(ImBuf *bbuf, int icon_id, int xofs, int yofs, int size, int type) { @@ -469,6 +470,7 @@ static void vicon_move_down_draw(int x, int y, int w, int h, float UNUSED(alpha) } #ifndef WITH_HEADLESS + static void init_brush_icons(void) { @@ -531,7 +533,7 @@ static void icon_verify_datatoc(IconImage *iimg) iimg->datatoc_size, IB_rect, NULL, "<matcap icon>"); /* w and h were set on initialize */ if (bbuf->x != iimg->h && bbuf->y != iimg->w) - IMB_scalefastImBuf(bbuf, iimg->w, iimg->h); + IMB_scaleImBuf(bbuf, iimg->w, iimg->h); iimg->rect = bbuf->rect; bbuf->rect = NULL; @@ -548,7 +550,7 @@ static void init_matcap_icons(void) int size = datatoc_ ##name## _jpg_size; \ DrawInfo *di; \ \ - di = def_internal_icon(NULL, icon_id, 0, 0, 128, ICON_TYPE_BUFFER); \ + di = def_internal_icon(NULL, icon_id, 0, 0, 96, ICON_TYPE_BUFFER); \ di->data.buffer.image->datatoc_rect = rect; \ di->data.buffer.image->datatoc_size = size; \ } (void)0 @@ -569,6 +571,14 @@ static void init_matcap_icons(void) INIT_MATCAP_ICON(ICON_MATCAP_14, mc14); INIT_MATCAP_ICON(ICON_MATCAP_15, mc15); INIT_MATCAP_ICON(ICON_MATCAP_16, mc16); + INIT_MATCAP_ICON(ICON_MATCAP_17, mc17); + INIT_MATCAP_ICON(ICON_MATCAP_18, mc18); + INIT_MATCAP_ICON(ICON_MATCAP_19, mc19); + INIT_MATCAP_ICON(ICON_MATCAP_20, mc20); + INIT_MATCAP_ICON(ICON_MATCAP_21, mc21); + INIT_MATCAP_ICON(ICON_MATCAP_22, mc22); + INIT_MATCAP_ICON(ICON_MATCAP_23, mc23); + INIT_MATCAP_ICON(ICON_MATCAP_24, mc24); #undef INIT_MATCAP_ICON @@ -781,6 +791,8 @@ static void free_iconfile_list(struct ListBase *list) } } +#endif /* WITH_HEADLESS */ + int UI_iconfile_get_index(const char *filename) { IconFile *ifile; @@ -1134,9 +1146,9 @@ static void icon_draw_size(float x, float y, int icon_id, float aspect, float al else if (di->type == ICON_TYPE_BUFFER) { /* it is a builtin icon */ iimg = di->data.buffer.image; - +#ifndef WITH_HEADLESS icon_verify_datatoc(iimg); - +#endif if (!iimg->rect) return; /* something has gone wrong! */ glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 0b94a0dabdc..eb7f09c7b34 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -319,7 +319,7 @@ struct uiBlock { void *handle_func_arg; /* custom extra handling */ - int (*block_event_func)(const struct bContext *C, struct uiBlock *, struct wmEvent *); + int (*block_event_func)(const struct bContext *C, struct uiBlock *, const struct wmEvent *); /* extra draw function for custom blocks */ void (*drawextra)(const struct bContext *C, void *idv, void *arg1, void *arg2, rcti *rect); @@ -468,7 +468,7 @@ ARegion *ui_searchbox_create(struct bContext *C, struct ARegion *butregion, uiBu int ui_searchbox_inside(struct ARegion *ar, int x, int y); void ui_searchbox_update(struct bContext *C, struct ARegion *ar, uiBut *but, int reset); void ui_searchbox_autocomplete(struct bContext *C, struct ARegion *ar, uiBut *but, char *str); -void ui_searchbox_event(struct bContext *C, struct ARegion *ar, uiBut *but, struct wmEvent *event); +void ui_searchbox_event(struct bContext *C, struct ARegion *ar, uiBut *but, const struct wmEvent *event); void ui_searchbox_apply(uiBut *but, struct ARegion *ar); void ui_searchbox_free(struct bContext *C, struct ARegion *ar); void ui_but_search_test(uiBut *but); @@ -489,7 +489,7 @@ int ui_step_name_menu(uiBut *but, int step); struct AutoComplete; /* interface_panel.c */ -extern int ui_handler_panel_region(struct bContext *C, struct wmEvent *event); +extern int ui_handler_panel_region(struct bContext *C, const struct wmEvent *event); extern void ui_draw_aligned_panel(struct uiStyle *style, uiBlock *block, rcti *rect); /* interface_draw.c */ @@ -507,7 +507,7 @@ void ui_draw_but_IMAGE(ARegion *ar, uiBut *but, struct uiWidgetColors *wcol, rct void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, struct uiWidgetColors *wcol, rcti *rect); /* interface_handlers.c */ -extern void ui_pan_to_scroll(struct wmEvent *event, int *type, int *val); +extern void ui_pan_to_scroll(const struct wmEvent *event, int *type, int *val); extern void ui_button_activate_do(struct bContext *C, struct ARegion *ar, uiBut *but); extern void ui_button_active_free(const struct bContext *C, uiBut *but); extern int ui_button_is_active(struct ARegion *ar); diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 10375824518..c69f53a53d2 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -624,6 +624,18 @@ void uiFileBrowseContextProperty(const bContext *C, PointerRNA *ptr, PropertyRNA /********************* Button Items *************************/ +/** + * Update a buttons tip with an enum's description if possible. + */ +static void ui_but_tip_from_enum_item(uiBut *but, EnumPropertyItem *item) +{ + if (but->tip == NULL || but->tip[0] == '\0') { + if (item->description && item->description[0]) { + but->tip = item->description; + } + } +} + /* disabled item */ static void ui_item_disabled(uiLayout *layout, const char *name) { @@ -837,6 +849,7 @@ void uiItemsFullEnumO(uiLayout *layout, const char *opname, const char *propname else { uiItemEnumO_ptr__internal(column, ot, item[i].name, item[i].icon, prop, item[i].value); } + ui_but_tip_from_enum_item(block->buttons.last, &item[i]); } else { if (item[i].name) { @@ -849,6 +862,8 @@ void uiItemsFullEnumO(uiLayout *layout, const char *opname, const char *propname uiItemL(column, item[i].name, ICON_NONE); bt = block->buttons.last; bt->flag = UI_TEXT_LEFT; + + ui_but_tip_from_enum_item(bt, &item[i]); } else { /* XXX bug here, colums draw bottom item badly */ uiItemS(column); @@ -1239,6 +1254,7 @@ void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname for (i = 0; i < totitem; i++) { if (item[i].identifier[0]) { uiItemEnumR(column, item[i].name, ICON_NONE, ptr, propname, item[i].value); + ui_but_tip_from_enum_item(block->buttons.last, &item[i]); } else { if (item[i].name) { @@ -1251,6 +1267,8 @@ void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname uiItemL(column, item[i].name, ICON_NONE); bt = block->buttons.last; bt->flag = UI_TEXT_LEFT; + + ui_but_tip_from_enum_item(bt, &item[i]); } else uiItemS(column); @@ -1393,7 +1411,11 @@ void ui_but_add_search(uiBut *but, PointerRNA *ptr, PropertyRNA *prop, PointerRN /* turn button into search button */ if (searchprop) { - but->type = SEARCH_MENU_UNLINK; + if (RNA_property_flag(prop) & PROP_NEVER_UNLINK) + but->type = SEARCH_MENU; + else + but->type = SEARCH_MENU_UNLINK; + but->hardmax = MAX2(but->hardmax, 256.0f); but->rnasearchpoin = *searchptr; but->rnasearchprop = searchprop; diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index e57e52d74b6..e03a171da18 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -661,11 +661,12 @@ static int reports_to_text_poll(bContext *C) static int reports_to_text_exec(bContext *C, wmOperator *UNUSED(op)) { ReportList *reports = CTX_wm_reports(C); + Main *bmain = CTX_data_main(C); Text *txt; char *str; /* create new text-block to write to */ - txt = BKE_text_add("Recent Reports"); + txt = BKE_text_add(bmain, "Recent Reports"); /* convert entire list to a display string, and add this to the text-block * - if commandline debug option enabled, show debug reports too @@ -803,7 +804,7 @@ static int editsource_text_edit(bContext *C, wmOperator *op, } if (text == NULL) { - text = BKE_text_load(filepath, bmain->name); + text = BKE_text_load(bmain, filepath, bmain->name); } if (text == NULL) { diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index c2c1de9cbd7..1b2034d6e40 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -875,7 +875,7 @@ static void ui_do_animate(const bContext *C, Panel *panel) void uiBeginPanels(const bContext *UNUSED(C), ARegion *ar) { Panel *pa; - + /* set all panels as inactive, so that at the end we know * which ones were used */ for (pa = ar->panels.first; pa; pa = pa->next) { @@ -1016,7 +1016,7 @@ static void check_panel_overlap(ARegion *ar, Panel *panel) /************************ panel dragging ****************************/ -static void ui_do_drag(const bContext *C, wmEvent *event, Panel *panel) +static void ui_do_drag(const bContext *C, const wmEvent *event, Panel *panel) { uiHandlePanelData *data = panel->activedata; ScrArea *sa = CTX_wm_area(C); @@ -1134,7 +1134,7 @@ static void ui_handle_panel_header(const bContext *C, uiBlock *block, int mx, in /* XXX should become modal keymap */ /* AKey is opening/closing panels, independent of button state now */ -int ui_handler_panel_region(bContext *C, wmEvent *event) +int ui_handler_panel_region(bContext *C, const wmEvent *event) { ARegion *ar = CTX_wm_region(C); uiBlock *block; @@ -1277,7 +1277,7 @@ int ui_handler_panel_region(bContext *C, wmEvent *event) /**************** window level modal panel interaction **************/ /* note, this is modal handler and should not swallow events for animation */ -static int ui_handler_panel(bContext *C, wmEvent *event, void *userdata) +static int ui_handler_panel(bContext *C, const wmEvent *event, void *userdata) { Panel *panel = userdata; uiHandlePanelData *data = panel->activedata; diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index e846fc3f078..9b2ed9f0984 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -893,7 +893,7 @@ void ui_searchbox_apply(uiBut *but, ARegion *ar) } } -void ui_searchbox_event(bContext *C, ARegion *ar, uiBut *but, wmEvent *event) +void ui_searchbox_event(bContext *C, ARegion *ar, uiBut *but, const wmEvent *event) { uiSearchboxData *data = ar->regiondata; int type = event->type, val = event->val; @@ -1532,7 +1532,7 @@ static void ui_block_region_draw(const bContext *C, ARegion *ar) static void ui_popup_block_clip(wmWindow *window, uiBlock *block) { uiBut *bt; - int width = UI_ThemeMenuShadowWidth(); + int width = UI_SCREEN_MARGIN; int winx, winy; if (block->flag & UI_BLOCK_NO_WIN_CLIP) { @@ -2195,7 +2195,7 @@ static void uiBlockPicker(uiBlock *block, float rgba[4], PointerRNA *ptr, Proper } -static int ui_picker_small_wheel_cb(const bContext *UNUSED(C), uiBlock *block, wmEvent *event) +static int ui_picker_small_wheel_cb(const bContext *UNUSED(C), uiBlock *block, const wmEvent *event) { float add = 0.0f; diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 58d59391939..0876e8f362c 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -1595,11 +1595,12 @@ static uiBlock *icon_view_menu(bContext *C, ARegion *ar, void *arg_litem) for (a = 0; item[a].identifier; a++) { int x, y; - x = (a % 8) * UI_UNIT_X * 6; - y = (a / 8) * UI_UNIT_X * 6; + /* XXX hardcoded size to 5 x unit */ + x = (a % 8) * UI_UNIT_X * 5; + y = (a / 8) * UI_UNIT_X * 5; icon = item[a].icon; - but = uiDefIconButR_prop(block, ROW, 0, icon, x, y, UI_UNIT_X * 6, UI_UNIT_Y * 6, &cb.ptr, cb.prop, -1, 0, icon, -1, -1, NULL); + but = uiDefIconButR_prop(block, ROW, 0, icon, x, y, UI_UNIT_X * 5, UI_UNIT_Y * 5, &cb.ptr, cb.prop, -1, 0, icon, -1, -1, NULL); uiButSetFlag(but, UI_HAS_ICON | UI_ICON_PREVIEW); } diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index 41bbed8eb19..ae89b25d5ea 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -1029,16 +1029,16 @@ void UI_view2d_view_ortho(View2D *v2d) /* XXX ton: this flag set by outliner, for icons */ if (v2d->flag & V2D_PIXELOFS_X) { - curmasked.xmin = floorf(curmasked.xmin) - 0.001f; - curmasked.xmax = floorf(curmasked.xmax) - 0.001f; + curmasked.xmin = floorf(curmasked.xmin) - (0.001f + xofs); + curmasked.xmax = floorf(curmasked.xmax) - (0.001f + xofs); } if (v2d->flag & V2D_PIXELOFS_Y) { - curmasked.ymin = floorf(curmasked.ymin) - 0.001f; - curmasked.ymax = floorf(curmasked.ymax) - 0.001f; + curmasked.ymin = floorf(curmasked.ymin) - (0.001f + yofs); + curmasked.ymax = floorf(curmasked.ymax) - (0.001f + yofs); } /* set matrix on all appropriate axes */ - wmOrtho2(curmasked.xmin - xofs, curmasked.xmax - xofs, curmasked.ymin - yofs, curmasked.ymax - yofs); + wmOrtho2(curmasked.xmin, curmasked.xmax, curmasked.ymin, curmasked.ymax); /* XXX is this necessary? */ glLoadIdentity(); diff --git a/source/blender/editors/io/io_collada.c b/source/blender/editors/io/io_collada.c index f53672b7092..2004b18adf6 100644 --- a/source/blender/editors/io/io_collada.c +++ b/source/blender/editors/io/io_collada.c @@ -308,18 +308,47 @@ void WM_OT_collada_export(wmOperatorType *ot) static int wm_collada_import_exec(bContext *C, wmOperator *op) { char filename[FILE_MAX]; + int import_units; if (!RNA_struct_property_is_set(op->ptr, "filepath")) { BKE_report(op->reports, RPT_ERROR, "No filename given"); return OPERATOR_CANCELLED; } - RNA_string_get(op->ptr, "filepath", filename); - if (collada_import(C, filename)) return OPERATOR_FINISHED; + /* Options panel */ + import_units = RNA_boolean_get(op->ptr, "import_units"); + RNA_string_get(op->ptr, "filepath", filename); + if (collada_import( C, + filename, + import_units)) { + return OPERATOR_FINISHED; + } + else { BKE_report(op->reports, RPT_ERROR, "Errors found during parsing COLLADA document (see console for details)"); + return OPERATOR_CANCELLED; + } +} + +static void uiCollada_importSettings(uiLayout *layout, PointerRNA *imfptr) +{ + uiLayout *box, *row; + + /* Import Options: */ + box = uiLayoutBox(layout); + row = uiLayoutRow(box, FALSE); + uiItemL(row, IFACE_("Import Data Options:"), ICON_MESH_DATA); - return OPERATOR_FINISHED; + row = uiLayoutRow(box, FALSE); + uiItemR(row, imfptr, "import_units", 0, NULL, ICON_NONE); +} + +static void wm_collada_import_draw(bContext *UNUSED(C), wmOperator *op) +{ + PointerRNA ptr; + + RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr); + uiCollada_importSettings(op->layout, &ptr); } void WM_OT_collada_import(wmOperatorType *ot) @@ -332,7 +361,15 @@ void WM_OT_collada_import(wmOperatorType *ot) ot->exec = wm_collada_import_exec; ot->poll = WM_operator_winactive; + //ot->flag |= OPTYPE_PRESET; + + ot->ui = wm_collada_import_draw; + WM_operator_properties_filesel(ot, FOLDERFILE | COLLADAFILE, FILE_BLENDER, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); + + RNA_def_boolean(ot->srna, "import_units", 0, "Import Units", + "If enabled use Units as defined in Collada Import, else keep Blender's current Units settings"); + } #endif diff --git a/source/blender/editors/mask/mask_ops.c b/source/blender/editors/mask/mask_ops.c index 35f85f3faee..0a996c11f14 100644 --- a/source/blender/editors/mask/mask_ops.c +++ b/source/blender/editors/mask/mask_ops.c @@ -36,6 +36,7 @@ #include "BKE_context.h" #include "BKE_depsgraph.h" +#include "BKE_main.h" #include "BKE_mask.h" #include "DNA_scene_types.h" @@ -261,9 +262,10 @@ int ED_mask_feather_find_nearest(const bContext *C, Mask *mask, float normal_co[ Mask *ED_mask_new(bContext *C, const char *name) { ScrArea *sa = CTX_wm_area(C); + Main *bmain = CTX_data_main(C); Mask *mask; - mask = BKE_mask_new(name); + mask = BKE_mask_new(bmain, name); if (sa && sa->spacedata.first) { switch (sa->spacetype) { diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index e49dc3c28f9..bc7fe783e78 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -645,6 +645,7 @@ static void knife_get_vert_faces(KnifeTool_OpData *kcd, KnifeVert *kfv, BMFace * { BMIter bmiter; BMFace *f; + Ref *r; if (kfv->isface && facef) { knife_append_list(kcd, lst, facef); @@ -654,6 +655,11 @@ static void knife_get_vert_faces(KnifeTool_OpData *kcd, KnifeVert *kfv, BMFace * knife_append_list(kcd, lst, f); } } + else { + for (r = kfv->faces.first; r; r = r->next) { + knife_append_list(kcd, lst, r->ref); + } + } } static void knife_get_edge_faces(KnifeTool_OpData *kcd, KnifeEdge *kfe, ListBase *lst) @@ -780,6 +786,7 @@ static void knife_cut_through(KnifeTool_OpData *kcd) kcd->totlinehit = 0; /* set up for next cut */ + kcd->curr.vert = lastv; kcd->prev = kcd->curr; } @@ -1853,7 +1860,7 @@ static void remerge_faces(KnifeTool_OpData *kcd) BMOperator bmop; int idx; - BMO_op_initf(bm, &bmop, "beautify_fill faces=%ff constrain_edges=%fe", FACE_NEW, BOUNDARY); + BMO_op_initf(bm, &bmop, "beautify_fill faces=%ff edges=%Fe", FACE_NEW, BOUNDARY); BMO_op_exec(bm, &bmop); BMO_slot_buffer_flag_enable(bm, &bmop, "geom.out", BM_FACE, FACE_NEW); diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index b411cd2bd27..647bb6c1d77 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -3314,9 +3314,12 @@ static int edbm_fill_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = BMEdit_FromObject(obedit); + int use_beauty = RNA_boolean_get(op->ptr, "use_beauty"); BMOperator bmop; - if (!EDBM_op_init(em, &bmop, op, "triangle_fill edges=%he", BM_ELEM_SELECT)) { + if (!EDBM_op_init(em, &bmop, op, + "triangle_fill edges=%he use_beauty=%b", + BM_ELEM_SELECT, use_beauty)) { return OPERATOR_CANCELLED; } @@ -3348,6 +3351,8 @@ void MESH_OT_fill(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + RNA_def_boolean(ot->srna, "use_beauty", true, "Beauty", "Use best triangulation division"); } static int edbm_beautify_fill_exec(bContext *C, wmOperator *op) @@ -3355,7 +3360,7 @@ static int edbm_beautify_fill_exec(bContext *C, wmOperator *op) Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = BMEdit_FromObject(obedit); - if (!EDBM_op_callf(em, op, "beautify_fill faces=%hf", BM_ELEM_SELECT)) + if (!EDBM_op_callf(em, op, "beautify_fill faces=%hf edges=ae", BM_ELEM_SELECT)) return OPERATOR_CANCELLED; EDBM_update_generic(em, TRUE, TRUE); @@ -3384,10 +3389,22 @@ static int edbm_quads_convert_to_tris_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = BMEdit_FromObject(obedit); + BMOperator bmop; int use_beauty = RNA_boolean_get(op->ptr, "use_beauty"); - if (!EDBM_op_callf(em, op, "triangulate faces=%hf use_beauty=%b", BM_ELEM_SELECT, use_beauty)) + EDBM_op_init(em, &bmop, op, "triangulate faces=%hf use_beauty=%b", BM_ELEM_SELECT, use_beauty); + BMO_op_exec(em->bm, &bmop); + + /* now call beauty fill */ + if (use_beauty) { + EDBM_op_callf(em, op, + "beautify_fill faces=%S edges=%S", + &bmop, "faces.out", &bmop, "edges.out"); + } + + if (!EDBM_op_finish(em, &bmop, op, TRUE)) { return OPERATOR_CANCELLED; + } EDBM_update_generic(em, TRUE, TRUE); @@ -3408,7 +3425,7 @@ void MESH_OT_quads_convert_to_tris(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - RNA_def_boolean(ot->srna, "use_beauty", 1, "Beauty", "Use best triangulation division (currently quads only)"); + RNA_def_boolean(ot->srna, "use_beauty", 1, "Beauty", "Use best triangulation division"); } static int edbm_tris_convert_to_quads_exec(bContext *C, wmOperator *op) @@ -3955,9 +3972,11 @@ static int edbm_select_mirror_exec(bContext *C, wmOperator *op) BMEditMesh *em = BMEdit_FromObject(obedit); int extend = RNA_boolean_get(op->ptr, "extend"); - EDBM_select_mirrored(obedit, em, extend); - EDBM_selectmode_flush(em); - WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); + if (em->bm->totvert && em->bm->totvertsel) { + EDBM_select_mirrored(obedit, em, extend); + EDBM_selectmode_flush(em); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); + } return OPERATOR_FINISHED; } diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c index 1d13aa36a6b..0c9a5aab537 100644 --- a/source/blender/editors/mesh/mesh_data.c +++ b/source/blender/editors/mesh/mesh_data.c @@ -575,13 +575,19 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, wmEvent *event) Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); View3D *v3d = CTX_wm_view3d(C); - Base *base = ED_view3d_give_base_under_cursor(C, event->mval); + Base *base; Image *ima = NULL; Mesh *me; Object *obedit; int exitmode = 0; - char name[MAX_ID_NAME - 2]; + if (v3d == NULL) { + BKE_report(op->reports, RPT_ERROR, "No 3D View Available"); + return OPERATOR_CANCELLED; + } + + base = ED_view3d_give_base_under_cursor(C, event->mval); + /* Check context */ if (base == NULL || base->object->type != OB_MESH) { BKE_report(op->reports, RPT_ERROR, "Not an object or mesh"); @@ -596,6 +602,7 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, wmEvent *event) ima = BKE_image_load_exists(path); } else { + char name[MAX_ID_NAME - 2]; RNA_string_get(op->ptr, "name", name); ima = (Image *)BKE_libblock_find_name(ID_IM, name); } @@ -641,7 +648,7 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, wmEvent *event) void MESH_OT_drop_named_image(wmOperatorType *ot) { /* identifiers */ - ot->name = "Assign Image to UV Map"; + ot->name = "Drop Image to Mesh UV Map"; ot->description = "Assign Image to active UV Map, or create an UV Map"; ot->idname = "MESH_OT_drop_named_image"; @@ -650,7 +657,7 @@ void MESH_OT_drop_named_image(wmOperatorType *ot) ot->invoke = drop_named_image_invoke; /* flags */ - ot->flag = OPTYPE_UNDO; + ot->flag = OPTYPE_UNDO | OPTYPE_INTERNAL; /* properties */ RNA_def_string(ot->srna, "name", "Image", MAX_ID_NAME - 2, "Name", "Image name to assign"); diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c index 9403299b0cd..140681304b2 100644 --- a/source/blender/editors/mesh/mesh_ops.c +++ b/source/blender/editors/mesh/mesh_ops.c @@ -203,7 +203,7 @@ void ED_operatormacros_mesh(void) OPTYPE_UNDO | OPTYPE_REGISTER); WM_operatortype_macro_define(ot, "MESH_OT_loopcut"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_edge_slide"); - RNA_struct_idprops_unset(otmacro->ptr, "release_confirm"); + RNA_boolean_set(otmacro->ptr, "release_confirm", false); ot = WM_operatortype_append_macro("MESH_OT_duplicate_move", "Add Duplicate", "Duplicate mesh and move", OPTYPE_UNDO | OPTYPE_REGISTER); diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 8457b278c6c..ffaa6f61cae 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -1558,7 +1558,7 @@ static int convert_exec(bContext *C, wmOperator *op) mb = newob->data; mb->id.us--; - newob->data = BKE_mesh_add("Mesh"); + newob->data = BKE_mesh_add(bmain, "Mesh"); newob->type = OB_MESH; me = newob->data; @@ -2005,7 +2005,8 @@ void OBJECT_OT_duplicate(wmOperatorType *ot) static int add_named_exec(bContext *C, wmOperator *op) { - wmEvent *event = CTX_wm_window(C)->eventstate; + wmWindow *win = CTX_wm_window(C); + wmEvent *event = win ? win->eventstate : NULL; Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); Base *basen, *base; @@ -2037,8 +2038,10 @@ static int add_named_exec(bContext *C, wmOperator *op) basen->lay = basen->object->lay = scene->lay; - ED_object_location_from_view(C, basen->object->loc); - ED_view3d_cursor3d_position(C, basen->object->loc, event->x, event->y); + if (event) { + ED_object_location_from_view(C, basen->object->loc); + ED_view3d_cursor3d_position(C, basen->object->loc, event->x, event->y); + } ED_base_object_activate(C, basen); diff --git a/source/blender/editors/object/object_group.c b/source/blender/editors/object/object_group.c index 7bf1a5db3b1..9b683a1ba98 100644 --- a/source/blender/editors/object/object_group.c +++ b/source/blender/editors/object/object_group.c @@ -311,7 +311,7 @@ static int group_create_exec(bContext *C, wmOperator *op) RNA_string_get(op->ptr, "name", name); - group = add_group(name); + group = add_group(bmain, name); CTX_DATA_BEGIN (C, Base *, base, selected_bases) { @@ -348,12 +348,13 @@ static int group_add_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); Object *ob = ED_object_context(C); + Main *bmain = CTX_data_main(C); Group *group; if (ob == NULL) return OPERATOR_CANCELLED; - group = add_group("Group"); + group = add_group(bmain, "Group"); add_to_group(group, ob, scene, NULL); WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index da12db50cc5..33b159f3cf2 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -2168,7 +2168,7 @@ void OBJECT_OT_drop_named_material(wmOperatorType *ot) ot->poll = ED_operator_objectmode; /* flags */ - ot->flag = OPTYPE_UNDO; + ot->flag = OPTYPE_UNDO | OPTYPE_INTERNAL; /* properties */ RNA_def_string(ot->srna, "name", "Material", MAX_ID_NAME - 2, "Name", "Material name to assign"); diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index 7a2eb5667a2..68075e7b6f9 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -57,6 +57,7 @@ #include "BKE_tessmesh.h" #include "BKE_multires.h" #include "BKE_armature.h" +#include "BKE_lattice.h" #include "RNA_define.h" #include "RNA_access.h" @@ -699,9 +700,11 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) } else { if (around == V3D_CENTROID) { - const float total_div = 1.0f / (float)em->bm->totvert; - BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { - madd_v3_v3fl(cent, eve->co, total_div); + if (em->bm->totvert) { + const float total_div = 1.0f / (float)em->bm->totvert; + BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { + madd_v3_v3fl(cent, eve->co, total_div); + } } } else { @@ -899,6 +902,20 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) break; } } + else if (ob->type == OB_LATTICE) { + Lattice *lt = ob->data; + + if (centermode == ORIGIN_TO_CURSOR) { /* done */ } + else if (around == V3D_CENTROID) { BKE_lattice_center_median(lt, cent); } + else { BKE_lattice_center_bounds(lt, cent); } + + negate_v3_v3(cent_neg, cent); + BKE_lattice_translate(lt, cent_neg, 1); + + tot_change++; + lt->id.flag |= LIB_DOIT; + do_inverse_offset = TRUE; + } /* offset other selected objects */ if (do_inverse_offset && (centermode != GEOMETRY_TO_ORIGIN)) { diff --git a/source/blender/editors/physics/CMakeLists.txt b/source/blender/editors/physics/CMakeLists.txt index 435327319aa..29d8aec4224 100644 --- a/source/blender/editors/physics/CMakeLists.txt +++ b/source/blender/editors/physics/CMakeLists.txt @@ -64,7 +64,7 @@ endif() if(WITH_BULLET) list(APPEND INC - ../../rigidbody + ../../../../intern/rigidbody ) add_definitions(-DWITH_BULLET) endif() diff --git a/source/blender/editors/physics/SConscript b/source/blender/editors/physics/SConscript index b68cc944925..7916ea24bde 100644 --- a/source/blender/editors/physics/SConscript +++ b/source/blender/editors/physics/SConscript @@ -33,7 +33,7 @@ incs = '../include ../../blenfont ../../blenlib ../../blenkernel ../../makesdna incs += ' ../../windowmanager #/intern/guardedalloc #/extern/glew/include' incs += ' ../../gpu ../../blenloader ../../bmesh' incs += ' ../../makesrna ../../render/extern/include #/intern/elbeem/extern' -incs += ' ../../rigidbody' +incs += ' #/intern/rigidbody' defs = [] diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index deddc649956..78377834b9f 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -3397,7 +3397,7 @@ static int brush_add(PEData *data, short number) weight[w] = 0.0f; } - if(totw > 0.0f) { + if (totw > 0.0f) { for (w=0; w<maxw; w++) weight[w] /= totw; } @@ -4151,7 +4151,7 @@ int PE_minmax(Scene *scene, float min[3], float max[3]) BKE_object_minmax(ob, min, max, TRUE); ok= 1; } - + return ok; } diff --git a/source/blender/editors/physics/rigidbody_constraint.c b/source/blender/editors/physics/rigidbody_constraint.c index fac835a414a..b2f53379090 100644 --- a/source/blender/editors/physics/rigidbody_constraint.c +++ b/source/blender/editors/physics/rigidbody_constraint.c @@ -45,6 +45,7 @@ #include "BKE_context.h" #include "BKE_depsgraph.h" +#include "BKE_global.h" #include "BKE_group.h" #include "BKE_object.h" #include "BKE_report.h" @@ -87,7 +88,7 @@ void ED_rigidbody_con_add(wmOperator *op, Scene *scene, Object *ob, int type) } /* create constraint group if it doesn't already exits */ if (rbw->constraints == NULL) { - rbw->constraints = add_group("RigidBodyConstraints"); + rbw->constraints = add_group(G.main, "RigidBodyConstraints"); } /* make rigidbody constraint settings */ ob->rigidbody_constraint = BKE_rigidbody_create_constraint(scene, ob, type); diff --git a/source/blender/editors/physics/rigidbody_object.c b/source/blender/editors/physics/rigidbody_object.c index 38ed903a161..9ce4656d4cd 100644 --- a/source/blender/editors/physics/rigidbody_object.c +++ b/source/blender/editors/physics/rigidbody_object.c @@ -46,6 +46,7 @@ #include "BKE_context.h" #include "BKE_depsgraph.h" +#include "BKE_global.h" #include "BKE_group.h" #include "BKE_object.h" #include "BKE_report.h" @@ -113,7 +114,7 @@ void ED_rigidbody_ob_add(wmOperator *op, Scene *scene, Object *ob, int type) scene->rigidbody_world = rbw; } if (rbw->group == NULL) { - rbw->group = add_group("RigidBodyWorld"); + rbw->group = add_group(G.main, "RigidBodyWorld"); } /* make rigidbody object settings */ @@ -337,12 +338,14 @@ static int rigidbody_obs_shape_change_exec(bContext *C, wmOperator *op) /* use RNA-system to change the property and perform all necessary changes */ RNA_pointer_create(&ob->id, &RNA_RigidBodyObject, ob->rigidbody_object, &ptr); RNA_enum_set(&ptr, "collision_shape", shape); + + DAG_id_tag_update(&ob->id, OB_RECALC_OB); } } CTX_DATA_END; /* send updates */ - WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); // XXX: wrong notifiers for now, but these also do the job... + WM_event_add_notifier(C, NC_OBJECT | ND_POINTCACHE, NULL); /* done */ return OPERATOR_FINISHED; @@ -583,12 +586,14 @@ static int rigidbody_obs_calc_mass_exec(bContext *C, wmOperator *op) /* use RNA-system to change the property and perform all necessary changes */ RNA_pointer_create(&ob->id, &RNA_RigidBodyObject, ob->rigidbody_object, &ptr); RNA_float_set(&ptr, "mass", mass); + + DAG_id_tag_update(&ob->id, OB_RECALC_OB); } } CTX_DATA_END; /* send updates */ - WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); // XXX: wrong notifiers for now, but these also do the job... + WM_event_add_notifier(C, NC_OBJECT | ND_POINTCACHE, NULL); /* done */ return OPERATOR_FINISHED; diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index 16ebaf58a59..994c7275ecd 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -1100,6 +1100,10 @@ void ED_preview_shader_job(const bContext *C, void *owner, ID *id, ID *parent, M ShaderPreview *sp; Scene *scene = CTX_data_scene(C); + /* node previews not supported for cycles */ + if (BKE_scene_use_new_shading_nodes(scene) && method == PR_NODE_RENDER) + return; + wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), owner, "Shader Preview", WM_JOB_EXCL_RENDER, WM_JOB_TYPE_RENDER_PREVIEW); sp = MEM_callocN(sizeof(ShaderPreview), "shader preview"); diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c index dfc53d0b195..aa1edb1c1b1 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -373,6 +373,7 @@ static int new_material_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); Material *ma = CTX_data_pointer_get_type(C, "material", &RNA_Material).data; + Main *bmain = CTX_data_main(C); PointerRNA ptr, idptr; PropertyRNA *prop; @@ -381,7 +382,7 @@ static int new_material_exec(bContext *C, wmOperator *UNUSED(op)) ma = BKE_material_copy(ma); } else { - ma = BKE_material_add("Material"); + ma = BKE_material_add(bmain, "Material"); if (BKE_scene_use_new_shading_nodes(scene)) { ED_node_shader_default(scene, &ma->id); @@ -426,6 +427,7 @@ void MATERIAL_OT_new(wmOperatorType *ot) static int new_texture_exec(bContext *C, wmOperator *UNUSED(op)) { Tex *tex = CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data; + Main *bmain = CTX_data_main(C); PointerRNA ptr, idptr; PropertyRNA *prop; @@ -433,7 +435,7 @@ static int new_texture_exec(bContext *C, wmOperator *UNUSED(op)) if (tex) tex = BKE_texture_copy(tex); else - tex = add_texture("Texture"); + tex = add_texture(bmain, "Texture"); /* hook into UI */ uiIDContextProperty(C, &ptr, &prop); @@ -473,6 +475,7 @@ static int new_world_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); World *wo = CTX_data_pointer_get_type(C, "world", &RNA_World).data; + Main *bmain = CTX_data_main(C); PointerRNA ptr, idptr; PropertyRNA *prop; @@ -481,7 +484,7 @@ static int new_world_exec(bContext *C, wmOperator *UNUSED(op)) wo = BKE_world_copy(wo); } else { - wo = add_world("World"); + wo = add_world(bmain, "World"); if (BKE_scene_use_new_shading_nodes(scene)) { ED_node_shader_default(scene, &wo->id); diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index cca713ec14a..7c22dff1b01 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -1337,13 +1337,14 @@ int ED_screen_area_active(const bContext *C) /* Do NOT call in area/region queues! */ void ED_screen_set(bContext *C, bScreen *sc) { + Main *bmain = CTX_data_main(C); wmWindowManager *wm = CTX_wm_manager(C); wmWindow *win = CTX_wm_window(C); bScreen *oldscreen = CTX_wm_screen(C); ID *id; /* validate screen, it's called with notifier reference */ - for (id = CTX_data_main(C)->screen.first; id; id = id->next) + for (id = bmain->screen.first; id; id = id->next) if (sc == (bScreen *)id) break; if (id == NULL) @@ -1355,7 +1356,7 @@ void ED_screen_set(bContext *C, bScreen *sc) if (sc->full) { /* find associated full */ bScreen *sc1; - for (sc1 = CTX_data_main(C)->screen.first; sc1; sc1 = sc1->id.next) { + for (sc1 = bmain->screen.first; sc1; sc1 = sc1->id.next) { ScrArea *sa = sc1->areabase.first; if (sa->full == sc) { sc = sc1; diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index e7f5e57552c..da2facc244a 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -360,7 +360,7 @@ int ED_operator_editarmature(bContext *C) /** * \brief check for pose mode (no mixed modes) * - * We wan't to enable most pose operations in weight paint mode, + * We want to enable most pose operations in weight paint mode, * when it comes to transforming bones, but managing bomes layers/groups * can be left for pose mode only. (not weight paint mode) */ @@ -3598,8 +3598,8 @@ static void SCENE_OT_delete(wmOperatorType *ot) /* ***************** region alpha blending ***************** */ /* implementation note: a disapplearing region needs at least 1 last draw with 100% backbuffer - texture over it- then triple buffer will clear it entirely. - This because flag RGN_HIDDEN is set in end - region doesnt draw at all then */ + * texture over it- then triple buffer will clear it entirely. + * This because flag RGN_HIDDEN is set in end - region doesnt draw at all then */ typedef struct RegionAlphaInfo { ScrArea *sa; diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c index efd0db3b442..1f7fee313b3 100644 --- a/source/blender/editors/screen/screendump.c +++ b/source/blender/editors/screen/screendump.c @@ -272,7 +272,8 @@ void SCREEN_OT_screenshot(wmOperatorType *ot) WM_operator_properties_filesel(ot, FOLDERFILE | IMAGEFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); - RNA_def_boolean(ot->srna, "full", 1, "Full Screen", "Capture the whole window. Otherwise only capture the active area"); + RNA_def_boolean(ot->srna, "full", 1, "Full Screen", + "Capture the whole window (otherwise only capture the active area)"); } /* *************** screenshot movie job ************************* */ @@ -500,5 +501,6 @@ void SCREEN_OT_screencast(wmOperatorType *ot) ot->flag = 0; RNA_def_property(ot->srna, "filepath", PROP_STRING, PROP_FILEPATH); - RNA_def_boolean(ot->srna, "full", 1, "Full Screen", "Capture the whole window. Otherwise only capture the active area"); + RNA_def_boolean(ot->srna, "full", 1, "Full Screen", + "Capture the whole window (otherwise only capture the active area)"); } diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index c60097e20eb..74399857a97 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -4347,7 +4347,7 @@ static int project_paint_sub_stroke(ProjPaintState *ps, BrushPainter *painter, c pos[1] = (float)(mval_i[1]); // we may want to use this later - // BKE_brush_painter_require_imbuf(painter, ((ibuf->rect_float)? 1: 0), 0, 0); + // BKE_brush_painter_require_imbuf(painter, ((ibuf->rect_float) ? 1 : 0), 0, 0); if (BKE_brush_painter_paint(painter, project_paint_op, pos, time, pressure, ps, 0)) { return 1; diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index 618d545b084..408572c7979 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -62,11 +62,12 @@ static int brush_add_exec(bContext *C, wmOperator *UNUSED(op)) /*int type = RNA_enum_get(op->ptr, "type");*/ Paint *paint = paint_get_active_from_context(C); struct Brush *br = paint_brush(paint); + Main *bmain = CTX_data_main(C); if (br) br = BKE_brush_copy(br); else - br = BKE_brush_add("Brush"); + br = BKE_brush_add(bmain, "Brush"); paint_brush_set(paint, br); @@ -272,7 +273,7 @@ static int brush_generic_tool_set(Main *bmain, Paint *paint, const int tool, brush = brush_tool_cycle(bmain, brush_orig, tool, tool_offset, ob_mode); if (!brush && brush_tool(brush_orig, tool_offset) != tool && create_missing) { - brush = BKE_brush_add(tool_name); + brush = BKE_brush_add(bmain, tool_name); brush_tool_set(brush, tool_offset, tool); brush->ob_mode = ob_mode; brush->toggle_brush = brush_orig; diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 5b04bdb8ee7..956f8d2c136 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -1029,6 +1029,7 @@ static int weight_sample_invoke(bContext *C, wmOperator *op, wmEvent *event) unsigned int index; view3d_operator_needs_opengl(C); + ED_view3d_init_mats_rv3d(vc.obact, vc.rv3d); if (use_vert_sel) { if (ED_mesh_pick_vert(C, vc.obact, event->mval, &index, ED_MESH_PICK_DEFAULT_VERT_SIZE, TRUE)) { @@ -1118,6 +1119,7 @@ static EnumPropertyItem *weight_paint_sample_enum_itemf(bContext *C, PointerRNA win->eventstate->y - vc.ar->winrct.ymin}; view3d_operator_needs_opengl(C); + ED_view3d_init_mats_rv3d(vc.obact, vc.rv3d); if (use_vert_sel) { if (ED_mesh_pick_vert(C, vc.obact, mval, &index, ED_MESH_PICK_DEFAULT_VERT_SIZE, TRUE)) { @@ -2230,7 +2232,8 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P indexar = wpd->indexar; view3d_operator_needs_opengl(C); - + ED_view3d_init_mats_rv3d(ob, vc->rv3d); + /* load projection matrix */ mult_m4_m4m4(mat, vc->rv3d->persmat, ob->obmat); @@ -2863,7 +2866,8 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P RNA_float_get_array(itemptr, "mouse", mval); view3d_operator_needs_opengl(C); - + ED_view3d_init_mats_rv3d(ob, vc->rv3d); + /* load projection matrix */ mult_m4_m4m4(mat, vc->rv3d->persmat, ob->obmat); diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index ce7d72f9787..10f4dc2aebc 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -654,7 +654,6 @@ static int sculpt_brush_test_cyl(SculptBrushTest *test, float co[3], float locat /* ===== Sculpting ===== * */ - static float overlapped_curve(Brush *br, float x) { @@ -4527,7 +4526,7 @@ static void SCULPT_OT_set_persistent_base(wmOperatorType *ot) static void sculpt_dynamic_topology_triangulate(BMesh *bm) { - BMO_op_callf(bm, BMO_FLAG_DEFAULTS, "triangulate faces=%af"); + BM_mesh_triangulate(bm, false, false, NULL, NULL); } void sculpt_pbvh_clear(Object *ob) @@ -4571,6 +4570,7 @@ void sculpt_dynamic_topology_enable(bContext *C) ss->bm = BM_mesh_create(&bm_mesh_allocsize_default); BM_mesh_bm_from_me(ss->bm, me, TRUE, ob->shapenr); + BM_mesh_normals_update(ss->bm, false); sculpt_dynamic_topology_triangulate(ss->bm); BM_data_layer_add(ss->bm, &ss->bm->vdata, CD_PAINT_MASK); BM_mesh_normals_update(ss->bm, TRUE); diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c index a80d425b90a..7e99e6c065d 100644 --- a/source/blender/editors/space_action/action_edit.c +++ b/source/blender/editors/space_action/action_edit.c @@ -53,6 +53,7 @@ #include "BKE_action.h" #include "BKE_fcurve.h" #include "BKE_global.h" +#include "BKE_main.h" #include "BKE_nla.h" #include "BKE_context.h" #include "BKE_report.h" @@ -104,8 +105,10 @@ static int act_new_exec(bContext *C, wmOperator *UNUSED(op)) action = BKE_action_copy(oldact); } else { + Main *bmain = CTX_data_main(C); + /* just make a new (empty) action */ - action = add_empty_action("Action"); + action = add_empty_action(bmain, "Action"); } /* when creating new ID blocks, use is already 1 (fake user), diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c index d0f76c21019..964a6a20c37 100644 --- a/source/blender/editors/space_action/action_select.c +++ b/source/blender/editors/space_action/action_select.c @@ -259,12 +259,35 @@ static void borderselect_action(bAnimContext *ac, rcti rect, short mode, short s !((ymax < rectf.ymin) || (ymin > rectf.ymax))) { /* loop over data selecting */ - if (ale->type == ANIMTYPE_GPLAYER) - ED_gplayer_frames_select_border(ale->data, rectf.xmin, rectf.xmax, selectmode); - else if (ale->type == ANIMTYPE_MASKLAYER) - ED_masklayer_frames_select_border(ale->data, rectf.xmin, rectf.xmax, selectmode); - else - ANIM_animchannel_keyframes_loop(&ked, ac->ads, ale, ok_cb, select_cb, NULL); + switch (ale->type) { + case ANIMTYPE_GPDATABLOCK: + { + bGPdata *gpd = ale->data; + bGPDlayer *gpl; + for (gpl = gpd->layers.first; gpl; gpl = gpl->next) { + ED_gplayer_frames_select_border(gpl, rectf.xmin, rectf.xmax, selectmode); + } + break; + } + case ANIMTYPE_GPLAYER: + ED_gplayer_frames_select_border(ale->data, rectf.xmin, rectf.xmax, selectmode); + break; + case ANIMTYPE_MASKDATABLOCK: + { + Mask *mask = ale->data; + MaskLayer *masklay; + for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) { + ED_masklayer_frames_select_border(ale->data, rectf.xmin, rectf.xmax, selectmode); + } + break; + } + case ANIMTYPE_MASKLAYER: + ED_masklayer_frames_select_border(ale->data, rectf.xmin, rectf.xmax, selectmode); + break; + default: + ANIM_animchannel_keyframes_loop(&ked, ac->ads, ale, ok_cb, select_cb, NULL); + break; + } } /* set minimum extent to be the maximum of the next channel */ @@ -944,6 +967,7 @@ static void actkeys_mselect_single(bAnimContext *ac, bAnimListElem *ale, short s else if (ale->type == ANIMTYPE_MASKLAYER) ED_mask_select_frame(ale->data, selx, select_mode); } + BLI_freelistN(&anim_data); } else { ANIM_animchannel_keyframes_loop(&ked, ac->ads, ale, ok_cb, select_cb, NULL); diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index cf4e76a8427..dfb69be6f18 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -160,6 +160,7 @@ static int open_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); bScreen *screen = CTX_wm_screen(C); + Main *bmain = CTX_data_main(C); PropertyPointerRNA *pprop; PointerRNA idptr; MovieClip *clip = NULL; @@ -191,7 +192,7 @@ static int open_exec(bContext *C, wmOperator *op) errno = 0; - clip = BKE_movieclip_file_add(str); + clip = BKE_movieclip_file_add(bmain, str); if (!clip) { if (op->customdata) diff --git a/source/blender/editors/space_clip/clip_toolbar.c b/source/blender/editors/space_clip/clip_toolbar.c index 1bdf5214192..ad70abf5732 100644 --- a/source/blender/editors/space_clip/clip_toolbar.c +++ b/source/blender/editors/space_clip/clip_toolbar.c @@ -219,23 +219,32 @@ static void clip_panel_operator_redo_operator(const bContext *C, Panel *pa, wmOp static void clip_panel_operator_redo(const bContext *C, Panel *pa) { wmOperator *op = WM_operator_last_redo(C); - uiBlock *block; + ARegion *ar; + ARegion *ar1; if (op == NULL) return; - if (WM_operator_poll((bContext *)C, op->type) == 0) - return; + /* keep in sync with logic in ED_undo_operator_repeat() */ + ar = CTX_wm_region(C); + ar1 = BKE_area_find_region_type(CTX_wm_area(C), RGN_TYPE_WINDOW); + if (ar1) + CTX_wm_region_set((bContext *)C, ar1); + + if (WM_operator_poll((bContext *)C, op->type)) { + uiBlock *block = uiLayoutGetBlock(pa->layout); - block = uiLayoutGetBlock(pa->layout); + if (!WM_operator_check_ui_enabled(C, op->type->name)) + uiLayoutSetEnabled(pa->layout, FALSE); - if (!WM_operator_check_ui_enabled(C, op->type->name)) - uiLayoutSetEnabled(pa->layout, FALSE); + /* note, blockfunc is a default but->func, use Handle func to allow button callbacks too */ + uiBlockSetHandleFunc(block, ED_undo_operator_repeat_cb_evt, op); - /* note, blockfunc is a default but->func, use Handle func to allow button callbacks too */ - uiBlockSetHandleFunc(block, ED_undo_operator_repeat_cb_evt, op); + clip_panel_operator_redo_operator(C, pa, op); + } - clip_panel_operator_redo_operator(C, pa, op); + /* set region back */ + CTX_wm_region_set((bContext *)C, ar); } void ED_clip_tool_props_register(ARegionType *art) diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index 778a3f4df3e..8c45b161d26 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -95,7 +95,7 @@ FileSelectParams *ED_fileselect_get_params(struct SpaceFile *sfile) } /** - * \note RNA_struct_property_is_set_ex is used here because we wan't + * \note RNA_struct_property_is_set_ex is used here because we want * the previously used settings to be used here rather then overriding them */ short ED_fileselect_set_params(SpaceFile *sfile) { @@ -244,9 +244,11 @@ short ED_fileselect_set_params(SpaceFile *sfile) params->display = FILE_SHORTDISPLAY; params->filter = 0; params->filter_glob[0] = '\0'; - params->sort = FILE_SORT_ALPHA; } + /* operator has no setting for this */ + params->sort = FILE_SORT_ALPHA; + /* initialize the list with previous folders */ if (!sfile->folders_prev) diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index ba4f8287cd7..00bc3d1d26b 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -425,11 +425,11 @@ static void sima_draw_alpha_pixelsf(float x1, float y1, int rectx, int recty, fl MEM_freeN(trectf); /* ogl trick below is slower... (on ATI 9600) */ // glColorMask(1, 0, 0, 0); -// glaDrawPixelsSafe(x1, y1, rectx, recty, rectx, GL_RGBA, GL_FLOAT, rectf+3); +// glaDrawPixelsSafe(x1, y1, rectx, recty, rectx, GL_RGBA, GL_FLOAT, rectf + 3); // glColorMask(0, 1, 0, 0); -// glaDrawPixelsSafe(x1, y1, rectx, recty, rectx, GL_RGBA, GL_FLOAT, rectf+2); +// glaDrawPixelsSafe(x1, y1, rectx, recty, rectx, GL_RGBA, GL_FLOAT, rectf + 2); // glColorMask(0, 0, 1, 0); -// glaDrawPixelsSafe(x1, y1, rectx, recty, rectx, GL_RGBA, GL_FLOAT, rectf+1); +// glaDrawPixelsSafe(x1, y1, rectx, recty, rectx, GL_RGBA, GL_FLOAT, rectf + 1); // glColorMask(1, 1, 1, 1); } @@ -514,16 +514,12 @@ static void draw_image_buffer(const bContext *C, SpaceImage *sima, ARegion *ar, unsigned char *display_buffer; void *cache_handle; - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - if (sima->flag & SI_USE_ALPHA) { + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + fdrawcheckerboard(x, y, x + ibuf->x * zoomx, y + ibuf->y * zoomy); } - else { - glColor4f(0.0f, 0.0f, 0.0f, 1.0f); - glRecti(x, y, x + ibuf->x * zoomx, y + ibuf->y * zoomy); - } display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle); @@ -536,7 +532,8 @@ static void draw_image_buffer(const bContext *C, SpaceImage *sima, ARegion *ar, IMB_display_buffer_release(cache_handle); - glDisable(GL_BLEND); + if (sima->flag & SI_USE_ALPHA) + glDisable(GL_BLEND); } /* reset zoom */ diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 23adf7eb575..2d2d29d9eaa 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -1716,6 +1716,7 @@ static int image_new_exec(bContext *C, wmOperator *op) Scene *scene; Object *obedit; Image *ima; + Main *bmain; PointerRNA ptr, idptr; PropertyRNA *prop; char name[MAX_ID_NAME - 2]; @@ -1726,6 +1727,7 @@ static int image_new_exec(bContext *C, wmOperator *op) sima = CTX_wm_space_image(C); scene = CTX_data_scene(C); obedit = CTX_data_edit_object(C); + bmain = CTX_data_main(C); RNA_string_get(op->ptr, "name", name); width = RNA_int_get(op->ptr, "width"); @@ -1735,15 +1737,10 @@ static int image_new_exec(bContext *C, wmOperator *op) RNA_float_get_array(op->ptr, "color", color); alpha = RNA_boolean_get(op->ptr, "alpha"); - if (!floatbuf) { - /* OCIO_TODO: perhaps we need to convert to display space, not just to sRGB */ - linearrgb_to_srgb_v3_v3(color, color); - } - if (!alpha) color[3] = 1.0f; - ima = BKE_image_add_generated(width, height, name, alpha ? 32 : 24, floatbuf, gen_type, color); + ima = BKE_image_add_generated(bmain, width, height, name, alpha ? 32 : 24, floatbuf, gen_type, color); if (!ima) return OPERATOR_CANCELLED; @@ -1806,6 +1803,7 @@ void IMAGE_OT_new(wmOperatorType *ot) RNA_def_int(ot->srna, "width", 1024, 1, INT_MAX, "Width", "Image width", 1, 16384); RNA_def_int(ot->srna, "height", 1024, 1, INT_MAX, "Height", "Image height", 1, 16384); prop = RNA_def_float_color(ot->srna, "color", 4, NULL, 0.0f, FLT_MAX, "Color", "Default fill color", 0.0f, 1.0f); + RNA_def_property_subtype(prop, PROP_COLOR_GAMMA); RNA_def_property_float_array_default(prop, default_color); RNA_def_boolean(ot->srna, "alpha", 1, "Alpha", "Create an image with an alpha channel"); RNA_def_enum(ot->srna, "generated_type", image_generated_type_items, IMA_GENTYPE_BLANK, diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 1c384ef38d7..35ba83a8bc6 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -152,7 +152,7 @@ static SpaceLink *image_new(const bContext *UNUSED(C)) simage->spacetype = SPACE_IMAGE; simage->zoom = 1.0f; simage->lock = TRUE; - simage->flag = SI_SHOW_GPENCIL; + simage->flag = SI_SHOW_GPENCIL | SI_USE_ALPHA; simage->iuser.ok = TRUE; simage->iuser.fie_ima = 2; diff --git a/source/blender/editors/space_info/info_ops.c b/source/blender/editors/space_info/info_ops.c index 663d136fdf2..22668a3de3a 100644 --- a/source/blender/editors/space_info/info_ops.c +++ b/source/blender/editors/space_info/info_ops.c @@ -266,10 +266,10 @@ static int unpack_item_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); ID *id; - char idname[BKE_ST_MAXNAME]; + char idname[MAX_ID_NAME - 2]; int type = RNA_int_get(op->ptr, "id_type"); int method = RNA_enum_get(op->ptr, "method"); - + RNA_string_get(op->ptr, "id_name", idname); id = BKE_libblock_find_name(type, idname); @@ -319,7 +319,7 @@ void FILE_OT_unpack_item(wmOperatorType *ot) /* properties */ RNA_def_enum(ot->srna, "method", unpack_item_method_items, PF_USE_LOCAL, "Method", "How to unpack"); RNA_def_string(ot->srna, "id_name", "", BKE_ST_MAXNAME, "ID name", "Name of ID block to unpack"); - RNA_def_int(ot->srna, "id_type", 0, 0, INT_MAX, "ID Type", "Identifier type of ID block", 0, INT_MAX); + RNA_def_int(ot->srna, "id_type", ID_IM, 0, INT_MAX, "ID Type", "Identifier type of ID block", 0, INT_MAX); } diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index f46151fd33a..fa7e888f8d7 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -1860,6 +1860,25 @@ static void draw_actuator_motion(uiLayout *layout, PointerRNA *ptr) uiItemR(col, ptr, "integral_coefficient", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(col, ptr, "derivate_coefficient", UI_ITEM_R_SLIDER, NULL, ICON_NONE); break; + case ACT_OBJECT_CHARACTER: + split = uiLayoutSplit(layout, 0.9, FALSE); + row = uiLayoutRow(split, FALSE); + uiItemR(row, ptr, "offset_location", 0, NULL, ICON_NONE); + row = uiLayoutRow(split, TRUE); + uiItemR(row, ptr, "use_local_location", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); + uiItemR(row, ptr, "use_add_character_location", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); + + split = uiLayoutSplit(layout, 0.9, FALSE); + row = uiLayoutRow(split, FALSE); + uiItemR(row, ptr, "offset_rotation", 0, NULL, ICON_NONE); + uiItemR(split, ptr, "use_local_rotation", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); + + split = uiLayoutSplit(layout, 0.9, FALSE); + row = uiLayoutRow(split, FALSE); + split = uiLayoutSplit(row, 0.7, FALSE); + uiItemL(split, "", ICON_NONE); /*Just use this for some spacing */ + uiItemR(split, ptr, "use_character_jump", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); + break; } } diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index cca1858f112..9b342ed8f44 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -1983,7 +1983,7 @@ static void node_composit_buts_distance_matte(uiLayout *layout, bContext *UNUSED uiLayout *col, *row; col = uiLayoutColumn(layout, TRUE); - + uiItemL(layout, IFACE_("Color Space:"), ICON_NONE); row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE); @@ -2379,6 +2379,12 @@ static void node_composit_buts_stabilize2d(uiLayout *layout, bContext *C, Pointe uiItemR(layout, ptr, "filter_type", 0, "", ICON_NONE); } +static void node_composit_buts_translate(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + uiItemR(layout, ptr, "use_relative", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "wrap_axis", 0, NULL, ICON_NONE); +} + static void node_composit_buts_transform(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiItemR(layout, ptr, "filter_type", 0, "", ICON_NONE); @@ -2931,6 +2937,9 @@ static void node_composit_set_butfunc(bNodeType *ntype) case CMP_NODE_TRANSFORM: ntype->uifunc = node_composit_buts_transform; break; + case CMP_NODE_TRANSLATE: + ntype->uifunc = node_composit_buts_translate; + break; case CMP_NODE_MOVIEDISTORTION: ntype->uifunc = node_composit_buts_moviedistortion; break; @@ -3283,17 +3292,9 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode) else { glPixelZoom(snode->zoom, snode->zoom); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - glColor4f(0.0f, 0.0f, 0.0f, 1.0f); - glRecti(x, y, x + ibuf->x * snode->zoom, y + ibuf->y * snode->zoom); - glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, display_buffer); glPixelZoom(1.0f, 1.0f); - - glDisable(GL_BLEND); } } diff --git a/source/blender/editors/space_node/node_add.c b/source/blender/editors/space_node/node_add.c index b47be150417..22631568d03 100644 --- a/source/blender/editors/space_node/node_add.c +++ b/source/blender/editors/space_node/node_add.c @@ -441,6 +441,7 @@ static int new_node_tree_exec(bContext *C, wmOperator *op) { SpaceNode *snode; bNodeTree *ntree; + Main *bmain; PointerRNA ptr, idptr; PropertyRNA *prop; int treetype; @@ -448,6 +449,7 @@ static int new_node_tree_exec(bContext *C, wmOperator *op) /* retrieve state */ snode = CTX_wm_space_node(C); + bmain = CTX_data_main(C); if (RNA_struct_property_is_set(op->ptr, "type")) treetype = RNA_enum_get(op->ptr, "type"); @@ -457,7 +459,7 @@ static int new_node_tree_exec(bContext *C, wmOperator *op) if (RNA_struct_property_is_set(op->ptr, "name")) RNA_string_get(op->ptr, "name", treename); - ntree = ntreeAddTree(treename, treetype, 0); + ntree = ntreeAddTree(bmain, treename, treetype, 0); if (!ntree) return OPERATOR_CANCELLED; diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 321eaa32e80..fb4e4f62e52 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -328,7 +328,7 @@ void ED_node_shader_default(Scene *scene, ID *id) int output_type, shader_type; float color[3], strength = 1.0f; - ntree = ntreeAddTree("Shader Nodetree", NTREE_SHADER, 0); + ntree = ntreeAddTree(G.main, "Shader Nodetree", NTREE_SHADER, 0); switch (GS(id->name)) { case ID_MA: @@ -424,7 +424,7 @@ void ED_node_composit_default(Scene *sce) return; } - sce->nodetree = ntreeAddTree("Compositing Nodetree", NTREE_COMPOSIT, 0); + sce->nodetree = ntreeAddTree(G.main, "Compositing Nodetree", NTREE_COMPOSIT, 0); sce->nodetree->chunksize = 256; sce->nodetree->edit_quality = NTREE_QUALITY_HIGH; @@ -468,7 +468,7 @@ void ED_node_texture_default(Tex *tx) return; } - tx->nodetree = ntreeAddTree("Texture Nodetree", NTREE_TEXTURE, 0); + tx->nodetree = ntreeAddTree(G.main, "Texture Nodetree", NTREE_TEXTURE, 0); ntemp.type = TEX_NODE_OUTPUT; out = nodeAddNode(tx->nodetree, &ntemp); diff --git a/source/blender/editors/space_node/node_group.c b/source/blender/editors/space_node/node_group.c index 4dd9c89375d..943f12c4c54 100644 --- a/source/blender/editors/space_node/node_group.c +++ b/source/blender/editors/space_node/node_group.c @@ -457,8 +457,10 @@ static int node_group_ungroup(bNodeTree *ntree, bNode *gnode) /* ensure unique node name in the nodee tree */ nodeUniqueName(ntree, node); - node->locx += gnode->locx; - node->locy += gnode->locy; + if (!node->parent) { + node->locx += gnode->locx; + node->locy += gnode->locy; + } node->flag |= NODE_SELECT; } @@ -673,8 +675,10 @@ static int node_group_separate_selected(bNodeTree *ntree, bNode *gnode, int make /* ensure unique node name in the node tree */ nodeUniqueName(ntree, newnode); - newnode->locx += gnode->locx; - newnode->locy += gnode->locy; + if (!newnode->parent) { + newnode->locx += gnode->locx; + newnode->locy += gnode->locy; + } } else { /* ensure valid parent pointers, detach if child stays inside the group */ @@ -865,12 +869,14 @@ static int node_group_make_test(bNodeTree *ntree, bNode *gnode) static void node_get_selected_minmax(bNodeTree *ntree, bNode *gnode, float *min, float *max) { bNode *node; + float loc[2]; INIT_MINMAX2(min, max); for (node = ntree->nodes.first; node; node = node->next) { if (node == gnode) continue; if (node->flag & NODE_SELECT) { - minmax_v2v2_v2(min, max, &node->locx); + nodeToView(node, 0.0f, 0.0f, &loc[0], &loc[1]); + minmax_v2v2_v2(min, max, loc); } } } @@ -921,8 +927,10 @@ static int node_group_make_insert_selected(bNodeTree *ntree, bNode *gnode) /* ensure unique node name in the ngroup */ nodeUniqueName(ngroup, node); - node->locx -= 0.5f * (min[0] + max[0]); - node->locy -= 0.5f * (min[1] + max[1]); + if (!node->parent) { + node->locx -= 0.5f * (min[0] + max[0]); + node->locy -= 0.5f * (min[1] + max[1]); + } } else { /* if the parent is to be inserted but not the child, detach properly */ @@ -1039,7 +1047,7 @@ static bNode *node_group_make_from_selected(bNodeTree *ntree) node_get_selected_minmax(ntree, NULL, min, max); /* new nodetree */ - ngroup = ntreeAddTree("NodeGroup", ntree->type, NODE_GROUP); + ngroup = ntreeAddTree(G.main, "NodeGroup", ntree->type, NODE_GROUP); /* make group node */ ntemp.type = NODE_GROUP; diff --git a/source/blender/editors/space_node/node_header.c b/source/blender/editors/space_node/node_header.c index e82917feb21..e92d93485a1 100644 --- a/source/blender/editors/space_node/node_header.c +++ b/source/blender/editors/space_node/node_header.c @@ -136,7 +136,7 @@ static void do_node_add_group(bContext *C, void *UNUSED(arg), int event) ntemp.type = -event; switch (ntemp.type) { case NODE_GROUP: - ntemp.ngroup = ntreeAddTree("Group", snode->treetype, ntemp.type); + ntemp.ngroup = ntreeAddTree(bmain, "Group", snode->treetype, ntemp.type); break; default: ntemp.ngroup = NULL; diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c index 513f6b43e9a..a5f6ca9ded0 100644 --- a/source/blender/editors/space_node/space_node.c +++ b/source/blender/editors/space_node/space_node.c @@ -119,7 +119,7 @@ static SpaceLink *node_new(const bContext *UNUSED(C)) snode = MEM_callocN(sizeof(SpaceNode), "initnode"); snode->spacetype = SPACE_NODE; - snode->flag = SNODE_SHOW_GPENCIL; + snode->flag = SNODE_SHOW_GPENCIL | SNODE_USE_ALPHA; /* backdrop */ snode->zoom = 1.0f; diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index a087ff65f63..ab660b9cd4a 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -1309,8 +1309,8 @@ static void do_outliner_keyingset_editop(SpaceOops *soops, KeyingSet *ks, ListBa * for now, we don't supply one, and just let this use the KeyingSet name */ BKE_keyingset_add_path(ks, id, NULL, path, array_index, flag, groupmode); ks->active_path = BLI_countlist(&ks->paths); + break; } - break; case KEYINGSET_EDITMODE_REMOVE: { /* find the relevant path, then remove it from the KeyingSet */ @@ -1322,8 +1322,8 @@ static void do_outliner_keyingset_editop(SpaceOops *soops, KeyingSet *ks, ListBa ks->active_path = 0; } + break; } - break; } /* free path, since it had to be generated */ @@ -1637,7 +1637,7 @@ void OUTLINER_OT_parent_drop(wmOperatorType *ot) ot->poll = ED_operator_outliner_active; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; /* properties */ RNA_def_string(ot->srna, "child", "Object", MAX_ID_NAME, "Child", "Child Object"); @@ -1726,7 +1726,7 @@ void OUTLINER_OT_parent_clear(wmOperatorType *ot) ot->poll = ED_operator_outliner_active; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; /* properties */ RNA_def_string(ot->srna, "dragged_obj", "Object", MAX_ID_NAME, "Child", "Child Object"); @@ -1819,7 +1819,7 @@ void OUTLINER_OT_scene_drop(wmOperatorType *ot) ot->poll = ED_operator_outliner_active; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; /* properties */ RNA_def_string(ot->srna, "object", "Object", MAX_ID_NAME, "Object", "Target Object"); @@ -1883,7 +1883,7 @@ void OUTLINER_OT_material_drop(wmOperatorType *ot) ot->poll = ED_operator_outliner_active; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; /* properties */ RNA_def_string(ot->srna, "object", "Object", MAX_ID_NAME, "Object", "Target Object"); diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 15528093869..97943f7e6ac 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -2463,9 +2463,15 @@ void SEQUENCER_OT_strip_jump(wmOperatorType *ot) static void swap_sequence(Scene *scene, Sequence *seqa, Sequence *seqb) { int gap = seqb->startdisp - seqa->enddisp; - seqb->start = (seqb->start - seqb->startdisp) + seqa->startdisp; + int seq_a_start; + int seq_b_start; + + seq_b_start = (seqb->start - seqb->startdisp) + seqa->startdisp; + BKE_sequence_translate(scene, seqb, seq_b_start - seqb->start); BKE_sequence_calc(scene, seqb); - seqa->start = (seqa->start - seqa->startdisp) + seqb->enddisp + gap; + + seq_a_start = (seqa->start - seqa->startdisp) + seqb->enddisp + gap; + BKE_sequence_translate(scene, seqa, seq_a_start - seqa->start); BKE_sequence_calc(scene, seqa); } diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 21966ef614c..1f209f90007 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -161,11 +161,12 @@ void text_update_edited(Text *text) static int text_new_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceText *st = CTX_wm_space_text(C); + Main *bmain = CTX_data_main(C); Text *text; PointerRNA ptr, idptr; PropertyRNA *prop; - text = BKE_text_add("Text"); + text = BKE_text_add(bmain, "Text"); /* hook into UI */ uiIDContextProperty(C, &ptr, &prop); @@ -226,6 +227,7 @@ static int text_open_cancel(bContext *UNUSED(C), wmOperator *op) static int text_open_exec(bContext *C, wmOperator *op) { SpaceText *st = CTX_wm_space_text(C); + Main *bmain = CTX_data_main(C); Text *text; PropertyPointerRNA *pprop; PointerRNA idptr; @@ -234,7 +236,7 @@ static int text_open_exec(bContext *C, wmOperator *op) RNA_string_get(op->ptr, "filepath", str); - text = BKE_text_load(str, G.main->name); + text = BKE_text_load(bmain, str, G.main->name); if (!text) { if (op->customdata) MEM_freeN(op->customdata); diff --git a/source/blender/editors/space_view3d/drawvolume.c b/source/blender/editors/space_view3d/drawvolume.c index 29daee3e11b..70d3857601f 100644 --- a/source/blender/editors/space_view3d/drawvolume.c +++ b/source/blender/editors/space_view3d/drawvolume.c @@ -74,61 +74,18 @@ #include "ED_mesh.h" - #include "BLF_api.h" - #include "view3d_intern.h" // own include +struct GPUTexture; -#ifdef _WIN32 -#include <time.h> -#include <stdio.h> -#include <conio.h> -#include <windows.h> - -static LARGE_INTEGER liFrequency; -static LARGE_INTEGER liStartTime; -static LARGE_INTEGER liCurrentTime; +// #define DEBUG_DRAW_TIME -static void tstart(void) -{ - QueryPerformanceFrequency(&liFrequency); - QueryPerformanceCounter(&liStartTime); -} -static void tend(void) -{ - QueryPerformanceCounter(&liCurrentTime); -} -static double tval(void) -{ - return ((double)( (liCurrentTime.QuadPart - liStartTime.QuadPart) * (double)1000.0 / (double)liFrequency.QuadPart)); -} -#else -#include <sys/time.h> -static struct timeval _tstart, _tend; -static struct timezone tz; -static void tstart(void) -{ - gettimeofday(&_tstart, &tz); -} -static void tend(void) -{ - gettimeofday(&_tend, &tz); -} - #if 0 -static double tval() -{ - double t1, t2; - t1 = ( double ) _tstart.tv_sec * 1000 + ( double ) _tstart.tv_usec / (1000); - t2 = ( double ) _tend.tv_sec * 1000 + ( double ) _tend.tv_usec / (1000); - return t2 - t1; -} - #endif +#ifdef DEBUG_DRAW_TIME +# include "PIL_time.h" #endif -struct GPUTexture; - static int intersect_edges(float *points, float a, float b, float c, float d, float edges[12][2][3]) { int i; @@ -275,7 +232,10 @@ void draw_smoke_volume(SmokeDomainSettings *sds, Object *ob, return; } - tstart(); +#ifdef DEBUG_DRAW_TIME + TIMEIT_START(draw); +#endif + /* generate flame spectrum texture */ #define SPEC_WIDTH 256 #define FIRE_THRESH 7 @@ -522,8 +482,10 @@ void draw_smoke_volume(SmokeDomainSettings *sds, Object *ob, n++; } - tend(); - // printf ( "Draw Time: %f\n",(float) tval() ); +#ifdef DEBUG_DRAW_TIME + printf("Draw Time: %f\n", (float)TIMEIT_VALUE(draw)); + TIMEIT_END(draw); +#endif if (tex_shadow) GPU_texture_unbind(tex_shadow); diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index b2d58cf41de..658196a1bd4 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -146,7 +146,7 @@ RegionView3D *ED_view3d_context_rv3d(bContext *C) if (rv3d == NULL) { ScrArea *sa = CTX_wm_area(C); if (sa && sa->spacetype == SPACE_VIEW3D) { - ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + ARegion *ar = BKE_area_find_region_active_win(sa); if (ar) { rv3d = ar->regiondata; } diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 562d1ec4b64..5c2e75776e4 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -921,8 +921,12 @@ static int viewrotate_invoke(bContext *C, wmOperator *op, wmEvent *event) } if (event->type == MOUSEPAN) { - /* invert it, trackpad scroll then follows how you mapped it globally */ - viewrotate_apply(vod, 2 * event->x - event->prevx, 2 * event->y - event->prevy); + /* Rotate direction we keep always same */ + if (U.uiflag2 & USER_TRACKPAD_NATURAL) + viewrotate_apply(vod, 2 * event->x - event->prevx, 2 * event->y - event->prevy); + else + viewrotate_apply(vod, event->prevx, event->prevy); + ED_view3d_depth_tag_update(rv3d); viewops_data_free(C, op); diff --git a/source/blender/editors/space_view3d/view3d_toolbar.c b/source/blender/editors/space_view3d/view3d_toolbar.c index bfeb56036e6..bb5b7aa6911 100644 --- a/source/blender/editors/space_view3d/view3d_toolbar.c +++ b/source/blender/editors/space_view3d/view3d_toolbar.c @@ -101,22 +101,33 @@ static void view3d_panel_operator_redo_operator(const bContext *C, Panel *pa, wm static void view3d_panel_operator_redo(const bContext *C, Panel *pa) { wmOperator *op = WM_operator_last_redo(C); - uiBlock *block; - - if (op == NULL) - return; - if (WM_operator_poll((bContext *)C, op->type) == 0) + ARegion *ar; + ARegion *ar1; + + if (op == NULL) { return; - - block = uiLayoutGetBlock(pa->layout); - - if (!WM_operator_check_ui_enabled(C, op->type->name)) - uiLayoutSetEnabled(pa->layout, FALSE); + } - /* note, blockfunc is a default but->func, use Handle func to allow button callbacks too */ - uiBlockSetHandleFunc(block, ED_undo_operator_repeat_cb_evt, op); - - view3d_panel_operator_redo_operator(C, pa, op); + /* keep in sync with logic in ED_undo_operator_repeat() */ + ar = CTX_wm_region(C); + ar1 = BKE_area_find_region_active_win(CTX_wm_area(C)); + if (ar1) + CTX_wm_region_set((bContext *)C, ar1); + + if (WM_operator_poll((bContext *)C, op->type)) { + uiBlock *block = uiLayoutGetBlock(pa->layout); + + if (!WM_operator_check_ui_enabled(C, op->type->name)) + uiLayoutSetEnabled(pa->layout, FALSE); + + /* note, blockfunc is a default but->func, use Handle func to allow button callbacks too */ + uiBlockSetHandleFunc(block, ED_undo_operator_repeat_cb_evt, op); + + view3d_panel_operator_redo_operator(C, pa, op); + } + + /* set region back */ + CTX_wm_region_set((bContext *)C, ar); } /* ******************* */ diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index c4960de1e19..98d4c5e7b81 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -4890,6 +4890,45 @@ static void len_v3_ensure(float v[3], const float length) } /** + * Find the closest point on the ngon on the opposite side. + * used to set the edge slide distance for ngons. + */ +static bool bm_loop_calc_opposite_co(BMLoop *l_tmp, + const float plane_no[3], + float r_co[3]) +{ + /* skip adjacent edges */ + BMLoop *l_first = l_tmp->next; + BMLoop *l_last = l_tmp->prev; + BMLoop *l_iter; + float dist = FLT_MAX; + + l_iter = l_first; + do { + float tvec[3]; + if (isect_line_plane_v3(tvec, + l_iter->v->co, l_iter->next->v->co, + l_tmp->v->co, plane_no, false)) + { + const float fac = line_point_factor_v3(tvec, l_iter->v->co, l_iter->next->v->co); + /* allow some overlap to avoid missing the intersection because of float precision */ + if ((fac > -FLT_EPSILON) && (fac < 1.0f + FLT_EPSILON)) { + /* likelyhood of multiple intersections per ngon is quite low, + * it would have to loop back on its self, but better support it + * so check for the closest opposite edge */ + const float tdist = len_v3v3(l_tmp->v->co, tvec); + if (tdist < dist) { + copy_v3_v3(r_co, tvec); + dist = tdist; + } + } + } + } while ((l_iter = l_iter->next) != l_last); + + return (dist != FLT_MAX); +} + +/** * Given 2 edges and a loop, step over the loops * and calculate a direction to slide along. * @@ -4919,21 +4958,39 @@ static BMLoop *get_next_loop(BMVert *v, BMLoop *l, else { /* When there is no edge to slide along, * we must slide along the vector defined by the face we're attach to */ - float e_dir_prev[3], e_dir_next[3], tvec[3]; + BMLoop *l_tmp = BM_face_vert_share_loop(l_first->f, v); - sub_v3_v3v3(e_dir_prev, BM_edge_other_vert(e_prev, v)->co, v->co); - sub_v3_v3v3(e_dir_next, BM_edge_other_vert(e_next, v)->co, v->co); + BLI_assert(ELEM(l_tmp->e, e_prev, e_next) && ELEM(l_tmp->prev->e, e_prev, e_next)); - cross_v3_v3v3(tvec, l->f->no, e_dir_prev); - cross_v3_v3v3(vec_accum, e_dir_next, l->f->no); + if (l_tmp->f->len == 4) { + /* we could use code below, but in this case + * sliding diagonally across the quad works well */ + sub_v3_v3v3(vec_accum, l_tmp->next->next->v->co, v->co); + } + else { + float tdir[3]; + BM_loop_calc_face_direction(l_tmp, tdir); + cross_v3_v3v3(vec_accum, l_tmp->f->no, tdir); +#if 0 + /* rough guess, we can do better! */ + len_v3_ensure(vec_accum, (BM_edge_calc_length(e_prev) + BM_edge_calc_length(e_next)) / 2.0f); +#else + /* be clever, check the opposite ngon edge to slide into. + * this gives best results */ + { + float tvec[3]; + float dist; - mid_v3_v3v3(vec_accum, vec_accum, tvec); + if (bm_loop_calc_opposite_co(l_tmp, tdir, tvec)) { + dist = len_v3v3(l_tmp->v->co, tvec); + } + else { + dist = (BM_edge_calc_length(e_prev) + BM_edge_calc_length(e_next)) / 2.0f; + } - /* check if we need to flip - * (compare the normal defines by the edges with the face normal) */ - cross_v3_v3v3(tvec, e_dir_prev, e_dir_next); - if (dot_v3v3(tvec, l->f->no) > 0.0f) { - negate_v3(vec_accum); + len_v3_ensure(vec_accum, dist); + } +#endif } } @@ -5025,6 +5082,7 @@ static int createEdgeSlideVerts(TransInfo *t) BMEdge *e, *e1; BMVert *v, *v2; TransDataEdgeSlideVert *sv_array; + int sv_tot; BMBVHTree *btree; SmallHash table; EdgeSlideData *sld = MEM_callocN(sizeof(*sld), "sld"); @@ -5124,10 +5182,10 @@ static int createEdgeSlideVerts(TransInfo *t) return 0; } - sv_array = MEM_callocN(sizeof(TransDataEdgeSlideVert) * j, "sv_array"); + sv_tot = j; + sv_array = MEM_callocN(sizeof(TransDataEdgeSlideVert) * sv_tot, "sv_array"); loop_nr = 0; - j = 0; while (1) { BMLoop *l, *l1, *l2; BMVert *v_first; @@ -5187,10 +5245,10 @@ static int createEdgeSlideVerts(TransInfo *t) /*iterate over the loop*/ v_first = v; do { - TransDataEdgeSlideVert *sv = sv_array + j; - - BLI_assert(j < MEM_allocN_len(sv_array) / sizeof(*sv)); + TransDataEdgeSlideVert *sv; + /* XXX, 'sv' will initialize multiple times, this is suspicious. see [#34024] */ + sv = sv_array + GET_INT_FROM_POINTER(BLI_smallhash_lookup(&table, (uintptr_t)v)); sv->v = v; sv->origvert = *v; sv->loop_nr = loop_nr; @@ -5212,11 +5270,7 @@ static int createEdgeSlideVerts(TransInfo *t) e1 = e; e = get_other_edge(v, e); if (!e) { - //v2=v, v = BM_edge_other_vert(l1->e, v); - - BLI_assert(j + 1 < MEM_allocN_len(sv_array) / sizeof(*sv)); - - sv = sv_array + j + 1; + sv = sv_array + GET_INT_FROM_POINTER(BLI_smallhash_lookup(&table, (uintptr_t)v)); sv->v = v; sv->origvert = *v; sv->loop_nr = loop_nr; @@ -5233,16 +5287,13 @@ static int createEdgeSlideVerts(TransInfo *t) BM_elem_flag_disable(v, BM_ELEM_TAG); BM_elem_flag_disable(v2, BM_ELEM_TAG); - - j += 2; + break; } l1 = get_next_loop(v, l1, e1, e, vec); l2 = l2 ? get_next_loop(v, l2, e1, e, vec2) : NULL; - j += 1; - BM_elem_flag_disable(v, BM_ELEM_TAG); BM_elem_flag_disable(v2, BM_ELEM_TAG); } while (e != v_first->e && l1); @@ -5253,7 +5304,7 @@ static int createEdgeSlideVerts(TransInfo *t) /* EDBM_flag_disable_all(em, BM_ELEM_SELECT); */ sld->sv = sv_array; - sld->totsv = j; + sld->totsv = sv_tot; /* find mouse vectors, the global one, and one per loop in case we have * multiple loops selected, in case they are oriented different */ @@ -5628,7 +5679,7 @@ void initEdgeSlide(TransInfo *t) /* set custom point first if you want value to be initialized by init */ setCustomPoints(t, &t->mouse, sld->end, sld->start); - initMouseInputMode(t, &t->mouse, INPUT_CUSTOM_RATIO); + initMouseInputMode(t, &t->mouse, INPUT_CUSTOM_RATIO_FLIP); t->idx_max = 0; t->num.idx_max = 0; @@ -5879,19 +5930,14 @@ static void calcVertSlideCustomPoints(struct TransInfo *t) TransDataVertSlideVert *sv = &sld->sv[sld->curr_sv_index]; float *co_orig = sv->co_orig_2d; float *co_curr = sv->co_link_orig_2d[sv->co_link_curr]; - float co_curr_flip[2]; - - flip_v2_v2v2(co_curr_flip, co_orig, co_curr); + const int start[2] = {co_orig[0], co_orig[1]}; + const int end[2] = {co_curr[0], co_curr[1]}; - { - const int start[2] = {co_orig[0], co_orig[1]}; - const int end[2] = {co_curr_flip[0], co_curr_flip[1]}; - if (!sld->flipped_vtx) { - setCustomPoints(t, &t->mouse, end, start); - } - else { - setCustomPoints(t, &t->mouse, start, end); - } + if (sld->flipped_vtx && sld->is_proportional == false) { + setCustomPoints(t, &t->mouse, start, end); + } + else { + setCustomPoints(t, &t->mouse, end, start); } } @@ -5977,7 +6023,7 @@ static int createVertSlideVerts(TransInfo *t) if (t->spacetype == SPACE_VIEW3D) { /* background mode support */ // v3d = t->sa ? t->sa->spacedata.first : NULL; - rv3d = t->ar ? t->ar->regiondata : NULL; + rv3d = ar ? ar->regiondata : NULL; } sld->is_proportional = true; @@ -6043,18 +6089,30 @@ static int createVertSlideVerts(TransInfo *t) if (!BM_elem_flag_test(e, BM_ELEM_HIDDEN)) { BMVert *v_other = BM_edge_other_vert(e, v); copy_v3_v3(sv_array[j].co_link_orig_3d[k], v_other->co); - ED_view3d_project_float_v2_m4(ar, - sv_array[j].co_link_orig_3d[k], - sv_array[j].co_link_orig_2d[k], - projectMat); + if (ar) { + ED_view3d_project_float_v2_m4(ar, + sv_array[j].co_link_orig_3d[k], + sv_array[j].co_link_orig_2d[k], + projectMat); + } + else { + copy_v2_v2(sv_array[j].co_link_orig_2d[k], + sv_array[j].co_link_orig_3d[k]); + } k++; } } - ED_view3d_project_float_v2_m4(ar, - sv_array[j].co_orig_3d, - sv_array[j].co_orig_2d, - projectMat); + if (ar) { + ED_view3d_project_float_v2_m4(ar, + sv_array[j].co_orig_3d, + sv_array[j].co_orig_2d, + projectMat); + } + else { + copy_v2_v2(sv_array[j].co_orig_2d, + sv_array[j].co_orig_3d); + } j++; } @@ -6147,16 +6205,17 @@ int handleEventVertSlide(struct TransInfo *t, struct wmEvent *event) case EKEY: if (event->val == KM_PRESS) { sld->is_proportional = !sld->is_proportional; + if (sld->flipped_vtx) { + calcVertSlideCustomPoints(t); + } return 1; } break; case FKEY: { if (event->val == KM_PRESS) { - if (sld->is_proportional == FALSE) { - sld->flipped_vtx = !sld->flipped_vtx; - calcVertSlideCustomPoints(t); - } + sld->flipped_vtx = !sld->flipped_vtx; + calcVertSlideCustomPoints(t); return 1; } break; diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index c72c6a83d82..a27fe91c3c3 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -677,7 +677,8 @@ typedef enum { INPUT_HORIZONTAL_ABSOLUTE, INPUT_VERTICAL_RATIO, INPUT_VERTICAL_ABSOLUTE, - INPUT_CUSTOM_RATIO + INPUT_CUSTOM_RATIO, + INPUT_CUSTOM_RATIO_FLIP } MouseInputMode; void initMouseInput(TransInfo *t, MouseInput *mi, const int center[2], const int mval[2]); diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 39c51ff456e..7d62775ae58 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -2642,6 +2642,14 @@ static void createTransNlaData(bContext *C, TransInfo *t) /* stop if trying to build list if nothing selected */ if (count == 0) { + /* clear temp metas that may have been created but aren't needed now + * because they fell on the wrong side of CFRA + */ + for (ale = anim_data.first; ale; ale = ale->next) { + NlaTrack *nlt = (NlaTrack *)ale->data; + BKE_nlastrips_clear_metas(&nlt->strips, 0, 1); + } + /* cleanup temp list */ BLI_freelistN(&anim_data); return; @@ -2686,14 +2694,14 @@ static void createTransNlaData(bContext *C, TransInfo *t) tdn->oldTrack = tdn->nlt = nlt; tdn->strip = strip; tdn->trackIndex = BLI_findindex(&adt->nla_tracks, nlt); - + yval = (float)(tdn->trackIndex * NLACHANNEL_STEP(snla)); - + tdn->h1[0] = strip->start; tdn->h1[1] = yval; tdn->h2[0] = strip->end; tdn->h2[1] = yval; - + center[0] = (float)CFRA; center[1] = yval; center[2] = 0.0f; diff --git a/source/blender/editors/transform/transform_input.c b/source/blender/editors/transform/transform_input.c index c805dfe1b41..dd1510498b0 100644 --- a/source/blender/editors/transform/transform_input.c +++ b/source/blender/editors/transform/transform_input.c @@ -180,7 +180,7 @@ void setCustomPoints(TransInfo *UNUSED(t), MouseInput *mi, const int start[2], c data[3] = end[1]; } -static void InputCustomRatio(TransInfo *UNUSED(t), MouseInput *mi, const int mval[2], float output[3]) +static void InputCustomRatioFlip(TransInfo *UNUSED(t), MouseInput *mi, const int mval[2], float output[3]) { double length; double distance; @@ -213,6 +213,12 @@ static void InputCustomRatio(TransInfo *UNUSED(t), MouseInput *mi, const int mva } } +static void InputCustomRatio(TransInfo *t, MouseInput *mi, const int mval[2], float output[3]) +{ + InputCustomRatioFlip(t, mi, mval, output); + output[0] = -output[0]; +} + static void InputAngle(TransInfo *UNUSED(t), MouseInput *mi, const int mval[2], float output[3]) { double dx2 = mval[0] - mi->center[0]; @@ -232,7 +238,7 @@ static void InputAngle(TransInfo *UNUSED(t), MouseInput *mi, const int mval[2], double deler = (((dx1 * dx1 + dy1 * dy1) + (dx2 * dx2 + dy2 * dy2) - (dx3 * dx3 + dy3 * dy3)) / (2.0 * ((A * B) ? (A * B) : 1.0))); - /* ((A*B)?(A*B):1.0) this takes care of potential divide by zero errors */ + /* ((A * B) ? (A * B) : 1.0) this takes care of potential divide by zero errors */ float dphi; @@ -358,6 +364,10 @@ void initMouseInputMode(TransInfo *t, MouseInput *mi, MouseInputMode mode) mi->apply = InputCustomRatio; t->helpline = HLP_NONE; break; + case INPUT_CUSTOM_RATIO_FLIP: + mi->apply = InputCustomRatioFlip; + t->helpline = HLP_NONE; + break; case INPUT_NONE: default: mi->apply = NULL; diff --git a/source/blender/editors/util/undo.c b/source/blender/editors/util/undo.c index 1dc7e0c90e8..8a0ef06ef12 100644 --- a/source/blender/editors/util/undo.c +++ b/source/blender/editors/util/undo.c @@ -339,8 +339,9 @@ int ED_undo_operator_repeat(bContext *C, struct wmOperator *op) wmWindowManager *wm = CTX_wm_manager(C); struct Scene *scene = CTX_data_scene(C); + /* keep in sync with logic in view3d_panel_operator_redo() */ ARegion *ar = CTX_wm_region(C); - ARegion *ar1 = BKE_area_find_region_type(CTX_wm_area(C), RGN_TYPE_WINDOW); + ARegion *ar1 = BKE_area_find_region_active_win(CTX_wm_area(C)); if (ar1) CTX_wm_region_set(C, ar1); diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c index 5d3a5983030..7e3302e233e 100644 --- a/source/blender/editors/uvedit/uvedit_parametrizer.c +++ b/source/blender/editors/uvedit/uvedit_parametrizer.c @@ -1057,7 +1057,7 @@ static PFace *p_face_add(PHandle *handle) e1->pair = NULL; e2->pair = NULL; e3->pair = NULL; - + e1->flag = 0; e2->flag = 0; e3->flag = 0; diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.c b/source/blender/editors/uvedit/uvedit_smart_stitch.c index b1bb5c85e50..1b43d829947 100644 --- a/source/blender/editors/uvedit/uvedit_smart_stitch.c +++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c @@ -650,7 +650,7 @@ static void stitch_uv_edge_generate_linked_edges(GHash *edge_hash, StitchState * edge2 = BLI_ghash_lookup(edge_hash, &edgetmp); /* here I am taking care of non manifold case, assuming more than two matching edges. - * I am not too sure we want this though */ + * I am not too sure we want this though */ last_set->next = edge2; last_set = edge2; /* set first, similarly to uv elements. Now we can iterate among common edges easily */ |