WIP: Brush assets project #106303

Draft
Julian Eisel wants to merge 381 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.
1 changed files with 26 additions and 26 deletions
Showing only changes of commit ef18df9db5 - Show all commits

View File

@ -6605,7 +6605,7 @@ void UI_but_string_info_get(bContext *C, uiBut *but, ...)
tmp = but->tip_func(C, but->tip_arg, but->tip); tmp = but->tip_func(C, but->tip_arg, but->tip);
} }
else if (but->tip && but->tip[0]) { else if (but->tip && but->tip[0]) {
tmp = BLI_strdup(but->tip); tmp = but->tip;
} }
else { else {
type = BUT_GET_RNA_TIP; /* Fail-safe solution... */ type = BUT_GET_RNA_TIP; /* Fail-safe solution... */
@ -6614,49 +6614,49 @@ void UI_but_string_info_get(bContext *C, uiBut *but, ...)
if (type == BUT_GET_RNAPROP_IDENTIFIER) { if (type == BUT_GET_RNAPROP_IDENTIFIER) {
if (but->rnaprop) { if (but->rnaprop) {
tmp = BLI_strdup(RNA_property_identifier(but->rnaprop)); tmp = RNA_property_identifier(but->rnaprop);
} }
} }
else if (type == BUT_GET_RNASTRUCT_IDENTIFIER) { else if (type == BUT_GET_RNASTRUCT_IDENTIFIER) {
if (but->rnaprop && but->rnapoin.data) { if (but->rnaprop && but->rnapoin.data) {
tmp = BLI_strdup(RNA_struct_identifier(but->rnapoin.type)); tmp = RNA_struct_identifier(but->rnapoin.type);
} }
else if (but->optype) { else if (but->optype) {
tmp = BLI_strdup(but->optype->idname); tmp = but->optype->idname;
} }
else if (ELEM(but->type, UI_BTYPE_MENU, UI_BTYPE_PULLDOWN)) { else if (ELEM(but->type, UI_BTYPE_MENU, UI_BTYPE_PULLDOWN)) {
MenuType *mt = UI_but_menutype_get(but); MenuType *mt = UI_but_menutype_get(but);
if (mt) { if (mt) {
tmp = BLI_strdup(mt->idname); tmp = mt->idname;
} }
} }
else if (but->type == UI_BTYPE_POPOVER) { else if (but->type == UI_BTYPE_POPOVER) {
PanelType *pt = UI_but_paneltype_get(but); PanelType *pt = UI_but_paneltype_get(but);
if (pt) { if (pt) {
tmp = BLI_strdup(pt->idname); tmp = pt->idname;
} }
} }
} }
else if (ELEM(type, BUT_GET_RNA_LABEL, BUT_GET_RNA_TIP)) { else if (ELEM(type, BUT_GET_RNA_LABEL, BUT_GET_RNA_TIP)) {
if (but->rnaprop) { if (but->rnaprop) {
if (type == BUT_GET_RNA_LABEL) { if (type == BUT_GET_RNA_LABEL) {
tmp = BLI_strdup(RNA_property_ui_name(but->rnaprop)); tmp = RNA_property_ui_name(but->rnaprop);
} }
else { else {
const char *t = RNA_property_ui_description(but->rnaprop); const char *t = RNA_property_ui_description(but->rnaprop);
if (t && t[0]) { if (t && t[0]) {
tmp = BLI_strdup(t); tmp = t;
} }
} }
} }
else if (but->optype) { else if (but->optype) {
if (type == BUT_GET_RNA_LABEL) { if (type == BUT_GET_RNA_LABEL) {
tmp = BLI_strdup(WM_operatortype_name(but->optype, opptr).c_str()); tmp = WM_operatortype_name(but->optype, opptr).c_str();
} }
else { else {
const bContextStore *previous_ctx = CTX_store_get(C); const bContextStore *previous_ctx = CTX_store_get(C);
CTX_store_set(C, but->context); CTX_store_set(C, but->context);
tmp = BLI_strdup(WM_operatortype_description(C, but->optype, opptr).c_str()); tmp = WM_operatortype_description(C, but->optype, opptr).c_str();
CTX_store_set(C, previous_ctx); CTX_store_set(C, previous_ctx);
} }
} }
@ -6665,14 +6665,14 @@ void UI_but_string_info_get(bContext *C, uiBut *but, ...)
MenuType *mt = UI_but_menutype_get(but); MenuType *mt = UI_but_menutype_get(but);
if (mt) { if (mt) {
if (type == BUT_GET_RNA_LABEL) { if (type == BUT_GET_RNA_LABEL) {
tmp = BLI_strdup(CTX_TIP_(mt->translation_context, mt->label)); tmp = CTX_TIP_(mt->translation_context, mt->label);
} }
else { else {
/* Not all menus are from Python. */ /* Not all menus are from Python. */
if (mt->rna_ext.srna) { if (mt->rna_ext.srna) {
const char *t = RNA_struct_ui_description(mt->rna_ext.srna); const char *t = RNA_struct_ui_description(mt->rna_ext.srna);
if (t && t[0]) { if (t && t[0]) {
tmp = BLI_strdup(t); tmp = t;
} }
} }
} }
@ -6683,10 +6683,10 @@ void UI_but_string_info_get(bContext *C, uiBut *but, ...)
wmOperatorType *ot = UI_but_operatortype_get_from_enum_menu(but, nullptr); wmOperatorType *ot = UI_but_operatortype_get_from_enum_menu(but, nullptr);
if (ot) { if (ot) {
if (type == BUT_GET_RNA_LABEL) { if (type == BUT_GET_RNA_LABEL) {
tmp = BLI_strdup(WM_operatortype_name(ot, nullptr).c_str()); tmp = WM_operatortype_name(ot, nullptr).c_str();
} }
else { else {
tmp = BLI_strdup(WM_operatortype_description(C, ot, nullptr).c_str()); tmp = WM_operatortype_description(C, ot, nullptr).c_str();
} }
} }
} }
@ -6695,7 +6695,7 @@ void UI_but_string_info_get(bContext *C, uiBut *but, ...)
PanelType *pt = UI_but_paneltype_get(but); PanelType *pt = UI_but_paneltype_get(but);
if (pt) { if (pt) {
if (type == BUT_GET_RNA_LABEL) { if (type == BUT_GET_RNA_LABEL) {
tmp = BLI_strdup(CTX_TIP_(pt->translation_context, pt->label)); tmp = CTX_TIP_(pt->translation_context, pt->label);
} }
else { else {
/* Not all panels are from Python. */ /* Not all panels are from Python. */
@ -6724,7 +6724,7 @@ void UI_but_string_info_get(bContext *C, uiBut *but, ...)
if (BLT_is_default_context(_tmp)) { if (BLT_is_default_context(_tmp)) {
_tmp = BLT_I18NCONTEXT_DEFAULT_BPYRNA; _tmp = BLT_I18NCONTEXT_DEFAULT_BPYRNA;
} }
tmp = BLI_strdup(_tmp); tmp = _tmp;
} }
else if (ELEM(type, BUT_GET_RNAENUM_IDENTIFIER, BUT_GET_RNAENUM_LABEL, BUT_GET_RNAENUM_TIP)) { else if (ELEM(type, BUT_GET_RNAENUM_IDENTIFIER, BUT_GET_RNAENUM_LABEL, BUT_GET_RNAENUM_TIP)) {
PointerRNA *ptr = nullptr; PointerRNA *ptr = nullptr;
@ -6773,13 +6773,13 @@ void UI_but_string_info_get(bContext *C, uiBut *but, ...)
} }
if (item && item->identifier) { if (item && item->identifier) {
if (type == BUT_GET_RNAENUM_IDENTIFIER) { if (type == BUT_GET_RNAENUM_IDENTIFIER) {
tmp = BLI_strdup(item->identifier); tmp = item->identifier;
} }
else if (type == BUT_GET_RNAENUM_LABEL) { else if (type == BUT_GET_RNAENUM_LABEL) {
tmp = BLI_strdup(item->name); tmp = item->name;
} }
else if (item->description && item->description[0]) { else if (item->description && item->description[0]) {
tmp = BLI_strdup(item->description); tmp = item->description;
} }
} }
} }
@ -6791,7 +6791,7 @@ void UI_but_string_info_get(bContext *C, uiBut *but, ...)
if (!(ui_block_is_menu(but->block) && !ui_block_is_pie_menu(but->block))) { if (!(ui_block_is_menu(but->block) && !ui_block_is_pie_menu(but->block))) {
char buf[128]; char buf[128];
if (ui_but_event_operator_string(C, but, buf, sizeof(buf))) { if (ui_but_event_operator_string(C, but, buf, sizeof(buf))) {
tmp = BLI_strdup(buf); tmp = buf;
} }
} }
} }
@ -6799,7 +6799,7 @@ void UI_but_string_info_get(bContext *C, uiBut *but, ...)
if (!(ui_block_is_menu(but->block) && !ui_block_is_pie_menu(but->block))) { if (!(ui_block_is_menu(but->block) && !ui_block_is_pie_menu(but->block))) {
char buf[128]; char buf[128];
if (ui_but_event_property_operator_string(C, but, buf, sizeof(buf))) { if (ui_but_event_property_operator_string(C, but, buf, sizeof(buf))) {
tmp = BLI_strdup(buf); tmp = buf;
} }
} }
} }
@ -6823,19 +6823,19 @@ void UI_but_extra_icon_string_info_get(bContext *C, uiButExtraOpIcon *extra_icon
va_start(args, extra_icon); va_start(args, extra_icon);
while ((si = (uiStringInfo *)va_arg(args, void *))) { while ((si = (uiStringInfo *)va_arg(args, void *))) {
char *tmp = nullptr; std::string tmp;
switch (si->type) { switch (si->type) {
case BUT_GET_LABEL: case BUT_GET_LABEL:
tmp = BLI_strdup(WM_operatortype_name(optype, opptr).c_str()); tmp = WM_operatortype_name(optype, opptr);
break; break;
case BUT_GET_TIP: case BUT_GET_TIP:
tmp = BLI_strdup(WM_operatortype_description(C, optype, opptr).c_str()); tmp = WM_operatortype_description(C, optype, opptr);
break; break;
case BUT_GET_OP_KEYMAP: { case BUT_GET_OP_KEYMAP: {
char buf[128]; char buf[128];
if (ui_but_extra_icon_event_operator_string(C, extra_icon, buf, sizeof(buf))) { if (ui_but_extra_icon_event_operator_string(C, extra_icon, buf, sizeof(buf))) {
tmp = BLI_strdup(buf); tmp = buf;
} }
break; break;
} }
@ -6845,7 +6845,7 @@ void UI_but_extra_icon_string_info_get(bContext *C, uiButExtraOpIcon *extra_icon
break; break;
} }
si->strinfo = tmp; si->strinfo = BLI_strdupn(tmp.c_str(), tmp.size());
} }
va_end(args); va_end(args);
} }