[Bf-blender-cvs] [028fd29] master: Pie Menus C code backend.

Antony Riakiotakis noreply at git.blender.org
Mon Aug 11 11:02:35 CEST 2014


Commit: 028fd29eeb092b6ed0625ed4d59b8100ae69596f
Author: Antony Riakiotakis
Date:   Mon Aug 11 10:39:59 2014 +0200
Branches: master
https://developer.blender.org/rB028fd29eeb092b6ed0625ed4d59b8100ae69596f

Pie Menus C code backend.

This commit merges the code in the pie-menu branch.

As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.

Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/

Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments

Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.

Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.

===================================================================

M	intern/ghost/intern/GHOST_SystemX11.cpp
M	intern/ghost/intern/GHOST_SystemX11.h
M	release/scripts/modules/bpy_types.py
M	release/scripts/startup/bl_operators/wm.py
M	release/scripts/startup/bl_ui/space_userpref.py
A	release/scripts/templates_py/ui_pie_menu.py
M	source/blender/blenkernel/BKE_blender.h
M	source/blender/editors/include/ED_space_api.h
M	source/blender/editors/include/UI_interface.h
M	source/blender/editors/interface/interface.c
M	source/blender/editors/interface/interface_handlers.c
M	source/blender/editors/interface/interface_intern.h
M	source/blender/editors/interface/interface_layout.c
M	source/blender/editors/interface/interface_panel.c
M	source/blender/editors/interface/interface_regions.c
M	source/blender/editors/interface/interface_widgets.c
M	source/blender/editors/interface/resources.c
M	source/blender/editors/space_api/spacetypes.c
M	source/blender/editors/space_view3d/view3d_edit.c
M	source/blender/makesdna/DNA_userdef_types.h
M	source/blender/makesrna/RNA_access.h
M	source/blender/makesrna/intern/rna_access.c
M	source/blender/makesrna/intern/rna_object.c
M	source/blender/makesrna/intern/rna_space.c
M	source/blender/makesrna/intern/rna_ui_api.c
M	source/blender/makesrna/intern/rna_userdef.c
M	source/blender/makesrna/intern/rna_wm.c
M	source/blender/makesrna/intern/rna_wm_api.c
M	source/blender/windowmanager/WM_api.h
M	source/blender/windowmanager/WM_keymap.h
M	source/blender/windowmanager/intern/wm_event_system.c
M	source/blender/windowmanager/intern/wm_init_exit.c
M	source/blender/windowmanager/intern/wm_keymap.c
M	source/blender/windowmanager/intern/wm_operators.c
M	source/blender/windowmanager/wm_event_system.h
M	source/blenderplayer/bad_level_call_stubs/stubs.c

===================================================================

diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp
index e347661..6d948b2 100644
--- a/intern/ghost/intern/GHOST_SystemX11.cpp
+++ b/intern/ghost/intern/GHOST_SystemX11.cpp
@@ -525,6 +525,16 @@ processEvents(
 				continue;
 			}
 #endif
+			/* when using autorepeat, some keypress events can actually come *after* the
+			 * last keyrelease. The next code takes care of that */
+			if (xevent.type == KeyRelease) {
+				m_last_release_keycode = xevent.xkey.keycode;
+				m_last_release_time = xevent.xkey.time;
+			}
+			else if (xevent.type == KeyPress) {
+				if ((xevent.xkey.keycode == m_last_release_keycode) && ((xevent.xkey.time <= m_last_release_time)))
+					continue;
+			}
 
 			processEvent(&xevent);
 			anyProcessed = true;
diff --git a/intern/ghost/intern/GHOST_SystemX11.h b/intern/ghost/intern/GHOST_SystemX11.h
index 1f95e4b..a21300e 100644
--- a/intern/ghost/intern/GHOST_SystemX11.h
+++ b/intern/ghost/intern/GHOST_SystemX11.h
@@ -356,6 +356,10 @@ private:
 	 *  and stop accumulating all events generated before that */
 	Time m_last_warp;
 
