From c9285f83abac4c8d0763d1a618647ce48d756382 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Thu, 16 Feb 2023 13:47:13 +0100 Subject: [PATCH 1/5] Fix #104698: Assert and failure adding shortcuts to curves sculpt tools The keymap name in `WM_keymap_guess_from_context` didn't match the name of the keymap in the Blender default keymap (`km_sculpt_curves`). Fix by changing the utility function to match the keymap name. Before right clicking on any tool in curves sculpt mode gave an assert, now it shows a context menu. Pull Request #104791 --- source/blender/windowmanager/intern/wm_keymap_utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/windowmanager/intern/wm_keymap_utils.c b/source/blender/windowmanager/intern/wm_keymap_utils.c index 0817b10f86e..cf8c0ebb859 100644 --- a/source/blender/windowmanager/intern/wm_keymap_utils.c +++ b/source/blender/windowmanager/intern/wm_keymap_utils.c @@ -141,7 +141,7 @@ wmKeyMap *WM_keymap_guess_from_context(const bContext *C) km_id = "Grease Pencil Stroke Vertex Mode"; break; case CTX_MODE_SCULPT_CURVES: - km_id = "Curves Sculpt"; + km_id = "Sculpt Curves"; break; } } -- 2.30.2 From 9d15b3f4248dd965dbd26907f65f783f6845c17c Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Thu, 16 Feb 2023 13:48:39 +0100 Subject: [PATCH 2/5] Fix #104697: Curves Sculpt: Setting brush shortcuts does not work The active tools in `_defs_curves_sculpt` don't use names that are exactly the same as the corresponding brush name with "builtin_brush." at the beginning, instead they use more standard identifiers without capitals or spaces. The "brush_select" utility operator assumed the names matched though. That can be fixed by manually mapping the brushes to the active tools. Pull Request #104792 --- .../blender/editors/sculpt_paint/paint_ops.cc | 50 +++++++++++++++++-- 1 file changed, 46 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/sculpt_paint/paint_ops.cc b/source/blender/editors/sculpt_paint/paint_ops.cc index c8216bda59d..ca102b5a0b8 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.cc +++ b/source/blender/editors/sculpt_paint/paint_ops.cc @@ -832,6 +832,36 @@ static Brush *brush_tool_toggle(Main *bmain, Paint *paint, Brush *brush_orig, co return nullptr; } +/** The name of the active tool is "builtin_brush." concatenated with the returned string. */ +static blender::StringRefNull curves_active_tool_name_get(const eBrushCurvesSculptTool tool) +{ + switch (tool) { + case CURVES_SCULPT_TOOL_COMB: + return "comb"; + case CURVES_SCULPT_TOOL_DELETE: + return "delete"; + case CURVES_SCULPT_TOOL_SNAKE_HOOK: + return "snake_hook"; + case CURVES_SCULPT_TOOL_ADD: + return "add"; + case CURVES_SCULPT_TOOL_GROW_SHRINK: + return "grow_shrink"; + case CURVES_SCULPT_TOOL_SELECTION_PAINT: + return "selection_paint"; + case CURVES_SCULPT_TOOL_PINCH: + return "pinch"; + case CURVES_SCULPT_TOOL_SMOOTH: + return "smooth"; + case CURVES_SCULPT_TOOL_PUFF: + return "puff"; + case CURVES_SCULPT_TOOL_DENSITY: + return "density"; + case CURVES_SCULPT_TOOL_SLIDE: + return "slide"; + } + return ""; +} + static bool brush_generic_tool_set(bContext *C, Main *bmain, Paint *paint, @@ -869,8 +899,14 @@ static bool brush_generic_tool_set(bContext *C, * tool_name again. */ int tool_result = brush_tool(brush, paint->runtime.tool_offset); ePaintMode paint_mode = BKE_paintmode_get_active_from_context(C); - const EnumPropertyItem *items = BKE_paint_get_tool_enum_from_paintmode(paint_mode); - RNA_enum_name_from_value(items, tool_result, &tool_name); + + if (paint_mode == PAINT_MODE_SCULPT_CURVES) { + tool_name = curves_active_tool_name_get(eBrushCurvesSculptTool(tool)).c_str(); + } + else { + const EnumPropertyItem *items = BKE_paint_get_tool_enum_from_paintmode(paint_mode); + RNA_enum_name_from_value(items, tool_result, &tool_name); + } char tool_id[MAX_NAME]; SNPRINTF(tool_id, "builtin_brush.%s", tool_name); @@ -921,8 +957,14 @@ static int brush_select_exec(bContext *C, wmOperator *op) if (paint == nullptr) { return OPERATOR_CANCELLED; } - const EnumPropertyItem *items = BKE_paint_get_tool_enum_from_paintmode(paint_mode); - RNA_enum_name_from_value(items, tool, &tool_name); + + if (paint_mode == PAINT_MODE_SCULPT_CURVES) { + tool_name = curves_active_tool_name_get(eBrushCurvesSculptTool(tool)).c_str(); + } + else { + const EnumPropertyItem *items = BKE_paint_get_tool_enum_from_paintmode(paint_mode); + RNA_enum_name_from_value(items, tool, &tool_name); + } if (brush_generic_tool_set(C, bmain, paint, tool, tool_name, create_missing, toggle)) { return OPERATOR_FINISHED; -- 2.30.2 From c785e7431e1c68035d4816c555aac8f05b3d0265 Mon Sep 17 00:00:00 2001 From: Pablo Vazquez Date: Thu, 16 Feb 2023 14:39:41 +0100 Subject: [PATCH 3/5] Themes: Fix several issues in Blender Light theme * Fix #92539: Hard to read the breadcrumbs. * Fix View Item active, hover, and text color (e.g. count numbers in the Spreadsheet were almost unreadable). * Fix mismatching node type colors with the default theme. Blender Light is meant to be simply a brighter version of the default, so screenshots and tutorials can be followed with both themes. * Use the same outline color for widgets, so they match when aligned in a row. * Make panels standout (not fully transparent), like in the default theme. --- .../presets/interface_theme/Blender_Light.xml | 277 ++++++++++-------- 1 file changed, 151 insertions(+), 126 deletions(-) diff --git a/release/scripts/presets/interface_theme/Blender_Light.xml b/release/scripts/presets/interface_theme/Blender_Light.xml index 49955bc3ff9..68245c53525 100644 --- a/release/scripts/presets/interface_theme/Blender_Light.xml +++ b/release/scripts/presets/interface_theme/Blender_Light.xml @@ -29,11 +29,11 @@ icon_modifier="#84b8ffff" icon_shading="#ea7581ff" icon_folder="#e3c16eff" - icon_border_intensity="0.85" + icon_border_intensity="1" > + + + + @@ -519,9 +535,9 @@ > @@ -552,7 +568,7 @@ header="#adadadff" header_text="#000000" header_text_hi="#ffffff" - button="#999999e6" + button="#b3b3b3ff" button_title="#1a1a1a" button_text="#000000" button_text_hi="#000000" @@ -565,9 +581,9 @@ > @@ -623,9 +639,9 @@ > @@ -698,9 +714,9 @@ > @@ -783,9 +799,9 @@ > @@ -843,14 +859,23 @@ > + + + + @@ -871,7 +896,7 @@ button_title="#000000" button_text="#000000" button_text_hi="#000000" - navigation_bar="#656565ff" + navigation_bar="#1d1d1dff" execution_buts="#00000000" tab_active="#6697e6" tab_inactive="#535353" @@ -880,9 +905,9 @@ > @@ -927,9 +952,9 @@ > @@ -939,44 +964,44 @@ @@ -1013,8 +1038,8 @@ @@ -1091,9 +1116,9 @@ > @@ -1125,9 +1150,9 @@ > @@ -1137,26 +1162,26 @@ @@ -1231,9 +1256,9 @@ > @@ -1274,9 +1299,9 @@ > @@ -1292,7 +1317,7 @@ title="#ffffff" text="#ffffff" text_hi="#ffffff" - header="#adadadff" + header="#999999ff" header_text="#1a1a1a" header_text_hi="#ffffff" button="#2f303500" @@ -1308,9 +1333,9 @@ > @@ -1331,7 +1356,7 @@ header="#adadadff" header_text="#000000" header_text_hi="#ffffff" - button="#999999e6" + button="#b3b3b3ff" button_title="#1a1a1a" button_text="#000000" button_text_hi="#000000" @@ -1344,9 +1369,9 @@ > @@ -1585,8 +1610,8 @@ shadow="3" shadow_offset_x="0" shadow_offset_y="-1" - shadow_alpha="0.3" - shadow_value="0.7" + shadow_alpha="1" + shadow_value="0.8" > @@ -1596,8 +1621,8 @@ shadow="3" shadow_offset_x="0" shadow_offset_y="-1" - shadow_alpha="0.3" - shadow_value="0.7" + shadow_alpha="0" + shadow_value="0.8" > @@ -1607,8 +1632,8 @@ shadow="1" shadow_offset_x="0" shadow_offset_y="-1" - shadow_alpha="0.3" - shadow_value="0.7" + shadow_alpha="0" + shadow_value="0.8" > -- 2.30.2 From 0620ec4df9bb5e45c6f0ccf811cdb1279468cfa3 Mon Sep 17 00:00:00 2001 From: Falk David Date: Thu, 16 Feb 2023 11:55:14 +0100 Subject: [PATCH 4/5] Curves: Add remove_selection function This adds a `remove_selection` function that can be used by other objects that make use of `CurvesGeometry`. --- source/blender/editors/curves/CMakeLists.txt | 1 + .../editors/curves/intern/curves_edit.cc | 38 +++++++++++++++++++ .../editors/curves/intern/curves_ops.cc | 20 +--------- source/blender/editors/include/ED_curves.h | 8 ++++ 4 files changed, 49 insertions(+), 18 deletions(-) create mode 100644 source/blender/editors/curves/intern/curves_edit.cc diff --git a/source/blender/editors/curves/CMakeLists.txt b/source/blender/editors/curves/CMakeLists.txt index 873df89b40c..36eb0e04647 100644 --- a/source/blender/editors/curves/CMakeLists.txt +++ b/source/blender/editors/curves/CMakeLists.txt @@ -23,6 +23,7 @@ set(INC set(SRC intern/curves_add.cc intern/curves_data.cc + intern/curves_edit.cc intern/curves_ops.cc intern/curves_selection.cc intern/curves_undo.cc diff --git a/source/blender/editors/curves/intern/curves_edit.cc b/source/blender/editors/curves/intern/curves_edit.cc new file mode 100644 index 00000000000..9d5e7730ba0 --- /dev/null +++ b/source/blender/editors/curves/intern/curves_edit.cc @@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +/** \file + * \ingroup edcurves + */ + +#include "BLI_index_mask_ops.hh" + +#include "BKE_curves.hh" + +#include "ED_curves.h" + +namespace blender::ed::curves { + +bool remove_selection(bke::CurvesGeometry &curves, const eAttrDomain selection_domain) +{ + const bke::AttributeAccessor attributes = curves.attributes(); + const VArray selection = attributes.lookup_or_default( + ".selection", selection_domain, true); + const int domain_size_orig = attributes.domain_size(selection_domain); + Vector indices; + const IndexMask mask = index_mask_ops::find_indices_from_virtual_array( + selection.index_range(), selection, 4096, indices); + switch (selection_domain) { + case ATTR_DOMAIN_POINT: + curves.remove_points(mask); + break; + case ATTR_DOMAIN_CURVE: + curves.remove_curves(mask); + break; + default: + BLI_assert_unreachable(); + } + + return attributes.domain_size(selection_domain) != domain_size_orig; +} + +} // namespace blender::ed::curves diff --git a/source/blender/editors/curves/intern/curves_ops.cc b/source/blender/editors/curves/intern/curves_ops.cc index d9496cf6e25..fa3792ceae5 100644 --- a/source/blender/editors/curves/intern/curves_ops.cc +++ b/source/blender/editors/curves/intern/curves_ops.cc @@ -1097,24 +1097,8 @@ static int delete_exec(bContext *C, wmOperator * /*op*/) { for (Curves *curves_id : get_unique_editable_curves(*C)) { bke::CurvesGeometry &curves = curves_id->geometry.wrap(); - const eAttrDomain domain = eAttrDomain(curves_id->selection_domain); - const bke::AttributeAccessor attributes = curves.attributes(); - const VArray selection = attributes.lookup_or_default(".selection", domain, false); - const int domain_size_orig = attributes.domain_size(domain); - Vector indices; - const IndexMask mask = index_mask_ops::find_indices_from_virtual_array( - selection.index_range(), selection, 4096, indices); - switch (domain) { - case ATTR_DOMAIN_POINT: - curves.remove_points(mask); - break; - case ATTR_DOMAIN_CURVE: - curves.remove_curves(mask); - break; - default: - BLI_assert_unreachable(); - } - if (attributes.domain_size(domain) != domain_size_orig) { + + if (remove_selection(curves, eAttrDomain(curves_id->selection_domain))) { DEG_id_tag_update(&curves_id->id, ID_RECALC_GEOMETRY); WM_event_add_notifier(C, NC_GEOM | ND_DATA, curves_id); } diff --git a/source/blender/editors/include/ED_curves.h b/source/blender/editors/include/ED_curves.h index 2bfe99ea2bd..d2e17c994a5 100644 --- a/source/blender/editors/include/ED_curves.h +++ b/source/blender/editors/include/ED_curves.h @@ -185,5 +185,13 @@ bool select_circle(const ViewContext &vc, eSelectOp sel_op); /** \} */ +/* -------------------------------------------------------------------- */ +/** \name Editing + * \{ */ + +bool remove_selection(bke::CurvesGeometry &curves, eAttrDomain selection_domain); + +/** \} */ + } // namespace blender::ed::curves #endif -- 2.30.2 From 1b5eddca705da1a23376065f6887ba410da01a7f Mon Sep 17 00:00:00 2001 From: Falk David Date: Thu, 16 Feb 2023 14:42:27 +0100 Subject: [PATCH 5/5] Cleanup --- source/blender/editors/curves/intern/curves_ops.cc | 1 - source/blender/editors/include/ED_curves.h | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/curves/intern/curves_ops.cc b/source/blender/editors/curves/intern/curves_ops.cc index fa3792ceae5..080307ef2bd 100644 --- a/source/blender/editors/curves/intern/curves_ops.cc +++ b/source/blender/editors/curves/intern/curves_ops.cc @@ -1097,7 +1097,6 @@ static int delete_exec(bContext *C, wmOperator * /*op*/) { for (Curves *curves_id : get_unique_editable_curves(*C)) { bke::CurvesGeometry &curves = curves_id->geometry.wrap(); - if (remove_selection(curves, eAttrDomain(curves_id->selection_domain))) { DEG_id_tag_update(&curves_id->id, ID_RECALC_GEOMETRY); WM_event_add_notifier(C, NC_GEOM | ND_DATA, curves_id); diff --git a/source/blender/editors/include/ED_curves.h b/source/blender/editors/include/ED_curves.h index d2e17c994a5..d9d6c0c2863 100644 --- a/source/blender/editors/include/ED_curves.h +++ b/source/blender/editors/include/ED_curves.h @@ -189,6 +189,10 @@ bool select_circle(const ViewContext &vc, /** \name Editing * \{ */ +/** + * Remove (dissolve) selected curves or points based on the ".selection" attribute. + * \returns true if any point or curve was removed. + */ bool remove_selection(bke::CurvesGeometry &curves, eAttrDomain selection_domain); /** \} */ -- 2.30.2