WIP: Brush assets project #106303

Draft
Julian Eisel wants to merge 392 commits from brush-assets-project into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
8 changed files with 27 additions and 24 deletions
Showing only changes of commit a45de2fd4f - Show all commits

View File

@ -589,7 +589,7 @@ using uiButSearchTooltipFn =
using uiButSearchListenFn = void (*)(const wmRegionListenerParams *params, void *arg); using uiButSearchListenFn = void (*)(const wmRegionListenerParams *params, void *arg);
/** Must return an allocated string. */ /** Must return an allocated string. */
using uiButToolTipFunc = char *(*)(bContext *C, void *argN, const char *tip); using uiButToolTipFunc = std::string (*)(bContext *C, void *argN, const char *tip);
using uiButToolTipCustomFunc = void (*)(bContext *C, uiTooltipData *data, void *argN); using uiButToolTipCustomFunc = void (*)(bContext *C, uiTooltipData *data, void *argN);

View File

@ -640,7 +640,7 @@ static void *uilist_item_use_dynamic_tooltip(PointerRNA *itemptr, const char *pr
return nullptr; return nullptr;
} }
static char *uilist_item_tooltip_func(bContext * /*C*/, void *argN, const char *tip) static std::string uilist_item_tooltip_func(bContext * /*C*/, void *argN, const char *tip)
{ {
char *dyn_tooltip = static_cast<char *>(argN); char *dyn_tooltip = static_cast<char *>(argN);
std::string tooltip_string = dyn_tooltip; std::string tooltip_string = dyn_tooltip;
@ -648,7 +648,7 @@ static char *uilist_item_tooltip_func(bContext * /*C*/, void *argN, const char *
tooltip_string += '\n'; tooltip_string += '\n';
tooltip_string += tip; tooltip_string += tip;
} }
return BLI_strdupn(tooltip_string.c_str(), tooltip_string.size()); return tooltip_string;
} }
/** /**

View File

@ -6141,7 +6141,7 @@ struct ProgressTooltip_Store {
void *owner; void *owner;
}; };
static char *progress_tooltip_func(bContext * /*C*/, void *argN, const char * /*tip*/) static std::string progress_tooltip_func(bContext * /*C*/, void *argN, const char * /*tip*/)
{ {
ProgressTooltip_Store *arg = static_cast<ProgressTooltip_Store *>(argN); ProgressTooltip_Store *arg = static_cast<ProgressTooltip_Store *>(argN);
wmWindowManager *wm = arg->wm; wmWindowManager *wm = arg->wm;
@ -6160,9 +6160,9 @@ static char *progress_tooltip_func(bContext * /*C*/, void *argN, const char * /*
BLI_timecode_string_from_time_simple(remaining_str, sizeof(remaining_str), remaining); BLI_timecode_string_from_time_simple(remaining_str, sizeof(remaining_str), remaining);
} }
return BLI_sprintfN( return fmt::format(
"Time Remaining: %s\n" "Time Remaining: {}\n"
"Time Elapsed: %s", "Time Elapsed: {}",
remaining_str, remaining_str,
elapsed_str); elapsed_str);
} }

View File

@ -323,7 +323,7 @@ static void file_draw_tooltip_custom_func(bContext * /*C*/, uiTooltipData *tip,
} }
} }
static char *file_draw_asset_tooltip_func(bContext * /*C*/, void *argN, const char * /*tip*/) static std::string file_draw_asset_tooltip_func(bContext * /*C*/, void *argN, const char * /*tip*/)
{ {
const auto *asset = static_cast<blender::asset_system::AssetRepresentation *>(argN); const auto *asset = static_cast<blender::asset_system::AssetRepresentation *>(argN);
std::string complete_string = asset->get_name(); std::string complete_string = asset->get_name();
@ -332,7 +332,7 @@ static char *file_draw_asset_tooltip_func(bContext * /*C*/, void *argN, const ch
complete_string += '\n'; complete_string += '\n';
complete_string += meta_data.description; complete_string += meta_data.description;
} }
return BLI_strdupn(complete_string.c_str(), complete_string.size()); return complete_string;
} }
static void draw_tile_background(const rcti *draw_rect, int colorid, int shade) static void draw_tile_background(const rcti *draw_rect, int colorid, int shade)

View File