+	/* detect autorepeat glitch */
+	unsigned int m_last_release_keycode;
+	Time m_last_release_time;
+
 	/**
 	 * Return the ghost window associated with the
 	 * X11 window xwind
diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py
index d268347..bc2e936 100644
--- a/release/scripts/modules/bpy_types.py
+++ b/release/scripts/modules/bpy_types.py
@@ -140,6 +140,15 @@ class WindowManager(bpy_types.ID):
         finally:
             self.pupmenu_end__internal(popup)
 
+    def popup_menu_pie(self, event, draw_func, title="", icon='NONE'):
+        import bpy
+        pie = self.piemenu_begin__internal(title, icon, event)
+
+        try:
+            draw_func(pie, bpy.context)
+        finally:
+            self.piemenu_end__internal(pie)
+
 
 class _GenericBone:
     """
diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py
index 4281c90..15e482a 100644
--- a/release/scripts/startup/bl_operators/wm.py
+++ b/release/scripts/startup/bl_operators/wm.py
@@ -527,7 +527,33 @@ class WM_OT_context_menu_enum(Operator):
 
         context.window_manager.popup_menu(draw_func=draw_cb, title=prop.name, icon=prop.icon)
 
-        return {'PASS_THROUGH'}
+        return {'FINISHED'}
+
+
+class WM_OT_context_pie_enum(Operator):
+    bl_idname = "wm.context_pie_enum"
+    bl_label = "Context Enum Pie"
+    bl_options = {'UNDO', 'INTERNAL'}
+    data_path = rna_path_prop
+
+    def invoke(self, context, event):
+        data_path = self.data_path
+        value = context_path_validate(context, data_path)
+
+        if value is Ellipsis:
+            return {'PASS_THROUGH'}
+
+        base_path, prop_string = data_path.rsplit(".", 1)
+        value_base = context_path_validate(context, base_path)
+        prop = value_base.bl_rna.properties[prop_string]
+
+        def draw_cb(self, context):
+            layout = self.layout
+            layout.prop(value_base, prop_string, expand=True)
+
+        context.window_manager.popup_menu_pie(draw_func=draw_cb, title=prop.name, icon=prop.icon, event=event)
+
+        return {'FINISHED'}
 
 
 class WM_OT_context_set_id(Operator):
diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py
index b325e8c..999e41e 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -217,6 +217,13 @@ class USERPREF_PT_interface(Panel):
         sub.prop(view, "open_sublevel_delay", text="Sub Level")
 
         col.separator()
+        col.label(text="Pie Menus:")
+        sub = col.column(align=True)
+        sub.prop(view, "pie_animation_timeout")
+        sub.prop(view, "pie_initial_timeout")
+        sub.prop(view, "pie_menu_radius")
+        sub.prop(view, "pie_menu_threshold")
+        col.separator()
         col.separator()
         col.separator()
 
@@ -681,6 +688,9 @@ class USERPREF_PT_theme(Panel):
             col.label(text="Menu:")
             self._theme_widget_style(col, ui.wcol_menu)
 
+            col.label(text="Pie Menu:")
+            self._theme_widget_style(col, ui.wcol_pie_menu)
+
             col.label(text="Pulldown:")
             self._theme_widget_style(col, ui.wcol_pulldown)
 
diff --git a/release/scripts/templates_py/ui_pie_menu.py b/release/scripts/templates_py/ui_pie_menu.py
new file mode 100644
index 0000000..87500b6
--- /dev/null
+++ b/release/scripts/templates_py/ui_pie_menu.py
@@ -0,0 +1,32 @@
+import bpy
+from bpy.types import Menu
+
+# spawn an edit mode selection pie (run while object is in edit mode to get a valid output)
+
+
+class VIEW3D_PIE_template(Menu):
+    # label is displayed at the center of the pie menu.
+    bl_label = "Select Mode"
+
+    def draw(self, context):
+        layout = self.layout
+
+        pie = layout.menu_pie()
+        # operator_enum will just spread all available options
+        # for the type enum of the operator on the pie
+        pie.operator_enum("mesh.select_mode", "type")
+
+
+def register():
+    bpy.utils.register_class(VIEW3D_PIE_template)
+
+
+def unregister():
+    bpy.utils.unregister_class(VIEW3D_PIE_template)
+
+
+if __name__ == "__main__":
+    register()
+
+    bpy.ops.wm.call_menu_pie(name="VIEW3D_PIE_template")
+
diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h
index 50639ba..ea90498 100644
--- a/source/blender/blenkernel/BKE_blender.h
+++ b/source/blender/blenkernel/BKE_blender.h
@@ -42,7 +42,7 @@ extern "C" {
  * and keep comment above the defines.
  * Use STRINGIFY() rather than defining with quotes */
 #define BLENDER_VERSION         271
-#define BLENDER_SUBVERSION      3
+#define BLENDER_SUBVERSION      4
 /* 262 was the last editmesh release but it has compatibility code for bmesh data */
 #define BLENDER_MINVERSION      270
 #define BLENDER_MINSUBVERSION   5
diff --git a/source/blender/editors/include/ED_space_api.h b/source/blender/editors/include/ED_space_api.h
index 4fbe01a..d268c57 100644
--- a/source/blender/editors/include/ED_space_api.h
+++ b/source/blender/editors/include/ED_space_api.h
@@ -35,6 +35,7 @@ struct ARegionType;
 struct bContext;
 
 void ED_spacetypes_init(void);
