[Bf-blender-cvs] [8f85cf033c7] blender2.8: Merge branch 'master' into blender2.8
Campbell Barton
noreply at git.blender.org
Sun Jun 24 11:10:10 CEST 2018
Commit: 8f85cf033c75db784a18ed9f23f816107c9f226c
Author: Campbell Barton
Date: Sun Jun 24 10:45:42 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB8f85cf033c75db784a18ed9f23f816107c9f226c
Merge branch 'master' into blender2.8
===================================================================
===================================================================
diff --cc source/blender/editors/interface/CMakeLists.txt
index 07ba3b90e11,3a05e60bd35..882db88879d
--- a/source/blender/editors/interface/CMakeLists.txt
+++ b/source/blender/editors/interface/CMakeLists.txt
@@@ -56,12 -55,9 +57,11 @@@ set(SR
interface_layout.c
interface_ops.c
interface_panel.c
- interface_regions.c
interface_region_color_picker.c
+ interface_region_hud.c
interface_region_menu_pie.c
interface_region_menu_popup.c
+ interface_region_popover.c
interface_region_popup.c
interface_region_search.c
interface_region_tooltip.c
diff --cc source/blender/editors/interface/interface_context_menu.c
index 00000000000,0306139bac0..fa09b316fb8
mode 000000,100644..100644
--- a/source/blender/editors/interface/interface_context_menu.c
+++ b/source/blender/editors/interface/interface_context_menu.c
@@@ -1,0 -1,635 +1,743 @@@
+ /*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+ /** \file blender/editors/interface/interface_context_menu.c
+ * \ingroup edinterface
+ *
+ * Generic context popup menus.
+ */
+
++#include <string.h>
++
+ #include "MEM_guardedalloc.h"
+
+ #include "DNA_scene_types.h"
+ #include "DNA_screen_types.h"
+
+ #include "BLI_path_util.h"
+ #include "BLI_string.h"
+ #include "BLI_utildefines.h"
+
+ #include "BLT_translation.h"
+
+ #include "BKE_addon.h"
+ #include "BKE_context.h"
+ #include "BKE_idprop.h"
+ #include "BKE_screen.h"
+
+ #include "ED_screen.h"
+ #include "ED_keyframing.h"
+
+ #include "UI_interface.h"
+
+ #include "interface_intern.h"
+
+ #include "RNA_access.h"
+
+ #include "WM_api.h"
+ #include "WM_types.h"
+
+ /* This hack is needed because we don't have a good way to re-reference keymap items once added: T42944 */
+ #define USE_KEYMAP_ADD_HACK
+
+ /* -------------------------------------------------------------------- */
+ /** \name Button Context Menu
+ * \{ */
+
+ static void but_shortcut_name_func(bContext *C, void *arg1, int UNUSED(event))
+ {
+ uiBut *but = (uiBut *)arg1;
+
+ if (but->optype) {
+ char shortcut_str[128];
+
+ IDProperty *prop = (but->opptr) ? but->opptr->data : NULL;
+
+ /* complex code to change name of button */
+ if (WM_key_event_operator_string(
+ C, but->optype->idname, but->opcontext, prop, true,
+ shortcut_str, sizeof(shortcut_str)))
+ {
+ ui_but_add_shortcut(but, shortcut_str, true);
+ }
+ else {
+ /* simply strip the shortcut */
+ ui_but_add_shortcut(but, NULL, true);
+ }
+ }
+ }
+
+ static uiBlock *menu_change_shortcut(bContext *C, ARegion *ar, void *arg)
+ {
+ wmWindowManager *wm = CTX_wm_manager(C);
+ uiBlock *block;
+ uiBut *but = (uiBut *)arg;
+ wmKeyMap *km;
+ wmKeyMapItem *kmi;
+ PointerRNA ptr;
+ uiLayout *layout;
+ uiStyle *style = UI_style_get_dpi();
+ IDProperty *prop = (but->opptr) ? but->opptr->data : NULL;
+
+ kmi = WM_key_event_operator(C, but->optype->idname, but->opcontext, prop, true, &km);
+ BLI_assert(kmi != NULL);
+
+ RNA_pointer_create(&wm->id, &RNA_KeyMapItem, kmi, &ptr);
+
+ block = UI_block_begin(C, ar, "_popup", UI_EMBOSS);
+ UI_block_func_handle_set(block, but_shortcut_name_func, but);
+ UI_block_flag_enable(block, UI_BLOCK_MOVEMOUSE_QUIT);
+ UI_block_direction_set(block, UI_DIR_CENTER_Y);
+
+ layout = UI_block_layout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, 200, 20, 0, style);
+
+ uiItemR(layout, &ptr, "type", UI_ITEM_R_FULL_EVENT | UI_ITEM_R_IMMEDIATE, "", ICON_NONE);
+
+ UI_block_bounds_set_popup(block, 6, -50, 26);
+
+ return block;
+ }
+
+ #ifdef USE_KEYMAP_ADD_HACK
+ static int g_kmi_id_hack;
+ #endif
+
+ static uiBlock *menu_add_shortcut(bContext *C, ARegion *ar, void *arg)
+ {
+ wmWindowManager *wm = CTX_wm_manager(C);
+ uiBlock *block;
+ uiBut *but = (uiBut *)arg;
+ wmKeyMap *km;
+ wmKeyMapItem *kmi;
+ PointerRNA ptr;
+ uiLayout *layout;
+ uiStyle *style = UI_style_get_dpi();
+ IDProperty *prop = (but->opptr) ? but->opptr->data : NULL;
+ int kmi_id;
+
+ /* XXX this guess_opname can potentially return a different keymap than being found on adding later... */
+ km = WM_keymap_guess_opname(C, but->optype->idname);
+ kmi = WM_keymap_add_item(km, but->optype->idname, AKEY, KM_PRESS, 0, 0);
+ kmi_id = kmi->id;
+
+ /* copy properties, prop can be NULL for reset */
+ if (prop)
+ prop = IDP_CopyProperty(prop);
+ WM_keymap_properties_reset(kmi, prop);
+
+ /* update and get pointers again */
+ WM_keyconfig_update(wm);
+
+ km = WM_keymap_guess_opname(C, but->optype->idname);
+ kmi = WM_keymap_item_find_id(km, kmi_id);
+
+ RNA_pointer_create(&wm->id, &RNA_KeyMapItem, kmi, &ptr);
+
+ block = UI_block_begin(C, ar, "_popup", UI_EMBOSS);
+ UI_block_func_handle_set(block, but_shortcut_name_func, but);
+ UI_block_direction_set(block, UI_DIR_CENTER_Y);
+
+ layout = UI_block_layout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, 200, 20, 0, style);
+
+ uiItemR(layout, &ptr, "type", UI_ITEM_R_FULL_EVENT | UI_ITEM_R_IMMEDIATE, "", ICON_NONE);
+
+ UI_block_bounds_set_popup(block, 6, -50, 26);
+
+ #ifdef USE_KEYMAP_ADD_HACK
+ g_kmi_id_hack = kmi_id;
+ #endif
+ return block;
+ }
+
+ static void menu_add_shortcut_cancel(struct bContext *C, void *arg1)
+ {
+ uiBut *but = (uiBut *)arg1;
+ wmKeyMap *km;
+ wmKeyMapItem *kmi;
+ #ifndef USE_KEYMAP_ADD_HACK
+ IDProperty *prop;
+ #endif
+ int kmi_id;
+
+ #ifdef USE_KEYMAP_ADD_HACK
+ km = WM_keymap_guess_opname(C, but->optype->idname);
+ kmi_id = g_kmi_id_hack;
+ UNUSED_VARS(but);
+ #else
+ prop = (but->opptr) ? but->opptr->data : NULL;
+ kmi_id = WM_key_event_operator_id(C, but->optype->idname, but->opcontext, prop, true, &km);
+ #endif
+
+ kmi = WM_keymap_item_find_id(km, kmi_id);
+ WM_keymap_remove_item(km, kmi);
+ }
+
+ static void popup_change_shortcut_func(bContext *C, void *arg1, void *UNUSED(arg2))
+ {
+ uiBut *but = (uiBut *)arg1;
+ UI_popup_block_invoke(C, menu_change_shortcut, but);
+ }
+
+ static void remove_shortcut_func(bContext *C, void *arg1, void *UNUSED(arg2))
+ {
+ uiBut *but = (uiBut *)arg1;
+ wmKeyMap *km;
+ wmKeyMapItem *kmi;
+ IDProperty *prop = (but->opptr) ? but->opptr->data : NULL;
+
+ kmi = WM_key_event_operator(C, but->optype->idname, but->opcontext, prop, true, &km);
+ BLI_assert(kmi != NULL);
+
+ WM_keymap_remove_item(km, kmi);
+
+ but_shortcut_name_func(C, but, 0);
+ }
+
+ static void popup_add_shortcut_func(bContext *C, void *arg1, void *UNUSED(arg2))
+ {
+ uiBut *but = (uiBut *)arg1;
+ UI_popup_block_ex(C, menu_add_shortcut, NULL, menu_add_shortcut_cancel, but, NULL);
+ }
+
++static void popup_user_menu_add_or_replace_func(bContext *C, void *arg1, void *arg2)
++{
++ uiBut *but = arg1;
++ bUserMenuItem *umi = arg2;
++ if (umi) {
++ ED_screen_user_menu_remove(umi);
++ }
++ char drawstr[sizeof(but->drawstr)];
++ STRNCPY(drawstr, but->drawstr);
++ if (but->flag & UI_BUT_HAS_SEP_CHAR) {
++ char *sep = strrchr(drawstr, UI_SEP_CHAR);
++ if (sep) {
++ *sep = '\0';
++ }
++ }
++ ED_screen_user_menu_add(C, drawstr, but->optype, but->opptr ? but->opptr->data : NULL, but->opcontext);
++}
++
++static void popup_user_menu_remove_func(bContext *UNUSED(C), void *UNUSED(arg1), void *arg2)
++{
++ bUserMenuItem *umi = arg2;
++ ED_screen_user_menu_remove(umi);
++}
++
+ static void ui_but_menu_add_path_operators(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop)
+ {
+ const PropertySubType subtype = RNA_property_subtype(prop);
+ wmOperatorType *ot = WM_operatortype_find("WM_OT_path_open", true);
+ char filepath[FILE_MAX];
+ char dir[FILE_MAXDIR];
+ char file[FILE_MAXFILE];
+ PointerRNA props_ptr;
+
+ BLI_assert(ELEM(subtype, PROP_FILEPATH, PROP_DIRPATH));
+ UNUSED_VARS_NDEBUG(subtype);
+
+ RNA_property_string_get(ptr, prop, filepath);
+ BLI_split_dirfile(filepath, dir, file, sizeof(dir), sizeof(file));
+
+ if (file[0]) {
+ BLI_assert(subtype == PROP_FILEPATH);
+ uiItemFullO_ptr(
+ layout, ot, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Open File Externally"),
+ ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0, &props_ptr);
+ RNA_string_set(&props_ptr, "filepath", filepath);
+ }
+
+ uiItemFullO_ptr(
+ layout, ot, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Open Location Externally"),
+ ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0, &props_ptr);
+ RNA_string_set(&props_ptr, "filepath", dir);
+ }
+
+ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but)
+ {
+ /* having this menu for some buttons makes no sense */
+ if (but->type == UI_BTYPE_IMAGE) {
+ return false;
+ }
+
+ uiPopupMenu *pup;
+ uiLayout *layout;
+
+ {
+ uiStringInfo label = {BUT_GET_LABEL, NULL};
+
+ /* highly unlikely getting the label ever fails */
+ UI_but_string_info_get(C, but, &label, NULL);
+
+ pup = UI_popup_menu_begin(C, label.strinfo ? label.strinfo : "", ICON_NONE);
+ layout = UI_popup_menu_layout(pup);
+ if (label.strinfo) {
+ MEM_freeN(label.strinfo);
+ }
+ uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_DEFAULT);
+ }
+
+ if (but->rnapoin.data && but->rnaprop) {
+ PointerRNA *ptr = &but->rnapoin;
+ PropertyRNA *prop = but->rnaprop;
+ const PropertyType type = RNA_property_type(prop);
+ const PropertySubType subtype = RNA_property_subtype(prop);
+ bool is_anim = RNA_property_animateable(ptr, prop);
+ bool is_editable = RNA_property_editable(ptr, prop);
+ /*bool is_idprop = RNA_property_is_idprop(prop);*/ /* XXX does not work as expected,
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list