2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2009-06-18 19:48:55 +00:00
|
|
|
* 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
|
2012-03-18 09:27:36 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
2009-06-18 19:48:55 +00:00
|
|
|
*
|
|
|
|
|
* 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,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2009-06-18 19:48:55 +00:00
|
|
|
*
|
|
|
|
|
* The Original Code is Copyright (C) 2009 Blender Foundation.
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*/
|
|
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup RNA
|
2011-02-27 20:20:01 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
2009-06-18 19:48:55 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <stdio.h>
|
2019-02-02 15:14:51 +11:00
|
|
|
#include <ctype.h>
|
2009-06-18 19:48:55 +00:00
|
|
|
|
2012-09-24 22:39:45 +00:00
|
|
|
#include "BLI_utildefines.h"
|
|
|
|
|
|
2009-06-18 19:48:55 +00:00
|
|
|
#include "RNA_define.h"
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
#include "RNA_enum_types.h"
|
|
|
|
|
|
|
|
|
|
#include "DNA_screen_types.h"
|
|
|
|
|
#include "DNA_space_types.h"
|
2010-11-20 16:39:15 +00:00
|
|
|
#include "DNA_windowmanager_types.h"
|
2009-06-18 19:48:55 +00:00
|
|
|
|
2018-11-28 23:24:10 +11:00
|
|
|
#include "UI_interface.h"
|
|
|
|
|
|
2013-09-06 22:54:22 +00:00
|
|
|
#include "wm_cursors.h"
|
2018-12-12 21:39:55 +11:00
|
|
|
#include "wm_event_types.h"
|
2013-09-06 22:54:22 +00:00
|
|
|
|
2012-09-22 13:40:31 +00:00
|
|
|
#include "rna_internal.h" /* own include */
|
|
|
|
|
|
2013-09-06 22:54:22 +00:00
|
|
|
/* confusingm 2 enums mixed up here */
|
2017-10-18 15:07:26 +11:00
|
|
|
const EnumPropertyItem rna_enum_window_cursor_items[] = {
|
2013-09-06 22:54:22 +00:00
|
|
|
{CURSOR_STD, "DEFAULT", 0, "Default", ""},
|
|
|
|
|
{CURSOR_NONE, "NONE", 0, "None", ""},
|
|
|
|
|
{CURSOR_WAIT, "WAIT", 0, "Wait", ""},
|
|
|
|
|
{CURSOR_EDIT, "CROSSHAIR", 0, "Crosshair", ""},
|
|
|
|
|
{CURSOR_X_MOVE, "MOVE_X", 0, "Move-X", ""},
|
|
|
|
|
{CURSOR_Y_MOVE, "MOVE_Y", 0, "Move-Y", ""},
|
|
|
|
|
|
|
|
|
|
/* new */
|
|
|
|
|
{BC_KNIFECURSOR, "KNIFE", 0, "Knife", ""},
|
|
|
|
|
{BC_TEXTEDITCURSOR, "TEXT", 0, "Text", ""},
|
|
|
|
|
{BC_PAINTBRUSHCURSOR, "PAINT_BRUSH", 0, "Paint Brush", ""},
|
|
|
|
|
{BC_HANDCURSOR, "HAND", 0, "Hand", ""},
|
|
|
|
|
{BC_EW_SCROLLCURSOR, "SCROLL_X", 0, "Scroll-X", ""},
|
|
|
|
|
{BC_NS_SCROLLCURSOR, "SCROLL_Y", 0, "Scroll-Y", ""},
|
|
|
|
|
{BC_NSEW_SCROLLCURSOR, "SCROLL_XY", 0, "Scroll-XY", ""},
|
|
|
|
|
{BC_EYEDROPPER_CURSOR, "EYEDROPPER", 0, "Eyedropper", ""},
|
2019-02-03 14:01:45 +11:00
|
|
|
{0, NULL, 0, NULL, NULL},
|
2013-09-06 22:54:22 +00:00
|
|
|
};
|
|
|
|
|
|
2009-06-18 19:48:55 +00:00
|
|
|
#ifdef RNA_RUNTIME
|
|
|
|
|
|
|
|
|
|
#include "BKE_context.h"
|
2019-02-04 15:01:55 +11:00
|
|
|
#include "BKE_undo_system.h"
|
2009-06-18 19:48:55 +00:00
|
|
|
|
2017-06-26 15:57:14 +10:00
|
|
|
#include "WM_types.h"
|
|
|
|
|
|
2018-11-28 23:24:10 +11:00
|
|
|
static void rna_KeyMapItem_to_string(wmKeyMapItem *kmi, bool compact, char *result)
|
|
|
|
|
{
|
|
|
|
|
WM_keymap_item_to_string(kmi, compact, result, UI_MAX_SHORTCUT_STR);
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-16 20:50:02 +00:00
|
|
|
static wmKeyMap *rna_keymap_active(wmKeyMap *km, bContext *C)
|
|
|
|
|
{
|
|
|
|
|
wmWindowManager *wm = CTX_wm_manager(C);
|
|
|
|
|
return WM_keymap_active(wm, km);
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-17 03:32:33 +00:00
|
|
|
static void rna_keymap_restore_item_to_default(wmKeyMap *km, bContext *C, wmKeyMapItem *kmi)
|
|
|
|
|
{
|
|
|
|
|
WM_keymap_restore_item_to_default(C, km, kmi);
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-17 09:45:45 +00:00
|
|
|
static void rna_Operator_report(wmOperator *op, int type, const char *msg)
|
2009-12-10 16:52:44 +00:00
|
|
|
{
|
|
|
|
|
BKE_report(op->reports, type, msg);
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-01 15:47:09 +02:00
|
|
|
static bool rna_Operator_is_repeat(wmOperator *op, bContext *C)
|
2017-03-15 03:43:44 +11:00
|
|
|
{
|
|
|
|
|
return WM_operator_is_repeat(C, op);
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-18 07:38:51 +00:00
|
|
|
/* since event isn't needed... */
|
2010-01-16 01:15:47 +00:00
|
|
|
static void rna_Operator_enum_search_invoke(bContext *C, wmOperator *op)
|
2010-01-15 22:40:33 +00:00
|
|
|
{
|
|
|
|
|
WM_enum_search_invoke(C, op, NULL);
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2010-01-15 22:40:33 +00:00
|
|
|
}
|
|
|
|
|
|
2018-07-01 15:47:09 +02:00
|
|
|
static bool rna_event_modal_handler_add(struct bContext *C, struct wmOperator *operator)
|
2010-02-21 11:56:00 +00:00
|
|
|
{
|
|
|
|
|
return WM_event_add_modal_handler(C, operator) != NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-28 04:55:24 +00:00
|
|
|
/* XXX, need a way for python to know event types, 0x0110 is hard coded */
|
2012-09-22 14:07:55 +00:00
|
|
|
static wmTimer *rna_event_timer_add(struct wmWindowManager *wm, float time_step, wmWindow *win)
|
2011-03-28 04:55:24 +00:00
|
|
|
{
|
|
|
|
|
return WM_event_add_timer(wm, win, 0x0110, time_step);
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-22 14:07:55 +00:00
|
|
|
static void rna_event_timer_remove(struct wmWindowManager *wm, wmTimer *timer)
|
2011-03-28 04:55:24 +00:00
|
|
|
{
|
2011-04-03 10:04:16 +00:00
|
|
|
WM_event_remove_timer(wm, timer->win, timer);
|
2011-03-28 04:55:24 +00:00
|
|
|
}
|
|
|
|
|
|
2017-06-26 15:57:14 +10:00
|
|
|
|
2018-07-14 23:49:00 +02:00
|
|
|
static wmGizmoGroupType *wm_gizmogrouptype_find_for_add_remove(ReportList *reports, const char *idname)
|
2017-06-26 15:57:14 +10:00
|
|
|
{
|
2018-07-15 14:24:10 +02:00
|
|
|
wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(idname, true);
|
|
|
|
|
if (gzgt == NULL) {
|
2018-07-14 23:49:00 +02:00
|
|
|
BKE_reportf(reports, RPT_ERROR, "Gizmo group type '%s' not found!", idname);
|
2017-06-26 15:57:14 +10:00
|
|
|
return NULL;
|
|
|
|
|
}
|
2018-07-15 14:24:10 +02:00
|
|
|
if (gzgt->flag & WM_GIZMOGROUPTYPE_PERSISTENT) {
|
2018-07-14 23:49:00 +02:00
|
|
|
BKE_reportf(reports, RPT_ERROR, "Gizmo group '%s' has 'PERSISTENT' option set!", idname);
|
2017-06-26 15:57:14 +10:00
|
|
|
return NULL;
|
|
|
|
|
}
|
2018-07-15 14:24:10 +02:00
|
|
|
return gzgt;
|
2017-06-26 15:57:14 +10:00
|
|
|
}
|
|
|
|
|
|
2018-12-04 10:15:02 +11:00
|
|
|
static void rna_gizmo_group_type_ensure(ReportList *reports, const char *idname)
|
2017-06-26 15:57:14 +10:00
|
|
|
{
|
2018-07-15 14:24:10 +02:00
|
|
|
wmGizmoGroupType *gzgt = wm_gizmogrouptype_find_for_add_remove(reports, idname);
|
|
|
|
|
if (gzgt != NULL) {
|
2018-12-04 10:15:02 +11:00
|
|
|
WM_gizmo_group_type_ensure_ptr(gzgt);
|
2017-06-26 15:57:14 +10:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-04 10:15:02 +11:00
|
|
|
static void rna_gizmo_group_type_unlink_delayed(ReportList *reports, const char *idname)
|
2017-06-26 15:57:14 +10:00
|
|
|
{
|
2018-07-15 14:24:10 +02:00
|
|
|
wmGizmoGroupType *gzgt = wm_gizmogrouptype_find_for_add_remove(reports, idname);
|
|
|
|
|
if (gzgt != NULL) {
|
2018-12-04 10:15:02 +11:00
|
|
|
WM_gizmo_group_type_unlink_delayed_ptr(gzgt);
|
2017-06-26 15:57:14 +10:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-19 14:47:11 +00:00
|
|
|
/* placeholder data for final implementation of a true progressbar */
|
2014-08-13 08:37:41 +10:00
|
|
|
static struct wmStaticProgress {
|
2013-04-19 14:47:11 +00:00
|
|
|
float min;
|
|
|
|
|
float max;
|
|
|
|
|
bool is_valid;
|
|
|
|
|
} wm_progress_state = {0, 0, false};
|
|
|
|
|
|
|
|
|
|
|
2013-09-20 06:35:28 +00:00
|
|
|
static void rna_progress_begin(struct wmWindowManager *UNUSED(wm), float min, float max)
|
2013-04-19 14:47:11 +00:00
|
|
|
{
|
|
|
|
|
float range = max - min;
|
|
|
|
|
if (range != 0) {
|
|
|
|
|
wm_progress_state.min = min;
|
|
|
|
|
wm_progress_state.max = max;
|
|
|
|
|
wm_progress_state.is_valid = true;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
wm_progress_state.is_valid = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_progress_update(struct wmWindowManager *wm, float value)
|
|
|
|
|
{
|
|
|
|
|
if (wm_progress_state.is_valid) {
|
|
|
|
|
/* Map to cursor_time range [0,9999] */
|
2013-11-27 19:20:02 +11:00
|
|
|
wmWindow *win = wm->winactive;
|
|
|
|
|
if (win) {
|
|
|
|
|
int val = (int)(10000 * (value - wm_progress_state.min) / (wm_progress_state.max - wm_progress_state.min));
|
|
|
|
|
WM_cursor_time(win, val);
|
|
|
|
|
}
|
2013-04-19 14:47:11 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_progress_end(struct wmWindowManager *wm)
|
|
|
|
|
{
|
|
|
|
|
if (wm_progress_state.is_valid) {
|
2013-11-27 19:20:02 +11:00
|
|
|
wmWindow *win = wm->winactive;
|
|
|
|
|
if (win) {
|
|
|
|
|
WM_cursor_modal_restore(win);
|
|
|
|
|
wm_progress_state.is_valid = false;
|
|
|
|
|
}
|
2013-04-19 14:47:11 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-13 09:03:46 +00:00
|
|
|
/* wrap these because of 'const wmEvent *' */
|
|
|
|
|
static int rna_Operator_confirm(bContext *C, wmOperator *op, wmEvent *event)
|
|
|
|
|
{
|
|
|
|
|
return WM_operator_confirm(C, op, event);
|
|
|
|
|
}
|
|
|
|
|
static int rna_Operator_props_popup(bContext *C, wmOperator *op, wmEvent *event)
|
|
|
|
|
{
|
|
|
|
|
return WM_operator_props_popup(C, op, event);
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-09 14:40:09 +02:00
|
|
|
static wmKeyMapItem *rna_KeyMap_item_new(
|
|
|
|
|
wmKeyMap *km, ReportList *reports, const char *idname, int type, int value,
|
2018-07-01 15:47:09 +02:00
|
|
|
bool any, bool shift, bool ctrl, bool alt, bool oskey, int keymodifier, bool head)
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
/* wmWindowManager *wm = CTX_wm_manager(C); */
|
Bugfix [#32437] Cannot define Alt-E keybinding in Text Editor window
WM_keymap_add_item(keymap, "TEXT_OT_insert", KM_TEXTINPUT, KM_ANY, KM_ANY, 0);
<--- this catch-all key map item at the end of the Text Editor keymap was
gobbling all the key events for user-defined hotkeys added after it in the
keymap. This includes all hotkeys for new operators defined by addons (via
keymap.keymap_items.new()).
As a slightly hacky workaround for this, I've added an extra parameter to
keymap_items.new() which will force the newly added item to get added to the
start of the key map items list (i.e. with top priority). To enable, simply add,
head=True to keymap_items.new() calls. For example:
keymap.keymap_items.new("MY_OP_my_operator_id", type='E', value='PRESS',
alt=True, head=True)
This should be useful for cases where there are similar catch-alls, where it is
necessary to insert our item before the offending catch-all (without knowing
which one it is). However, in general, it's recommended not to use this, unless
all other methods (inlcuding choosing another key combination if your first
choice doesn't work) fails.
2012-08-30 14:08:43 +00:00
|
|
|
wmKeyMapItem *kmi = NULL;
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
char idname_bl[OP_MAX_TYPENAME];
|
2012-03-05 23:30:41 +00:00
|
|
|
int modifier = 0;
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
|
|
|
|
|
/* only on non-modal maps */
|
|
|
|
|
if (km->flag & KEYMAP_MODAL) {
|
2011-09-19 13:23:58 +00:00
|
|
|
BKE_report(reports, RPT_ERROR, "Not a non-modal keymap");
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WM_operator_bl_idname(idname_bl, idname);
|
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (shift) modifier |= KM_SHIFT;
|
|
|
|
|
if (ctrl) modifier |= KM_CTRL;
|
|
|
|
|
if (alt) modifier |= KM_ALT;
|
|
|
|
|
if (oskey) modifier |= KM_OSKEY;
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (any) modifier = KM_ANY;
|
2018-06-09 14:40:09 +02:00
|
|
|
|
Bugfix [#32437] Cannot define Alt-E keybinding in Text Editor window
WM_keymap_add_item(keymap, "TEXT_OT_insert", KM_TEXTINPUT, KM_ANY, KM_ANY, 0);
<--- this catch-all key map item at the end of the Text Editor keymap was
gobbling all the key events for user-defined hotkeys added after it in the
keymap. This includes all hotkeys for new operators defined by addons (via
keymap.keymap_items.new()).
As a slightly hacky workaround for this, I've added an extra parameter to
keymap_items.new() which will force the newly added item to get added to the
start of the key map items list (i.e. with top priority). To enable, simply add,
head=True to keymap_items.new() calls. For example:
keymap.keymap_items.new("MY_OP_my_operator_id", type='E', value='PRESS',
alt=True, head=True)
This should be useful for cases where there are similar catch-alls, where it is
necessary to insert our item before the offending catch-all (without knowing
which one it is). However, in general, it's recommended not to use this, unless
all other methods (inlcuding choosing another key combination if your first
choice doesn't work) fails.
2012-08-30 14:08:43 +00:00
|
|
|
/* create keymap item */
|
|
|
|
|
kmi = WM_keymap_add_item(km, idname_bl, type, value, modifier, keymodifier);
|
2018-06-09 14:40:09 +02:00
|
|
|
|
|
|
|
|
/* [#32437] allow scripts to define hotkeys that get added to start of keymap
|
Bugfix [#32437] Cannot define Alt-E keybinding in Text Editor window
WM_keymap_add_item(keymap, "TEXT_OT_insert", KM_TEXTINPUT, KM_ANY, KM_ANY, 0);
<--- this catch-all key map item at the end of the Text Editor keymap was
gobbling all the key events for user-defined hotkeys added after it in the
keymap. This includes all hotkeys for new operators defined by addons (via
keymap.keymap_items.new()).
As a slightly hacky workaround for this, I've added an extra parameter to
keymap_items.new() which will force the newly added item to get added to the
start of the key map items list (i.e. with top priority). To enable, simply add,
head=True to keymap_items.new() calls. For example:
keymap.keymap_items.new("MY_OP_my_operator_id", type='E', value='PRESS',
alt=True, head=True)
This should be useful for cases where there are similar catch-alls, where it is
necessary to insert our item before the offending catch-all (without knowing
which one it is). However, in general, it's recommended not to use this, unless
all other methods (inlcuding choosing another key combination if your first
choice doesn't work) fails.
2012-08-30 14:08:43 +00:00
|
|
|
* so that they stand a chance against catch-all defines later on
|
|
|
|
|
*/
|
|
|
|
|
if (head) {
|
|
|
|
|
BLI_remlink(&km->items, kmi);
|
|
|
|
|
BLI_addhead(&km->items, kmi);
|
|
|
|
|
}
|
2018-06-09 14:40:09 +02:00
|
|
|
|
Bugfix [#32437] Cannot define Alt-E keybinding in Text Editor window
WM_keymap_add_item(keymap, "TEXT_OT_insert", KM_TEXTINPUT, KM_ANY, KM_ANY, 0);
<--- this catch-all key map item at the end of the Text Editor keymap was
gobbling all the key events for user-defined hotkeys added after it in the
keymap. This includes all hotkeys for new operators defined by addons (via
keymap.keymap_items.new()).
As a slightly hacky workaround for this, I've added an extra parameter to
keymap_items.new() which will force the newly added item to get added to the
start of the key map items list (i.e. with top priority). To enable, simply add,
head=True to keymap_items.new() calls. For example:
keymap.keymap_items.new("MY_OP_my_operator_id", type='E', value='PRESS',
alt=True, head=True)
This should be useful for cases where there are similar catch-alls, where it is
necessary to insert our item before the offending catch-all (without knowing
which one it is). However, in general, it's recommended not to use this, unless
all other methods (inlcuding choosing another key combination if your first
choice doesn't work) fails.
2012-08-30 14:08:43 +00:00
|
|
|
return kmi;
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
}
|
|
|
|
|
|
2018-11-23 15:16:13 +11:00
|
|
|
static wmKeyMapItem *rna_KeyMap_item_new_from_item(
|
|
|
|
|
wmKeyMap *km, ReportList *reports, wmKeyMapItem *kmi_src, bool head)
|
|
|
|
|
{
|
|
|
|
|
/* wmWindowManager *wm = CTX_wm_manager(C); */
|
|
|
|
|
|
|
|
|
|
if ((km->flag & KEYMAP_MODAL) == (kmi_src->idname[0] != '\0')) {
|
2018-12-24 12:31:39 +01:00
|
|
|
BKE_report(reports, RPT_ERROR, "Can not mix modal/non-modal items");
|
2018-11-23 15:16:13 +11:00
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* create keymap item */
|
|
|
|
|
wmKeyMapItem *kmi = WM_keymap_add_item_copy(km, kmi_src);
|
|
|
|
|
if (head) {
|
|
|
|
|
BLI_remlink(&km->items, kmi);
|
|
|
|
|
BLI_addhead(&km->items, kmi);
|
|
|
|
|
}
|
|
|
|
|
return kmi;
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-09 14:40:09 +02:00
|
|
|
static wmKeyMapItem *rna_KeyMap_item_new_modal(
|
|
|
|
|
wmKeyMap *km, ReportList *reports, const char *propvalue_str,
|
2018-07-01 15:47:09 +02:00
|
|
|
int type, int value, bool any, bool shift, bool ctrl, bool alt,
|
|
|
|
|
bool oskey, int keymodifier)
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
int modifier = 0;
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
int propvalue = 0;
|
|
|
|
|
|
|
|
|
|
/* only modal maps */
|
|
|
|
|
if ((km->flag & KEYMAP_MODAL) == 0) {
|
2011-09-19 13:23:58 +00:00
|
|
|
BKE_report(reports, RPT_ERROR, "Not a modal keymap");
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (shift) modifier |= KM_SHIFT;
|
|
|
|
|
if (ctrl) modifier |= KM_CTRL;
|
|
|
|
|
if (alt) modifier |= KM_ALT;
|
|
|
|
|
if (oskey) modifier |= KM_OSKEY;
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (any) modifier = KM_ANY;
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
|
2012-04-17 15:40:04 +00:00
|
|
|
/* not initialized yet, do delayed lookup */
|
|
|
|
|
if (!km->modal_items)
|
|
|
|
|
return WM_modalkeymap_add_item_str(km, type, value, modifier, keymodifier, propvalue_str);
|
|
|
|
|
|
|
|
|
|
if (RNA_enum_value_from_id(km->modal_items, propvalue_str, &propvalue) == 0)
|
|
|
|
|
BKE_report(reports, RPT_WARNING, "Property value not in enumeration");
|
|
|
|
|
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
return WM_modalkeymap_add_item(km, type, value, modifier, keymodifier, propvalue);
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-02 09:41:26 +00:00
|
|
|
static void rna_KeyMap_item_remove(wmKeyMap *km, ReportList *reports, PointerRNA *kmi_ptr)
|
|
|
|
|
{
|
|
|
|
|
wmKeyMapItem *kmi = kmi_ptr->data;
|
|
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
if (WM_keymap_remove_item(km, kmi) == false) {
|
2012-11-07 14:56:53 +00:00
|
|
|
BKE_reportf(reports, RPT_ERROR, "KeyMapItem '%s' cannot be removed from '%s'", kmi->idname, km->idname);
|
2012-11-02 09:41:26 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RNA_POINTER_INVALIDATE(kmi_ptr);
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-09 12:26:10 +11:00
|
|
|
static PointerRNA rna_KeyMap_item_find_from_operator(
|
|
|
|
|
ID *id,
|
|
|
|
|
wmKeyMap *km,
|
|
|
|
|
const char *idname,
|
|
|
|
|
PointerRNA *properties,
|
|
|
|
|
int include_mask, int exclude_mask)
|
|
|
|
|
{
|
|
|
|
|
char idname_bl[OP_MAX_TYPENAME];
|
|
|
|
|
WM_operator_bl_idname(idname_bl, idname);
|
|
|
|
|
|
|
|
|
|
wmKeyMapItem *kmi = WM_key_event_operator_from_keymap(
|
|
|
|
|
km, idname_bl, properties->data, include_mask, exclude_mask);
|
|
|
|
|
PointerRNA kmi_ptr;
|
|
|
|
|
RNA_pointer_create(id, &RNA_KeyMapItem, kmi, &kmi_ptr);
|
|
|
|
|
return kmi_ptr;
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-13 21:01:32 +01:00
|
|
|
static wmKeyMap *rna_keymap_new(wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid, bool modal, bool tool)
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
{
|
2018-11-13 21:01:32 +01:00
|
|
|
wmKeyMap *keymap;
|
|
|
|
|
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
if (modal == 0) {
|
2018-11-13 21:01:32 +01:00
|
|
|
keymap = WM_keymap_ensure(keyconf, idname, spaceid, regionid);
|
2012-03-24 06:24:53 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2018-11-13 21:01:32 +01:00
|
|
|
keymap = WM_modalkeymap_add(keyconf, idname, NULL); /* items will be lazy init */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (keymap && tool) {
|
|
|
|
|
keymap->flag |= KEYMAP_TOOL;
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
}
|
2018-11-13 21:01:32 +01:00
|
|
|
|
|
|
|
|
return keymap;
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static wmKeyMap *rna_keymap_find(wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid)
|
|
|
|
|
{
|
|
|
|
|
return WM_keymap_list_find(&keyconf->keymaps, idname, spaceid, regionid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static wmKeyMap *rna_keymap_find_modal(wmKeyConfig *UNUSED(keyconf), const char *idname)
|
|
|
|
|
{
|
|
|
|
|
wmOperatorType *ot = WM_operatortype_find(idname, 0);
|
|
|
|
|
|
|
|
|
|
if (!ot)
|
|
|
|
|
return NULL;
|
|
|
|
|
else
|
|
|
|
|
return ot->modalkeymap;
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-27 14:05:07 +00:00
|
|
|
static void rna_KeyMap_remove(wmKeyConfig *keyconfig, ReportList *reports, PointerRNA *keymap_ptr)
|
|
|
|
|
{
|
|
|
|
|
wmKeyMap *keymap = keymap_ptr->data;
|
|
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
if (WM_keymap_remove(keyconfig, keymap) == false) {
|
2013-09-27 14:05:07 +00:00
|
|
|
BKE_reportf(reports, RPT_ERROR, "KeyConfig '%s' cannot be removed", keymap->idname);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RNA_POINTER_INVALIDATE(keymap_ptr);
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-02 09:41:26 +00:00
|
|
|
static void rna_KeyConfig_remove(wmWindowManager *wm, ReportList *reports, PointerRNA *keyconf_ptr)
|
|
|
|
|
{
|
|
|
|
|
wmKeyConfig *keyconf = keyconf_ptr->data;
|
|
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
if (WM_keyconfig_remove(wm, keyconf) == false) {
|
2012-11-07 14:56:53 +00:00
|
|
|
BKE_reportf(reports, RPT_ERROR, "KeyConfig '%s' cannot be removed", keyconf->idname);
|
2012-11-02 09:41:26 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RNA_POINTER_INVALIDATE(keyconf_ptr);
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-21 10:33:27 +02:00
|
|
|
static PointerRNA rna_KeyConfig_find_item_from_operator(
|
|
|
|
|
wmWindowManager *wm,
|
|
|
|
|
bContext *C,
|
|
|
|
|
const char *idname,
|
|
|
|
|
int opcontext,
|
|
|
|
|
PointerRNA *properties,
|
2018-12-12 21:39:55 +11:00
|
|
|
int include_mask, int exclude_mask,
|
2018-05-21 10:53:50 +02:00
|
|
|
PointerRNA *km_ptr)
|
2018-05-21 10:33:27 +02:00
|
|
|
{
|
|
|
|
|
char idname_bl[OP_MAX_TYPENAME];
|
|
|
|
|
WM_operator_bl_idname(idname_bl, idname);
|
|
|
|
|
|
|
|
|
|
wmKeyMap *km = NULL;
|
2018-12-12 21:39:55 +11:00
|
|
|
wmKeyMapItem *kmi = WM_key_event_operator(
|
|
|
|
|
C, idname_bl, opcontext, properties->data, include_mask, exclude_mask, &km);
|
2018-05-21 10:53:50 +02:00
|
|
|
PointerRNA kmi_ptr;
|
|
|
|
|
RNA_pointer_create(&wm->id, &RNA_KeyMap, km, km_ptr);
|
|
|
|
|
RNA_pointer_create(&wm->id, &RNA_KeyMapItem, kmi, &kmi_ptr);
|
|
|
|
|
return kmi_ptr;
|
2018-05-21 10:33:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_KeyConfig_update(wmWindowManager *wm)
|
|
|
|
|
{
|
|
|
|
|
WM_keyconfig_update(wm);
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-01 04:06:38 +00:00
|
|
|
/* popup menu wrapper */
|
2018-04-22 10:49:45 +02:00
|
|
|
static PointerRNA rna_PopMenuBegin(bContext *C, const char *title, int icon)
|
2013-06-01 04:06:38 +00:00
|
|
|
{
|
|
|
|
|
PointerRNA r_ptr;
|
|
|
|
|
void *data;
|
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
data = (void *)UI_popup_menu_begin(C, title, icon);
|
2013-06-01 04:06:38 +00:00
|
|
|
|
|
|
|
|
RNA_pointer_create(NULL, &RNA_UIPopupMenu, data, &r_ptr);
|
|
|
|
|
|
|
|
|
|
return r_ptr;
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-22 10:49:45 +02:00
|
|
|
static void rna_PopMenuEnd(bContext *C, PointerRNA *handle)
|
2013-06-01 04:06:38 +00:00
|
|
|
{
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_popup_menu_end(C, handle->data);
|
2013-06-01 04:06:38 +00:00
|
|
|
}
|
|
|
|
|
|
2018-04-22 17:16:39 +02:00
|
|
|
/* popover wrapper */
|
2018-07-03 19:50:00 +02:00
|
|
|
static PointerRNA rna_PopoverBegin(bContext *C, int ui_units_x)
|
2018-04-22 17:16:39 +02:00
|
|
|
{
|
|
|
|
|
PointerRNA r_ptr;
|
|
|
|
|
void *data;
|
|
|
|
|
|
2018-07-03 19:50:00 +02:00
|
|
|
data = (void *)UI_popover_begin(C, U.widget_unit * ui_units_x);
|
2018-04-22 17:16:39 +02:00
|
|
|
|
|
|
|
|
RNA_pointer_create(NULL, &RNA_UIPopover, data, &r_ptr);
|
|
|
|
|
|
|
|
|
|
return r_ptr;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-20 22:34:18 +02:00
|
|
|
static void rna_PopoverEnd(bContext *C, PointerRNA *handle, wmKeyMap *keymap)
|
2018-04-22 17:16:39 +02:00
|
|
|
{
|
2018-05-20 22:34:18 +02:00
|
|
|
UI_popover_end(C, handle->data, keymap);
|
2018-04-22 17:16:39 +02:00
|
|
|
}
|
|
|
|
|
|
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.
2014-08-11 10:39:59 +02:00
|
|
|
/* pie menu wrapper */
|
|
|
|
|
static PointerRNA rna_PieMenuBegin(bContext *C, const char *title, int icon, PointerRNA *event)
|
|
|
|
|
{
|
|
|
|
|
PointerRNA r_ptr;
|
|
|
|
|
void *data;
|
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
data = (void *)UI_pie_menu_begin(C, title, icon, event->data);
|
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.
2014-08-11 10:39:59 +02:00
|
|
|
|
|
|
|
|
RNA_pointer_create(NULL, &RNA_UIPieMenu, data, &r_ptr);
|
|
|
|
|
|
|
|
|
|
return r_ptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_PieMenuEnd(bContext *C, PointerRNA *handle)
|
|
|
|
|
{
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_pie_menu_end(C, handle->data);
|
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.
2014-08-11 10:39:59 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-04 15:01:55 +11:00
|
|
|
static void rna_WindowManager_print_undo_steps(wmWindowManager *wm)
|
|
|
|
|
{
|
|
|
|
|
BKE_undosys_print(wm->undo_stack);
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-27 10:03:57 +02:00
|
|
|
static PointerRNA rna_WindoManager_operator_properties_last(const char *idname)
|
|
|
|
|
{
|
|
|
|
|
wmOperatorType *ot = WM_operatortype_find(idname, true);
|
|
|
|
|
|
|
|
|
|
if (ot != NULL) {
|
|
|
|
|
PointerRNA ptr;
|
2018-05-02 17:59:43 +02:00
|
|
|
WM_operator_last_properties_ensure(ot, &ptr);
|
2018-04-27 10:03:57 +02:00
|
|
|
return ptr;
|
|
|
|
|
}
|
|
|
|
|
return PointerRNA_NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-02 15:14:51 +11:00
|
|
|
static wmEvent *rna_Window_event_add_simulate(
|
|
|
|
|
wmWindow *win, ReportList *reports,
|
|
|
|
|
int type, int value, const char *unicode,
|
|
|
|
|
int x, int y,
|
|
|
|
|
bool shift, bool ctrl, bool alt, bool oskey)
|
|
|
|
|
{
|
|
|
|
|
if ((G.f & G_FLAG_EVENT_SIMULATE) == 0) {
|
|
|
|
|
BKE_report(reports, RPT_ERROR, "Not running with '--enable-event-simulate' enabled");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!ELEM(value, KM_PRESS, KM_RELEASE, KM_NOTHING)) {
|
|
|
|
|
BKE_report(reports, RPT_ERROR, "value: only 'PRESS/RELEASE/NOTHING' are supported");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
if (ISKEYBOARD(type) || ISMOUSE_BUTTON(type)) {
|
|
|
|
|
if (!ELEM(value, KM_PRESS, KM_RELEASE)) {
|
|
|
|
|
BKE_report(reports, RPT_ERROR, "value: must be 'PRESS/RELEASE' for keyboard/buttons");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (ELEM(type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) {
|
|
|
|
|
if (value != KM_NOTHING) {
|
|
|
|
|
BKE_report(reports, RPT_ERROR, "value: must be 'NOTHING' for motion");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (unicode != NULL) {
|
|
|
|
|
if (value != KM_PRESS) {
|
|
|
|
|
BKE_report(reports, RPT_ERROR, "value: must be 'PRESS' when unicode is set");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/* TODO: validate NDOF. */
|
|
|
|
|
|
|
|
|
|
char ascii = 0;
|
|
|
|
|
if (unicode != NULL) {
|
|
|
|
|
int len = BLI_str_utf8_size(unicode);
|
|
|
|
|
if (len == -1 || unicode[len] != '\0') {
|
|
|
|
|
BKE_report(reports, RPT_ERROR, "Only a single character supported");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
if (len == 1 && isascii(unicode[0])) {
|
|
|
|
|
ascii = unicode[0];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-08 19:00:51 +11:00
|
|
|
wmEvent e = *win->eventstate;
|
2019-02-02 15:14:51 +11:00
|
|
|
e.type = type;
|
|
|
|
|
e.val = value;
|
|
|
|
|
e.x = x;
|
|
|
|
|
e.y = y;
|
|
|
|
|
/* Note: KM_MOD_FIRST, KM_MOD_SECOND aren't used anywhere, set as bools */
|
|
|
|
|
e.shift = shift;
|
|
|
|
|
e.ctrl = ctrl;
|
|
|
|
|
e.alt = alt;
|
|
|
|
|
e.oskey = oskey;
|
|
|
|
|
|
2019-02-08 19:00:51 +11:00
|
|
|
e.prevx = win->eventstate->x;
|
|
|
|
|
e.prevy = win->eventstate->y;
|
|
|
|
|
e.prevval = win->eventstate->val;
|
|
|
|
|
e.prevtype = win->eventstate->type;
|
2019-02-02 15:14:51 +11:00
|
|
|
|
2019-02-08 19:00:51 +11:00
|
|
|
e.ascii = '\0';
|
|
|
|
|
e.utf8_buf[0] = '\0';
|
2019-02-02 15:14:51 +11:00
|
|
|
if (unicode != NULL) {
|
|
|
|
|
e.ascii = ascii;
|
|
|
|
|
STRNCPY(e.utf8_buf, unicode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return WM_event_add_simulate(win, &e);
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-18 19:48:55 +00:00
|
|
|
#else
|
|
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
#define WM_GEN_INVOKE_EVENT (1 << 0)
|
|
|
|
|
#define WM_GEN_INVOKE_SIZE (1 << 1)
|
|
|
|
|
#define WM_GEN_INVOKE_RETURN (1 << 2)
|
2010-03-20 18:03:59 +00:00
|
|
|
|
|
|
|
|
static void rna_generic_op_invoke(FunctionRNA *func, int flag)
|
2010-01-15 22:40:33 +00:00
|
|
|
{
|
|
|
|
|
PropertyRNA *parm;
|
|
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_CONTEXT);
|
2012-03-05 23:30:41 +00:00
|
|
|
parm = RNA_def_pointer(func, "operator", "Operator", "", "Operator to call");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
2010-01-15 22:40:33 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (flag & WM_GEN_INVOKE_EVENT) {
|
|
|
|
|
parm = RNA_def_pointer(func, "event", "Event", "", "Event");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
2010-01-15 22:40:33 +00:00
|
|
|
}
|
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (flag & WM_GEN_INVOKE_SIZE) {
|
2011-09-19 13:23:58 +00:00
|
|
|
RNA_def_int(func, "width", 300, 0, INT_MAX, "", "Width of the popup", 0, INT_MAX);
|
|
|
|
|
RNA_def_int(func, "height", 20, 0, INT_MAX, "", "Height of the popup", 0, INT_MAX);
|
2010-03-22 09:30:00 +00:00
|
|
|
}
|
2010-03-20 18:03:59 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (flag & WM_GEN_INVOKE_RETURN) {
|
2015-11-23 13:49:52 +11:00
|
|
|
parm = RNA_def_enum_flag(func, "result", rna_enum_operator_return_items, OPERATOR_CANCELLED, "result", "");
|
2010-01-15 22:40:33 +00:00
|
|
|
RNA_def_function_return(func, parm);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-06 22:54:22 +00:00
|
|
|
void RNA_api_window(StructRNA *srna)
|
|
|
|
|
{
|
|
|
|
|
FunctionRNA *func;
|
|
|
|
|
PropertyRNA *parm;
|
|
|
|
|
|
2013-09-06 23:17:29 +00:00
|
|
|
func = RNA_def_function(srna, "cursor_warp", "WM_cursor_warp");
|
|
|
|
|
parm = RNA_def_int(func, "x", 0, INT_MIN, INT_MAX, "", "", INT_MIN, INT_MAX);
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
2013-09-06 23:17:29 +00:00
|
|
|
parm = RNA_def_int(func, "y", 0, INT_MIN, INT_MAX, "", "", INT_MIN, INT_MAX);
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
2013-09-06 23:17:29 +00:00
|
|
|
RNA_def_function_ui_description(func, "Set the cursor position");
|
2013-09-06 22:54:22 +00:00
|
|
|
|
|
|
|
|
func = RNA_def_function(srna, "cursor_set", "WM_cursor_set");
|
2013-09-06 23:17:29 +00:00
|
|
|
parm = RNA_def_property(func, "cursor", PROP_ENUM, PROP_NONE);
|
2015-11-23 13:49:52 +11:00
|
|
|
RNA_def_property_enum_items(parm, rna_enum_window_cursor_items);
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
2013-09-06 22:54:22 +00:00
|
|
|
RNA_def_function_ui_description(func, "Set the cursor");
|
|
|
|
|
|
|
|
|
|
func = RNA_def_function(srna, "cursor_modal_set", "WM_cursor_modal_set");
|
2013-09-06 23:17:29 +00:00
|
|
|
parm = RNA_def_property(func, "cursor", PROP_ENUM, PROP_NONE);
|
2015-11-23 13:49:52 +11:00
|
|
|
RNA_def_property_enum_items(parm, rna_enum_window_cursor_items);
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
2013-09-06 22:54:22 +00:00
|
|
|
RNA_def_function_ui_description(func, "Set the cursor, so the previous cursor can be restored");
|
|
|
|
|
|
|
|
|
|
RNA_def_function(srna, "cursor_modal_restore", "WM_cursor_modal_restore");
|
|
|
|
|
RNA_def_function_ui_description(func, "Restore the previous cursor after calling ``cursor_modal_set``");
|
2019-02-02 15:14:51 +11:00
|
|
|
|
|
|
|
|
/* Arguments match 'rna_KeyMap_item_new'. */
|
|
|
|
|
func = RNA_def_function(srna, "event_simulate", "rna_Window_event_add_simulate");
|
|
|
|
|
RNA_def_function_flag(func, FUNC_USE_REPORTS);
|
|
|
|
|
parm = RNA_def_enum(func, "type", rna_enum_event_type_items, 0, "Type", "");
|
|
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
|
|
|
|
parm = RNA_def_enum(func, "value", rna_enum_event_value_items, 0, "Value", "");
|
|
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
|
|
|
|
parm = RNA_def_string(func, "unicode", NULL, 0, "", "");
|
|
|
|
|
RNA_def_parameter_clear_flags(parm, PROP_NEVER_NULL, 0);
|
|
|
|
|
|
|
|
|
|
RNA_def_int(func, "x", 0, INT_MIN, INT_MAX, "", "", INT_MIN, INT_MAX);
|
|
|
|
|
RNA_def_int(func, "y", 0, INT_MIN, INT_MAX, "", "", INT_MIN, INT_MAX);
|
|
|
|
|
|
|
|
|
|
RNA_def_boolean(func, "shift", 0, "Shift", "");
|
|
|
|
|
RNA_def_boolean(func, "ctrl", 0, "Ctrl", "");
|
|
|
|
|
RNA_def_boolean(func, "alt", 0, "Alt", "");
|
|
|
|
|
RNA_def_boolean(func, "oskey", 0, "OS Key", "");
|
|
|
|
|
parm = RNA_def_pointer(func, "event", "Event", "Item", "Added key map item");
|
|
|
|
|
RNA_def_function_return(func, parm);
|
2013-09-06 22:54:22 +00:00
|
|
|
}
|
|
|
|
|
|
2009-06-18 19:48:55 +00:00
|
|
|
void RNA_api_wm(StructRNA *srna)
|
|
|
|
|
{
|
|
|
|
|
FunctionRNA *func;
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
PropertyRNA *parm;
|
2009-06-18 19:48:55 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "fileselect_add", "WM_event_add_fileselect");
|
2012-02-07 06:07:02 +00:00
|
|
|
RNA_def_function_ui_description(func, "Opens a file selector with an operator. "
|
2012-03-18 09:27:36 +00:00
|
|
|
"The string properties 'filepath', 'filename', 'directory' and a 'files' "
|
|
|
|
|
"collection are assigned when present in the operator");
|
2010-03-20 18:03:59 +00:00
|
|
|
rna_generic_op_invoke(func, 0);
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "modal_handler_add", "rna_event_modal_handler_add");
|
2016-09-05 10:58:33 +02:00
|
|
|
RNA_def_function_ui_description(func, "Add a modal handler to the window manager, for the given modal operator "
|
|
|
|
|
"(called by invoke() with self, just before returning {'RUNNING_MODAL'})");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_CONTEXT);
|
2012-03-05 23:30:41 +00:00
|
|
|
parm = RNA_def_pointer(func, "operator", "Operator", "", "Operator to call");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
2016-09-05 10:58:33 +02:00
|
|
|
RNA_def_function_return(func, RNA_def_boolean(func, "handle", 1, "", "Whether adding the handler was successful"));
|
2010-02-21 11:56:00 +00:00
|
|
|
|
2011-03-28 04:55:24 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "event_timer_add", "rna_event_timer_add");
|
2016-09-05 10:58:33 +02:00
|
|
|
RNA_def_function_ui_description(func, "Add a timer to the given window, to generate periodic 'TIMER' events");
|
2012-03-05 23:30:41 +00:00
|
|
|
parm = RNA_def_property(func, "time_step", PROP_FLOAT, PROP_NONE);
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
2011-03-28 04:55:24 +00:00
|
|
|
RNA_def_property_range(parm, 0.0, FLT_MAX);
|
|
|
|
|
RNA_def_property_ui_text(parm, "Time Step", "Interval in seconds between timer events");
|
2016-09-05 10:58:33 +02:00
|
|
|
RNA_def_pointer(func, "window", "Window", "", "Window to attach the timer to, or None");
|
2012-03-05 23:30:41 +00:00
|
|
|
parm = RNA_def_pointer(func, "result", "Timer", "", "");
|
2011-03-28 04:55:24 +00:00
|
|
|
RNA_def_function_return(func, parm);
|
|
|
|
|
|
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "event_timer_remove", "rna_event_timer_remove");
|
|
|
|
|
parm = RNA_def_pointer(func, "timer", "Timer", "", "");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
|
2011-03-28 04:55:24 +00:00
|
|
|
|
2018-12-04 10:15:02 +11:00
|
|
|
func = RNA_def_function(srna, "gizmo_group_type_ensure", "rna_gizmo_group_type_ensure");
|
2017-06-26 15:57:14 +10:00
|
|
|
RNA_def_function_ui_description(func, "Activate an existing widget group (when the persistent option isn't set)");
|
|
|
|
|
RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_REPORTS);
|
2018-07-14 23:49:00 +02:00
|
|
|
parm = RNA_def_string(func, "identifier", NULL, 0, "", "Gizmo group type name");
|
2017-06-26 15:57:14 +10:00
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
|
|
|
|
|
2018-12-04 10:15:02 +11:00
|
|
|
func = RNA_def_function(srna, "gizmo_group_type_unlink_delayed", "rna_gizmo_group_type_unlink_delayed");
|
|
|
|
|
RNA_def_function_ui_description(func, "Unlink a widget group (when the persistent option is set)");
|
|
|
|
|
RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_REPORTS);
|
2018-07-14 23:49:00 +02:00
|
|
|
parm = RNA_def_string(func, "identifier", NULL, 0, "", "Gizmo group type name");
|
2017-06-26 15:57:14 +10:00
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
|
|
|
|
|
2013-04-19 14:47:11 +00:00
|
|
|
/* Progress bar interface */
|
|
|
|
|
func = RNA_def_function(srna, "progress_begin", "rna_progress_begin");
|
2015-10-26 14:10:25 +01:00
|
|
|
RNA_def_function_ui_description(func, "Start progress report");
|
2013-04-19 14:47:11 +00:00
|
|
|
parm = RNA_def_property(func, "min", PROP_FLOAT, PROP_NONE);
|
2013-07-17 17:07:11 +00:00
|
|
|
RNA_def_property_ui_text(parm, "min", "any value in range [0,9999]");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
2013-04-19 14:47:11 +00:00
|
|
|
parm = RNA_def_property(func, "max", PROP_FLOAT, PROP_NONE);
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
2013-07-17 17:07:11 +00:00
|
|
|
RNA_def_property_ui_text(parm, "max", "any value in range [min+1,9998]");
|
2013-04-19 14:47:11 +00:00
|
|
|
|
|
|
|
|
func = RNA_def_function(srna, "progress_update", "rna_progress_update");
|
2016-09-05 10:58:33 +02:00
|
|
|
RNA_def_function_ui_description(func, "Update the progress feedback");
|
2013-04-19 14:47:11 +00:00
|
|
|
parm = RNA_def_property(func, "value", PROP_FLOAT, PROP_NONE);
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
2016-09-05 10:58:33 +02:00
|
|
|
RNA_def_property_ui_text(parm, "value", "Any value between min and max as set in progress_begin()");
|
2013-04-19 14:47:11 +00:00
|
|
|
|
|
|
|
|
func = RNA_def_function(srna, "progress_end", "rna_progress_end");
|
2015-10-26 14:10:25 +01:00
|
|
|
RNA_def_function_ui_description(func, "Terminate progress report");
|
2011-03-28 04:55:24 +00:00
|
|
|
|
2009-10-27 02:54:25 +00:00
|
|
|
/* invoke functions, for use with python */
|
2013-03-13 09:03:46 +00:00
|
|
|
func = RNA_def_function(srna, "invoke_props_popup", "rna_Operator_props_popup");
|
2016-09-05 10:58:33 +02:00
|
|
|
RNA_def_function_ui_description(func, "Operator popup invoke "
|
|
|
|
|
"(show operator properties and execute it automatically on changes)");
|
2012-05-12 11:01:29 +00:00
|
|
|
rna_generic_op_invoke(func, WM_GEN_INVOKE_EVENT | WM_GEN_INVOKE_RETURN);
|
2010-03-20 18:03:59 +00:00
|
|
|
|
|
|
|
|
/* invoked dialog opens popup with OK button, does not auto-exec operator. */
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "invoke_props_dialog", "WM_operator_props_dialog_popup");
|
2016-09-05 10:58:33 +02:00
|
|
|
RNA_def_function_ui_description(func, "Operator dialog (non-autoexec popup) invoke "
|
|
|
|
|
"(show operator properties and only execute it on click on OK button)");
|
2012-05-12 11:01:29 +00:00
|
|
|
rna_generic_op_invoke(func, WM_GEN_INVOKE_SIZE | WM_GEN_INVOKE_RETURN);
|
2009-12-07 00:16:57 +00:00
|
|
|
|
2010-01-15 22:40:33 +00:00
|
|
|
/* invoke enum */
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "invoke_search_popup", "rna_Operator_enum_search_invoke");
|
2018-01-26 11:52:01 +11:00
|
|
|
RNA_def_function_ui_description(
|
|
|
|
|
func,
|
|
|
|
|
"Operator search popup invoke which "
|
|
|
|
|
"searches values of the operator's :class:`bpy.types.Operator.bl_property` "
|
|
|
|
|
"(which must be an EnumProperty), executing it on confirmation");
|
2010-03-20 18:03:59 +00:00
|
|
|
rna_generic_op_invoke(func, 0);
|
2009-12-06 04:35:00 +00:00
|
|
|
|
|
|
|
|
/* invoke functions, for use with python */
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "invoke_popup", "WM_operator_ui_popup");
|
2016-09-05 10:58:33 +02:00
|
|
|
RNA_def_function_ui_description(func, "Operator popup invoke "
|
|
|
|
|
"(only shows operator's properties, without executing it)");
|
2012-05-12 11:01:29 +00:00
|
|
|
rna_generic_op_invoke(func, WM_GEN_INVOKE_SIZE | WM_GEN_INVOKE_RETURN);
|
2010-11-22 13:43:51 +00:00
|
|
|
|
2013-03-13 09:03:46 +00:00
|
|
|
func = RNA_def_function(srna, "invoke_confirm", "rna_Operator_confirm");
|
2016-09-05 10:58:33 +02:00
|
|
|
RNA_def_function_ui_description(func, "Operator confirmation popup "
|
|
|
|
|
"(only to let user confirm the execution, no operator properties shown)");
|
2012-05-12 11:01:29 +00:00
|
|
|
rna_generic_op_invoke(func, WM_GEN_INVOKE_EVENT | WM_GEN_INVOKE_RETURN);
|
2013-06-01 04:06:38 +00:00
|
|
|
|
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
/* wrap UI_popup_menu_begin */
|
2018-04-22 10:49:45 +02:00
|
|
|
func = RNA_def_function(srna, "popmenu_begin__internal", "rna_PopMenuBegin");
|
2013-06-01 04:06:38 +00:00
|
|
|
RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_CONTEXT);
|
2014-01-16 21:43:22 +11:00
|
|
|
parm = RNA_def_string(func, "title", NULL, 0, "", "");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
2013-06-01 04:06:38 +00:00
|
|
|
parm = RNA_def_property(func, "icon", PROP_ENUM, PROP_NONE);
|
2015-11-23 13:49:52 +11:00
|
|
|
RNA_def_property_enum_items(parm, rna_enum_icon_items);
|
2013-06-01 04:06:38 +00:00
|
|
|
/* return */
|
|
|
|
|
parm = RNA_def_pointer(func, "menu", "UIPopupMenu", "", "");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_RNAPTR);
|
2013-06-01 04:06:38 +00:00
|
|
|
RNA_def_function_return(func, parm);
|
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
/* wrap UI_popup_menu_end */
|
2018-04-22 10:49:45 +02:00
|
|
|
func = RNA_def_function(srna, "popmenu_end__internal", "rna_PopMenuEnd");
|
2013-06-01 04:06:38 +00:00
|
|
|
RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_CONTEXT);
|
|
|
|
|
parm = RNA_def_pointer(func, "menu", "UIPopupMenu", "", "");
|
2018-08-28 13:48:01 +10:00
|
|
|
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_RNAPTR | PARM_REQUIRED);
|
2018-04-22 17:16:39 +02:00
|
|
|
|
2018-05-18 19:55:04 +02:00
|
|
|
/* wrap UI_popover_begin */
|
2018-04-22 17:16:39 +02:00
|
|
|
func = RNA_def_function(srna, "popover_begin__internal", "rna_PopoverBegin");
|
|
|
|
|
RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_CONTEXT);
|
2018-07-03 19:50:00 +02:00
|
|
|
RNA_def_property(func, "ui_units_x", PROP_INT, PROP_UNSIGNED);
|
2018-04-22 17:16:39 +02:00
|
|
|
/* return */
|
|
|
|
|
parm = RNA_def_pointer(func, "menu", "UIPopover", "", "");
|
|
|
|
|
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_RNAPTR);
|
|
|
|
|
RNA_def_function_return(func, parm);
|
|
|
|
|
|
2018-05-18 19:55:04 +02:00
|
|
|
/* wrap UI_popover_end */
|
2018-04-22 17:16:39 +02:00
|
|
|
func = RNA_def_function(srna, "popover_end__internal", "rna_PopoverEnd");
|
|
|
|
|
RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_CONTEXT);
|
|
|
|
|
parm = RNA_def_pointer(func, "menu", "UIPopover", "", "");
|
2018-08-28 13:48:01 +10:00
|
|
|
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_RNAPTR | PARM_REQUIRED);
|
2018-05-20 22:34:18 +02:00
|
|
|
RNA_def_pointer(func, "keymap", "KeyMap", "Key Map", "Active key map");
|
2018-04-22 17:16:39 +02:00
|
|
|
|
|
|
|
|
|
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.
2014-08-11 10:39:59 +02:00
|
|
|
/* wrap uiPieMenuBegin */
|
|
|
|
|
func = RNA_def_function(srna, "piemenu_begin__internal", "rna_PieMenuBegin");
|
|
|
|
|
RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_CONTEXT);
|
|
|
|
|
parm = RNA_def_string(func, "title", NULL, 0, "", "");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
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.
2014-08-11 10:39:59 +02:00
|
|
|
parm = RNA_def_property(func, "icon", PROP_ENUM, PROP_NONE);
|
2015-11-23 13:49:52 +11:00
|
|
|
RNA_def_property_enum_items(parm, rna_enum_icon_items);
|
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.
2014-08-11 10:39:59 +02:00
|
|
|
parm = RNA_def_pointer(func, "event", "Event", "", "");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_RNAPTR);
|
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.
2014-08-11 10:39:59 +02:00
|
|
|
/* return */
|
|
|
|
|
parm = RNA_def_pointer(func, "menu_pie", "UIPieMenu", "", "");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_RNAPTR);
|
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.
2014-08-11 10:39:59 +02:00
|
|
|
RNA_def_function_return(func, parm);
|
|
|
|
|
|
|
|
|
|
/* wrap uiPieMenuEnd */
|
|
|
|
|
func = RNA_def_function(srna, "piemenu_end__internal", "rna_PieMenuEnd");
|
|
|
|
|
RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_CONTEXT);
|
|
|
|
|
parm = RNA_def_pointer(func, "menu", "UIPieMenu", "", "");
|
2018-08-28 13:48:01 +10:00
|
|
|
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_RNAPTR | PARM_REQUIRED);
|
2018-04-27 10:03:57 +02:00
|
|
|
|
|
|
|
|
/* access last operator options (optionally create). */
|
|
|
|
|
func = RNA_def_function(srna, "operator_properties_last", "rna_WindoManager_operator_properties_last");
|
|
|
|
|
RNA_def_function_flag(func, FUNC_NO_SELF);
|
|
|
|
|
parm = RNA_def_string(func, "operator", NULL, 0, "", "");
|
|
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
|
|
|
|
/* return */
|
|
|
|
|
parm = RNA_def_pointer(func, "result", "OperatorProperties", "", "");
|
|
|
|
|
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_RNAPTR);
|
|
|
|
|
RNA_def_function_return(func, parm);
|
|
|
|
|
|
2019-02-04 15:01:55 +11:00
|
|
|
RNA_def_function(srna, "print_undo_steps", "rna_WindowManager_print_undo_steps");
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
}
|
|
|
|
|
|
2009-12-10 16:52:44 +00:00
|
|
|
void RNA_api_operator(StructRNA *srna)
|
|
|
|
|
{
|
|
|
|
|
FunctionRNA *func;
|
|
|
|
|
PropertyRNA *parm;
|
|
|
|
|
|
2009-12-24 16:10:26 +00:00
|
|
|
/* utility, not for registering */
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "report", "rna_Operator_report");
|
2015-11-23 13:49:52 +11:00
|
|
|
parm = RNA_def_enum_flag(func, "type", rna_enum_wm_report_items, 0, "Type", "");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
2014-01-16 21:43:22 +11:00
|
|
|
parm = RNA_def_string(func, "message", NULL, 0, "Report Message", "");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
2009-12-24 16:10:26 +00:00
|
|
|
|
2017-03-15 03:43:44 +11:00
|
|
|
/* utility, not for registering */
|
|
|
|
|
func = RNA_def_function(srna, "is_repeat", "rna_Operator_is_repeat");
|
|
|
|
|
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
|
|
|
|
|
/* return */
|
|
|
|
|
parm = RNA_def_boolean(func, "result", 0, "result", "");
|
|
|
|
|
RNA_def_function_return(func, parm);
|
2009-12-24 16:10:26 +00:00
|
|
|
|
|
|
|
|
/* Registration */
|
|
|
|
|
|
|
|
|
|
/* poll */
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "poll", NULL);
|
2011-09-19 13:23:58 +00:00
|
|
|
RNA_def_function_ui_description(func, "Test if the operator can be called or not");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_REGISTER_OPTIONAL);
|
2009-12-24 16:10:26 +00:00
|
|
|
RNA_def_function_return(func, RNA_def_boolean(func, "visible", 1, "", ""));
|
2012-03-05 23:30:41 +00:00
|
|
|
parm = RNA_def_pointer(func, "context", "Context", "", "");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
|
2009-12-24 16:10:26 +00:00
|
|
|
|
|
|
|
|
/* exec */
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "execute", NULL);
|
2011-09-19 13:23:58 +00:00
|
|
|
RNA_def_function_ui_description(func, "Execute the operator");
|
2012-11-03 14:31:38 +00:00
|
|
|
RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE);
|
2012-03-05 23:30:41 +00:00
|
|
|
parm = RNA_def_pointer(func, "context", "Context", "", "");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
|
2009-12-24 16:10:26 +00:00
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
/* better name? */
|
2015-11-23 13:49:52 +11:00
|
|
|
parm = RNA_def_enum_flag(func, "result", rna_enum_operator_return_items, OPERATOR_CANCELLED, "result", "");
|
2009-12-24 16:10:26 +00:00
|
|
|
RNA_def_function_return(func, parm);
|
|
|
|
|
|
2010-09-17 09:27:31 +00:00
|
|
|
/* check */
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "check", NULL);
|
2011-09-19 13:23:58 +00:00
|
|
|
RNA_def_function_ui_description(func, "Check the operator settings, return True to signal a change to redraw");
|
2012-11-03 14:31:38 +00:00
|
|
|
RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE);
|
2012-03-05 23:30:41 +00:00
|
|
|
parm = RNA_def_pointer(func, "context", "Context", "", "");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
|
2010-09-17 09:27:31 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
parm = RNA_def_boolean(func, "result", 0, "result", ""); /* better name? */
|
2010-09-17 09:27:31 +00:00
|
|
|
RNA_def_function_return(func, parm);
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2009-12-24 16:10:26 +00:00
|
|
|
/* invoke */
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "invoke", NULL);
|
2011-09-19 13:23:58 +00:00
|
|
|
RNA_def_function_ui_description(func, "Invoke the operator");
|
2012-11-03 14:31:38 +00:00
|
|
|
RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE);
|
2012-03-05 23:30:41 +00:00
|
|
|
parm = RNA_def_pointer(func, "context", "Context", "", "");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
|
2012-03-05 23:30:41 +00:00
|
|
|
parm = RNA_def_pointer(func, "event", "Event", "", "");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
|
2009-12-24 16:10:26 +00:00
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
/* better name? */
|
2015-11-23 13:49:52 +11:00
|
|
|
parm = RNA_def_enum_flag(func, "result", rna_enum_operator_return_items, OPERATOR_CANCELLED, "result", "");
|
2009-12-24 16:10:26 +00:00
|
|
|
RNA_def_function_return(func, parm);
|
2009-12-24 21:17:14 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "modal", NULL); /* same as invoke */
|
2011-09-19 13:23:58 +00:00
|
|
|
RNA_def_function_ui_description(func, "Modal operator function");
|
2012-11-03 14:31:38 +00:00
|
|
|
RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE);
|
2012-03-05 23:30:41 +00:00
|
|
|
parm = RNA_def_pointer(func, "context", "Context", "", "");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
|
2012-03-05 23:30:41 +00:00
|
|
|
parm = RNA_def_pointer(func, "event", "Event", "", "");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
|
2010-02-21 11:56:00 +00:00
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
/* better name? */
|
2015-11-23 13:49:52 +11:00
|
|
|
parm = RNA_def_enum_flag(func, "result", rna_enum_operator_return_items, OPERATOR_CANCELLED, "result", "");
|
2010-02-21 11:56:00 +00:00
|
|
|
RNA_def_function_return(func, parm);
|
|
|
|
|
|
2009-12-24 21:17:14 +00:00
|
|
|
/* draw */
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "draw", NULL);
|
2011-09-19 13:23:58 +00:00
|
|
|
RNA_def_function_ui_description(func, "Draw function for the operator");
|
2009-12-24 21:17:14 +00:00
|
|
|
RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
|
2012-03-05 23:30:41 +00:00
|
|
|
parm = RNA_def_pointer(func, "context", "Context", "", "");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
|
2011-03-17 07:02:02 +00:00
|
|
|
|
|
|
|
|
/* cancel */
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "cancel", NULL);
|
2012-03-08 04:12:11 +00:00
|
|
|
RNA_def_function_ui_description(func, "Called when the operator is canceled");
|
2012-11-03 14:31:38 +00:00
|
|
|
RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE);
|
2012-03-05 23:30:41 +00:00
|
|
|
parm = RNA_def_pointer(func, "context", "Context", "", "");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
|
2009-12-10 16:52:44 +00:00
|
|
|
}
|
|
|
|
|
|
2009-12-30 22:14:32 +00:00
|
|
|
void RNA_api_macro(StructRNA *srna)
|
|
|
|
|
{
|
|
|
|
|
FunctionRNA *func;
|
|
|
|
|
PropertyRNA *parm;
|
|
|
|
|
|
|
|
|
|
/* utility, not for registering */
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "report", "rna_Operator_report");
|
2015-11-23 13:49:52 +11:00
|
|
|
parm = RNA_def_enum_flag(func, "type", rna_enum_wm_report_items, 0, "Type", "");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
2014-01-16 21:43:22 +11:00
|
|
|
parm = RNA_def_string(func, "message", NULL, 0, "Report Message", "");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
2009-12-30 22:14:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Registration */
|
|
|
|
|
|
|
|
|
|
/* poll */
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "poll", NULL);
|
2011-09-19 13:23:58 +00:00
|
|
|
RNA_def_function_ui_description(func, "Test if the operator can be called or not");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_REGISTER_OPTIONAL);
|
2009-12-30 22:14:32 +00:00
|
|
|
RNA_def_function_return(func, RNA_def_boolean(func, "visible", 1, "", ""));
|
2012-03-05 23:30:41 +00:00
|
|
|
parm = RNA_def_pointer(func, "context", "Context", "", "");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
|
2009-12-30 22:14:32 +00:00
|
|
|
|
|
|
|
|
/* draw */
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "draw", NULL);
|
2011-09-19 13:23:58 +00:00
|
|
|
RNA_def_function_ui_description(func, "Draw function for the operator");
|
2009-12-30 22:14:32 +00:00
|
|
|
RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
|
2012-03-05 23:30:41 +00:00
|
|
|
parm = RNA_def_pointer(func, "context", "Context", "", "");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
|
2009-12-30 22:14:32 +00:00
|
|
|
}
|
|
|
|
|
|
2012-09-24 22:39:45 +00:00
|
|
|
void RNA_api_keyconfig(StructRNA *UNUSED(srna))
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
/* FunctionRNA *func; */
|
|
|
|
|
/* PropertyRNA *parm; */
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RNA_api_keymap(StructRNA *srna)
|
|
|
|
|
{
|
|
|
|
|
FunctionRNA *func;
|
|
|
|
|
PropertyRNA *parm;
|
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "active", "rna_keymap_active");
|
2009-11-16 20:50:02 +00:00
|
|
|
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
|
2012-03-05 23:30:41 +00:00
|
|
|
parm = RNA_def_pointer(func, "keymap", "KeyMap", "Key Map", "Active key map");
|
2009-11-16 20:50:02 +00:00
|
|
|
RNA_def_function_return(func, parm);
|
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "restore_to_default", "WM_keymap_restore_to_default");
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
|
2009-12-17 03:32:33 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "restore_item_to_default", "rna_keymap_restore_item_to_default");
|
2009-12-17 03:32:33 +00:00
|
|
|
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
|
2012-03-05 23:30:41 +00:00
|
|
|
parm = RNA_def_pointer(func, "item", "KeyMapItem", "Item", "");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
|
2009-06-18 19:48:55 +00:00
|
|
|
}
|
|
|
|
|
|
Keymap conflict detection operator.
Takes into account the hierarchical structures of keymaps as well as wildcards (KM_ANY) in event definitions, user remaps (emulate numpad, action/select mouse buttons, ...) and event values that overlap (click, press and release)
For now, doesn't do anything other than print conflicts in the console.
As a result, I cleaned up a lot of keymaps that had double definitions, moved some keymap items in more appropriate places, fixed wrong definitions and removed kmi that were added for testing a long long time ago.
Out of all the remaining conflicts, after removing obvious non-issues, here's what remains: http://www.pasteall.org/9898
2009-12-17 22:14:43 +00:00
|
|
|
void RNA_api_keymapitem(StructRNA *srna)
|
|
|
|
|
{
|
|
|
|
|
FunctionRNA *func;
|
|
|
|
|
PropertyRNA *parm;
|
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "compare", "WM_keymap_item_compare");
|
|
|
|
|
parm = RNA_def_pointer(func, "item", "KeyMapItem", "Item", "");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
2012-03-05 23:30:41 +00:00
|
|
|
parm = RNA_def_boolean(func, "result", 0, "Comparison result", "");
|
Keymap conflict detection operator.
Takes into account the hierarchical structures of keymaps as well as wildcards (KM_ANY) in event definitions, user remaps (emulate numpad, action/select mouse buttons, ...) and event values that overlap (click, press and release)
For now, doesn't do anything other than print conflicts in the console.
As a result, I cleaned up a lot of keymaps that had double definitions, moved some keymap items in more appropriate places, fixed wrong definitions and removed kmi that were added for testing a long long time ago.
Out of all the remaining conflicts, after removing obvious non-issues, here's what remains: http://www.pasteall.org/9898
2009-12-17 22:14:43 +00:00
|
|
|
RNA_def_function_return(func, parm);
|
2018-11-28 23:24:10 +11:00
|
|
|
|
|
|
|
|
func = RNA_def_function(srna, "to_string", "rna_KeyMapItem_to_string");
|
|
|
|
|
RNA_def_boolean(func, "compact", false, "Compact", "");
|
|
|
|
|
parm = RNA_def_string(func, "result", NULL, UI_MAX_SHORTCUT_STR, "result", "");
|
|
|
|
|
RNA_def_parameter_flags(parm, PROP_THICK_WRAP, 0);
|
|
|
|
|
RNA_def_function_output(func, parm);
|
Keymap conflict detection operator.
Takes into account the hierarchical structures of keymaps as well as wildcards (KM_ANY) in event definitions, user remaps (emulate numpad, action/select mouse buttons, ...) and event values that overlap (click, press and release)
For now, doesn't do anything other than print conflicts in the console.
As a result, I cleaned up a lot of keymaps that had double definitions, moved some keymap items in more appropriate places, fixed wrong definitions and removed kmi that were added for testing a long long time ago.
Out of all the remaining conflicts, after removing obvious non-issues, here's what remains: http://www.pasteall.org/9898
2009-12-17 22:14:43 +00:00
|
|
|
}
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
|
|
|
|
|
void RNA_api_keymapitems(StructRNA *srna)
|
|
|
|
|
{
|
|
|
|
|
FunctionRNA *func;
|
|
|
|
|
PropertyRNA *parm;
|
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "new", "rna_KeyMap_item_new");
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
RNA_def_function_flag(func, FUNC_USE_REPORTS);
|
2014-01-16 21:43:22 +11:00
|
|
|
parm = RNA_def_string(func, "idname", NULL, 0, "Operator Identifier", "");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
2015-11-23 13:49:52 +11:00
|
|
|
parm = RNA_def_enum(func, "type", rna_enum_event_type_items, 0, "Type", "");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
2015-11-23 13:49:52 +11:00
|
|
|
parm = RNA_def_enum(func, "value", rna_enum_event_value_items, 0, "Value", "");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
RNA_def_boolean(func, "any", 0, "Any", "");
|
|
|
|
|
RNA_def_boolean(func, "shift", 0, "Shift", "");
|
|
|
|
|
RNA_def_boolean(func, "ctrl", 0, "Ctrl", "");
|
|
|
|
|
RNA_def_boolean(func, "alt", 0, "Alt", "");
|
|
|
|
|
RNA_def_boolean(func, "oskey", 0, "OS Key", "");
|
2015-11-23 13:49:52 +11:00
|
|
|
RNA_def_enum(func, "key_modifier", rna_enum_event_type_items, 0, "Key Modifier", "");
|
2018-06-09 14:40:09 +02:00
|
|
|
RNA_def_boolean(func, "head", 0, "At Head",
|
Bugfix [#32437] Cannot define Alt-E keybinding in Text Editor window
WM_keymap_add_item(keymap, "TEXT_OT_insert", KM_TEXTINPUT, KM_ANY, KM_ANY, 0);
<--- this catch-all key map item at the end of the Text Editor keymap was
gobbling all the key events for user-defined hotkeys added after it in the
keymap. This includes all hotkeys for new operators defined by addons (via
keymap.keymap_items.new()).
As a slightly hacky workaround for this, I've added an extra parameter to
keymap_items.new() which will force the newly added item to get added to the
start of the key map items list (i.e. with top priority). To enable, simply add,
head=True to keymap_items.new() calls. For example:
keymap.keymap_items.new("MY_OP_my_operator_id", type='E', value='PRESS',
alt=True, head=True)
This should be useful for cases where there are similar catch-alls, where it is
necessary to insert our item before the offending catch-all (without knowing
which one it is). However, in general, it's recommended not to use this, unless
all other methods (inlcuding choosing another key combination if your first
choice doesn't work) fails.
2012-08-30 14:08:43 +00:00
|
|
|
"Force item to be added at start (not end) of key map so that "
|
|
|
|
|
"it doesn't get blocked by an existing key map item");
|
2012-03-05 23:30:41 +00:00
|
|
|
parm = RNA_def_pointer(func, "item", "KeyMapItem", "Item", "Added key map item");
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
RNA_def_function_return(func, parm);
|
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "new_modal", "rna_KeyMap_item_new_modal");
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
RNA_def_function_flag(func, FUNC_USE_REPORTS);
|
2014-01-16 21:43:22 +11:00
|
|
|
parm = RNA_def_string(func, "propvalue", NULL, 0, "Property Value", "");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
2015-11-23 13:49:52 +11:00
|
|
|
parm = RNA_def_enum(func, "type", rna_enum_event_type_items, 0, "Type", "");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
2015-11-23 13:49:52 +11:00
|
|
|
parm = RNA_def_enum(func, "value", rna_enum_event_value_items, 0, "Value", "");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
RNA_def_boolean(func, "any", 0, "Any", "");
|
|
|
|
|
RNA_def_boolean(func, "shift", 0, "Shift", "");
|
|
|
|
|
RNA_def_boolean(func, "ctrl", 0, "Ctrl", "");
|
|
|
|
|
RNA_def_boolean(func, "alt", 0, "Alt", "");
|
|
|
|
|
RNA_def_boolean(func, "oskey", 0, "OS Key", "");
|
2015-11-23 13:49:52 +11:00
|
|
|
RNA_def_enum(func, "key_modifier", rna_enum_event_type_items, 0, "Key Modifier", "");
|
2012-03-05 23:30:41 +00:00
|
|
|
parm = RNA_def_pointer(func, "item", "KeyMapItem", "Item", "Added key map item");
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
RNA_def_function_return(func, parm);
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2018-11-23 15:16:13 +11:00
|
|
|
func = RNA_def_function(srna, "new_from_item", "rna_KeyMap_item_new_from_item");
|
|
|
|
|
RNA_def_function_flag(func, FUNC_USE_REPORTS);
|
|
|
|
|
parm = RNA_def_pointer(func, "item", "KeyMapItem", "Item", "Item to use as a reference");
|
|
|
|
|
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
|
|
|
|
|
RNA_def_boolean(func, "head", 0, "At Head", "");
|
|
|
|
|
parm = RNA_def_pointer(func, "result", "KeyMapItem", "Item", "Added key map item");
|
|
|
|
|
RNA_def_function_return(func, parm);
|
|
|
|
|
|
2012-11-02 09:41:26 +00:00
|
|
|
func = RNA_def_function(srna, "remove", "rna_KeyMap_item_remove");
|
|
|
|
|
RNA_def_function_flag(func, FUNC_USE_REPORTS);
|
2012-03-05 23:30:41 +00:00
|
|
|
parm = RNA_def_pointer(func, "item", "KeyMapItem", "Item", "");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
|
|
|
|
|
RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "from_id", "WM_keymap_item_find_id");
|
|
|
|
|
parm = RNA_def_property(func, "id", PROP_INT, PROP_NONE);
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
RNA_def_property_ui_text(parm, "id", "ID of the item");
|
2012-03-05 23:30:41 +00:00
|
|
|
parm = RNA_def_pointer(func, "item", "KeyMapItem", "Item", "");
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
RNA_def_function_return(func, parm);
|
2019-01-09 12:26:10 +11:00
|
|
|
|
|
|
|
|
/* Keymap introspection
|
|
|
|
|
* Args follow: KeyConfigs.find_item_from_operator */
|
|
|
|
|
func = RNA_def_function(srna, "find_from_operator", "rna_KeyMap_item_find_from_operator");
|
|
|
|
|
RNA_def_function_flag(func, FUNC_USE_SELF_ID);
|
|
|
|
|
parm = RNA_def_string(func, "idname", NULL, 0, "Operator Identifier", "");
|
|
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
|
|
|
|
parm = RNA_def_pointer(func, "properties", "OperatorProperties", "", "");
|
|
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_RNAPTR);
|
|
|
|
|
RNA_def_enum_flag(func, "include", rna_enum_event_type_mask_items, EVT_TYPE_MASK_ALL, "Include", "");
|
|
|
|
|
RNA_def_enum_flag(func, "exclude", rna_enum_event_type_mask_items, 0, "Exclude", "");
|
|
|
|
|
parm = RNA_def_pointer(func, "item", "KeyMapItem", "", "");
|
|
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_RNAPTR);
|
|
|
|
|
RNA_def_function_return(func, parm);
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RNA_api_keymaps(StructRNA *srna)
|
|
|
|
|
{
|
|
|
|
|
FunctionRNA *func;
|
|
|
|
|
PropertyRNA *parm;
|
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "new", "rna_keymap_new"); /* add_keymap */
|
2014-01-16 21:43:22 +11:00
|
|
|
parm = RNA_def_string(func, "name", NULL, 0, "Name", "");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
2015-11-23 13:49:52 +11:00
|
|
|
RNA_def_enum(func, "space_type", rna_enum_space_type_items, SPACE_EMPTY, "Space Type", "");
|
|
|
|
|
RNA_def_enum(func, "region_type", rna_enum_region_type_items, RGN_TYPE_WINDOW, "Region Type", "");
|
2018-11-13 21:01:32 +01:00
|
|
|
RNA_def_boolean(func, "modal", 0, "Modal", "Keymap for modal operators");
|
|
|
|
|
RNA_def_boolean(func, "tool", 0, "Tool", "Keymap for active tools");
|
2012-03-05 23:30:41 +00:00
|
|
|
parm = RNA_def_pointer(func, "keymap", "KeyMap", "Key Map", "Added key map");
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
RNA_def_function_return(func, parm);
|
|
|
|
|
|
2013-09-27 14:05:07 +00:00
|
|
|
func = RNA_def_function(srna, "remove", "rna_KeyMap_remove"); /* remove_keymap */
|
|
|
|
|
RNA_def_function_flag(func, FUNC_USE_REPORTS);
|
|
|
|
|
parm = RNA_def_pointer(func, "keymap", "KeyMap", "Key Map", "Removed key map");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
|
|
|
|
|
RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
|
2013-09-27 14:05:07 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "find", "rna_keymap_find"); /* find_keymap */
|
2014-01-16 21:43:22 +11:00
|
|
|
parm = RNA_def_string(func, "name", NULL, 0, "Name", "");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
2015-11-23 13:49:52 +11:00
|
|
|
RNA_def_enum(func, "space_type", rna_enum_space_type_items, SPACE_EMPTY, "Space Type", "");
|
|
|
|
|
RNA_def_enum(func, "region_type", rna_enum_region_type_items, RGN_TYPE_WINDOW, "Region Type", "");
|
2012-03-05 23:30:41 +00:00
|
|
|
parm = RNA_def_pointer(func, "keymap", "KeyMap", "Key Map", "Corresponding key map");
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
RNA_def_function_return(func, parm);
|
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "find_modal", "rna_keymap_find_modal"); /* find_keymap_modal */
|
2014-01-16 21:43:22 +11:00
|
|
|
parm = RNA_def_string(func, "name", NULL, 0, "Operator Name", "");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
2012-03-05 23:30:41 +00:00
|
|
|
parm = RNA_def_pointer(func, "keymap", "KeyMap", "Key Map", "Corresponding key map");
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
RNA_def_function_return(func, parm);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RNA_api_keyconfigs(StructRNA *srna)
|
|
|
|
|
{
|
|
|
|
|
FunctionRNA *func;
|
|
|
|
|
PropertyRNA *parm;
|
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "new", "WM_keyconfig_new_user"); /* add_keyconfig */
|
2014-01-16 21:43:22 +11:00
|
|
|
parm = RNA_def_string(func, "name", NULL, 0, "Name", "");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
2012-03-05 23:30:41 +00:00
|
|
|
parm = RNA_def_pointer(func, "keyconfig", "KeyConfig", "Key Configuration", "Added key configuration");
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
RNA_def_function_return(func, parm);
|
|
|
|
|
|
2012-11-02 09:41:26 +00:00
|
|
|
func = RNA_def_function(srna, "remove", "rna_KeyConfig_remove"); /* remove_keyconfig */
|
|
|
|
|
RNA_def_function_flag(func, FUNC_USE_REPORTS);
|
2012-03-05 23:30:41 +00:00
|
|
|
parm = RNA_def_pointer(func, "keyconfig", "KeyConfig", "Key Configuration", "Removed key configuration");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
|
|
|
|
|
RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
|
2018-05-21 10:33:27 +02:00
|
|
|
|
|
|
|
|
/* Helper functions */
|
|
|
|
|
|
|
|
|
|
/* Keymap introspection */
|
|
|
|
|
func = RNA_def_function(srna, "find_item_from_operator", "rna_KeyConfig_find_item_from_operator");
|
|
|
|
|
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
|
|
|
|
|
parm = RNA_def_string(func, "idname", NULL, 0, "Operator Identifier", "");
|
|
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
|
|
|
|
parm = RNA_def_property(func, "context", PROP_ENUM, PROP_NONE);
|
|
|
|
|
RNA_def_property_enum_items(parm, rna_enum_operator_context_items);
|
|
|
|
|
parm = RNA_def_pointer(func, "properties", "OperatorProperties", "", "");
|
|
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_RNAPTR);
|
2018-12-12 21:39:55 +11:00
|
|
|
RNA_def_enum_flag(func, "include", rna_enum_event_type_mask_items, EVT_TYPE_MASK_ALL, "Include", "");
|
|
|
|
|
RNA_def_enum_flag(func, "exclude", rna_enum_event_type_mask_items, 0, "Exclude", "");
|
2018-05-21 11:13:56 +02:00
|
|
|
parm = RNA_def_pointer(func, "keymap", "KeyMap", "", "");
|
|
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_RNAPTR | PARM_OUTPUT);
|
2018-05-21 12:38:47 +02:00
|
|
|
parm = RNA_def_pointer(func, "item", "KeyMapItem", "", "");
|
|
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_RNAPTR);
|
2018-05-21 10:33:27 +02:00
|
|
|
RNA_def_function_return(func, parm);
|
|
|
|
|
|
|
|
|
|
RNA_def_function(srna, "update", "rna_KeyConfig_update"); /* WM_keyconfig_update */
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
}
|
|
|
|
|
|
2009-06-18 19:48:55 +00:00
|
|
|
#endif
|