+void ED_spacemacros_init(void);
 
 /* the pluginnable API for export to editors */
 
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index d7b4f75..c02ab1e 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -102,6 +102,7 @@ typedef struct uiLayout uiLayout;
 #define UI_EMBOSSN      1   /* Nothing, only icon and/or text */
 #define UI_EMBOSSP      2   /* Pulldown menu style */
 #define UI_EMBOSST      3   /* Table */
+#define UI_EMBOSSR      4   /* Pie Menu */
 
 /* uiBlock->direction */
 #define UI_DIRECTION       (UI_TOP | UI_DOWN | UI_LEFT | UI_RIGHT)
@@ -137,6 +138,7 @@ typedef struct uiLayout uiLayout;
 /* block->flag bits 14-17 are identical to but->drawflag bits */
 
 #define UI_BLOCK_LIST_ITEM   (1 << 19)
+#define UI_BLOCK_RADIAL      (1 << 20)
 
 /* uiPopupBlockHandle->menuretval */
 #define UI_RETURN_CANCEL     (1 << 0)   /* cancel all menus cascading */
@@ -360,6 +362,17 @@ struct uiLayout *uiPupMenuLayout(uiPopupMenu *head);
 void uiPupMenuReports(struct bContext *C, struct ReportList *reports) ATTR_NONNULL();
 bool uiPupMenuInvoke(struct bContext *C, const char *idname, struct ReportList *reports) ATTR_NONNULL(1, 2);
 
+/* Pie menus */
+typedef struct uiPieMenu uiPieMenu;
+
+void uiPieMenuInvoke(struct bContext *C, const char *idname, const struct wmEvent *event);
+void uiPieOperatorEnumInvoke(struct bContext *C, const char *title, const char *opname,
+                             const char *propname, const struct wmEvent *event);
+void uiPieEnumInvoke(struct bContext *C, const char *title, const char *path, const struct wmEvent *event);
+
+struct uiPieMenu *uiPieMenuBegin(struct bContext *C, const char *title, int icon, const struct wmEvent *event) ATTR_NONNULL();
+void uiPieMenuEnd(struct bContext *C, uiPieMenu *pie);
+struct uiLayout *uiPieMenuLayout(struct uiPieMenu *pie);
 /* Popup Blocks
  *
  * Functions used to create popup blocks. These are like popup menus
@@ -417,7 +430,8 @@ typedef enum {
 	UI_BLOCK_BOUNDS_TEXT,
 	UI_BLOCK_BOUNDS_POPUP_MOUSE,
 	UI_BLOCK_BOUNDS_POPUP_MENU,
-	UI_BLOCK_BOUNDS_POPUP_CENTER
+	UI_BLOCK_BOUNDS_POPUP_CENTER,
+	UI_BLOCK_BOUNDS_PIE_CENTER,
 } eBlockBoundsCalc;
 
 void uiBoundsBlock(struct uiBlock *block, int addval);
@@ -705,7 +719,7 @@ void                       UI_panel_category_draw_all(struct ARegion *ar, const
  * as screen/ if ED_KEYMAP_UI is set, or internally in popup functions. */
 
 void UI_add_region_handlers(struct ListBase *handlers);
-void UI_add_popup_handlers(struct bContext *C, struct ListBase *handlers, uiPopupBlockHandle *popup);
+void UI_add_popup_handlers(struct bContext *C, struct ListBase *handlers, uiPopupBlockHandle *popup, const bool accept_dbl_click);
 void UI_remove_popup_handlers(struct ListBase *handlers, uiPopupBlockHandle *popup);
 void UI_remove_popup_handlers_all(struct bContext *C, struct ListBase *handlers);
 
@@ -737,6 +751,7 @@ void UI_exit(void);
 #define UI_LAYOUT_HEADER        1
 #define UI_LAYOUT_MENU          2
 #define UI_LAYOUT_TOOLBAR       3
+#define UI_LAYOUT_PIEMENU       4
 
 #define UI_UNIT_X               ((void)0, U.widget_unit)
 #define UI_UNIT_Y               ((void)0, U.widget_unit)
@@ -827,8 +842,8 @@ uiLayout *uiLayoutListBox(uiLayout *layout, struct uiList *ui_list, struct Point
 uiLayout *uiLayoutAbsolute(uiLayout *layout, int align);
 uiLayout *uiLayoutSplit(uiLayout *layout, float percentage, int align);
 uiLayout *uiLayoutOverlap(uiLayout *layout);
-
 uiBlock *uiLayoutAbsoluteBlock(uiLayout *layout);
+uiLayout *uiLayoutRadial(uiLayout *layout);
 
 /* templates */
 void uiTemplateHeader(uiLayout *layout, struct bContext *C);
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 0a45ffc..73eb5f6 100644
--- a/source/blender/editors/interface/interface.c
++

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list