@ -1550,9 +1550,9 @@ static bool node_socket_has_tooltip(const bNodeTree &ntree, const bNodeSocket &s
return false; return false;
} }
static char *node_socket_get_tooltip(const SpaceNode *snode, static std::string node_socket_get_tooltip(const SpaceNode *snode,
const bNodeTree &ntree, const bNodeTree &ntree,
const bNodeSocket &socket) const bNodeSocket &socket)
{ {
TreeDrawContext tree_draw_ctx; TreeDrawContext tree_draw_ctx;
if (snode != nullptr) { if (snode != nullptr) {
@ -1601,7 +1601,7 @@ static char *node_socket_get_tooltip(const SpaceNode *snode,
output << bke::nodeSocketLabel(&socket); output << bke::nodeSocketLabel(&socket);
} }
return BLI_strdup(output.str().c_str()); return output.str();
} }
static void node_socket_add_tooltip_in_node_editor(const bNodeTree &ntree, static void node_socket_add_tooltip_in_node_editor(const bNodeTree &ntree,
@ -2301,7 +2301,7 @@ struct NodeErrorsTooltipData {
Span<geo_log::NodeWarning> warnings; Span<geo_log::NodeWarning> warnings;
}; };
static char *node_errors_tooltip_fn(bContext * /*C*/, void *argN, const char * /*tip*/) static std::string node_errors_tooltip_fn(bContext * /*C*/, void *argN, const char * /*tip*/)
{ {
NodeErrorsTooltipData &data = *(NodeErrorsTooltipData *)argN; NodeErrorsTooltipData &data = *(NodeErrorsTooltipData *)argN;
@ -2318,7 +2318,7 @@ static char *node_errors_tooltip_fn(bContext * /*C*/, void *argN, const char * /
/* Let the tooltip system automatically add the last period. */ /* Let the tooltip system automatically add the last period. */
complete_string += data.warnings.last().message; complete_string += data.warnings.last().message;
return BLI_strdupn(complete_string.c_str(), complete_string.size()); return complete_string;
} }
#define NODE_HEADER_ICON_SIZE (0.8f * U.widget_unit) #define NODE_HEADER_ICON_SIZE (0.8f * U.widget_unit)
@ -2500,7 +2500,7 @@ struct NamedAttributeTooltipArg {
Map<StringRefNull, geo_log::NamedAttributeUsage> usage_by_attribute; Map<StringRefNull, geo_log::NamedAttributeUsage> usage_by_attribute;
}; };
static char *named_attribute_tooltip(bContext * /*C*/, void *argN, const char * /*tip*/) static std::string named_attribute_tooltip(bContext * /*C*/, void *argN, const char * /*tip*/)
{ {
NamedAttributeTooltipArg &arg = *static_cast<NamedAttributeTooltipArg *>(argN); NamedAttributeTooltipArg &arg = *static_cast<NamedAttributeTooltipArg *>(argN);
@ -2547,7 +2547,7 @@ static char *named_attribute_tooltip(bContext * /*C*/, void *argN, const char *
ss << "\n"; ss << "\n";
ss << TIP_( ss << TIP_(
"Attributes with these names used within the group may conflict with existing attributes"); "Attributes with these names used within the group may conflict with existing attributes");
return BLI_strdup(ss.str().c_str()); return ss.str();
} }
static NodeExtraInfoRow row_from_used_named_attribute( static NodeExtraInfoRow row_from_used_named_attribute(

View File

@ -92,10 +92,10 @@ static void displayed_channel_range_get(const SeqChannelDrawContext *context,
CLAMP(r_channel_range[1], strip_boundbox.ymin, MAXSEQ); CLAMP(r_channel_range[1], strip_boundbox.ymin, MAXSEQ);
} }
static char *draw_channel_widget_tooltip(bContext * /*C*/, void *argN, const char * /*tip*/) static std::string draw_channel_widget_tooltip(bContext * /*C*/, void *argN, const char * /*tip*/)
{ {
char *dyn_tooltip = static_cast<char *>(argN); char *dyn_tooltip = static_cast<char *>(argN);
return BLI_strdup(dyn_tooltip); return dyn_tooltip;
} }
static float draw_channel_widget_mute(const SeqChannelDrawContext *context, static float draw_channel_widget_mute(const SeqChannelDrawContext *context,

View File

@ -13,6 +13,7 @@ set(INC
../../makesrna ../../makesrna
../../nodes ../../nodes
../../windowmanager ../../windowmanager
../../../../extern/fmtlib/include
# RNA_prototypes.h # RNA_prototypes.h
${CMAKE_BINARY_DIR}/source/blender/makesrna ${CMAKE_BINARY_DIR}/source/blender/makesrna

View File

@ -5,6 +5,8 @@
#include <iomanip> #include <iomanip>
#include <sstream> #include <sstream>
#include <fmt/format.h>
#include "BLI_math_color.hh" #include "BLI_math_color.hh"
#include "BLI_math_quaternion_types.hh" #include "BLI_math_quaternion_types.hh"
#include "BLI_math_vector_types.hh" #include "BLI_math_vector_types.hh"
@ -389,11 +391,11 @@ class SpreadsheetLayoutDrawer : public SpreadsheetDrawer {
[](bContext * /*C*/, void *argN, const char * /*tip*/) { [](bContext * /*C*/, void *argN, const char * /*tip*/) {
const uint32_t uint_color = POINTER_AS_UINT(argN); const uint32_t uint_color = POINTER_AS_UINT(argN);
ColorGeometry4b color = *(ColorGeometry4b *)&uint_color; ColorGeometry4b color = *(ColorGeometry4b *)&uint_color;
return BLI_sprintfN(TIP_("Byte Color (sRGB encoded):\n%3d %3d %3d %3d"), return fmt::format(TIP_("Byte Color (sRGB encoded):\n{} {} {} {}"),
color.r, color.r,
color.g, color.g,
color.b, color.b,
color.a); color.a);
}, },
POINTER_FROM_UINT(*(uint32_t *)&color), POINTER_FROM_UINT(*(uint32_t *)&color),
nullptr); nullptr);