Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Eisel <julian@blender.org>2021-01-13 17:08:09 +0300
committerJulian Eisel <julian@blender.org>2021-01-13 17:31:02 +0300
commit2771dfd5632ad6d982ee4bf3e87decdb197ebed7 (patch)
tree515ef4f88aaf9ad2a3873ba9dec5133317703d18 /source/blender/editors/interface/interface.c
parentad4202a14fbce95b7c40df0e815c1ac261515b05 (diff)
UI: Revert design changes to data-block selector for the 2.92 release
Partially reverts 2250b5cefee7. Removing the user count and fake user count icons was controversial (which was expected) and there are a few further changes needed, that won't make it in time for the release, see D9946. While there is a design to bring back the user count and fake user indicators, a new design idea was proposed that the UI team wants to follow. This came too late for the 2.92 release, the new design is targeted at the 2.93 release now. Meanwhile, UI team decision was to simply revert the design changes. The new design is being worked on in https://developer.blender.org/T84669. Note that this commit does not revert some internal changes done in 2250b5cefee7. Namely the introduction of `ed_util_ops.c` and data-block operators in there. These will still be needed in the new design.
Diffstat (limited to 'source/blender/editors/interface/interface.c')
-rw-r--r--source/blender/editors/interface/interface.c143
1 files changed, 57 insertions, 86 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 9644e6e0238..e53dfa83867 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -1168,21 +1168,16 @@ void ui_but_add_shortcut(uiBut *but, const char *shortcut_str, const bool do_str
* \{ */
static bool ui_but_event_operator_string_from_operator(const bContext *C,
- wmOperatorCallParams *op_call_params,
+ uiBut *but,
char *buf,
const size_t buf_len)
{
- BLI_assert(op_call_params->optype != NULL);
+ BLI_assert(but->optype != NULL);
bool found = false;
- IDProperty *prop = (op_call_params->opptr) ? op_call_params->opptr->data : NULL;
-
- if (WM_key_event_operator_string(C,
- op_call_params->optype->idname,
- op_call_params->opcontext,
- prop,
- true,
- buf,
- buf_len)) {
+ IDProperty *prop = (but->opptr) ? but->opptr->data : NULL;
+
+ if (WM_key_event_operator_string(
+ C, but->optype->idname, but->opcontext, prop, true, buf, buf_len)) {
found = true;
}
return found;
@@ -1259,22 +1254,15 @@ static bool ui_but_event_operator_string_from_panel(const bContext *C,
return found;
}
-static bool ui_but_event_operator_string(
- const bContext *C, uiBut *but, uiButExtraOpIcon *extra_icon, char *buf, const size_t buf_len)
+static bool ui_but_event_operator_string(const bContext *C,
+ uiBut *but,
+ char *buf,
+ const size_t buf_len)
{
bool found = false;
- wmOperatorType *extra_icon_optype = UI_but_extra_operator_icon_optype_get(extra_icon);
- if (extra_icon_optype) {
- found = ui_but_event_operator_string_from_operator(C, extra_icon->optype_params, buf, buf_len);
- }
- else if (but->optype != NULL) {
- found = ui_but_event_operator_string_from_operator(
- C,
- &(wmOperatorCallParams){
- .optype = but->optype, .opptr = but->opptr, .opcontext = but->opcontext},
- buf,
- buf_len);
+ if (but->optype != NULL) {
+ found = ui_but_event_operator_string_from_operator(C, but, buf, buf_len);
}
else if (UI_but_menutype_get(but) != NULL) {
found = ui_but_event_operator_string_from_menu(C, but, buf, buf_len);
@@ -1577,7 +1565,7 @@ static void ui_menu_block_set_keymaps(const bContext *C, uiBlock *block)
continue;
}
- if (ui_but_event_operator_string(C, but, NULL, buf, sizeof(buf))) {
+ if (ui_but_event_operator_string(C, but, buf, sizeof(buf))) {
ui_but_add_shortcut(but, buf, false);
}
else if (ui_but_event_property_operator_string(C, but, buf, sizeof(buf))) {
@@ -1618,12 +1606,12 @@ typedef enum PredefinedExtraOpIconType {
PREDEFINED_EXTRA_OP_ICON_EYEDROPPER,
} PredefinedExtraOpIconType;
-static uiButExtraOpIcon *ui_but_extra_operator_icon_add_ptr(uiBut *but,
- wmOperatorType *optype,
- short opcontext,
- int icon)
+static PointerRNA *ui_but_extra_operator_icon_add_ptr(uiBut *but,
+ wmOperatorType *optype,
+ short opcontext,
+ int icon)
{
- uiButExtraOpIcon *extra_op_icon = MEM_callocN(sizeof(*extra_op_icon), __func__);
+ uiButExtraOpIcon *extra_op_icon = MEM_mallocN(sizeof(*extra_op_icon), __func__);
extra_op_icon->icon = (BIFIconID)icon;
extra_op_icon->optype_params = MEM_callocN(sizeof(*extra_op_icon->optype_params),
@@ -1638,15 +1626,13 @@ static uiButExtraOpIcon *ui_but_extra_operator_icon_add_ptr(uiBut *but,
BLI_addtail(&but->extra_op_icons, extra_op_icon);
- return extra_op_icon;
+ return extra_op_icon->optype_params->opptr;
}
static void ui_but_extra_operator_icon_free(uiButExtraOpIcon *extra_icon)
{
- if (extra_icon->optype_params->opptr) {
- WM_operator_properties_free(extra_icon->optype_params->opptr);
- MEM_freeN(extra_icon->optype_params->opptr);
- }
+ WM_operator_properties_free(extra_icon->optype_params->opptr);
+ MEM_freeN(extra_icon->optype_params->opptr);
MEM_freeN(extra_icon->optype_params);
MEM_freeN(extra_icon);
}
@@ -1659,25 +1645,18 @@ void ui_but_extra_operator_icons_free(uiBut *but)
BLI_listbase_clear(&but->extra_op_icons);
}
-uiButExtraOpIcon *UI_but_extra_operator_icon_add(uiBut *but,
- const char *opname,
- short opcontext,
- int icon)
+PointerRNA *UI_but_extra_operator_icon_add(uiBut *but,
+ const char *opname,
+ short opcontext,
+ int icon)
{
wmOperatorType *optype = WM_operatortype_find(opname, false);
- BLI_assert(optype);
- return ui_but_extra_operator_icon_add_ptr(but, optype, opcontext, icon);
-}
-
-PointerRNA *UI_but_extra_operator_icon_opptr_get(uiButExtraOpIcon *extra_icon)
-{
- return extra_icon->optype_params->opptr;
-}
+ if (optype) {
+ return ui_but_extra_operator_icon_add_ptr(but, optype, opcontext, icon);
+ }
-wmOperatorType *UI_but_extra_operator_icon_optype_get(uiButExtraOpIcon *extra_icon)
-{
- return extra_icon ? extra_icon->optype_params->optype : NULL;
+ return NULL;
}
static bool ui_but_icon_extra_is_visible_text_clear(const uiBut *but)
@@ -6840,7 +6819,7 @@ void UI_but_func_hold_set(uiBut *but, uiButHandleHoldFunc func, void *argN)
but->hold_argN = argN;
}
-void UI_but_string_info_get(bContext *C, uiBut *but, uiButExtraOpIcon *extra_icon, ...)
+void UI_but_string_info_get(bContext *C, uiBut *but, ...)
{
va_list args;
uiStringInfo *si;
@@ -6849,19 +6828,13 @@ void UI_but_string_info_get(bContext *C, uiBut *but, uiButExtraOpIcon *extra_ico
int totitems;
bool free_items = false;
- wmOperatorType *extra_icon_optype = UI_but_extra_operator_icon_optype_get(extra_icon);
- wmOperatorType *optype = extra_icon ? extra_icon_optype : but->optype;
-
- /* Don't query RNA data when the extra-icon overrides the button. */
- PropertyRNA *rnaprop = extra_icon ? NULL : but->rnaprop;
-
- va_start(args, extra_icon);
+ va_start(args, but);
while ((si = (uiStringInfo *)va_arg(args, void *))) {
uiStringInfoType type = si->type;
char *tmp = NULL;
if (type == BUT_GET_LABEL) {
- if (but->str && but->str[0] && !extra_icon) {
+ if (but->str && but->str[0]) {
const char *str_sep;
size_t str_len;
@@ -6891,16 +6864,16 @@ void UI_but_string_info_get(bContext *C, uiBut *but, uiButExtraOpIcon *extra_ico
}
if (type == BUT_GET_RNAPROP_IDENTIFIER) {
- if (rnaprop) {
- tmp = BLI_strdup(RNA_property_identifier(rnaprop));
+ if (but->rnaprop) {
+ tmp = BLI_strdup(RNA_property_identifier(but->rnaprop));
}
}
else if (type == BUT_GET_RNASTRUCT_IDENTIFIER) {
- if (rnaprop && but->rnapoin.data) {
+ if (but->rnaprop && but->rnapoin.data) {
tmp = BLI_strdup(RNA_struct_identifier(but->rnapoin.type));
}
- else if (optype) {
- tmp = BLI_strdup(optype->idname);
+ else if (but->optype) {
+ tmp = BLI_strdup(but->optype->idname);
}
else if (ELEM(but->type, UI_BTYPE_MENU, UI_BTYPE_PULLDOWN)) {
MenuType *mt = UI_but_menutype_get(but);
@@ -6916,25 +6889,23 @@ void UI_but_string_info_get(bContext *C, uiBut *but, uiButExtraOpIcon *extra_ico
}
}
else if (ELEM(type, BUT_GET_RNA_LABEL, BUT_GET_RNA_TIP)) {
- if (rnaprop) {
+ if (but->rnaprop) {
if (type == BUT_GET_RNA_LABEL) {
- tmp = BLI_strdup(RNA_property_ui_name(rnaprop));
+ tmp = BLI_strdup(RNA_property_ui_name(but->rnaprop));
}
else {
- const char *t = RNA_property_ui_description(rnaprop);
+ const char *t = RNA_property_ui_description(but->rnaprop);
if (t && t[0]) {
tmp = BLI_strdup(t);
}
}
}
- else if (optype) {
- PointerRNA *opptr = extra_icon_optype ? UI_but_extra_operator_icon_opptr_get(extra_icon) :
- but->opptr;
+ else if (but->optype) {
if (type == BUT_GET_RNA_LABEL) {
- tmp = BLI_strdup(WM_operatortype_name(optype, opptr));
+ tmp = BLI_strdup(WM_operatortype_name(but->optype, but->opptr));
}
else {
- tmp = WM_operatortype_description(C, optype, opptr);
+ tmp = WM_operatortype_description(C, but->optype, but->opptr);
}
}
else if (ELEM(but->type, UI_BTYPE_MENU, UI_BTYPE_PULLDOWN, UI_BTYPE_POPOVER)) {
@@ -6986,11 +6957,11 @@ void UI_but_string_info_get(bContext *C, uiBut *but, uiButExtraOpIcon *extra_ico
}
else if (type == BUT_GET_RNA_LABEL_CONTEXT) {
const char *_tmp = BLT_I18NCONTEXT_DEFAULT;
- if (rnaprop) {
- _tmp = RNA_property_translation_context(rnaprop);
+ if (but->rnaprop) {
+ _tmp = RNA_property_translation_context(but->rnaprop);
}
- else if (optype) {
- _tmp = RNA_struct_translation_context(optype->srna);
+ else if (but->optype) {
+ _tmp = RNA_struct_translation_context(but->optype->srna);
}
else if (ELEM(but->type, UI_BTYPE_MENU, UI_BTYPE_PULLDOWN)) {
MenuType *mt = UI_but_menutype_get(but);
@@ -7009,16 +6980,16 @@ void UI_but_string_info_get(bContext *C, uiBut *but, uiButExtraOpIcon *extra_ico
int value = 0;
/* get the enum property... */
- if (rnaprop && RNA_property_type(rnaprop) == PROP_ENUM) {
+ if (but->rnaprop && RNA_property_type(but->rnaprop) == PROP_ENUM) {
/* enum property */
ptr = &but->rnapoin;
- prop = rnaprop;
+ prop = but->rnaprop;
value = (ELEM(but->type, UI_BTYPE_ROW, UI_BTYPE_TAB)) ? (int)but->hardmax :
(int)ui_but_value_get(but);
}
- else if (optype) {
- PointerRNA *opptr = extra_icon_optype ? UI_but_extra_operator_icon_opptr_get(extra_icon) :
- UI_but_operator_ptr_get(but);
+ else if (but->optype) {
+ PointerRNA *opptr = UI_but_operator_ptr_get(but);
+ wmOperatorType *ot = but->optype;
/* so the context is passed to itemf functions */
WM_operator_properties_sanitize(opptr, false);
@@ -7028,11 +6999,11 @@ void UI_but_string_info_get(bContext *C, uiBut *but, uiButExtraOpIcon *extra_ico
* operator menus in the Anim Editors will show tooltips for the different
* operations instead of the meaningless generic operator tooltip
*/
- if (optype->prop && RNA_property_type(optype->prop) == PROP_ENUM) {
- if (RNA_struct_contains_property(opptr, optype->prop)) {
+ if (ot->prop && RNA_property_type(ot->prop) == PROP_ENUM) {
+ if (RNA_struct_contains_property(opptr, ot->prop)) {
ptr = opptr;
- prop = optype->prop;
- value = RNA_property_enum_get(opptr, optype->prop);
+ prop = ot->prop;
+ value = RNA_property_enum_get(opptr, ot->prop);
}
}
}
@@ -7065,7 +7036,7 @@ void UI_but_string_info_get(bContext *C, uiBut *but, uiButExtraOpIcon *extra_ico
else if (type == BUT_GET_OP_KEYMAP) {
if (!ui_block_is_menu(but->block)) {
char buf[128];
- if (ui_but_event_operator_string(C, but, extra_icon, buf, sizeof(buf))) {
+ if (ui_but_event_operator_string(C, but, buf, sizeof(buf))) {
tmp = BLI_strdup(buf);
}
}