diff options
Diffstat (limited to 'source')
28 files changed, 482 insertions, 113 deletions
diff --git a/source/blender/blenfont/intern/blf_internal_types.h b/source/blender/blenfont/intern/blf_internal_types.h index 0294a6219b9..45086de0f61 100644 --- a/source/blender/blenfont/intern/blf_internal_types.h +++ b/source/blender/blenfont/intern/blf_internal_types.h @@ -80,9 +80,8 @@ typedef struct GlyphCacheBLF { /* and the last texture, aka. the current texture. */ unsigned int texture_current; - /* like bftgl, we draw every glyph in a big texture, so this is the - * current position inside the texture. - */ + /* We draw every glyph in a big texture, so this is the + * current position inside the texture. */ int offset_x; int offset_y; diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h index a1900c1af94..dfa1b311eb0 100644 --- a/source/blender/blenkernel/BKE_blender_version.h +++ b/source/blender/blenkernel/BKE_blender_version.h @@ -26,8 +26,8 @@ * * \note Use #STRINGIFY() rather than defining with quotes. */ -#define BLENDER_VERSION 281 -#define BLENDER_SUBVERSION 15 +#define BLENDER_VERSION 282 +#define BLENDER_SUBVERSION 1 /** Several breakages with 280, e.g. collections vs layers. */ #define BLENDER_MINVERSION 280 #define BLENDER_MINSUBVERSION 0 @@ -36,7 +36,7 @@ /** Can be left blank, otherwise a,b,c... etc with no quotes. */ #define BLENDER_VERSION_CHAR /** alpha/beta/rc/release, docs use this. */ -#define BLENDER_VERSION_CYCLE beta +#define BLENDER_VERSION_CYCLE alpha /** Optionally set to 1,2,... for example to to get alpha1 or rc2. */ #define BLENDER_VERSION_CYCLE_NUMBER diff --git a/source/blender/blenkernel/intern/mesh_remesh_voxel.c b/source/blender/blenkernel/intern/mesh_remesh_voxel.c index b93fe157f2a..ba8ed5facad 100644 --- a/source/blender/blenkernel/intern/mesh_remesh_voxel.c +++ b/source/blender/blenkernel/intern/mesh_remesh_voxel.c @@ -311,7 +311,7 @@ Mesh *BKE_mesh_remesh_voxel_to_mesh_nomain(Mesh *mesh, OpenVDBLevelSet_free(level_set); OpenVDBTransform_free(xform); #else - UNUSED_VARS(mesh, voxel_size, adaptivity); + UNUSED_VARS(mesh, voxel_size, adaptivity, isovalue); #endif return new_mesh; } diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c b/source/blender/blenkernel/intern/pbvh_bmesh.c index c2fff7aa0e4..6d38ae13994 100644 --- a/source/blender/blenkernel/intern/pbvh_bmesh.c +++ b/source/blender/blenkernel/intern/pbvh_bmesh.c @@ -1978,7 +1978,7 @@ bool BKE_pbvh_bmesh_update_topology(PBVH *bvh, if (mode & PBVH_Collapse) { EdgeQueue q; - BLI_mempool *queue_pool = BLI_mempool_create(sizeof(BMVert * [2]), 0, 128, BLI_MEMPOOL_NOP); + BLI_mempool *queue_pool = BLI_mempool_create(sizeof(BMVert *[2]), 0, 128, BLI_MEMPOOL_NOP); EdgeQueueContext eq_ctx = { &q, queue_pool, @@ -1997,7 +1997,7 @@ bool BKE_pbvh_bmesh_update_topology(PBVH *bvh, if (mode & PBVH_Subdivide) { EdgeQueue q; - BLI_mempool *queue_pool = BLI_mempool_create(sizeof(BMVert * [2]), 0, 128, BLI_MEMPOOL_NOP); + BLI_mempool *queue_pool = BLI_mempool_create(sizeof(BMVert *[2]), 0, 128, BLI_MEMPOOL_NOP); EdgeQueueContext eq_ctx = { &q, queue_pool, diff --git a/source/blender/blenlib/BLI_compiler_compat.h b/source/blender/blenlib/BLI_compiler_compat.h index bd1cd327d3c..312991e7f15 100644 --- a/source/blender/blenlib/BLI_compiler_compat.h +++ b/source/blender/blenlib/BLI_compiler_compat.h @@ -15,7 +15,7 @@ */ #ifndef __BLI_COMPILER_COMPAT_H__ -# define __BLI_COMPILER_COMPAT_H__ +#define __BLI_COMPILER_COMPAT_H__ /** \file * \ingroup bli @@ -23,32 +23,32 @@ * Use to help with cross platform portability. */ -# if defined(_MSC_VER) -# define alloca _alloca -# endif +#if defined(_MSC_VER) +# define alloca _alloca +#endif -# if (defined(__GNUC__) || defined(__clang__)) && defined(__cplusplus) +#if (defined(__GNUC__) || defined(__clang__)) && defined(__cplusplus) extern "C++" { /* Some magic to be sure we don't have reference in the type. */ template<typename T> static inline T decltype_helper(T x) { return x; } -# define typeof(x) decltype(decltype_helper(x)) +# define typeof(x) decltype(decltype_helper(x)) } -# endif +#endif /* little macro so inline keyword works */ -# if defined(_MSC_VER) -# define BLI_INLINE static __forceinline -# else -# define BLI_INLINE static inline __attribute__((always_inline)) __attribute__((__unused__)) -# endif +#if defined(_MSC_VER) +# define BLI_INLINE static __forceinline +#else +# define BLI_INLINE static inline __attribute__((always_inline)) __attribute__((__unused__)) +#endif -# if defined(__GNUC__) -# define BLI_NOINLINE __attribute__((noinline)) -# else -# define BLI_NOINLINE -# endif +#if defined(__GNUC__) +# define BLI_NOINLINE __attribute__((noinline)) +#else +# define BLI_NOINLINE +#endif #endif /* __BLI_COMPILER_COMPAT_H__ */ diff --git a/source/blender/blenlib/intern/BLI_temporary_allocator.cc b/source/blender/blenlib/intern/BLI_temporary_allocator.cc index e41cf36f66d..b145e65530d 100644 --- a/source/blender/blenlib/intern/BLI_temporary_allocator.cc +++ b/source/blender/blenlib/intern/BLI_temporary_allocator.cc @@ -73,7 +73,7 @@ struct ThreadLocalBuffers { } }; -thread_local ThreadLocalBuffers local_storage; +static thread_local ThreadLocalBuffers local_storage; void *BLI_temporary_allocate(uint size) { diff --git a/source/blender/blenloader/intern/versioning_userdef.c b/source/blender/blenloader/intern/versioning_userdef.c index d2192f1e22a..e1ee020940e 100644 --- a/source/blender/blenloader/intern/versioning_userdef.c +++ b/source/blender/blenloader/intern/versioning_userdef.c @@ -637,6 +637,10 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef) } } + if (!USER_VERSION_ATLEAST(282, 1)) { + userdef->file_space_data.filter_id = U_default.file_space_data.filter_id; + } + /** * Include next version bump. */ diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c index 68624540d08..af315597e68 100644 --- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c +++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c @@ -139,14 +139,9 @@ static void gpencil_calc_vertex(GPENCIL_StorageList *stl, } Object *ob = cache_ob->ob; - const DRWContextState *draw_ctx = DRW_context_state_get(); - const bool main_onion = draw_ctx->v3d != NULL ? - (draw_ctx->v3d->gp_flag & V3D_GP_SHOW_ONION_SKIN) : - true; + const bool main_onion = stl->storage->is_main_onion; const bool playing = stl->storage->is_playing; - const bool overlay = draw_ctx->v3d != NULL ? - (bool)((draw_ctx->v3d->flag2 & V3D_HIDE_OVERLAYS) == 0) : - true; + const bool overlay = stl->storage->is_main_overlay; const bool do_onion = (bool)((gpd->flag & GP_DATA_STROKE_WEIGHTMODE) == 0) && overlay && main_onion && !playing && gpencil_onion_active(gpd); @@ -1802,8 +1797,8 @@ static void gpencil_shgroups_create(GPENCIL_e_data *e_data, const bool overlay = draw_ctx->v3d != NULL ? (bool)((draw_ctx->v3d->flag2 & V3D_HIDE_OVERLAYS) == 0) : true; - const bool main_onion = v3d != NULL ? (v3d->gp_flag & V3D_GP_SHOW_ONION_SKIN) : true; - const bool do_onion = (bool)((gpd->flag & GP_DATA_STROKE_WEIGHTMODE) == 0) && main_onion && + const bool screen_onion = v3d != NULL ? (v3d->gp_flag & V3D_GP_SHOW_ONION_SKIN) : true; + const bool do_onion = (bool)((gpd->flag & GP_DATA_STROKE_WEIGHTMODE) == 0) && screen_onion && overlay && gpencil_onion_active(gpd); int start_stroke = 0; @@ -2083,13 +2078,9 @@ void gpencil_populate_datablock(GPENCIL_e_data *e_data, bGPdata *gpd_eval = (bGPdata *)ob->data; bGPdata *gpd = (bGPdata *)DEG_get_original_id(&gpd_eval->id); - const bool main_onion = draw_ctx->v3d != NULL ? - (draw_ctx->v3d->gp_flag & V3D_GP_SHOW_ONION_SKIN) : - true; + const bool main_onion = stl->storage->is_main_onion; const bool playing = stl->storage->is_playing; - const bool overlay = draw_ctx->v3d != NULL ? - (bool)((draw_ctx->v3d->flag2 & V3D_HIDE_OVERLAYS) == 0) : - true; + const bool overlay = stl->storage->is_main_overlay; const bool do_onion = (bool)((gpd->flag & GP_DATA_STROKE_WEIGHTMODE) == 0) && overlay && main_onion && !playing && gpencil_onion_active(gpd); diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c index aaadf680955..9554e9c0275 100644 --- a/source/blender/draw/engines/gpencil/gpencil_engine.c +++ b/source/blender/draw/engines/gpencil/gpencil_engine.c @@ -24,11 +24,13 @@ #include "BKE_gpencil.h" #include "BKE_library.h" +#include "BKE_main.h" #include "BKE_object.h" #include "BKE_paint.h" #include "BKE_shader_fx.h" #include "DNA_gpencil_types.h" +#include "DNA_screen_types.h" #include "DNA_view3d_types.h" #include "draw_mode_engines.h" @@ -305,6 +307,43 @@ static void GPENCIL_engine_free(void) GPENCIL_delete_fx_shaders(&e_data); } +/* Helper: Check if the main overlay and onion switches are enabled in any screen. + * + * This is required to generate the onion skin and limit the times the cache is updated because the + * cache is generated only in the first screen and if the first screen has the onion disabled the + * cache for onion skin is not generated. The loop adds time, but always is faster than regenerate + * the cache all the times. + */ +static void gpencil_check_screen_switches(const DRWContextState *draw_ctx, + GPENCIL_StorageList *stl) +{ + stl->storage->is_main_overlay = false; + stl->storage->is_main_onion = false; + /* Check if main onion switch is enabled in any screen. */ + Main *bmain = CTX_data_main(draw_ctx->evil_C); + + for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { + for (const ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { + if (sa && sa->spacetype == SPACE_VIEW3D) { + View3D *v3d = sa->spacedata.first; + if (v3d == NULL) { + continue; + } + if ((v3d->flag2 & V3D_HIDE_OVERLAYS) == 0) { + stl->storage->is_main_overlay = true; + } + if (v3d->gp_flag & V3D_GP_SHOW_ONION_SKIN) { + stl->storage->is_main_onion = true; + } + } + /* If found, don't need loop more. */ + if ((stl->storage->is_main_overlay) && (stl->storage->is_main_onion)) { + return; + } + } + } +} + void GPENCIL_cache_init(void *vedata) { GPENCIL_PassList *psl = ((GPENCIL_Data *)vedata)->psl; @@ -391,10 +430,15 @@ void GPENCIL_cache_init(void *vedata) stl->storage->reset_cache = true; } stl->storage->is_playing = playing; + + /* Found if main overlay and onion switches are enabled in any screen. */ + gpencil_check_screen_switches(draw_ctx, stl); } else { stl->storage->is_playing = false; stl->storage->reset_cache = false; + stl->storage->is_main_overlay = false; + stl->storage->is_main_onion = false; } /* save render state */ stl->storage->is_render = DRW_state_is_image_render(); diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h b/source/blender/draw/engines/gpencil/gpencil_engine.h index 10cab248317..36bc205f41a 100644 --- a/source/blender/draw/engines/gpencil/gpencil_engine.h +++ b/source/blender/draw/engines/gpencil/gpencil_engine.h @@ -143,6 +143,8 @@ typedef struct GPENCIL_Storage { bool is_playing; bool is_render; bool is_mat_preview; + bool is_main_overlay; + bool is_main_onion; bool background_ready; int is_xray; bool is_ontop; diff --git a/source/blender/draw/engines/workbench/workbench_private.h b/source/blender/draw/engines/workbench/workbench_private.h index f28cf12405e..595b92d19d0 100644 --- a/source/blender/draw/engines/workbench/workbench_private.h +++ b/source/blender/draw/engines/workbench/workbench_private.h @@ -407,7 +407,8 @@ BLI_INLINE eGPUTextureFormat workbench_color_texture_format(const WORKBENCH_Priv return result; } -BLI_INLINE bool workbench_background_dither_factor(const WORKBENCH_PrivateData *wpd) { +BLI_INLINE bool workbench_background_dither_factor(const WORKBENCH_PrivateData *wpd) +{ /* Only apply dithering when rendering on a RGBA8 texture. * The dithering will remove banding when using a gradient as background */ return workbench_color_texture_format(wpd) == GPU_RGBA8; diff --git a/source/blender/draw/modes/edit_mesh_mode.c b/source/blender/draw/modes/edit_mesh_mode.c index 623a4a52aed..9957dbae3fb 100644 --- a/source/blender/draw/modes/edit_mesh_mode.c +++ b/source/blender/draw/modes/edit_mesh_mode.c @@ -688,7 +688,7 @@ static void edit_mesh_add_ob_to_pass(Scene *scene, skin_roots = DRW_mesh_batch_cache_get_edit_skin_roots(ob->data); /* NOTE(fclem) We cannot use ob here since it would offset the instance attribs with - * baseinstance offset. */ + * base instance offset. */ DRW_shgroup_call(grp, skin_roots, NULL); } } diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index 29d06d5b297..36583ecf060 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -1181,7 +1181,7 @@ static int select_timeline_marker_frame(ListBase *markers, LISTBASE_CIRCULAR_FORWARD_BEGIN (markers, marker, marker_selected) { /* this way a not-extend select will always give 1 selected marker */ - if ((marker->frame == frame)) { + if (marker->frame == frame) { marker->flag ^= SELECT; break; } diff --git a/source/blender/editors/interface/CMakeLists.txt b/source/blender/editors/interface/CMakeLists.txt index bc8d25e8d9e..d33023c69a1 100644 --- a/source/blender/editors/interface/CMakeLists.txt +++ b/source/blender/editors/interface/CMakeLists.txt @@ -50,6 +50,7 @@ set(SRC interface_eyedropper_datablock.c interface_eyedropper_depth.c interface_eyedropper_driver.c + interface_eyedropper_gpencil_color.c interface_handlers.c interface_icons.c interface_icons_event.c diff --git a/source/blender/editors/interface/interface_eyedropper.c b/source/blender/editors/interface/interface_eyedropper.c index 3c26c37b610..988dea270f5 100644 --- a/source/blender/editors/interface/interface_eyedropper.c +++ b/source/blender/editors/interface/interface_eyedropper.c @@ -69,6 +69,7 @@ wmKeyMap *eyedropper_modal_keymap(wmKeyConfig *keyconf) WM_modalkeymap_assign(keymap, "UI_OT_eyedropper_id"); WM_modalkeymap_assign(keymap, "UI_OT_eyedropper_depth"); WM_modalkeymap_assign(keymap, "UI_OT_eyedropper_driver"); + WM_modalkeymap_assign(keymap, "UI_OT_eyedropper_gpencil_color"); return keymap; } diff --git a/source/blender/editors/interface/interface_eyedropper_gpencil_color.c b/source/blender/editors/interface/interface_eyedropper_gpencil_color.c new file mode 100644 index 00000000000..02d4596e93c --- /dev/null +++ b/source/blender/editors/interface/interface_eyedropper_gpencil_color.c @@ -0,0 +1,324 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2009 Blender Foundation. + * All rights reserved. + */ + +/** \file + * \ingroup edinterface + * + * Eyedropper (RGB Color) + * + * Defines: + * - #UI_OT_eyedropper_gpencil_color + */ + +#include "MEM_guardedalloc.h" + +#include "BLI_string.h" + +#include "BLT_translation.h" + +#include "DNA_gpencil_types.h" +#include "DNA_space_types.h" + +#include "BKE_context.h" +#include "BKE_gpencil.h" +#include "BKE_main.h" +#include "BKE_material.h" +#include "BKE_report.h" + +#include "UI_interface.h" + +#include "IMB_colormanagement.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "RNA_access.h" +#include "RNA_define.h" + +#include "ED_gpencil.h" +#include "ED_screen.h" +#include "ED_undo.h" + +#include "DEG_depsgraph.h" +#include "DEG_depsgraph_build.h" + +#include "interface_intern.h" +#include "interface_eyedropper_intern.h" + +typedef struct EyedropperGPencil { + struct ColorManagedDisplay *display; + /** color under cursor RGB */ + float color[3]; +} EyedropperGPencil; + +/* Helper: Draw status message while the user is running the operator */ +static void eyedropper_gpencil_status_indicators(bContext *C) +{ + char msg_str[UI_MAX_DRAW_STR]; + BLI_strncpy( + msg_str, TIP_("LMB: Stroke - Shift: Fill - Shift+Ctrl: Stroke + Fill"), UI_MAX_DRAW_STR); + + ED_workspace_status_text(C, msg_str); +} + +/* Initialize. */ +static bool eyedropper_gpencil_init(bContext *C, wmOperator *op) +{ + EyedropperGPencil *eye = MEM_callocN(sizeof(EyedropperGPencil), __func__); + + op->customdata = eye; + Scene *scene = CTX_data_scene(C); + + const char *display_device; + display_device = scene->display_settings.display_device; + eye->display = IMB_colormanagement_display_get_named(display_device); + + return true; +} + +/* Exit and free memory. */ +static void eyedropper_gpencil_exit(bContext *C, wmOperator *op) +{ + /* Clear status message area. */ + ED_workspace_status_text(C, NULL); + + MEM_SAFE_FREE(op->customdata); +} + +/* Set the material. */ +static void eyedropper_gpencil_color_set(bContext *C, const wmEvent *event, EyedropperGPencil *eye) +{ + Main *bmain = CTX_data_main(C); + Object *ob = CTX_data_active_object(C); + Material *ma = NULL; + + const bool only_stroke = ((!event->ctrl) && (!event->shift)); + const bool only_fill = ((!event->ctrl) && (event->shift)); + const bool both = ((event->ctrl) && (event->shift)); + + float col_conv[4]; + bool found = false; + + /* Convert from linear rgb space to display space because grease pencil colors are in display + * space, and this conversion is needed to undo the conversion to linear performed by + * eyedropper_color_sample_fl. */ + if (eye->display) { + copy_v3_v3(col_conv, eye->color); + IMB_colormanagement_scene_linear_to_display_v3(col_conv, eye->display); + } + else { + copy_v3_v3(col_conv, eye->color); + } + + /* Look for a similar material in grease pencil slots. */ + short *totcol = give_totcolp(ob); + for (short i = 0; i < *totcol; i++) { + ma = give_current_material(ob, i + 1); + if (ma == NULL) { + continue; + } + + MaterialGPencilStyle *gp_style = ma->gp_style; + if (gp_style != NULL) { + /* Check stroke color. */ + bool found_stroke = compare_v3v3(gp_style->stroke_rgba, col_conv, 0.01f) && + (gp_style->flag & GP_STYLE_STROKE_SHOW); + /* Check fill color. */ + bool found_fill = compare_v3v3(gp_style->fill_rgba, col_conv, 0.01f) && + (gp_style->flag & GP_STYLE_FILL_SHOW); + + if ((only_stroke) && (found_stroke) && ((gp_style->flag & GP_STYLE_FILL_SHOW) == 0)) { + found = true; + } + else if ((only_fill) && (found_fill) && ((gp_style->flag & GP_STYLE_STROKE_SHOW) == 0)) { + found = true; + } + else if ((both) && (found_stroke) && (found_fill)) { + found = true; + } + + /* Found existing material. */ + if (found) { + ob->actcol = i + 1; + WM_main_add_notifier(NC_MATERIAL | ND_SHADING_LINKS, NULL); + WM_main_add_notifier(NC_SPACE | ND_SPACE_VIEW3D, NULL); + return; + } + } + } + + /* If material was not found add a new material with stroke and/or fill color + * depending of the secondary key (LMB: Stroke, Shift: Fill, Shift+Ctrl: Stroke/Fill) + */ + int idx; + Material *ma_new = BKE_gpencil_object_material_new(bmain, ob, "Material", &idx); + WM_main_add_notifier(NC_OBJECT | ND_OB_SHADING, &ob->id); + WM_main_add_notifier(NC_MATERIAL | ND_SHADING_LINKS, NULL); + DEG_relations_tag_update(bmain); + + BLI_assert(ma_new != NULL); + + MaterialGPencilStyle *gp_style_new = ma_new->gp_style; + BLI_assert(gp_style_new != NULL); + + /* Only create Stroke (default option). */ + if (only_stroke) { + /* Stroke color. */ + gp_style_new->flag |= GP_STYLE_STROKE_SHOW; + gp_style_new->flag &= ~GP_STYLE_FILL_SHOW; + copy_v3_v3(gp_style_new->stroke_rgba, col_conv); + zero_v4(gp_style_new->fill_rgba); + } + /* Fill Only. */ + else if (only_fill) { + /* Fill color. */ + gp_style_new->flag &= ~GP_STYLE_STROKE_SHOW; + gp_style_new->flag |= GP_STYLE_FILL_SHOW; + zero_v4(gp_style_new->stroke_rgba); + copy_v3_v3(gp_style_new->fill_rgba, col_conv); + } + /* Stroke and Fill. */ + else if (both) { + gp_style_new->flag |= GP_STYLE_STROKE_SHOW | GP_STYLE_FILL_SHOW; + copy_v3_v3(gp_style_new->stroke_rgba, col_conv); + copy_v3_v3(gp_style_new->fill_rgba, col_conv); + } + /* Push undo for new created material. */ + ED_undo_push(C, "Add Grease Pencil Material"); +} + +/* Sample the color below cursor. */ +static void eyedropper_gpencil_color_sample(bContext *C, EyedropperGPencil *eye, int mx, int my) +{ + eyedropper_color_sample_fl(C, mx, my, eye->color); +} + +/* Cancel operator. */ +static void eyedropper_gpencil_cancel(bContext *C, wmOperator *op) +{ + eyedropper_gpencil_exit(C, op); +} + +/* Main modal status check. */ +static int eyedropper_gpencil_modal(bContext *C, wmOperator *op, const wmEvent *event) +{ + EyedropperGPencil *eye = (EyedropperGPencil *)op->customdata; + /* Handle modal keymap */ + switch (event->type) { + case EVT_MODAL_MAP: { + switch (event->val) { + case EYE_MODAL_SAMPLE_BEGIN: { + return OPERATOR_RUNNING_MODAL; + } + case EYE_MODAL_CANCEL: { + eyedropper_gpencil_cancel(C, op); + return OPERATOR_CANCELLED; + } + case EYE_MODAL_SAMPLE_CONFIRM: { + eyedropper_gpencil_color_sample(C, eye, event->x, event->y); + + /* Create material. */ + eyedropper_gpencil_color_set(C, event, eye); + WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL); + + eyedropper_gpencil_exit(C, op); + return OPERATOR_FINISHED; + break; + } + default: { + break; + } + } + break; + } + case MOUSEMOVE: + case INBETWEEN_MOUSEMOVE: { + eyedropper_gpencil_color_sample(C, eye, event->x, event->y); + break; + } + default: { + break; + } + } + + return OPERATOR_RUNNING_MODAL; +} + +/* Modal Operator init */ +static int eyedropper_gpencil_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) +{ + /* Init. */ + if (eyedropper_gpencil_init(C, op)) { + /* Add modal temp handler. */ + WM_event_add_modal_handler(C, op); + /* Status message. */ + eyedropper_gpencil_status_indicators(C); + + return OPERATOR_RUNNING_MODAL; + } + else { + return OPERATOR_PASS_THROUGH; + } +} + +/* Repeat operator */ +static int eyedropper_gpencil_exec(bContext *C, wmOperator *op) +{ + /* init */ + if (eyedropper_gpencil_init(C, op)) { + + /* cleanup */ + eyedropper_gpencil_exit(C, op); + + return OPERATOR_FINISHED; + } + else { + return OPERATOR_PASS_THROUGH; + } +} + +static bool eyedropper_gpencil_poll(bContext *C) +{ + /* Only valid if the current active object is grease pencil. */ + Object *obact = CTX_data_active_object(C); + if ((obact == NULL) || (obact->type != OB_GPENCIL)) { + return false; + } + + /* Test we have a window below. */ + return (CTX_wm_window(C) != NULL); +} + +void UI_OT_eyedropper_gpencil_color(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Grease Pencil Eyedropper"; + ot->idname = "UI_OT_eyedropper_gpencil_color"; + ot->description = "Sample a color from the Blender Window and create Grease Pencil material"; + + /* api callbacks */ + ot->invoke = eyedropper_gpencil_invoke; + ot->modal = eyedropper_gpencil_modal; + ot->cancel = eyedropper_gpencil_cancel; + ot->exec = eyedropper_gpencil_exec; + ot->poll = eyedropper_gpencil_poll; + + /* flags */ + ot->flag = OPTYPE_UNDO | OPTYPE_BLOCKING; +} diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 4351b75eb86..81979b1fc8f 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -971,6 +971,9 @@ void UI_OT_eyedropper_depth(struct wmOperatorType *ot); /* interface_eyedropper_driver.c */ void UI_OT_eyedropper_driver(struct wmOperatorType *ot); +/* interface_eyedropper_gpencil_color.c */ +void UI_OT_eyedropper_gpencil_color(struct wmOperatorType *ot); + /* interface_util.c */ /** diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index 4e56a02997b..7ce4242c697 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -1751,6 +1751,7 @@ void ED_operatortypes_ui(void) WM_operatortype_append(UI_OT_eyedropper_id); WM_operatortype_append(UI_OT_eyedropper_depth); WM_operatortype_append(UI_OT_eyedropper_driver); + WM_operatortype_append(UI_OT_eyedropper_gpencil_color); } /** diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index c068fbdf7cb..9957fe0515c 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -2869,7 +2869,7 @@ void ED_region_info_draw(ARegion *ar, float fill_color[4], const bool full_redraw) { - ED_region_info_draw_multiline(ar, (const char * [2]){text, NULL}, fill_color, full_redraw); + ED_region_info_draw_multiline(ar, (const char *[2]){text, NULL}, fill_color, full_redraw); } #define MAX_METADATA_STR 1024 diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 5ea95383892..3cdcc07f081 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -2395,60 +2395,49 @@ void FILE_OT_filenum(struct wmOperatorType *ot) RNA_def_int(ot->srna, "increment", 1, -100, 100, "Increment", "", -100, 100); } -static int file_rename_exec(bContext *C, wmOperator *UNUSED(op)) +static void file_rename_state_activate(SpaceFile *sfile, int file_idx, bool require_selected) { - ScrArea *sa = CTX_wm_area(C); - SpaceFile *sfile = (SpaceFile *)CTX_wm_space_data(C); + const int numfiles = filelist_files_ensure(sfile->files); - if (sfile->params) { - int idx = sfile->params->highlight_file; - int numfiles = filelist_files_ensure(sfile->files); - if ((0 <= idx) && (idx < numfiles)) { - FileDirEntry *file = filelist_file(sfile->files, idx); + if ((file_idx >= 0) && (file_idx < numfiles)) { + FileDirEntry *file = filelist_file(sfile->files, file_idx); + + if ((require_selected == false) || + (filelist_entry_select_get(sfile->files, file, CHECK_ALL) & FILE_SEL_SELECTED)) { filelist_entry_select_index_set( - sfile->files, idx, FILE_SEL_ADD, FILE_SEL_EDITING, CHECK_ALL); + sfile->files, file_idx, FILE_SEL_ADD, FILE_SEL_EDITING, CHECK_ALL); BLI_strncpy(sfile->params->renamefile, file->relpath, FILE_MAXFILE); /* We can skip the pending state, * as we can directly set FILE_SEL_EDITING on the expected entry here. */ sfile->params->rename_flag = FILE_PARAMS_RENAME_ACTIVE; } + } +} + +static int file_rename_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event)) +{ + ScrArea *sa = CTX_wm_area(C); + SpaceFile *sfile = (SpaceFile *)CTX_wm_space_data(C); + + if (sfile->params) { + file_rename_state_activate(sfile, sfile->params->active_file, true); ED_area_tag_redraw(sa); } return OPERATOR_FINISHED; } -static bool file_rename_poll(bContext *C) +static int file_rename_exec(bContext *C, wmOperator *UNUSED(op)) { - bool poll = ED_operator_file_active(C); - SpaceFile *sfile = CTX_wm_space_file(C); - - if (sfile && sfile->params) { - int idx = sfile->params->highlight_file; - int numfiles = filelist_files_ensure(sfile->files); - - if ((0 <= idx) && (idx < numfiles)) { - FileDirEntry *file = filelist_file(sfile->files, idx); - if (FILENAME_IS_CURRPAR(file->relpath)) { - poll = false; - } - } + ScrArea *sa = CTX_wm_area(C); + SpaceFile *sfile = (SpaceFile *)CTX_wm_space_data(C); - if (sfile->params->highlight_file < 0) { - poll = false; - } - else { - char dir[FILE_MAX_LIBEXTRA]; - if (filelist_islibrary(sfile->files, dir, NULL)) { - poll = false; - } - } - } - else { - poll = false; + if (sfile->params) { + file_rename_state_activate(sfile, sfile->params->highlight_file, false); + ED_area_tag_redraw(sa); } - return poll; + return OPERATOR_FINISHED; } void FILE_OT_rename(struct wmOperatorType *ot) @@ -2459,8 +2448,9 @@ void FILE_OT_rename(struct wmOperatorType *ot) ot->idname = "FILE_OT_rename"; /* api callbacks */ + ot->invoke = file_rename_invoke; ot->exec = file_rename_exec; - ot->poll = file_rename_poll; + ot->poll = ED_operator_file_active; } static bool file_delete_poll(bContext *C) diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index ba4ccb4fba9..bb3906a961b 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -103,10 +103,9 @@ short ED_fileselect_set_params(SpaceFile *sfile) sizeof(sfile->params->dir), sizeof(sfile->params->file)); sfile->params->filter_glob[0] = '\0'; - /* set the default thumbnails size */ sfile->params->thumbnail_size = U_default.file_space_data.thumbnail_size; - /* Show size column by default. */ sfile->params->details_flags = U_default.file_space_data.details_flags; + sfile->params->filter_id = U_default.file_space_data.filter_id; } params = sfile->params; @@ -246,9 +245,6 @@ short ED_fileselect_set_params(SpaceFile *sfile) } } - /* For now, always init filterid to 'all true' */ - params->filter_id = FILTER_ID_ALL; - if (U.uiflag & USER_HIDE_DOT) { params->flag |= FILE_HIDE_DOT; } @@ -348,6 +344,7 @@ void ED_fileselect_set_params_from_userdef(SpaceFile *sfile) } sfile->params->thumbnail_size = sfile_udata->thumbnail_size; sfile->params->details_flags = sfile_udata->details_flags; + sfile->params->filter_id = sfile_udata->filter_id; /* Combine flags we take from params with the flags we take from userdef. */ sfile->params->flag = (sfile->params->flag & ~PARAMS_FLAGS_REMEMBERED) | @@ -371,6 +368,7 @@ void ED_fileselect_params_to_userdef(SpaceFile *sfile, int temp_win_size[2]) sfile_udata_new->sort_type = sfile->params->sort; sfile_udata_new->details_flags = sfile->params->details_flags; sfile_udata_new->flag = sfile->params->flag & PARAMS_FLAGS_REMEMBERED; + sfile_udata_new->filter_id = sfile->params->filter_id; if (temp_win_size) { sfile_udata_new->temp_win_sizex = temp_win_size[0]; diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index aafd36a5bb8..3ee9755cb06 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1422,18 +1422,24 @@ static void draw_grid_unit_name( { if (!rv3d->is_persp && RV3D_VIEW_IS_AXIS(rv3d->view)) { const char *grid_unit = NULL; + int font_id = BLF_default(); ED_view3d_grid_view_scale(scene, v3d, rv3d, &grid_unit); if (grid_unit) { char numstr[32] = ""; - UI_FontThemeColor(BLF_default(), TH_TEXT_HI); + UI_FontThemeColor(font_id, TH_TEXT_HI); if (v3d->grid != 1.0f) { BLI_snprintf(numstr, sizeof(numstr), "%s x %.4g", grid_unit, v3d->grid); } *yoffset -= U.widget_unit; + BLF_enable(font_id, BLF_SHADOW); + BLF_shadow(font_id, 5, (const float[4]){0.0f, 0.0f, 0.0f, 1.0f}); + BLF_shadow_offset(font_id, 1, -1); BLF_draw_default_ascii( xoffset, *yoffset, 0.0f, numstr[0] ? numstr : grid_unit, sizeof(numstr)); + + BLF_disable(font_id, BLF_SHADOW); } } } diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h index 47bf49294b6..f303f7720c3 100644 --- a/source/blender/makesdna/DNA_ID.h +++ b/source/blender/makesdna/DNA_ID.h @@ -699,10 +699,11 @@ enum { #define FILTER_ID_ALL \ (FILTER_ID_AC | FILTER_ID_AR | FILTER_ID_BR | FILTER_ID_CA | FILTER_ID_CU | FILTER_ID_GD | \ - FILTER_ID_LS | FILTER_ID_LT | FILTER_ID_MA | FILTER_ID_MB | FILTER_ID_MC | FILTER_ID_ME | \ - FILTER_ID_MSK | FILTER_ID_NT | FILTER_ID_OB | FILTER_ID_PA | FILTER_ID_PAL | FILTER_ID_PC | \ - FILTER_ID_SCE | FILTER_ID_SPK | FILTER_ID_SO | FILTER_ID_TE | FILTER_ID_TXT | FILTER_ID_VF | \ - FILTER_ID_WO | FILTER_ID_CF | FILTER_ID_WS | FILTER_ID_LP) + FILTER_ID_GR | FILTER_ID_IM | FILTER_ID_LA | FILTER_ID_LS | FILTER_ID_LT | FILTER_ID_MA | \ + FILTER_ID_MB | FILTER_ID_MC | FILTER_ID_ME | FILTER_ID_MSK | FILTER_ID_NT | FILTER_ID_OB | \ + FILTER_ID_PA | FILTER_ID_PAL | FILTER_ID_PC | FILTER_ID_SCE | FILTER_ID_SPK | FILTER_ID_SO | \ + FILTER_ID_TE | FILTER_ID_TXT | FILTER_ID_VF | FILTER_ID_WO | FILTER_ID_CF | FILTER_ID_WS | \ + FILTER_ID_LP) /* IMPORTANT: this enum matches the order currently use in set_listbasepointers, * keep them in sync! */ diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index b9f43c0e579..c726c5e132e 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -588,8 +588,7 @@ typedef struct UserDef_FileSpaceData { int sort_type; /* FileSelectParams.sort */ int details_flags; /* FileSelectParams.details_flags */ int flag; /* FileSelectParams.flag */ - - char _pad[4]; + int filter_id; /* FileSelectParams.filter_id */ /** Info used when creating the file browser in a temporary window. */ int temp_win_sizex; diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index fad9ec761aa..f9fa6e78163 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -787,13 +787,18 @@ static void rna_Space_view2d_sync_update(Main *UNUSED(bmain), static void rna_GPencil_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *UNUSED(ptr)) { + bool changed = false; /* need set all caches as dirty to recalculate onion skinning */ for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) { if (ob->type == OB_GPENCIL) { - DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); + bGPdata *gpd = (bGPdata *)ob->data; + DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY); + changed = true; } } - WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL); + if (changed) { + WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL); + } } /* Space 3D View */ @@ -5290,7 +5295,11 @@ static void rna_def_fileselect_params(BlenderRNA *brna) {FILTER_ID_TXT, "TEXT", ICON_TEXT, "Texts", "Show/hide Text data-blocks"}, {FILTER_ID_VF, "FONT", ICON_FONT_DATA, "Fonts", "Show/hide Font data-blocks"}, {FILTER_ID_WO, "WORLD", ICON_WORLD_DATA, "Worlds", "Show/hide World data-blocks"}, - {FILTER_ID_WS, "WORK_SPACE", ICON_NONE, "Workspaces", "Show/hide workspace data-blocks"}, + {FILTER_ID_WS, + "WORK_SPACE", + ICON_WORKSPACE, + "Workspaces", + "Show/hide workspace data-blocks"}, {0, NULL, 0, NULL, NULL}, }; diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c index c85a1d9ba05..c4a363e25e5 100644 --- a/source/blender/python/generic/py_capi_utils.c +++ b/source/blender/python/generic/py_capi_utils.c @@ -31,12 +31,6 @@ #include <Python.h> #include <frameobject.h> -/* Needed for 'PyInterpreterState', we should remove this dependency. */ -#if PY_VERSION_HEX >= 0x03080000 -# define Py_BUILD_CORE -# include <internal/pycore_pystate.h> -#endif - #include "BLI_utildefines.h" /* for bool */ #include "py_capi_utils.h" @@ -757,9 +751,10 @@ PyObject *PyC_UnicodeFromByte(const char *str) ****************************************************************************/ PyObject *PyC_DefaultNameSpace(const char *filename) { - PyInterpreterState *interp = PyThreadState_GET()->interp; + PyObject *modules = PyImport_GetModuleDict(); + PyObject *builtins = PyEval_GetBuiltins(); PyObject *mod_main = PyModule_New("__main__"); - PyDict_SetItemString(interp->modules, "__main__", mod_main); + PyDict_SetItemString(modules, "__main__", mod_main); Py_DECREF(mod_main); /* sys.modules owns now */ PyModule_AddStringConstant(mod_main, "__name__", "__main__"); if (filename) { @@ -767,8 +762,8 @@ PyObject *PyC_DefaultNameSpace(const char *filename) * note: this wont map to a real file when executing text-blocks and buttons. */ PyModule_AddObject(mod_main, "__file__", PyC_UnicodeFromByte(filename)); } - PyModule_AddObject(mod_main, "__builtins__", interp->builtins); - Py_INCREF(interp->builtins); /* AddObject steals a reference */ + PyModule_AddObject(mod_main, "__builtins__", builtins); + Py_INCREF(builtins); /* AddObject steals a reference */ return PyModule_GetDict(mod_main); } @@ -795,15 +790,15 @@ bool PyC_NameSpace_ImportArray(PyObject *py_dict, const char *imports[]) /* restore MUST be called after this */ void PyC_MainModule_Backup(PyObject **main_mod) { - PyInterpreterState *interp = PyThreadState_GET()->interp; - *main_mod = PyDict_GetItemString(interp->modules, "__main__"); + PyObject *modules = PyImport_GetModuleDict(); + *main_mod = PyDict_GetItemString(modules, "__main__"); Py_XINCREF(*main_mod); /* don't free */ } void PyC_MainModule_Restore(PyObject *main_mod) { - PyInterpreterState *interp = PyThreadState_GET()->interp; - PyDict_SetItemString(interp->modules, "__main__", main_mod); + PyObject *modules = PyImport_GetModuleDict(); + PyDict_SetItemString(modules, "__main__", main_mod); Py_XDECREF(main_mod); } diff --git a/source/blender/python/mathutils/mathutils_kdtree.c b/source/blender/python/mathutils/mathutils_kdtree.c index 65eac901df5..e3f2cd9bd14 100644 --- a/source/blender/python/mathutils/mathutils_kdtree.c +++ b/source/blender/python/mathutils/mathutils_kdtree.c @@ -436,7 +436,7 @@ PyTypeObject PyKDTree_Type = { (destructor)NULL, /* tp_del */ }; -PyDoc_STRVAR(py_kdtree_doc, "Generic 3-dimentional kd-tree to perform spatial searches."); +PyDoc_STRVAR(py_kdtree_doc, "Generic 3-dimensional kd-tree to perform spatial searches."); static struct PyModuleDef kdtree_moduledef = { PyModuleDef_HEAD_INIT, "mathutils.kdtree", /* m_name */ diff --git a/source/tools b/source/tools -Subproject 4ad446dbddd1b23acc185b8c056474d27b69278 +Subproject d8c4ae2c23a36d9609d47142dc72f243551258f |