diff options
Diffstat (limited to 'source/blender/windowmanager')
71 files changed, 798 insertions, 1834 deletions
diff --git a/source/blender/windowmanager/CMakeLists.txt b/source/blender/windowmanager/CMakeLists.txt index 03b2fb49085..bd8e97e7177 100644 --- a/source/blender/windowmanager/CMakeLists.txt +++ b/source/blender/windowmanager/CMakeLists.txt @@ -1,22 +1,5 @@ -# ***** BEGIN GPL LICENSE BLOCK ***** -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# The Original Code is Copyright (C) 2006, Blender Foundation -# All rights reserved. -# ***** END GPL LICENSE BLOCK ***** +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright 2006 Blender Foundation. All rights reserved. set(INC . @@ -135,10 +118,6 @@ if(WITH_CYCLES) add_definitions(-DWITH_CYCLES) endif() -if(WITH_INTERNATIONAL) - add_definitions(-DWITH_INTERNATIONAL) -endif() - if(WITH_OPENCOLLADA) add_definitions(-DWITH_COLLADA) endif() diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 5f8a831706b..21d76ce93bd 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -1,21 +1,5 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2007 Blender Foundation. - * All rights reserved. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright 2007 Blender Foundation. All rights reserved. */ #pragma once /** \file @@ -1259,6 +1243,8 @@ enum { WM_JOB_TYPE_COMPOSITE, WM_JOB_TYPE_RENDER, WM_JOB_TYPE_RENDER_PREVIEW, /* UI preview */ + /** Job for the UI to load previews from the file system (uses OS thumbnail cache). */ + WM_JOB_TYPE_LOAD_PREVIEW, /* UI preview */ WM_JOB_TYPE_OBJECT_SIM_OCEAN, WM_JOB_TYPE_OBJECT_SIM_FLUID, WM_JOB_TYPE_OBJECT_BAKE_TEXTURE, @@ -1437,15 +1423,17 @@ bool WM_window_modal_keymap_status_draw(struct bContext *C, */ void WM_event_print(const struct wmEvent *event); -int WM_event_modifier_flag(const struct wmEvent *event); - /** - * For modal callbacks, check configuration for how to interpret exit with tweaks. + * For modal callbacks, check configuration for how to interpret exit when dragging. */ -bool WM_event_is_modal_tweak_exit(const struct wmEvent *event, int tweak_event); +bool WM_event_is_modal_drag_exit(const struct wmEvent *event, + short init_event_type, + short init_event_val); bool WM_event_is_last_mousemove(const struct wmEvent *event); bool WM_event_is_mouse_drag(const struct wmEvent *event); bool WM_event_is_mouse_drag_or_press(const wmEvent *event); +int WM_event_drag_direction(const wmEvent *event); + /** * Detect motion between selection (callers should only use this for selection picking), * typically mouse press/click events. @@ -1595,8 +1583,7 @@ bool WM_xr_action_create(wmXrData *xr, const char *action_set_name, const char *action_name, eXrActionType type, - unsigned int count_subaction_paths, - const char **subaction_paths, + const ListBase *user_paths, struct wmOperatorType *ot, struct IDProperty *op_properties, const char *haptic_name, @@ -1611,9 +1598,8 @@ bool WM_xr_action_binding_create(wmXrData *xr, const char *action_set_name, const char *action_name, const char *profile_path, - unsigned int count_subaction_paths, - const char **subaction_paths, - const char **component_paths, + const ListBase *user_paths, + const ListBase *component_paths, const float *float_thresholds, const eXrAxisFlag *axis_flags, const struct wmXrPose *poses); diff --git a/source/blender/windowmanager/WM_keymap.h b/source/blender/windowmanager/WM_keymap.h index 4f1a2c8b923..068dbb32be2 100644 --- a/source/blender/windowmanager/WM_keymap.h +++ b/source/blender/windowmanager/WM_keymap.h @@ -1,21 +1,5 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2007 Blender Foundation. - * All rights reserved. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright 2007 Blender Foundation. All rights reserved. */ #pragma once @@ -58,8 +42,13 @@ void WM_keymap_clear(struct wmKeyMap *keymap); /** * Always add item. */ -wmKeyMapItem *WM_keymap_add_item( - struct wmKeyMap *keymap, const char *idname, int type, int val, int modifier, int keymodifier); +wmKeyMapItem *WM_keymap_add_item(struct wmKeyMap *keymap, + const char *idname, + int type, + int val, + int modifier, + int keymodifier, + int direction); wmKeyMapItem *WM_keymap_add_item_copy(struct wmKeyMap *keymap, wmKeyMapItem *kmi_src); bool WM_keymap_remove_item(struct wmKeyMap *keymap, struct wmKeyMapItem *kmi); @@ -96,32 +85,43 @@ bool WM_keymap_item_compare(const struct wmKeyMapItem *k1, const struct wmKeyMap /** * Menu wrapper for #WM_keymap_add_item. */ -wmKeyMapItem *WM_keymap_add_menu( - struct wmKeyMap *keymap, const char *idname, int type, int val, int modifier, int keymodifier); +wmKeyMapItem *WM_keymap_add_menu(struct wmKeyMap *keymap, + const char *idname, + int type, + int val, + int modifier, + int keymodifier, + int direction); /** * Pie-menu wrapper for #WM_keymap_add_item. */ -wmKeyMapItem *WM_keymap_add_menu_pie( - struct wmKeyMap *keymap, const char *idname, int type, int val, int modifier, int keymodifier); +wmKeyMapItem *WM_keymap_add_menu_pie(struct wmKeyMap *keymap, + const char *idname, + int type, + int val, + int modifier, + int keymodifier, + int direction); /** * Panel (popover) wrapper for #WM_keymap_add_item. */ -wmKeyMapItem *WM_keymap_add_panel( - struct wmKeyMap *keymap, const char *idname, int type, int val, int modifier, int keymodifier); +wmKeyMapItem *WM_keymap_add_panel(struct wmKeyMap *keymap, + const char *idname, + int type, + int val, + int modifier, + int keymodifier, + int direction); /** * Tool wrapper for #WM_keymap_add_item. */ -wmKeyMapItem *WM_keymap_add_tool( - struct wmKeyMap *keymap, const char *idname, int type, int val, int modifier, int keymodifier); - -/** Useful for mapping numbers to an enum. */ -void WM_keymap_add_context_enum_set_items(wmKeyMap *keymap, - const struct EnumPropertyItem *items, - const char *data_path, - int type_start, - int val, - int modifier, - int keymodifier); +wmKeyMapItem *WM_keymap_add_tool(struct wmKeyMap *keymap, + const char *idname, + int type, + int val, + int modifier, + int keymodifier, + int direction); wmKeyMap *WM_keymap_guess_from_context(const struct bContext *C); @@ -153,10 +153,20 @@ wmKeyMap *WM_modalkeymap_ensure(struct wmKeyConfig *keyconf, const char *idname, const struct EnumPropertyItem *items); wmKeyMap *WM_modalkeymap_find(struct wmKeyConfig *keyconf, const char *idname); -wmKeyMapItem *WM_modalkeymap_add_item( - struct wmKeyMap *km, int type, int val, int modifier, int keymodifier, int value); -wmKeyMapItem *WM_modalkeymap_add_item_str( - struct wmKeyMap *km, int type, int val, int modifier, int keymodifier, const char *value); +wmKeyMapItem *WM_modalkeymap_add_item(struct wmKeyMap *km, + int type, + int val, + int modifier, + int keymodifier, + int direction, + int value); +wmKeyMapItem *WM_modalkeymap_add_item_str(struct wmKeyMap *km, + int type, + int val, + int modifier, + int keymodifier, + int direction, + const char *value); const wmKeyMapItem *WM_modalkeymap_find_propvalue(const wmKeyMap *km, int propvalue); void WM_modalkeymap_assign(struct wmKeyMap *km, const char *opname); diff --git a/source/blender/windowmanager/WM_message.h b/source/blender/windowmanager/WM_message.h index 25d5bae392b..91aa5294662 100644 --- a/source/blender/windowmanager/WM_message.h +++ b/source/blender/windowmanager/WM_message.h @@ -1,18 +1,4 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /** \file * \ingroup wm diff --git a/source/blender/windowmanager/WM_toolsystem.h b/source/blender/windowmanager/WM_toolsystem.h index 5cbe1e2da14..a9e1495d9bf 100644 --- a/source/blender/windowmanager/WM_toolsystem.h +++ b/source/blender/windowmanager/WM_toolsystem.h @@ -1,18 +1,4 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ #pragma once /** \file diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index d1f790ce3e2..c4858a8a1fa 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -1,21 +1,5 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2007 Blender Foundation. - * All rights reserved. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright 2007 Blender Foundation. All rights reserved. */ /** \file * \ingroup wm @@ -241,35 +225,68 @@ typedef enum eOperatorPropTags { } eOperatorPropTags; #define OP_PROP_TAG_ADVANCED ((eOperatorPropTags)OP_PROP_TAG_ADVANCED) -/* ************** wmKeyMap ************************ */ +/* -------------------------------------------------------------------- */ +/** \name #wmKeyMapItem + * \{ */ -/* modifier */ -#define KM_SHIFT 1 -#define KM_CTRL 2 -#define KM_ALT 4 -#define KM_OSKEY 8 - -/* Used for key-map item creation function arguments (never stored in DNA). */ -#define KM_SHIFT_ANY 16 -#define KM_CTRL_ANY 32 -#define KM_ALT_ANY 64 -#define KM_OSKEY_ANY 128 +/** + * Modifier keys, not actually used for #wmKeyMapItem (never stored in DNA), used for: + * - #wmEvent.modifier without the `KM_*_ANY` flags. + * - #WM_keymap_add_item & #WM_modalkeymap_add_item + */ +enum { + KM_SHIFT = (1 << 0), + KM_CTRL = (1 << 1), + KM_ALT = (1 << 2), + KM_OSKEY = (1 << 3), + + /* Used for key-map item creation function arguments. */ + KM_SHIFT_ANY = (1 << 4), + KM_CTRL_ANY = (1 << 5), + KM_ALT_ANY = (1 << 6), + KM_OSKEY_ANY = (1 << 7), +}; -/* KM_MOD_ flags for `wmKeyMapItem` and `wmEvent.alt/shift/oskey/ctrl`. */ -/* note that KM_ANY and KM_NOTHING are used with these defines too */ +/* `KM_MOD_*` flags for #wmKeyMapItem and `wmEvent.alt/shift/oskey/ctrl`. */ +/* Note that #KM_ANY and #KM_NOTHING are used with these defines too. */ #define KM_MOD_HELD 1 -/* type: defined in wm_event_types.c */ -#define KM_TEXTINPUT -2 +/** + * #wmKeyMapItem.type + * NOTE: most types are defined in `wm_event_types.h`. + */ +enum { + KM_TEXTINPUT = -2, +}; -/* val */ -#define KM_ANY -1 -#define KM_NOTHING 0 -#define KM_PRESS 1 -#define KM_RELEASE 2 -#define KM_CLICK 3 -#define KM_DBL_CLICK 4 -#define KM_CLICK_DRAG 5 +/** #wmKeyMapItem.val */ +enum { + KM_ANY = -1, + KM_NOTHING = 0, + KM_PRESS = 1, + KM_RELEASE = 2, + KM_CLICK = 3, + KM_DBL_CLICK = 4, + KM_CLICK_DRAG = 5, +}; + +/** + * #wmKeyMapItem.direction + * + * Value of tweaks and line gestures. #KM_ANY (-1) works for this case too. + */ +enum { + KM_DIRECTION_N = 1, + KM_DIRECTION_NE = 2, + KM_DIRECTION_E = 3, + KM_DIRECTION_SE = 4, + KM_DIRECTION_S = 5, + KM_DIRECTION_SW = 6, + KM_DIRECTION_W = 7, + KM_DIRECTION_NW = 8, +}; + +/** \} */ /* ************** UI Handler ***************** */ @@ -486,6 +503,7 @@ typedef struct wmNotifier { #define NS_EDITMODE_ARMATURE (8 << 8) #define NS_MODE_POSE (9 << 8) #define NS_MODE_PARTICLE (10 << 8) +#define NS_EDITMODE_CURVES (11 << 8) /* subtype 3d view editing */ #define NS_VIEW3D_GPU (16 << 8) @@ -509,7 +527,6 @@ typedef struct wmNotifier { /* ************** Gesture Manager data ************** */ /* wmGesture->type */ -#define WM_GESTURE_TWEAK 0 #define WM_GESTURE_LINES 1 #define WM_GESTURE_RECT 2 #define WM_GESTURE_CROSS_RECT 3 @@ -519,12 +536,15 @@ typedef struct wmNotifier { /** * wmGesture is registered to #wmWindow.gesture, handled by operator callbacks. - * Tweak gesture is builtin feature. */ typedef struct wmGesture { struct wmGesture *next, *prev; /** #wmEvent.type */ int event_type; + /** #wmEvent.modifier */ + uint8_t event_modifier; + /** #wmEvent.keymodifier */ + short event_keymodifier; /** Gesture type define. */ int type; /** bounds of region to draw gesture within. */ @@ -571,6 +591,22 @@ typedef struct wmGesture { /* ************** wmEvent ************************ */ +typedef enum eWM_EventFlag { + /** + * True if the operating system inverted the delta x/y values and resulting + * `prev_xy` values, for natural scroll direction. + * For absolute scroll direction, the delta must be negated again. + */ + WM_EVENT_SCROLL_INVERT = (1 << 0), + /** + * Generated by auto-repeat, note that this must only ever be set for keyboard events + * where `ISKEYBOARD(event->type) == true`. + * + * See #KMI_REPEAT_IGNORE for details on how key-map handling uses this. + */ + WM_EVENT_IS_REPEAT = (1 << 1), +} eWM_EventFlag; + typedef struct wmTabletData { /** 0=EVT_TABLET_NONE, 1=EVT_TABLET_STYLUS, 2=EVT_TABLET_ERASER. */ int active; @@ -627,22 +663,10 @@ typedef struct wmEvent { /** From ghost, fallback if utf8 isn't set. */ char ascii; - /** - * Generated by auto-repeat, note that this must only ever be set for keyboard events - * where `ISKEYBOARD(event->type) == true`. - * - * See #KMI_REPEAT_IGNORE for details on how key-map handling uses this. - */ - char is_repeat; - /** The previous value of `type`. */ short prev_type; /** The previous value of `val`. */ short prev_val; - /** The time when the key is pressed, see #PIL_check_seconds_timer. */ - double prev_click_time; - /** The location when the key is pressed (used to enforce drag thresholds). */ - int prev_click_xy[2]; /** * The previous value of #wmEvent.xy, * Unlike other previous state variables, this is set on any mouse motion. @@ -650,29 +674,40 @@ typedef struct wmEvent { */ int prev_xy[2]; - /** Modifier states. */ - /** 'oskey' is apple or windows-key, value denotes order of pressed. */ - short shift, ctrl, alt, oskey; + /** The `type` at the point of the click action. */ + short prev_click_type; + /** The time when the key is pressed, see #PIL_check_seconds_timer. */ + double prev_click_time; + /** The location when the key is pressed (used to enforce drag thresholds). */ + int prev_click_xy[2]; + /** The `modifier` at the point of the click action. */ + uint8_t prev_click_modifier; + /** The `keymodifier` at the point of the click action. */ + short prev_click_keymodifier; + + /** + * Modifier states. + * #KM_SHIFT, #KM_CTRL, #KM_ALT & #KM_OSKEY is apple or windows-key. + */ + uint8_t modifier; + + /** The direction (for #KM_CLICK_DRAG events only). */ + int8_t direction; + /** Raw-key modifier (allow using any key as a modifier). */ short keymodifier; /** Tablet info, available for mouse move and button events. */ wmTabletData tablet; + eWM_EventFlag flag; + /* Custom data. */ /** Custom data type, stylus, 6dof, see wm_event_types.h */ short custom; short customdata_free; - int pad2; /** Ascii, unicode, mouse-coords, angles, vectors, NDOF data, drag-drop info. */ void *customdata; - - /** - * True if the operating system inverted the delta x/y values and resulting - * `prev_xy` values, for natural scroll direction. - * For absolute scroll direction, the delta must be negated again. - */ - char is_direction_inverted; } wmEvent; /** @@ -1048,6 +1083,10 @@ typedef struct wmDragActiveDropState { * it as needed. */ struct ARegion *region_from; + /** If `active_dropbox` is set, additional context provided by the active (i.e. hovered) button. + * Activated before context sensitive operations (polling, drawing, dropping). */ + struct bContextStore *ui_context; + /** Text to show when a dropbox poll succeeds (so the dropbox itself is available) but the * operator poll fails. Typically the message the operator set with * CTX_wm_operator_poll_msg_set(). */ diff --git a/source/blender/windowmanager/gizmo/WM_gizmo_api.h b/source/blender/windowmanager/gizmo/WM_gizmo_api.h index 5bcb9b195bf..6b497c7462a 100644 --- a/source/blender/windowmanager/gizmo/WM_gizmo_api.h +++ b/source/blender/windowmanager/gizmo/WM_gizmo_api.h @@ -1,21 +1,5 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2016 Blender Foundation. - * All rights reserved. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright 2016 Blender Foundation. All rights reserved. */ /** \file * \ingroup wm diff --git a/source/blender/windowmanager/gizmo/WM_gizmo_types.h b/source/blender/windowmanager/gizmo/WM_gizmo_types.h index 8bf82a41c91..03fafdd7d74 100644 --- a/source/blender/windowmanager/gizmo/WM_gizmo_types.h +++ b/source/blender/windowmanager/gizmo/WM_gizmo_types.h @@ -1,21 +1,5 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2016 Blender Foundation. - * All rights reserved. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright 2016 Blender Foundation. All rights reserved. */ /** \file * \ingroup wm diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo.c index d4f11c79d46..05564f3bd0a 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo.c @@ -1,21 +1,5 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2014 Blender Foundation. - * All rights reserved. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright 2014 Blender Foundation. All rights reserved. */ /** \file * \ingroup wm diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c index 6f10e4f3f0d..2971cdf40c3 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c @@ -1,21 +1,5 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2014 Blender Foundation. - * All rights reserved. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright 2014 Blender Foundation. All rights reserved. */ /** \file * \ingroup wm @@ -656,24 +640,29 @@ wmKeyMap *wm_gizmogroup_tweak_modal_keymap(wmKeyConfig *keyconf) keymap = WM_modalkeymap_ensure(keyconf, name, modal_items); /* items for modal map */ - WM_modalkeymap_add_item(keymap, EVT_ESCKEY, KM_PRESS, KM_ANY, 0, TWEAK_MODAL_CANCEL); - WM_modalkeymap_add_item(keymap, RIGHTMOUSE, KM_PRESS, KM_ANY, 0, TWEAK_MODAL_CANCEL); + WM_modalkeymap_add_item(keymap, EVT_ESCKEY, KM_PRESS, KM_ANY, 0, KM_ANY, TWEAK_MODAL_CANCEL); + WM_modalkeymap_add_item(keymap, RIGHTMOUSE, KM_PRESS, KM_ANY, 0, KM_ANY, TWEAK_MODAL_CANCEL); - WM_modalkeymap_add_item(keymap, EVT_RETKEY, KM_PRESS, KM_ANY, 0, TWEAK_MODAL_CONFIRM); - WM_modalkeymap_add_item(keymap, EVT_PADENTER, KM_PRESS, KM_ANY, 0, TWEAK_MODAL_CONFIRM); + WM_modalkeymap_add_item(keymap, EVT_RETKEY, KM_PRESS, KM_ANY, 0, KM_ANY, TWEAK_MODAL_CONFIRM); + WM_modalkeymap_add_item(keymap, EVT_PADENTER, KM_PRESS, KM_ANY, 0, KM_ANY, TWEAK_MODAL_CONFIRM); WM_modalkeymap_add_item( - keymap, EVT_RIGHTSHIFTKEY, KM_PRESS, KM_ANY, 0, TWEAK_MODAL_PRECISION_ON); + keymap, EVT_RIGHTSHIFTKEY, KM_PRESS, KM_ANY, 0, KM_ANY, TWEAK_MODAL_PRECISION_ON); + WM_modalkeymap_add_item( + keymap, EVT_RIGHTSHIFTKEY, KM_RELEASE, KM_ANY, 0, KM_ANY, TWEAK_MODAL_PRECISION_OFF); WM_modalkeymap_add_item( - keymap, EVT_RIGHTSHIFTKEY, KM_RELEASE, KM_ANY, 0, TWEAK_MODAL_PRECISION_OFF); - WM_modalkeymap_add_item(keymap, EVT_LEFTSHIFTKEY, KM_PRESS, KM_ANY, 0, TWEAK_MODAL_PRECISION_ON); + keymap, EVT_LEFTSHIFTKEY, KM_PRESS, KM_ANY, 0, KM_ANY, TWEAK_MODAL_PRECISION_ON); WM_modalkeymap_add_item( - keymap, EVT_LEFTSHIFTKEY, KM_RELEASE, KM_ANY, 0, TWEAK_MODAL_PRECISION_OFF); + keymap, EVT_LEFTSHIFTKEY, KM_RELEASE, KM_ANY, 0, KM_ANY, TWEAK_MODAL_PRECISION_OFF); - WM_modalkeymap_add_item(keymap, EVT_RIGHTCTRLKEY, KM_PRESS, KM_ANY, 0, TWEAK_MODAL_SNAP_ON); - WM_modalkeymap_add_item(keymap, EVT_RIGHTCTRLKEY, KM_RELEASE, KM_ANY, 0, TWEAK_MODAL_SNAP_OFF); - WM_modalkeymap_add_item(keymap, EVT_LEFTCTRLKEY, KM_PRESS, KM_ANY, 0, TWEAK_MODAL_SNAP_ON); - WM_modalkeymap_add_item(keymap, EVT_LEFTCTRLKEY, KM_RELEASE, KM_ANY, 0, TWEAK_MODAL_SNAP_OFF); + WM_modalkeymap_add_item( + keymap, EVT_RIGHTCTRLKEY, KM_PRESS, KM_ANY, 0, KM_ANY, TWEAK_MODAL_SNAP_ON); + WM_modalkeymap_add_item( + keymap, EVT_RIGHTCTRLKEY, KM_RELEASE, KM_ANY, 0, KM_ANY, TWEAK_MODAL_SNAP_OFF); + WM_modalkeymap_add_item( + keymap, EVT_LEFTCTRLKEY, KM_PRESS, KM_ANY, 0, KM_ANY, TWEAK_MODAL_SNAP_ON); + WM_modalkeymap_add_item( + keymap, EVT_LEFTCTRLKEY, KM_RELEASE, KM_ANY, 0, KM_ANY, TWEAK_MODAL_SNAP_OFF); WM_modalkeymap_assign(keymap, "GIZMOGROUP_OT_gizmo_tweak"); @@ -706,7 +695,7 @@ wmKeyMap *WM_gizmogroup_setup_keymap_generic_maybe_drag(const wmGizmoGroupType * /** * Variation of #WM_gizmogroup_keymap_common but with keymap items for selection * - * TODO(campbell): move to Python. + * TODO(@campbellbarton): move to Python. * * \param name: Typically #wmGizmoGroupType.name * \param params: Typically #wmGizmoGroupType.gzmap_params @@ -719,30 +708,32 @@ static wmKeyMap *WM_gizmogroup_keymap_template_select_ex( wmKeyMap *km = WM_keymap_ensure(kc, name, params->spaceid, params->regionid); const bool do_init = BLI_listbase_is_empty(&km->items); - /* FIXME(campbell) */ + /* FIXME(@campbellbarton): Currently hard coded. */ #if 0 const int select_mouse = (U.flag & USER_LMOUSESELECT) ? LEFTMOUSE : RIGHTMOUSE; const int select_tweak = (U.flag & USER_LMOUSESELECT) ? EVT_TWEAK_L : EVT_TWEAK_R; const int action_mouse = (U.flag & USER_LMOUSESELECT) ? RIGHTMOUSE : LEFTMOUSE; #else - const int select_mouse = RIGHTMOUSE; - const int select_tweak = EVT_TWEAK_R; - const int action_mouse = LEFTMOUSE; + const int select_mouse = RIGHTMOUSE, select_mouse_val = KM_PRESS; + const int select_tweak = RIGHTMOUSE, select_tweak_val = KM_CLICK_DRAG; + const int action_mouse = LEFTMOUSE, action_mouse_val = KM_PRESS; #endif if (do_init) { - WM_keymap_add_item(km, "GIZMOGROUP_OT_gizmo_tweak", action_mouse, KM_PRESS, KM_ANY, 0); - WM_keymap_add_item(km, "GIZMOGROUP_OT_gizmo_tweak", select_tweak, KM_ANY, 0, 0); + WM_keymap_add_item( + km, "GIZMOGROUP_OT_gizmo_tweak", action_mouse, action_mouse_val, KM_ANY, 0, KM_ANY); + WM_keymap_add_item( + km, "GIZMOGROUP_OT_gizmo_tweak", select_tweak, select_tweak_val, 0, 0, KM_ANY); } if (do_init) { wmKeyMapItem *kmi = WM_keymap_add_item( - km, "GIZMOGROUP_OT_gizmo_select", select_mouse, KM_PRESS, 0, 0); + km, "GIZMOGROUP_OT_gizmo_select", select_mouse, select_mouse_val, 0, 0, KM_ANY); RNA_boolean_set(kmi->ptr, "extend", false); RNA_boolean_set(kmi->ptr, "deselect", false); RNA_boolean_set(kmi->ptr, "toggle", false); kmi = WM_keymap_add_item( - km, "GIZMOGROUP_OT_gizmo_select", select_mouse, KM_PRESS, KM_SHIFT, 0); + km, "GIZMOGROUP_OT_gizmo_select", select_mouse, select_mouse_val, KM_SHIFT, 0, KM_ANY); RNA_boolean_set(kmi->ptr, "extend", false); RNA_boolean_set(kmi->ptr, "deselect", false); RNA_boolean_set(kmi->ptr, "toggle", true); @@ -1145,7 +1136,8 @@ void WM_gizmo_group_refresh(const bContext *C, wmGizmoGroup *gzgroup) ARegion *region = CTX_wm_region(C); BLI_assert(region->gizmo_map == gzmap); /* Check if the tweak event originated from this region. */ - if ((win->tweak != NULL) && BLI_rcti_compare(®ion->winrct, &win->tweak->winrct)) { + if ((win->eventstate != NULL) && (win->event_queue_check_drag) && + BLI_rcti_isect_pt_v(®ion->winrct, win->eventstate->prev_click_xy)) { /* We need to run refresh again. */ gzgroup->init_flag &= ~WM_GIZMOGROUP_INIT_REFRESH; WM_gizmomap_tag_refresh_drawstep(gzmap, WM_gizmomap_drawstep_from_gizmo_group(gzgroup)); diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group_type.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group_type.c index 0a36068bb21..e6b5e8f4aa6 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group_type.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group_type.c @@ -1,18 +1,4 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /** \file * \ingroup wm diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_intern.h b/source/blender/windowmanager/gizmo/intern/wm_gizmo_intern.h index 187612f2651..ef6bee0c1fe 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_intern.h +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_intern.h @@ -1,18 +1,4 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /** \file * \ingroup wm diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c index ab955a9e233..f1ac19f4651 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c @@ -1,21 +1,5 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2014 Blender Foundation. - * All rights reserved. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright 2014 Blender Foundation. All rights reserved. */ /** \file * \ingroup wm @@ -572,7 +556,7 @@ static int gizmo_find_intersected_3d_intern(wmGizmo **visible_gizmos, Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); rcti rect; /* Almost certainly overkill, but allow for many custom gizmos. */ - uint buffer[MAXPICKBUF]; + GPUSelectResult buffer[MAXPICKELEMS]; short hits; BLI_rcti_init_pt_radius(&rect, co, hotspot); @@ -582,19 +566,19 @@ static int gizmo_find_intersected_3d_intern(wmGizmo **visible_gizmos, * - #GPU_SELECT_ALL: Use it to check if there is anything at the cursor location * (only ever runs once). * - #GPU_SELECT_PICK_NEAREST: Use if there are more than 1 item at the cursor location, - * select the best one. + * pick the nearest one. * - #GPU_SELECT_PICK_ALL: Use for the same purpose as #GPU_SELECT_PICK_NEAREST * when the selection depths need to re-ordered based on a bias. * */ - const int gpu_select_mode = (use_depth_test ? - (has_3d_select_bias ? - /* Using select bias means the depths need to be - * re-calculated based on the bias to pick the best. */ - GPU_SELECT_PICK_ALL : - /* No bias, just pick the closest. */ - GPU_SELECT_PICK_NEAREST) : - /* Fast-path (occlusion queries). */ - GPU_SELECT_ALL); + const eGPUSelectMode gpu_select_mode = + (use_depth_test ? (has_3d_select_bias ? + /* Using select bias means the depths need to be + * re-calculated based on the bias to pick the best. */ + GPU_SELECT_PICK_ALL : + /* No bias, just pick the closest. */ + GPU_SELECT_PICK_NEAREST) : + /* Fast-path (occlusion queries). */ + GPU_SELECT_ALL); /* When switching between modes and the mouse pointer is over a gizmo, the highlight test is * performed before the viewport is fully initialized (region->draw_buffer = NULL). @@ -657,14 +641,14 @@ static int gizmo_find_intersected_3d_intern(wmGizmo **visible_gizmos, GPU_matrix_unproject_3fv(co_screen, rv3d->viewinv, rv3d->winmat, viewport, co_3d_origin); - uint *buf_iter = buffer; + GPUSelectResult *buf_iter = buffer; float dot_best = FLT_MAX; - for (int i = 0; i < hits; i++, buf_iter += 4) { - BLI_assert(buf_iter[3] != -1); - wmGizmo *gz = visible_gizmos[buf_iter[3] >> 8]; + for (int i = 0; i < hits; i++, buf_iter++) { + BLI_assert(buf_iter->id != -1); + wmGizmo *gz = visible_gizmos[buf_iter->id >> 8]; float co_3d[3]; - co_screen[2] = int_as_float(buf_iter[1]); + co_screen[2] = int_as_float(buf_iter->depth); GPU_matrix_unproject_3fv(co_screen, rv3d->viewinv, rv3d->winmat, viewport, co_3d); float select_bias = gz->select_bias; if ((gz->flag & WM_GIZMO_DRAW_NO_SCALE) == 0) { @@ -674,14 +658,14 @@ static int gizmo_find_intersected_3d_intern(wmGizmo **visible_gizmos, const float dot_test = dot_v3v3(co_3d, co_direction) - select_bias; if (dot_best > dot_test) { dot_best = dot_test; - hit_found = buf_iter[3]; + hit_found = buf_iter->id; } } } else { - const uint *hit_near = GPU_select_buffer_near(buffer, hits); + const GPUSelectResult *hit_near = GPU_select_buffer_near(buffer, hits); if (hit_near) { - hit_found = hit_near[3]; + hit_found = hit_near->id; } } @@ -742,7 +726,7 @@ static wmGizmo *gizmo_find_intersected_3d(bContext *C, * - First, don't use the depth buffer at all, use occlusion queries to detect any gizmos. * If there are no gizmos or only one - early exit, otherwise. * - * - Bind the depth buffer and and use selection picking logic. + * - Bind the depth buffer and use selection picking logic. * This is much slower than occlusion queries (since it's reading depths while drawing). * When there is a single gizmo under the cursor (quite common), early exit, otherwise. * @@ -835,8 +819,6 @@ wmGizmo *wm_gizmomap_highlight_find(wmGizmoMap *gzmap, do_step[i] = WM_gizmo_context_check_drawstep(C, i); } - const int event_modifier = WM_event_modifier_flag(event); - LISTBASE_FOREACH (wmGizmoGroup *, gzgroup, &gzmap->groups) { /* If it were important we could initialize here, @@ -855,11 +837,11 @@ wmGizmo *wm_gizmomap_highlight_find(wmGizmoMap *gzmap, } if (step == WM_GIZMOMAP_DRAWSTEP_3D) { wm_gizmogroup_intersectable_gizmos_to_list( - wm, gzgroup, event_modifier, &visible_3d_gizmos); + wm, gzgroup, event->modifier, &visible_3d_gizmos); } else if (step == WM_GIZMOMAP_DRAWSTEP_2D) { if ((gz = wm_gizmogroup_find_intersected_gizmo( - wm, gzgroup, C, event_modifier, event->mval, r_part))) { + wm, gzgroup, C, event->modifier, event->mval, r_part))) { break; } } diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_target_props.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_target_props.c index 57555fb5416..af083630623 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_target_props.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_target_props.c @@ -1,18 +1,4 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /** \file * \ingroup wm diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c index 602100a624e..9d0e60824f3 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c @@ -1,18 +1,4 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /** \file * \ingroup wm diff --git a/source/blender/windowmanager/gizmo/wm_gizmo_fn.h b/source/blender/windowmanager/gizmo/wm_gizmo_fn.h index ac4f6b761ac..a9904f47510 100644 --- a/source/blender/windowmanager/gizmo/wm_gizmo_fn.h +++ b/source/blender/windowmanager/gizmo/wm_gizmo_fn.h @@ -1,18 +1,4 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /** \file * \ingroup wm diff --git a/source/blender/windowmanager/gizmo/wm_gizmo_wmapi.h b/source/blender/windowmanager/gizmo/wm_gizmo_wmapi.h index 0612ba97db0..7bcb7dfa5e1 100644 --- a/source/blender/windowmanager/gizmo/wm_gizmo_wmapi.h +++ b/source/blender/windowmanager/gizmo/wm_gizmo_wmapi.h @@ -1,21 +1,5 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2016 Blender Foundation. - * All rights reserved. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright 2016 Blender Foundation. All rights reserved. */ /** \file * \ingroup wm diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c index 40f8da63e11..c333d8149ed 100644 --- a/source/blender/windowmanager/intern/wm.c +++ b/source/blender/windowmanager/intern/wm.c @@ -1,21 +1,5 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2007 Blender Foundation. - * All rights reserved. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright 2007 Blender Foundation. All rights reserved. */ /** \file * \ingroup wm @@ -172,7 +156,6 @@ static void window_manager_blend_read_data(BlendDataReader *reader, ID *id) win->gpuctx = NULL; win->eventstate = NULL; win->cursor_keymap_status = NULL; - win->tweak = NULL; #if defined(WIN32) || defined(__APPLE__) win->ime_data = NULL; #endif diff --git a/source/blender/windowmanager/intern/wm_cursors.c b/source/blender/windowmanager/intern/wm_cursors.c index 74ec2bcd41f..b7066178abd 100644 --- a/source/blender/windowmanager/intern/wm_cursors.c +++ b/source/blender/windowmanager/intern/wm_cursors.c @@ -1,21 +1,5 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2005-2007 Blender Foundation - * All rights reserved. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright 2005-2007 Blender Foundation. All rights reserved. */ /** \file * \ingroup wm diff --git a/source/blender/windowmanager/intern/wm_dragdrop.c b/source/blender/windowmanager/intern/wm_dragdrop.c index 9610960d178..4ffb6b90e11 100644 --- a/source/blender/windowmanager/intern/wm_dragdrop.c +++ b/source/blender/windowmanager/intern/wm_dragdrop.c @@ -1,21 +1,5 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2010 Blender Foundation. - * All rights reserved. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright 2010 Blender Foundation. All rights reserved. */ /** \file * \ingroup wm @@ -226,6 +210,30 @@ void wm_drags_exit(wmWindowManager *wm, wmWindow *win) } } +static bContextStore *wm_drop_ui_context_create(const bContext *C) +{ + uiBut *active_but = UI_region_active_but_get(CTX_wm_region(C)); + if (!active_but) { + return NULL; + } + + bContextStore *but_context = UI_but_context_get(active_but); + if (!but_context) { + return NULL; + } + + return CTX_store_copy(but_context); +} + +static void wm_drop_ui_context_free(bContextStore **context_store) +{ + if (!*context_store) { + return; + } + CTX_store_free(*context_store); + *context_store = NULL; +} + void WM_event_drag_image(wmDrag *drag, ImBuf *imb, float scale, int sx, int sy) { drag->imb = imb; @@ -259,6 +267,7 @@ void WM_drag_free(wmDrag *drag) if (drag->flags & WM_DRAG_FREE_DATA) { WM_drag_data_free(drag->type, drag->poin); } + wm_drop_ui_context_free(&drag->drop_state.ui_context); if (drag->drop_state.free_disabled_info) { MEM_SAFE_FREE(drag->drop_state.disabled_info); } @@ -309,6 +318,10 @@ static wmDropBox *dropbox_active(bContext *C, wmEventHandler_Dropbox *handler = (wmEventHandler_Dropbox *)handler_base; if (handler->dropboxes) { LISTBASE_FOREACH (wmDropBox *, drop, handler->dropboxes) { + if (drag->drop_state.ui_context) { + CTX_store_set(C, drag->drop_state.ui_context); + } + if (!drop->poll(C, drag, event)) { /* If the drop's poll fails, don't set the disabled-info. This would be too aggressive. * Instead show it only if the drop box could be used in principle, but the operator @@ -367,6 +380,10 @@ static void wm_drop_update_active(bContext *C, wmDrag *drag, const wmEvent *even return; } + /* Update UI context, before polling so polls can query this context. */ + wm_drop_ui_context_free(&drag->drop_state.ui_context); + drag->drop_state.ui_context = wm_drop_ui_context_create(C); + wmDropBox *drop_prev = drag->drop_state.active_dropbox; wmDropBox *drop = wm_dropbox_active(C, drag, event); if (drop != drop_prev) { @@ -381,11 +398,20 @@ static void wm_drop_update_active(bContext *C, wmDrag *drag, const wmEvent *even drag->drop_state.area_from = drop ? CTX_wm_area(C) : NULL; drag->drop_state.region_from = drop ? CTX_wm_region(C) : NULL; } + + if (!drag->drop_state.active_dropbox) { + wm_drop_ui_context_free(&drag->drop_state.ui_context); + } } void wm_drop_prepare(bContext *C, wmDrag *drag, wmDropBox *drop) { const wmOperatorCallContext opcontext = wm_drop_operator_context_get(drop); + + if (drag->drop_state.ui_context) { + CTX_store_set(C, drag->drop_state.ui_context); + } + /* Optionally copy drag information to operator properties. Don't call it if the * operator fails anyway, it might do more than just set properties (e.g. * typically import an asset). */ @@ -396,6 +422,11 @@ void wm_drop_prepare(bContext *C, wmDrag *drag, wmDropBox *drop) wm_drags_exit(CTX_wm_manager(C), CTX_wm_window(C)); } +void wm_drop_end(bContext *C, wmDrag *UNUSED(drag), wmDropBox *UNUSED(drop)) +{ + CTX_store_set(C, NULL); +} + void wm_drags_check_ops(bContext *C, const wmEvent *event) { wmWindowManager *wm = CTX_wm_manager(C); @@ -901,6 +932,7 @@ void wm_drags_draw(bContext *C, wmWindow *win) if (drag->drop_state.active_dropbox) { CTX_wm_area_set(C, drag->drop_state.area_from); CTX_wm_region_set(C, drag->drop_state.region_from); + CTX_store_set(C, drag->drop_state.ui_context); /* Drawing should be allowed to assume the context from handling and polling (that's why we * restore it above). */ @@ -919,4 +951,5 @@ void wm_drags_draw(bContext *C, wmWindow *win) GPU_blend(GPU_BLEND_NONE); CTX_wm_area_set(C, NULL); CTX_wm_region_set(C, NULL); + CTX_store_set(C, NULL); } diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index 9dfac54a91e..46f7b67c2ba 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -1,21 +1,5 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2007 Blender Foundation. - * All rights reserved. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright 2007 Blender Foundation. All rights reserved. */ /** \file * \ingroup wm diff --git a/source/blender/windowmanager/intern/wm_event_query.c b/source/blender/windowmanager/intern/wm_event_query.c index 22cd68ddbd7..ee13e1832ed 100644 --- a/source/blender/windowmanager/intern/wm_event_query.c +++ b/source/blender/windowmanager/intern/wm_event_query.c @@ -1,21 +1,5 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2007 Blender Foundation. - * All rights reserved. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright 2007 Blender Foundation. All rights reserved. */ /** \file * \ingroup wm @@ -63,12 +47,7 @@ static void event_ids_from_type_and_value(const short type, RNA_enum_identifier(rna_enum_event_type_items, type, r_type_id); /* Value. */ - if (ISTWEAK(type)) { - RNA_enum_identifier(rna_enum_event_value_tweak_items, val, r_val_id); - } - else { - RNA_enum_identifier(rna_enum_event_value_all_items, val, r_val_id); - } + RNA_enum_identifier(rna_enum_event_value_items, val, r_val_id); } void WM_event_print(const wmEvent *event) @@ -96,12 +75,12 @@ void WM_event_print(const wmEvent *event) prev_type_id, event->prev_val, prev_val_id, - event->shift, - event->ctrl, - event->alt, - event->oskey, + (event->modifier & KM_SHIFT) != 0, + (event->modifier & KM_CTRL) != 0, + (event->modifier & KM_ALT) != 0, + (event->modifier & KM_OSKEY) != 0, event->keymodifier, - event->is_repeat, + (event->flag & WM_EVENT_IS_REPEAT) != 0, event->xy[0], event->xy[1], event->ascii, @@ -145,24 +124,6 @@ void WM_event_print(const wmEvent *event) /** \name Event Modifier/Type Queries * \{ */ -int WM_event_modifier_flag(const wmEvent *event) -{ - int flag = 0; - if (event->ctrl) { - flag |= KM_CTRL; - } - if (event->alt) { - flag |= KM_ALT; - } - if (event->shift) { - flag |= KM_SHIFT; - } - if (event->oskey) { - flag |= KM_OSKEY; - } - return flag; -} - bool WM_event_type_mask_test(const int event_type, const enum eEventType_Mask mask) { /* Keyboard. */ @@ -194,13 +155,6 @@ bool WM_event_type_mask_test(const int event_type, const enum eEventType_Mask ma } } - /* Tweak. */ - if (mask & EVT_TYPE_MASK_TWEAK) { - if (ISTWEAK(event_type)) { - return true; - } - } - /* Action Zone. */ if (mask & EVT_TYPE_MASK_ACTIONZONE) { if (IS_EVENT_ACTIONZONE(event_type)) { @@ -217,34 +171,30 @@ bool WM_event_type_mask_test(const int event_type, const enum eEventType_Mask ma /** \name Event Motion Queries * \{ */ -bool WM_event_is_modal_tweak_exit(const wmEvent *event, int tweak_event) +bool WM_event_is_modal_drag_exit(const wmEvent *event, + const short init_event_type, + const short init_event_val) { - /* if the release-confirm userpref setting is enabled, - * tweak events can be canceled when mouse is released - */ + /* If the release-confirm preference setting is enabled, + * drag events can be canceled when mouse is released. */ if (U.flag & USER_RELEASECONFIRM) { /* option on, so can exit with km-release */ if (event->val == KM_RELEASE) { - switch (tweak_event) { - case EVT_TWEAK_L: - case EVT_TWEAK_M: - case EVT_TWEAK_R: - return 1; + if ((init_event_val == KM_CLICK_DRAG) && (event->type == init_event_type)) { + return 1; } } else { - /* if the initial event wasn't a tweak event then - * ignore USER_RELEASECONFIRM setting: see T26756. */ - if (ELEM(tweak_event, EVT_TWEAK_L, EVT_TWEAK_M, EVT_TWEAK_R) == 0) { + /* If the initial event wasn't a drag event then + * ignore #USER_RELEASECONFIRM setting: see T26756. */ + if (init_event_val != KM_CLICK_DRAG) { return 1; } } } else { - /* this is fine as long as not doing km-release, otherwise - * some items (i.e. markers) being tweaked may end up getting - * dropped all over - */ + /* This is fine as long as not doing km-release, otherwise some items (i.e. markers) + * being tweaked may end up getting dropped all over. */ if (event->val != KM_RELEASE) { return 1; } @@ -265,7 +215,7 @@ bool WM_event_is_last_mousemove(const wmEvent *event) bool WM_event_is_mouse_drag(const wmEvent *event) { - return ISTWEAK(event->type) || (ISMOUSE_BUTTON(event->type) && (event->val == KM_CLICK_DRAG)); + return (ISMOUSE_BUTTON(event->type) && (event->val == KM_CLICK_DRAG)); } bool WM_event_is_mouse_drag_or_press(const wmEvent *event) @@ -274,6 +224,68 @@ bool WM_event_is_mouse_drag_or_press(const wmEvent *event) (ISMOUSE_BUTTON(event->type) && (event->val == KM_PRESS)); } +int WM_event_drag_direction(const wmEvent *event) +{ + const int delta[2] = { + event->xy[0] - event->prev_click_xy[0], + event->xy[1] - event->prev_click_xy[1], + }; + + int theta = round_fl_to_int(4.0f * atan2f((float)delta[1], (float)delta[0]) / (float)M_PI); + int val = KM_DIRECTION_W; + + if (theta == 0) { + val = KM_DIRECTION_E; + } + else if (theta == 1) { + val = KM_DIRECTION_NE; + } + else if (theta == 2) { + val = KM_DIRECTION_N; + } + else if (theta == 3) { + val = KM_DIRECTION_NW; + } + else if (theta == -1) { + val = KM_DIRECTION_SE; + } + else if (theta == -2) { + val = KM_DIRECTION_S; + } + else if (theta == -3) { + val = KM_DIRECTION_SW; + } + +#if 0 + /* debug */ + if (val == 1) { + printf("tweak north\n"); + } + if (val == 2) { + printf("tweak north-east\n"); + } + if (val == 3) { + printf("tweak east\n"); + } + if (val == 4) { + printf("tweak south-east\n"); + } + if (val == 5) { + printf("tweak south\n"); + } + if (val == 6) { + printf("tweak south-west\n"); + } + if (val == 7) { + printf("tweak west\n"); + } + if (val == 8) { + printf("tweak north-west\n"); + } +#endif + return val; +} + bool WM_cursor_test_motion_and_update(const int mval[2]) { static int mval_prev[2] = {-1, -1}; @@ -294,8 +306,8 @@ bool WM_cursor_test_motion_and_update(const int mval[2]) int WM_event_drag_threshold(const struct wmEvent *event) { int drag_threshold; - if (ISMOUSE(event->prev_type)) { - BLI_assert(event->prev_type != MOUSEMOVE); + if (ISMOUSE(event->prev_click_type)) { + BLI_assert(event->prev_click_type != MOUSEMOVE); /* Using the previous type is important is we want to check the last pressed/released button, * The `event->type` would include #MOUSEMOVE which is always the case when dragging * and does not help us know which threshold to use. */ @@ -347,12 +359,6 @@ int WM_userdef_event_map(int kmitype) int WM_userdef_event_type_from_keymap_type(int kmitype) { switch (kmitype) { - case EVT_TWEAK_L: - return LEFTMOUSE; - case EVT_TWEAK_M: - return MIDDLEMOUSE; - case EVT_TWEAK_R: - return RIGHTMOUSE; case WHEELOUTMOUSE: return (U.uiflag & USER_WHEELZOOMDIR) ? WHEELUPMOUSE : WHEELDOWNMOUSE; case WHEELINMOUSE: @@ -474,7 +480,7 @@ int WM_event_absolute_delta_x(const struct wmEvent *event) { int dx = event->xy[0] - event->prev_xy[0]; - if (!event->is_direction_inverted) { + if ((event->flag & WM_EVENT_SCROLL_INVERT) == 0) { dx = -dx; } @@ -485,7 +491,7 @@ int WM_event_absolute_delta_y(const struct wmEvent *event) { int dy = event->xy[1] - event->prev_xy[1]; - if (!event->is_direction_inverted) { + if ((event->flag & WM_EVENT_SCROLL_INVERT) == 0) { dy = -dy; } @@ -507,8 +513,8 @@ int WM_event_absolute_delta_y(const struct wmEvent *event) */ bool WM_event_is_ime_switch(const struct wmEvent *event) { - return event->val == KM_PRESS && event->type == EVT_SPACEKEY && - (event->ctrl || event->oskey || event->alt); + return (event->val == KM_PRESS) && (event->type == EVT_SPACEKEY) && + (event->modifier & (KM_CTRL | KM_OSKEY | KM_ALT)); } #endif diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index d9ef7dc63ff..36ac6f401b1 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -1,21 +1,5 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2007 Blender Foundation. - * All rights reserved. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright 2007 Blender Foundation. All rights reserved. */ /** \file * \ingroup wm @@ -169,7 +153,7 @@ wmEvent *WM_event_add_simulate(wmWindow *win, const wmEvent *event_to_add) win->eventstate->type = event->type; if (event->val == KM_PRESS) { - if (event->is_repeat == false) { + if ((event->flag & WM_EVENT_IS_REPEAT) == 0) { copy_v2_v2_int(win->eventstate->prev_click_xy, event->xy); } } @@ -182,7 +166,7 @@ void wm_event_free(wmEvent *event) #ifndef NDEBUG /* Don't use assert here because it's fairly harmless in most cases, * more an issue of correctness, something we should avoid in general. */ - if (event->is_repeat && !ISKEYBOARD(event->type)) { + if ((event->flag & WM_EVENT_IS_REPEAT) && !ISKEYBOARD(event->type)) { printf("%s: 'is_repeat=true' for non-keyboard event, this should not happen.\n", __func__); WM_event_print(event); } @@ -755,7 +739,7 @@ void wm_event_handler_ui_cancel_ex(bContext *C, wm_event_init_from_window(win, &event); event.type = EVT_BUT_CANCEL; event.val = reactivate_button ? 0 : 1; - event.is_repeat = false; + event.flag = 0; handler->handle_fn(C, &event, handler->user_data); } } @@ -1081,7 +1065,7 @@ static int wm_operator_exec(bContext *C, wmOperator *op, const bool repeat, cons } } - /* XXX(mont29) Disabled the repeat check to address part 2 of T31840. + /* XXX(@mont29): Disabled the repeat check to address part 2 of T31840. * Carefully checked all calls to wm_operator_exec and WM_operator_repeat, don't see any reason * why this was needed, but worth to note it in case something turns bad. */ if (retval & (OPERATOR_FINISHED | OPERATOR_CANCELLED) /* && repeat == 0 */) { @@ -1998,7 +1982,7 @@ static bool wm_eventmatch(const wmEvent *winevent, const wmKeyMapItem *kmi) return false; } - if (winevent->is_repeat) { + if (winevent->flag & WM_EVENT_IS_REPEAT) { if (kmi->flag & KMI_REPEAT_IGNORE) { return false; } @@ -2045,29 +2029,41 @@ static bool wm_eventmatch(const wmEvent *winevent, const wmKeyMapItem *kmi) } } + if (kmi->val == KM_CLICK_DRAG) { + if (kmi->direction != KM_ANY) { + if (kmi->direction != winevent->direction) { + return false; + } + } + } + + const bool shift = (winevent->modifier & KM_SHIFT) != 0; + const bool ctrl = (winevent->modifier & KM_CTRL) != 0; + const bool alt = (winevent->modifier & KM_ALT) != 0; + const bool oskey = (winevent->modifier & KM_OSKEY) != 0; + /* Modifiers also check bits, so it allows modifier order. * Account for rare case of when these keys are used as the 'type' not as modifiers. */ if (kmi->shift != KM_ANY) { - if ((winevent->shift != kmi->shift) && !(winevent->shift & kmi->shift) && + if ((shift != kmi->shift) && !(shift & kmi->shift) && !ELEM(winevent->type, EVT_LEFTSHIFTKEY, EVT_RIGHTSHIFTKEY)) { return false; } } if (kmi->ctrl != KM_ANY) { - if (winevent->ctrl != kmi->ctrl && !(winevent->ctrl & kmi->ctrl) && + if (ctrl != kmi->ctrl && !(ctrl & kmi->ctrl) && !ELEM(winevent->type, EVT_LEFTCTRLKEY, EVT_RIGHTCTRLKEY)) { return false; } } if (kmi->alt != KM_ANY) { - if (winevent->alt != kmi->alt && !(winevent->alt & kmi->alt) && + if (alt != kmi->alt && !(alt & kmi->alt) && !ELEM(winevent->type, EVT_LEFTALTKEY, EVT_RIGHTALTKEY)) { return false; } } if (kmi->oskey != KM_ANY) { - if (winevent->oskey != kmi->oskey && !(winevent->oskey & kmi->oskey) && - (winevent->type != EVT_OSKEY)) { + if (oskey != kmi->oskey && !(oskey & kmi->oskey) && (winevent->type != EVT_OSKEY)) { return false; } } @@ -2787,7 +2783,7 @@ static int wm_handlers_do_gizmo_handler(bContext *C, { /* Drag events use the previous click location to highlight the gizmos, * Get the highlight again in case the user dragged off the gizmo. */ - const bool is_event_drag = ISTWEAK(event->type) || (event->val == KM_CLICK_DRAG); + const bool is_event_drag = (event->val == KM_CLICK_DRAG); const bool is_event_modifier = ISKEYMODIFIER(event->type); /* Only keep the highlight if the gizmo becomes modal as result of event handling. * Without this check, even un-handled drag events will set the highlight if the drag @@ -2898,15 +2894,10 @@ static int wm_handlers_do_gizmo_handler(bContext *C, wmEvent event_test_click_drag = *event; event_test_click_drag.val = KM_CLICK_DRAG; - wmEvent event_test_tweak = *event; - event_test_tweak.type = EVT_TWEAK_L + (event->type - LEFTMOUSE); - event_test_tweak.val = KM_ANY; - LISTBASE_FOREACH (wmKeyMapItem *, kmi, &keymap->items) { if ((kmi->flag & KMI_INACTIVE) == 0) { if (wm_eventmatch(&event_test_click, kmi) || - wm_eventmatch(&event_test_click_drag, kmi) || - wm_eventmatch(&event_test_tweak, kmi)) { + wm_eventmatch(&event_test_click_drag, kmi)) { wmOperatorType *ot = WM_operatortype_find(kmi->idname, 0); if (WM_operator_poll_context(C, ot, WM_OP_INVOKE_DEFAULT)) { is_event_handle_all = true; @@ -3076,6 +3067,8 @@ static int wm_handlers_do_intern(bContext *C, wmWindow *win, wmEvent *event, Lis event->customdata = NULL; event->custom = 0; + wm_drop_end(C, drag, drop); + /* XXX fileread case. */ if (CTX_wm_window(C) == NULL) { return action; @@ -3165,38 +3158,49 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers) } if (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) { - /* Test for CLICK_DRAG events. */ - if (wm_action_not_handled(action)) { + /* Test for #WM_CLICK_DRAG events. */ + + /* NOTE(@campbellbarton): Needed so drag can be used for editors that support both click + * selection and passing through the drag action to box select. See #WM_generic_select_modal. + * Unlike click, accept `action` when break isn't set. + * Operators can return `OPERATOR_FINISHED | OPERATOR_PASS_THROUGH` which results + * in `action` setting #WM_HANDLER_HANDLED, but not #WM_HANDLER_BREAK. */ + if ((action & WM_HANDLER_BREAK) == 0 || wm_action_not_handled(action)) { if (win->event_queue_check_drag) { if (WM_event_drag_test(event, event->prev_click_xy)) { win->event_queue_check_drag_handled = true; + const int direction = WM_event_drag_direction(event); - int xy[2] = {UNPACK2(event->xy)}; - short val = event->val; - short type = event->type; + const int prev_xy[2] = {UNPACK2(event->xy)}; + const short prev_val = event->val; + const short prev_type = event->type; + const uint8_t prev_modifier = event->modifier; + const short prev_keymodifier = event->keymodifier; copy_v2_v2_int(event->xy, event->prev_click_xy); event->val = KM_CLICK_DRAG; - event->type = event->prev_type; + event->type = event->prev_click_type; + event->modifier = event->prev_click_modifier; + event->keymodifier = event->prev_click_keymodifier; + event->direction = direction; CLOG_INFO(WM_LOG_HANDLERS, 1, "handling PRESS_DRAG"); action |= wm_handlers_do_intern(C, win, event, handlers); - event->val = val; - event->type = type; - copy_v2_v2_int(event->xy, xy); + event->direction = 0; + event->keymodifier = prev_keymodifier; + event->modifier = prev_modifier; + event->val = prev_val; + event->type = prev_type; + copy_v2_v2_int(event->xy, prev_xy); win->event_queue_check_click = false; - if (!wm_action_not_handled(action)) { - /* Only disable when handled as other handlers may use this drag event. */ - win->event_queue_check_drag = false; - } } } - } - else { - win->event_queue_check_drag = false; + else { + win->event_queue_check_drag = false; + } } } else if (ISMOUSE_BUTTON(event->type) || ISKEYBOARD(event->type)) { @@ -3208,17 +3212,26 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers) * wasn't handled, the KM_RELEASE will become a KM_CLICK */ if (event->val == KM_PRESS) { - if (event->is_repeat == false) { + if ((event->flag & WM_EVENT_IS_REPEAT) == 0) { win->event_queue_check_click = true; win->event_queue_check_drag = true; win->event_queue_check_drag_handled = false; } } else if (event->val == KM_RELEASE) { - win->event_queue_check_drag = false; + if (win->event_queue_check_drag) { + if ((event->prev_click_type != event->type) && + (ISKEYMODIFIER(event->type) || (event->type == event->prev_click_keymodifier))) { + /* Support releasing modifier keys without canceling the drag event, see T89989. + * NOTE: this logic is replicated for tweak gestures. */ + } + else { + win->event_queue_check_drag = false; + } + } } - if (event->prev_type == event->type) { + if (event->prev_click_type == event->type) { if (event->val == KM_RELEASE) { if (event->prev_val == KM_PRESS) { @@ -3259,7 +3272,6 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers) } else { win->event_queue_check_click = false; - win->event_queue_check_drag = false; } } else if (ISMOUSE_WHEEL(event->type) || ISMOUSE_GESTURE(event->type)) { @@ -3706,8 +3718,10 @@ void wm_event_do_handlers(bContext *C) /* Check dragging, creates new event or frees, adds draw tag. */ wm_event_drag_and_drop_test(wm, win, event); - /* Builtin tweak, if action is break it removes tweak. */ - wm_tweakevent_test(C, event, action); + /* Builtin drag: #KM_CLICK_DRAG. */ + if (action & WM_HANDLER_BREAK) { + win->event_queue_check_drag = false; + } if ((action & WM_HANDLER_BREAK) == 0) { /* NOTE: setting subwin active should be done here, after modal handlers have been done. */ @@ -3809,7 +3823,7 @@ void wm_event_do_handlers(bContext *C) tevent.type = MOUSEMOVE; tevent.prev_xy[0] = tevent.xy[0]; tevent.prev_xy[1] = tevent.xy[1]; - tevent.is_repeat = false; + tevent.flag = 0; wm_event_add(win, &tevent); win->addmousemove = 0; } @@ -4501,19 +4515,18 @@ static void wm_eventemulation(wmEvent *event, bool test_only) if (U.flag & USER_TWOBUTTONMOUSE) { if (event->type == LEFTMOUSE) { - short *mod = ( + const uint8_t mod_test = ( #if !defined(WIN32) - (U.mouse_emulate_3_button_modifier == USER_EMU_MMB_MOD_OSKEY) ? &event->oskey : - &event->alt + (U.mouse_emulate_3_button_modifier == USER_EMU_MMB_MOD_OSKEY) ? KM_OSKEY : KM_ALT #else /* Disable for WIN32 for now because it accesses the start menu. */ - &event->alt + KM_ALT #endif ); if (event->val == KM_PRESS) { - if (*mod) { - *mod = 0; + if (event->modifier & mod_test) { + event->modifier &= ~mod_test; event->type = MIDDLEMOUSE; if (!test_only) { @@ -4525,7 +4538,7 @@ static void wm_eventemulation(wmEvent *event, bool test_only) /* Only send middle-mouse release if emulated. */ if (emulating_event == MIDDLEMOUSE) { event->type = MIDDLEMOUSE; - *mod = 0; + event->modifier &= ~mod_test; } if (!test_only) { @@ -4701,6 +4714,9 @@ static void wm_event_prev_values_set(wmEvent *event, wmEvent *event_state) static void wm_event_prev_click_set(wmEvent *event, wmEvent *event_state) { event->prev_click_time = event_state->prev_click_time = PIL_check_seconds_timer(); + event->prev_click_type = event_state->prev_click_type = event_state->type; + event->prev_click_modifier = event_state->prev_click_modifier = event_state->modifier; + event->prev_click_keymodifier = event_state->prev_click_keymodifier = event_state->keymodifier; event->prev_click_xy[0] = event_state->prev_click_xy[0] = event_state->xy[0]; event->prev_click_xy[1] = event_state->prev_click_xy[1] = event_state->xy[1]; } @@ -4714,7 +4730,7 @@ static wmEvent *wm_event_add_mousemove(wmWindow *win, const wmEvent *event) * them for better performance. */ if (event_last && event_last->type == MOUSEMOVE) { event_last->type = INBETWEEN_MOUSEMOVE; - event_last->is_repeat = false; + event_last->flag = 0; } wmEvent *event_new = wm_event_add(win, event); @@ -4766,7 +4782,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, void /* Initialize and copy state (only mouse x y and modifiers). */ event = *event_state; - event.is_repeat = false; + event.flag = 0; /** * Always support accessing the last key press/release. This is set from `win->eventstate`, @@ -4864,7 +4880,9 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, void event.val = KM_NOTHING; /* The direction is inverted from the device due to system preferences. */ - event.is_direction_inverted = pd->isDirectionInverted; + if (pd->isDirectionInverted) { + event.flag |= WM_EVENT_SCROLL_INVERT; + } wm_event_add_trackpad(win, &event, pd->deltaX, -pd->deltaY); break; @@ -4945,12 +4963,16 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, void case GHOST_kEventKeyDown: case GHOST_kEventKeyUp: { GHOST_TEventKeyData *kd = customdata; - short keymodifier = KM_NOTHING; + /* Only copy these flags into the `event_state`. */ + const eWM_EventFlag event_state_flag_mask = WM_EVENT_IS_REPEAT; + bool keymodifier = 0; event.type = convert_key(kd->key); event.ascii = kd->ascii; /* Might be not NULL terminated. */ memcpy(event.utf8_buf, kd->utf8_buf, sizeof(event.utf8_buf)); - event.is_repeat = kd->is_repeat; + if (kd->is_repeat) { + event.flag |= WM_EVENT_IS_REPEAT; + } event.val = (type == GHOST_kEventKeyDown) ? KM_PRESS : KM_RELEASE; wm_eventemulation(&event, false); @@ -4959,7 +4981,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, void /* Copy to event state. */ event_state->val = event.val; event_state->type = event.type; - event_state->is_repeat = event.is_repeat; + event_state->flag = (event.flag & event_state_flag_mask); /* Exclude arrow keys, esc, etc from text input. */ if (type == GHOST_kEventKeyUp) { @@ -4995,29 +5017,57 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, void case EVT_LEFTSHIFTKEY: case EVT_RIGHTSHIFTKEY: if (event.val == KM_PRESS) { - keymodifier = KM_MOD_HELD; + keymodifier = true; + } + if (keymodifier) { + event.modifier |= KM_SHIFT; + event_state->modifier |= KM_SHIFT; + } + else { + event.modifier &= ~KM_SHIFT; + event_state->modifier &= ~KM_SHIFT; } - event.shift = event_state->shift = keymodifier; break; case EVT_LEFTCTRLKEY: case EVT_RIGHTCTRLKEY: if (event.val == KM_PRESS) { - keymodifier = KM_MOD_HELD; + keymodifier = true; + } + if (keymodifier) { + event.modifier |= KM_CTRL; + event_state->modifier |= KM_CTRL; + } + else { + event.modifier &= ~KM_CTRL; + event_state->modifier &= ~KM_CTRL; } - event.ctrl = event_state->ctrl = keymodifier; break; case EVT_LEFTALTKEY: case EVT_RIGHTALTKEY: if (event.val == KM_PRESS) { - keymodifier = KM_MOD_HELD; + keymodifier = true; + } + if (keymodifier) { + event.modifier |= KM_ALT; + event_state->modifier |= KM_ALT; + } + else { + event.modifier &= ~KM_ALT; + event_state->modifier &= ~KM_ALT; } - event.alt = event_state->alt = keymodifier; break; case EVT_OSKEY: if (event.val == KM_PRESS) { - keymodifier = KM_MOD_HELD; + keymodifier = true; + } + if (keymodifier) { + event.modifier |= KM_OSKEY; + event_state->modifier |= KM_OSKEY; + } + else { + event.modifier &= ~KM_OSKEY; + event_state->modifier &= ~KM_OSKEY; } - event.oskey = event_state->oskey = keymodifier; break; default: if (event.val == KM_PRESS && event.keymodifier == 0) { @@ -5055,14 +5105,14 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, void * XXX Keep global for now? */ if ((event.type == EVT_ESCKEY && event.val == KM_PRESS) && /* Check other modifiers because ms-windows uses these to bring up the task manager. */ - (event.shift == 0 && event.ctrl == 0 && event.alt == 0)) { + ((event.modifier & (KM_SHIFT | KM_CTRL | KM_ALT)) == 0)) { G.is_break = true; } /* Double click test - only for press. */ if (event.val == KM_PRESS) { /* Don't reset timer & location when holding the key generates repeat events. */ - if (event.is_repeat == false) { + if ((event.flag & WM_EVENT_IS_REPEAT) == 0) { wm_event_prev_click_set(&event, event_state); } } @@ -5183,7 +5233,7 @@ void wm_event_add_xrevent(wmWindow *win, wmXrActionData *actiondata, short val) wmEvent event = { .type = EVT_XR_ACTION, .val = val, - .is_repeat = false, + .flag = 0, .custom = EVT_DATA_XR, .customdata = actiondata, .customdata_free = true, @@ -5315,9 +5365,7 @@ wmKeyMapItem *WM_event_match_keymap_item_from_handlers( /** State storage to detect changes between calls to refresh the information. */ struct CursorKeymapInfo_State { - struct { - short shift, ctrl, alt, oskey; - } modifiers; + uint8_t modifier; short space_type; short region_type; /* Never use, just compare memory for changes. */ @@ -5340,10 +5388,7 @@ static void wm_event_cursor_store(struct CursorKeymapInfo_State *state, short region_type, const bToolRef *tref) { - state->modifiers.shift = event->shift; - state->modifiers.ctrl = event->ctrl; - state->modifiers.alt = event->alt; - state->modifiers.oskey = event->oskey; + state->modifier = event->modifier; state->space_type = space_type; state->region_type = region_type; state->tref = tref ? *tref : (bToolRef){0}; @@ -5474,15 +5519,15 @@ void WM_window_cursor_keymap_status_refresh(bContext *C, wmWindow *win) } event_data[] = { {0, 0, LEFTMOUSE, KM_PRESS}, {0, 0, LEFTMOUSE, KM_CLICK}, - {0, 1, EVT_TWEAK_L, KM_ANY}, + {0, 0, LEFTMOUSE, KM_CLICK_DRAG}, {1, 0, MIDDLEMOUSE, KM_PRESS}, {1, 0, MIDDLEMOUSE, KM_CLICK}, - {1, 1, EVT_TWEAK_M, KM_ANY}, + {1, 0, MIDDLEMOUSE, KM_CLICK_DRAG}, {2, 0, RIGHTMOUSE, KM_PRESS}, {2, 0, RIGHTMOUSE, KM_CLICK}, - {2, 1, EVT_TWEAK_R, KM_ANY}, + {2, 0, RIGHTMOUSE, KM_CLICK_DRAG}, }; for (int button_index = 0; button_index < 3; button_index++) { diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 1478712c3cd..7471d41b44c 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -1,21 +1,5 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright 2001-2002 NaN Holding BV. All rights reserved. */ /** \file * \ingroup wm @@ -874,18 +858,16 @@ static void file_read_reports_finalize(BlendFileReadReport *bf_reports) duration_lib_override_recursive_resync_seconds); } - if (bf_reports->count.linked_proxies != 0 || - bf_reports->count.proxies_to_lib_overrides_success != 0 || + if (bf_reports->count.proxies_to_lib_overrides_success != 0 || bf_reports->count.proxies_to_lib_overrides_failures != 0) { - BKE_reportf(bf_reports->reports, - RPT_WARNING, - "Proxies are deprecated (%d proxies were automatically converted to library " - "overrides, %d proxies could not be converted and %d linked proxies were kept " - "untouched). If you need to keep proxies for the time being, please disable the " - "`Proxy to Override Auto Conversion` in Experimental user preferences", - bf_reports->count.proxies_to_lib_overrides_success, - bf_reports->count.proxies_to_lib_overrides_failures, - bf_reports->count.linked_proxies); + BKE_reportf( + bf_reports->reports, + RPT_WARNING, + "Proxies have been removed from Blender (%d proxies were automatically converted " + "to library overrides, %d proxies could not be converted and were cleared). " + "Please also consider re-saving any library .blend file with the newest Blender version.", + bf_reports->count.proxies_to_lib_overrides_success, + bf_reports->count.proxies_to_lib_overrides_failures); } if (bf_reports->count.sequence_strips_skipped != 0) { @@ -2706,7 +2688,7 @@ static char *wm_open_mainfile_description(struct bContext *UNUSED(C), BLI_stat_t stats; if (BLI_stat(path, &stats) == -1) { - return BLI_sprintfN("%s\n\n%s", path, N_("File Not Found")); + return BLI_sprintfN("%s\n\n%s", path, TIP_("File Not Found")); } /* Date. */ @@ -2716,7 +2698,7 @@ static char *wm_open_mainfile_description(struct bContext *UNUSED(C), BLI_filelist_entry_datetime_to_string( NULL, (int64_t)stats.st_mtime, false, time_st, date_st, &is_today, &is_yesterday); if (is_today || is_yesterday) { - BLI_strncpy(date_st, is_today ? N_("Today") : N_("Yesterday"), sizeof(date_st)); + BLI_strncpy(date_st, is_today ? TIP_("Today") : TIP_("Yesterday"), sizeof(date_st)); } /* Size. */ @@ -2724,7 +2706,7 @@ static char *wm_open_mainfile_description(struct bContext *UNUSED(C), BLI_filelist_entry_size_to_string(NULL, (uint64_t)stats.st_size, false, size_str); return BLI_sprintfN( - "%s\n\n%s: %s %s\n%s: %s", path, N_("Modified"), date_st, time_st, N_("Size"), size_str); + "%s\n\n%s: %s %s\n%s: %s", path, TIP_("Modified"), date_st, time_st, TIP_("Size"), size_str); } /* currently fits in a pointer */ @@ -3171,8 +3153,8 @@ static char *wm_save_as_mainfile_get_description(bContext *UNUSED(C), PointerRNA *ptr) { if (RNA_boolean_get(ptr, "copy")) { - return BLI_strdup( - "Save the current file in the desired location but do not make the saved file active"); + return BLI_strdup(TIP_( + "Save the current file in the desired location but do not make the saved file active")); } return NULL; } diff --git a/source/blender/windowmanager/intern/wm_files_link.c b/source/blender/windowmanager/intern/wm_files_link.c index cf6ecd55757..25b9678ef11 100644 --- a/source/blender/windowmanager/intern/wm_files_link.c +++ b/source/blender/windowmanager/intern/wm_files_link.c @@ -1,21 +1,5 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2007 Blender Foundation. - * All rights reserved. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright 2007 Blender Foundation. All rights reserved. */ /** \file * \ingroup wm diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c index 7f923d4af60..a6fbad8b171 100644 --- a/source/blender/windowmanager/intern/wm_gesture.c +++ b/source/blender/windowmanager/intern/wm_gesture.c @@ -1,21 +1,5 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2008 Blender Foundation. - * All rights reserved. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright 2008 Blender Foundation. All rights reserved. */ /** \file * \ingroup wm @@ -58,6 +42,8 @@ wmGesture *WM_gesture_new(wmWindow *window, const ARegion *region, const wmEvent gesture->type = type; gesture->event_type = event->type; + gesture->event_modifier = event->modifier; + gesture->event_keymodifier = event->keymodifier; gesture->winrct = region->winrct; gesture->user_data.use_free = true; /* Free if userdata is set. */ gesture->modal_state = GESTURE_MODAL_NOP; @@ -66,7 +52,6 @@ wmGesture *WM_gesture_new(wmWindow *window, const ARegion *region, const wmEvent if (ELEM(type, WM_GESTURE_RECT, WM_GESTURE_CROSS_RECT, - WM_GESTURE_TWEAK, WM_GESTURE_CIRCLE, WM_GESTURE_STRAIGHTLINE)) { rcti *rect = MEM_callocN(sizeof(rcti), "gesture rect new"); @@ -97,9 +82,6 @@ wmGesture *WM_gesture_new(wmWindow *window, const ARegion *region, const wmEvent void WM_gesture_end(wmWindow *win, wmGesture *gesture) { - if (win->tweak == gesture) { - win->tweak = NULL; - } BLI_remlink(&win->gesture, gesture); MEM_freeN(gesture->customdata); WM_generic_user_data_free(&gesture->user_data); @@ -128,74 +110,6 @@ bool WM_gesture_is_modal_first(const wmGesture *gesture) return (gesture->is_active_prev == false); } -int wm_gesture_evaluate(wmGesture *gesture, const wmEvent *event) -{ - if (gesture->type == WM_GESTURE_TWEAK) { - rcti *rect = gesture->customdata; - const int delta[2] = { - BLI_rcti_size_x(rect), - BLI_rcti_size_y(rect), - }; - - if (WM_event_drag_test_with_delta(event, delta)) { - int theta = round_fl_to_int(4.0f * atan2f((float)delta[1], (float)delta[0]) / (float)M_PI); - int val = EVT_GESTURE_W; - - if (theta == 0) { - val = EVT_GESTURE_E; - } - else if (theta == 1) { - val = EVT_GESTURE_NE; - } - else if (theta == 2) { - val = EVT_GESTURE_N; - } - else if (theta == 3) { - val = EVT_GESTURE_NW; - } - else if (theta == -1) { - val = EVT_GESTURE_SE; - } - else if (theta == -2) { - val = EVT_GESTURE_S; - } - else if (theta == -3) { - val = EVT_GESTURE_SW; - } - -#if 0 - /* debug */ - if (val == 1) { - printf("tweak north\n"); - } - if (val == 2) { - printf("tweak north-east\n"); - } - if (val == 3) { - printf("tweak east\n"); - } - if (val == 4) { - printf("tweak south-east\n"); - } - if (val == 5) { - printf("tweak south\n"); - } - if (val == 6) { - printf("tweak south-west\n"); - } - if (val == 7) { - printf("tweak west\n"); - } - if (val == 8) { - printf("tweak north-west\n"); - } -#endif - return val; - } - } - return 0; -} - /* ******************* gesture draw ******************* */ static void wm_gesture_draw_line_active_side(rcti *rect, const bool flip) @@ -525,11 +439,6 @@ void wm_gesture_draw(wmWindow *win) if (gt->type == WM_GESTURE_RECT) { wm_gesture_draw_rect(gt); } -#if 0 - else if (gt->type == WM_GESTURE_TWEAK) { - wm_gesture_draw_line(gt); - } -#endif else if (gt->type == WM_GESTURE_CIRCLE) { wm_gesture_draw_circle(gt); } diff --git a/source/blender/windowmanager/intern/wm_gesture_ops.c b/source/blender/windowmanager/intern/wm_gesture_ops.c index 8d45d5aed67..1fdc8bbe2c8 100644 --- a/source/blender/windowmanager/intern/wm_gesture_ops.c +++ b/source/blender/windowmanager/intern/wm_gesture_ops.c @@ -1,21 +1,5 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2007 Blender Foundation. - * All rights reserved. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright 2007 Blender Foundation. All rights reserved. */ /** \file * \ingroup wm @@ -487,118 +471,6 @@ void WM_OT_circle_gesture(wmOperatorType *ot) /** \} */ /* -------------------------------------------------------------------- */ -/** \name Tweak Gesture - * \{ */ - -static void gesture_tweak_modal(bContext *C, const wmEvent *event) -{ - wmWindow *window = CTX_wm_window(C); - wmGesture *gesture = window->tweak; - rcti *rect = gesture->customdata; - bool gesture_end = false; - - switch (event->type) { - case MOUSEMOVE: - case INBETWEEN_MOUSEMOVE: { - - rect->xmax = event->xy[0] - gesture->winrct.xmin; - rect->ymax = event->xy[1] - gesture->winrct.ymin; - - const int val = wm_gesture_evaluate(gesture, event); - if (val != 0) { - wmEvent tevent; - - wm_event_init_from_window(window, &tevent); - /* We want to get coord from start of drag, - * not from point where it becomes a tweak event, see T40549. */ - tevent.xy[0] = rect->xmin + gesture->winrct.xmin; - tevent.xy[1] = rect->ymin + gesture->winrct.ymin; - if (gesture->event_type == LEFTMOUSE) { - tevent.type = EVT_TWEAK_L; - } - else if (gesture->event_type == RIGHTMOUSE) { - tevent.type = EVT_TWEAK_R; - } - else { - tevent.type = EVT_TWEAK_M; - } - tevent.val = val; - tevent.is_repeat = false; - /* mouse coords! */ - - /* important we add immediately after this event, so future mouse releases - * (which may be in the queue already), are handled in order, see T44740 */ - wm_event_add_ex(window, &tevent, event); - - gesture_end = true; - } - - break; - } - - case LEFTMOUSE: - case RIGHTMOUSE: - case MIDDLEMOUSE: - if (gesture->event_type == event->type) { - gesture_end = true; - - /* when tweak fails we should give the other keymap entries a chance */ - - /* XXX, assigning to readonly, BAD JUJU! */ - ((wmEvent *)event)->val = KM_RELEASE; - } - break; - default: - if (!ISTIMER(event->type) && event->type != EVENT_NONE) { - gesture_end = true; - } - break; - } - - if (gesture_end) { - /* Frees gesture itself, and unregisters from window. */ - WM_gesture_end(window, gesture); - - /* This isn't very nice but needed to redraw gizmos which are hidden while tweaking, - * See #WM_GIZMOGROUPTYPE_DELAY_REFRESH_FOR_TWEAK for details. */ - ARegion *region = CTX_wm_region(C); - if ((region != NULL) && (region->gizmo_map != NULL)) { - if (WM_gizmomap_tag_delay_refresh_for_tweak_check(region->gizmo_map)) { - ED_region_tag_redraw(region); - } - } - } -} - -void wm_tweakevent_test(bContext *C, const wmEvent *event, int action) -{ - wmWindow *win = CTX_wm_window(C); - - if (win->tweak == NULL) { - const ARegion *region = CTX_wm_region(C); - - if (region) { - if (event->val == KM_PRESS) { - if (ELEM(event->type, LEFTMOUSE, MIDDLEMOUSE, RIGHTMOUSE)) { - win->tweak = WM_gesture_new(win, region, event, WM_GESTURE_TWEAK); - } - } - } - } - else { - /* no tweaks if event was handled */ - if (action & WM_HANDLER_BREAK) { - WM_gesture_end(win, win->tweak); - } - else { - gesture_tweak_modal(C, event); - } - } -} - -/** \} */ - -/* -------------------------------------------------------------------- */ /** \name Lasso Gesture * \{ */ diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 6caac79c4d5..6cefbf0bae5 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -1,21 +1,5 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2007 Blender Foundation. - * All rights reserved. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright 2007 Blender Foundation. All rights reserved. */ /** \file * \ingroup wm @@ -356,10 +340,10 @@ void WM_init(bContext *C, int argc, const char **argv) if (!G.background) { if (wm_start_with_console) { - GHOST_toggleConsole(1); + setConsoleWindowState(GHOST_kConsoleWindowStateShow); } else { - GHOST_toggleConsole(3); + setConsoleWindowState(GHOST_kConsoleWindowStateHideForNonConsoleLaunch); } } @@ -594,9 +578,7 @@ void WM_exit_ex(bContext *C, const bool do_python) DRW_opengl_context_destroy(); } -#ifdef WITH_INTERNATIONAL BLT_lang_free(); -#endif ANIM_keyingset_infos_exit(); diff --git a/source/blender/windowmanager/intern/wm_jobs.c b/source/blender/windowmanager/intern/wm_jobs.c index e7ad654d3e5..701a93c7e21 100644 --- a/source/blender/windowmanager/intern/wm_jobs.c +++ b/source/blender/windowmanager/intern/wm_jobs.c @@ -1,21 +1,5 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2009 Blender Foundation. - * All rights reserved. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright 2009 Blender Foundation. All rights reserved. */ /** \file * \ingroup wm diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index 0214fce59b2..ffac585cde7 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -1,21 +1,5 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2007 Blender Foundation. - * All rights reserved. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright 2007 Blender Foundation. All rights reserved. */ /** \file * \ingroup wm @@ -185,6 +169,7 @@ static bool wm_keymap_item_equals(wmKeyMapItem *a, wmKeyMapItem *b) return (wm_keymap_item_equals_result(a, b) && a->type == b->type && a->val == b->val && a->shift == b->shift && a->ctrl == b->ctrl && a->alt == b->alt && a->oskey == b->oskey && a->keymodifier == b->keymodifier && a->maptype == b->maptype && + ((a->val != KM_CLICK_DRAG) || (a->direction == b->direction)) && ((ISKEYBOARD(a->type) == 0) || (a->flag & KMI_REPEAT_IGNORE) == (b->flag & KMI_REPEAT_IGNORE))); } @@ -211,9 +196,6 @@ int WM_keymap_item_map_type_get(const wmKeyMapItem *kmi) if (ISKEYBOARD(kmi->type)) { return KMI_TYPE_KEYBOARD; } - if (ISTWEAK(kmi->type)) { - return KMI_TYPE_TWEAK; - } if (ISMOUSE(kmi->type)) { return KMI_TYPE_MOUSE; } @@ -475,11 +457,12 @@ bool WM_keymap_poll(bContext *C, wmKeyMap *keymap) } static void keymap_event_set( - wmKeyMapItem *kmi, short type, short val, int modifier, short keymodifier) + wmKeyMapItem *kmi, short type, short val, int modifier, short keymodifier, int direction) { kmi->type = type; kmi->val = val; kmi->keymodifier = keymodifier; + kmi->direction = direction; if (modifier == KM_ANY) { kmi->shift = kmi->ctrl = kmi->alt = kmi->oskey = KM_ANY; @@ -513,15 +496,20 @@ static void keymap_item_set_id(wmKeyMap *keymap, wmKeyMapItem *kmi) } } -wmKeyMapItem *WM_keymap_add_item( - wmKeyMap *keymap, const char *idname, int type, int val, int modifier, int keymodifier) +wmKeyMapItem *WM_keymap_add_item(wmKeyMap *keymap, + const char *idname, + int type, + int val, + int modifier, + int keymodifier, + int direction) { wmKeyMapItem *kmi = MEM_callocN(sizeof(wmKeyMapItem), "keymap entry"); BLI_addtail(&keymap->items, kmi); BLI_strncpy(kmi->idname, idname, OP_MAX_TYPENAME); - keymap_event_set(kmi, type, val, modifier, keymodifier); + keymap_event_set(kmi, type, val, modifier, keymodifier, direction); wm_keymap_item_properties_set(kmi); keymap_item_set_id(keymap, kmi); @@ -935,14 +923,14 @@ wmKeyMap *WM_modalkeymap_find(wmKeyConfig *keyconf, const char *idname) } wmKeyMapItem *WM_modalkeymap_add_item( - wmKeyMap *km, int type, int val, int modifier, int keymodifier, int value) + wmKeyMap *km, int type, int val, int modifier, int keymodifier, int direction, int value) { wmKeyMapItem *kmi = MEM_callocN(sizeof(wmKeyMapItem), "keymap entry"); BLI_addtail(&km->items, kmi); kmi->propvalue = value; - keymap_event_set(kmi, type, val, modifier, keymodifier); + keymap_event_set(kmi, type, val, modifier, keymodifier, direction); keymap_item_set_id(km, kmi); @@ -951,15 +939,20 @@ wmKeyMapItem *WM_modalkeymap_add_item( return kmi; } -wmKeyMapItem *WM_modalkeymap_add_item_str( - wmKeyMap *km, int type, int val, int modifier, int keymodifier, const char *value) +wmKeyMapItem *WM_modalkeymap_add_item_str(wmKeyMap *km, + int type, + int val, + int modifier, + int keymodifier, + int direction, + const char *value) { wmKeyMapItem *kmi = MEM_callocN(sizeof(wmKeyMapItem), "keymap entry"); BLI_addtail(&km->items, kmi); BLI_strncpy(kmi->propvalue_str, value, sizeof(kmi->propvalue_str)); - keymap_event_set(kmi, type, val, modifier, keymodifier); + keymap_event_set(kmi, type, val, modifier, keymodifier, direction); keymap_item_set_id(km, kmi); @@ -1746,6 +1739,9 @@ bool WM_keymap_item_compare(const wmKeyMapItem *k1, const wmKeyMapItem *k2) if (k1->val != k2->val) { return 0; } + if (k1->val == KM_CLICK_DRAG && (k1->direction != k2->direction)) { + return 0; + } } if (k1->shift != KM_ANY && k2->shift != KM_ANY && k1->shift != k2->shift) { diff --git a/source/blender/windowmanager/intern/wm_keymap_utils.c b/source/blender/windowmanager/intern/wm_keymap_utils.c index d424eef8262..24c221221d1 100644 --- a/source/blender/windowmanager/intern/wm_keymap_utils.c +++ b/source/blender/windowmanager/intern/wm_keymap_utils.c @@ -1,18 +1,4 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /** \file * \ingroup wm @@ -43,64 +29,64 @@ /** \name Wrappers for #WM_keymap_add_item * \{ */ -wmKeyMapItem *WM_keymap_add_menu( - wmKeyMap *keymap, const char *idname, int type, int val, int modifier, int keymodifier) +wmKeyMapItem *WM_keymap_add_menu(wmKeyMap *keymap, + const char *idname, + int type, + int val, + int modifier, + int keymodifier, + int direction) { wmKeyMapItem *kmi = WM_keymap_add_item( - keymap, "WM_OT_call_menu", type, val, modifier, keymodifier); + keymap, "WM_OT_call_menu", type, val, modifier, keymodifier, direction); RNA_string_set(kmi->ptr, "name", idname); return kmi; } -wmKeyMapItem *WM_keymap_add_menu_pie( - wmKeyMap *keymap, const char *idname, int type, int val, int modifier, int keymodifier) +wmKeyMapItem *WM_keymap_add_menu_pie(wmKeyMap *keymap, + const char *idname, + int type, + int val, + int modifier, + int keymodifier, + int direction) { wmKeyMapItem *kmi = WM_keymap_add_item( - keymap, "WM_OT_call_menu_pie", type, val, modifier, keymodifier); + keymap, "WM_OT_call_menu_pie", type, val, modifier, keymodifier, direction); RNA_string_set(kmi->ptr, "name", idname); return kmi; } -wmKeyMapItem *WM_keymap_add_panel( - wmKeyMap *keymap, const char *idname, int type, int val, int modifier, int keymodifier) +wmKeyMapItem *WM_keymap_add_panel(wmKeyMap *keymap, + const char *idname, + int type, + int val, + int modifier, + int keymodifier, + int direction) { wmKeyMapItem *kmi = WM_keymap_add_item( - keymap, "WM_OT_call_panel", type, val, modifier, keymodifier); + keymap, "WM_OT_call_panel", type, val, modifier, keymodifier, direction); RNA_string_set(kmi->ptr, "name", idname); /* TODO: we might want to disable this. */ RNA_boolean_set(kmi->ptr, "keep_open", false); return kmi; } -wmKeyMapItem *WM_keymap_add_tool( - wmKeyMap *keymap, const char *idname, int type, int val, int modifier, int keymodifier) +wmKeyMapItem *WM_keymap_add_tool(wmKeyMap *keymap, + const char *idname, + int type, + int val, + int modifier, + int keymodifier, + int direction) { wmKeyMapItem *kmi = WM_keymap_add_item( - keymap, "WM_OT_tool_set_by_id", type, val, modifier, keymodifier); + keymap, "WM_OT_tool_set_by_id", type, val, modifier, keymodifier, direction); RNA_string_set(kmi->ptr, "name", idname); return kmi; } -void WM_keymap_add_context_enum_set_items(wmKeyMap *keymap, - const EnumPropertyItem *items, - const char *data_path, - int type_start, - int val, - int modifier, - int keymodifier) -{ - for (int i = 0, type_offset = 0; items[i].identifier; i++) { - if (items[i].identifier[0] == '\0') { - continue; - } - wmKeyMapItem *kmi = WM_keymap_add_item( - keymap, "WM_OT_context_set_enum", type_start + type_offset, val, modifier, keymodifier); - RNA_string_set(kmi->ptr, "data_path", data_path); - RNA_string_set(kmi->ptr, "value", items[i].identifier); - type_offset += 1; - } -} - /** \} */ /* -------------------------------------------------------------------- */ @@ -120,6 +106,9 @@ wmKeyMap *WM_keymap_guess_from_context(const bContext *C) case CTX_MODE_EDIT_CURVE: km_id = "Curve"; break; + case CTX_MODE_EDIT_CURVES: + km_id = "Curves"; + break; case CTX_MODE_EDIT_SURFACE: km_id = "Curve"; break; @@ -171,6 +160,9 @@ wmKeyMap *WM_keymap_guess_from_context(const bContext *C) case CTX_MODE_VERTEX_GPENCIL: km_id = "Grease Pencil Stroke Vertex Mode"; break; + case CTX_MODE_SCULPT_CURVES: + km_id = "Curves Sculpt"; + break; } } else if (sl->spacetype == SPACE_IMAGE) { diff --git a/source/blender/windowmanager/intern/wm_menu_type.c b/source/blender/windowmanager/intern/wm_menu_type.c index 799b6fc2e52..9e50ebb1ce5 100644 --- a/source/blender/windowmanager/intern/wm_menu_type.c +++ b/source/blender/windowmanager/intern/wm_menu_type.c @@ -1,18 +1,4 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /** \file * \ingroup wm diff --git a/source/blender/windowmanager/intern/wm_operator_props.c b/source/blender/windowmanager/intern/wm_operator_props.c index ebd6719d54d..ca0a41604bb 100644 --- a/source/blender/windowmanager/intern/wm_operator_props.c +++ b/source/blender/windowmanager/intern/wm_operator_props.c @@ -1,21 +1,5 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2007 Blender Foundation. - * All rights reserved. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright 2007 Blender Foundation. All rights reserved. */ /** \file * \ingroup wm diff --git a/source/blender/windowmanager/intern/wm_operator_type.c b/source/blender/windowmanager/intern/wm_operator_type.c index 0f6096e7b8b..be1fe726c57 100644 --- a/source/blender/windowmanager/intern/wm_operator_type.c +++ b/source/blender/windowmanager/intern/wm_operator_type.c @@ -1,18 +1,4 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /** \file * \ingroup wm diff --git a/source/blender/windowmanager/intern/wm_operator_utils.c b/source/blender/windowmanager/intern/wm_operator_utils.c index dbcfd814692..5a817075cd5 100644 --- a/source/blender/windowmanager/intern/wm_operator_utils.c +++ b/source/blender/windowmanager/intern/wm_operator_utils.c @@ -1,18 +1,4 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /** \file * \ingroup wm @@ -129,11 +115,11 @@ static bool interactive_value_update(ValueInteraction *inter, (((float)(mval_curr - mval_init) / inter->context_vars.region->winx) * value_range)) * value_scale; - if (event->ctrl) { + if (event->modifier & KM_CTRL) { const double snap = 0.1; value_delta = (float)roundf((double)value_delta / snap) * snap; } - if (event->shift) { + if (event->modifier & KM_SHIFT) { value_delta *= 0.1f; } const float value_final = inter->init.prop_value + value_delta; @@ -147,8 +133,8 @@ static bool interactive_value_update(ValueInteraction *inter, } inter->prev.prop_value = value_final; - inter->prev.is_snap = event->ctrl; - inter->prev.is_precise = event->shift; + inter->prev.is_snap = (event->modifier & KM_CTRL) != 0; + inter->prev.is_precise = (event->modifier & KM_SHIFT) != 0; *r_value_final = value_final; return changed; diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 6c9b0af5186..7e680af4537 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1,21 +1,5 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2007 Blender Foundation. - * All rights reserved. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright 2007 Blender Foundation. All rights reserved. */ /** \file * \ingroup wm @@ -927,7 +911,6 @@ int WM_generic_select_modal(bContext *C, wmOperator *op, const wmEvent *event) ret_value = op->type->exec(C, op); OPERATOR_RETVAL_CHECK(ret_value); - op->customdata = POINTER_FROM_INT((int)event->type); if (ret_value & OPERATOR_RUNNING_MODAL) { WM_event_add_modal_handler(C, op); @@ -2046,7 +2029,7 @@ static void WM_OT_quit_blender(wmOperatorType *ot) static int wm_console_toggle_exec(bContext *UNUSED(C), wmOperator *UNUSED(op)) { - GHOST_toggleConsole(2); + setConsoleWindowState(GHOST_kConsoleWindowStateToggle); return OPERATOR_FINISHED; } @@ -2838,7 +2821,7 @@ static int radial_control_modal(bContext *C, wmOperator *op, const wmEvent *even float numValue; /* TODO: fix hardcoded events */ - bool snap = event->ctrl != 0; + bool snap = (event->modifier & KM_CTRL) != 0; /* Modal numinput active, try to handle numeric inputs first... */ if (event->val == KM_PRESS && has_numInput && handleNumInput(C, &rc->num_input, event)) { diff --git a/source/blender/windowmanager/intern/wm_panel_type.c b/source/blender/windowmanager/intern/wm_panel_type.c index 609bb55e075..bfcc86c38e7 100644 --- a/source/blender/windowmanager/intern/wm_panel_type.c +++ b/source/blender/windowmanager/intern/wm_panel_type.c @@ -1,18 +1,4 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /** \file * \ingroup wm diff --git a/source/blender/windowmanager/intern/wm_platform_support.c b/source/blender/windowmanager/intern/wm_platform_support.c index 54fc454ee65..becc2d896d0 100644 --- a/source/blender/windowmanager/intern/wm_platform_support.c +++ b/source/blender/windowmanager/intern/wm_platform_support.c @@ -1,21 +1,5 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2019 Blender Foundation. - * All rights reserved. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright 2019 Blender Foundation. All rights reserved. */ /** \file * \ingroup wm diff --git a/source/blender/windowmanager/intern/wm_platform_support.h b/source/blender/windowmanager/intern/wm_platform_support.h index 6346f517343..389ce1afa88 100644 --- a/source/blender/windowmanager/intern/wm_platform_support.h +++ b/source/blender/windowmanager/intern/wm_platform_support.h @@ -1,21 +1,5 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2019 Blender Foundation. - * All rights reserved. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright 2019 Blender Foundation. All rights reserved. */ /** \file * \ingroup wm diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c index 640fef82085..95879829d42 100644 --- a/source/blender/windowmanager/intern/wm_playanim.c +++ b/source/blender/windowmanager/intern/wm_playanim.c @@ -1,21 +1,5 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright 2001-2002 NaN Holding BV. All rights reserved. */ /** \file * \ingroup wm @@ -499,7 +483,6 @@ static void draw_display_buffer(PlayState *ps, ImBuf *ibuf) if (!glsl_used) { immBindBuiltinProgram(GPU_SHADER_2D_IMAGE_COLOR); immUniformColor3f(1.0f, 1.0f, 1.0f); - immUniform1i("image", 0); } immBegin(GPU_PRIM_TRI_FAN, 4); diff --git a/source/blender/windowmanager/intern/wm_splash_screen.c b/source/blender/windowmanager/intern/wm_splash_screen.c index 7513e4d31cc..2e04a629308 100644 --- a/source/blender/windowmanager/intern/wm_splash_screen.c +++ b/source/blender/windowmanager/intern/wm_splash_screen.c @@ -1,21 +1,5 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2007 Blender Foundation. - * All rights reserved. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright 2007 Blender Foundation. All rights reserved. */ /** \file * \ingroup wm diff --git a/source/blender/windowmanager/intern/wm_stereo.c b/source/blender/windowmanager/intern/wm_stereo.c index a62ced1a4bf..182308cbe5e 100644 --- a/source/blender/windowmanager/intern/wm_stereo.c +++ b/source/blender/windowmanager/intern/wm_stereo.c @@ -1,21 +1,5 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2015 by Blender Foundation - * All rights reserved. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright 2015 Blender Foundation. All rights reserved. */ /** \file * \ingroup wm @@ -83,7 +67,7 @@ void wm_stereo3d_draw_sidebyside(wmWindow *win, int view) const float halfx = GLA_PIXEL_OFS / sizex; const float halfy = GLA_PIXEL_OFS / sizex; - immUniform1i("image", 0); /* texture is already bound to GL_TEXTURE0 unit */ + /* Texture is already bound to GL_TEXTURE0 unit. */ immBegin(GPU_PRIM_TRI_FAN, 4); @@ -127,7 +111,7 @@ void wm_stereo3d_draw_topbottom(wmWindow *win, int view) const float halfx = GLA_PIXEL_OFS / sizex; const float halfy = GLA_PIXEL_OFS / sizex; - immUniform1i("image", 0); /* texture is already bound to GL_TEXTURE0 unit */ + /* Texture is already bound to GL_TEXTURE0 unit. */ immBegin(GPU_PRIM_TRI_FAN, 4); diff --git a/source/blender/windowmanager/intern/wm_subwindow.c b/source/blender/windowmanager/intern/wm_subwindow.c index 524580ac88f..151b6918839 100644 --- a/source/blender/windowmanager/intern/wm_subwindow.c +++ b/source/blender/windowmanager/intern/wm_subwindow.c @@ -1,21 +1,5 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright 2001-2002 NaN Holding BV. All rights reserved. */ /** \file * \ingroup wm diff --git a/source/blender/windowmanager/intern/wm_surface.c b/source/blender/windowmanager/intern/wm_surface.c index 385b55f36f9..2c96ae1f140 100644 --- a/source/blender/windowmanager/intern/wm_surface.c +++ b/source/blender/windowmanager/intern/wm_surface.c @@ -1,18 +1,4 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /** \file * \ingroup wm diff --git a/source/blender/windowmanager/intern/wm_toolsystem.c b/source/blender/windowmanager/intern/wm_toolsystem.c index df6f0a9e1ff..51e4bc9faa8 100644 --- a/source/blender/windowmanager/intern/wm_toolsystem.c +++ b/source/blender/windowmanager/intern/wm_toolsystem.c @@ -1,18 +1,4 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /** \file * \ingroup wm @@ -677,6 +663,8 @@ static const char *toolsystem_default_tool(const bToolKey *tkey) return "builtin_brush.Weight"; case CTX_MODE_VERTEX_GPENCIL: return "builtin_brush.Draw"; + case CTX_MODE_SCULPT_CURVES: + return "builtin_brush.Test 1"; /* end temporary hack. */ case CTX_MODE_PARTICLE: diff --git a/source/blender/windowmanager/intern/wm_tooltip.c b/source/blender/windowmanager/intern/wm_tooltip.c index 3bcd122f08d..fa8138e6057 100644 --- a/source/blender/windowmanager/intern/wm_tooltip.c +++ b/source/blender/windowmanager/intern/wm_tooltip.c @@ -1,18 +1,4 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /** \file * \ingroup wm diff --git a/source/blender/windowmanager/intern/wm_uilist_type.c b/source/blender/windowmanager/intern/wm_uilist_type.c index a2ae42d5ead..88eacf9013b 100644 --- a/source/blender/windowmanager/intern/wm_uilist_type.c +++ b/source/blender/windowmanager/intern/wm_uilist_type.c @@ -1,18 +1,4 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /** \file * \ingroup wm diff --git a/source/blender/windowmanager/intern/wm_utils.c b/source/blender/windowmanager/intern/wm_utils.c index 163ab257beb..55f24cb799c 100644 --- a/source/blender/windowmanager/intern/wm_utils.c +++ b/source/blender/windowmanager/intern/wm_utils.c @@ -1,18 +1,4 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /** \file * \ingroup wm diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 0a229b2ea56..e93ffe48aba 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -1,22 +1,5 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2007 Blender Foundation but based - * on ghostwinlay.c (C) 2001-2002 by NaN Holding BV - * All rights reserved. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright 2001-2002 NaN Holding BV. All rights reserved. 2007 Blender Foundation. */ /** \file * \ingroup wm @@ -1121,10 +1104,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr win->active = 0; /* XXX */ /* clear modifiers for inactive windows */ - win->eventstate->alt = 0; - win->eventstate->ctrl = 0; - win->eventstate->shift = 0; - win->eventstate->oskey = 0; + win->eventstate->modifier = 0; win->eventstate->keymodifier = 0; break; @@ -1155,7 +1135,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr kdata.ascii = '\0'; kdata.utf8_buf[0] = '\0'; - if (win->eventstate->shift) { + if (win->eventstate->modifier & KM_SHIFT) { if ((keymodifier & KM_SHIFT) == 0) { kdata.key = GHOST_kKeyLeftShift; wm_event_add_ghostevent(wm, win, GHOST_kEventKeyUp, &kdata); @@ -1164,11 +1144,11 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr #ifdef USE_WIN_ACTIVATE else { if (keymodifier & KM_SHIFT) { - win->eventstate->shift = KM_MOD_HELD; + win->eventstate->modifier |= KM_SHIFT; } } #endif - if (win->eventstate->ctrl) { + if (win->eventstate->modifier & KM_CTRL) { if ((keymodifier & KM_CTRL) == 0) { kdata.key = GHOST_kKeyLeftControl; wm_event_add_ghostevent(wm, win, GHOST_kEventKeyUp, &kdata); @@ -1177,11 +1157,11 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr #ifdef USE_WIN_ACTIVATE else { if (keymodifier & KM_CTRL) { - win->eventstate->ctrl = KM_MOD_HELD; + win->eventstate->modifier |= KM_CTRL; } } #endif - if (win->eventstate->alt) { + if (win->eventstate->modifier & KM_ALT) { if ((keymodifier & KM_ALT) == 0) { kdata.key = GHOST_kKeyLeftAlt; wm_event_add_ghostevent(wm, win, GHOST_kEventKeyUp, &kdata); @@ -1190,11 +1170,11 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr #ifdef USE_WIN_ACTIVATE else { if (keymodifier & KM_ALT) { - win->eventstate->alt = KM_MOD_HELD; + win->eventstate->modifier |= KM_ALT; } } #endif - if (win->eventstate->oskey) { + if (win->eventstate->modifier & KM_OSKEY) { if ((keymodifier & KM_OSKEY) == 0) { kdata.key = GHOST_kKeyOS; wm_event_add_ghostevent(wm, win, GHOST_kEventKeyUp, &kdata); @@ -1203,7 +1183,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr #ifdef USE_WIN_ACTIVATE else { if (keymodifier & KM_OSKEY) { - win->eventstate->oskey = KM_MOD_HELD; + win->eventstate->modifier |= KM_OSKEY; } } #endif @@ -1233,7 +1213,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr wm_event_init_from_window(win, &event); event.type = MOUSEMOVE; copy_v2_v2_int(event.prev_xy, event.xy); - event.is_repeat = false; + event.flag = 0; wm_event_add(win, &event); @@ -1364,7 +1344,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr /* activate region */ event.type = MOUSEMOVE; copy_v2_v2_int(event.prev_xy, event.xy); - event.is_repeat = false; + event.flag = 0; /* No context change! C->wm->windrawable is drawable, or for area queues. */ wm->winactive = win; @@ -1483,7 +1463,11 @@ static bool wm_window_timer(const bContext *C) wt->delta = time - wt->ltime; wt->duration += wt->delta; wt->ltime = time; - wt->ntime = wt->stime + wt->timestep * ceil(wt->duration / wt->timestep); + + wt->ntime = wt->stime; + if (wt->timestep != 0.0f) { + wt->ntime += wt->timestep * ceil(wt->duration / wt->timestep); + } if (wt->event_type == TIMERJOBS) { wm_jobs_timer(wm, wt); @@ -1501,7 +1485,7 @@ static bool wm_window_timer(const bContext *C) event.type = wt->event_type; event.val = KM_NOTHING; event.keymodifier = 0; - event.is_repeat = false; + event.flag = 0; event.custom = EVT_DATA_TIMER; event.customdata = wt; wm_event_add(win, &event); @@ -1596,6 +1580,7 @@ void WM_event_timer_sleep(wmWindowManager *wm, wmTimer *WM_event_add_timer(wmWindowManager *wm, wmWindow *win, int event_type, double timestep) { wmTimer *wt = MEM_callocN(sizeof(wmTimer), "window timer"); + BLI_assert(timestep >= 0.0f); wt->event_type = event_type; wt->ltime = PIL_check_seconds_timer(); @@ -1615,6 +1600,7 @@ wmTimer *WM_event_add_timer_notifier(wmWindowManager *wm, double timestep) { wmTimer *wt = MEM_callocN(sizeof(wmTimer), "window timer"); + BLI_assert(timestep >= 0.0f); wt->event_type = TIMERNOTIFIER; wt->ltime = PIL_check_seconds_timer(); diff --git a/source/blender/windowmanager/intern/wm_window_private.h b/source/blender/windowmanager/intern/wm_window_private.h index c208d07ee37..f68d4e3e693 100644 --- a/source/blender/windowmanager/intern/wm_window_private.h +++ b/source/blender/windowmanager/intern/wm_window_private.h @@ -1,21 +1,5 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2019 Blender Foundation. - * All rights reserved. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright 2019 Blender Foundation. All rights reserved. */ /** \file * \ingroup wm diff --git a/source/blender/windowmanager/message_bus/intern/wm_message_bus.c b/source/blender/windowmanager/message_bus/intern/wm_message_bus.c index 81ef8c881f5..bf2107c3db3 100644 --- a/source/blender/windowmanager/message_bus/intern/wm_message_bus.c +++ b/source/blender/windowmanager/message_bus/intern/wm_message_bus.c @@ -1,18 +1,4 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /** \file * \ingroup wm diff --git a/source/blender/windowmanager/message_bus/intern/wm_message_bus_intern.h b/source/blender/windowmanager/message_bus/intern/wm_message_bus_intern.h index 18df17c3d1c..89bee5e0a2f 100644 --- a/source/blender/windowmanager/message_bus/intern/wm_message_bus_intern.h +++ b/source/blender/windowmanager/message_bus/intern/wm_message_bus_intern.h @@ -1,18 +1,4 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /** \file * \ingroup wm diff --git a/source/blender/windowmanager/message_bus/intern/wm_message_bus_rna.c b/source/blender/windowmanager/message_bus/intern/wm_message_bus_rna.c index bc083793395..be153195cee 100644 --- a/source/blender/windowmanager/message_bus/intern/wm_message_bus_rna.c +++ b/source/blender/windowmanager/message_bus/intern/wm_message_bus_rna.c @@ -1,18 +1,4 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /** \file * \ingroup wm diff --git a/source/blender/windowmanager/message_bus/intern/wm_message_bus_static.c b/source/blender/windowmanager/message_bus/intern/wm_message_bus_static.c index c47cec4b3e4..0e4f6a937bd 100644 --- a/source/blender/windowmanager/message_bus/intern/wm_message_bus_static.c +++ b/source/blender/windowmanager/message_bus/intern/wm_message_bus_static.c @@ -1,18 +1,4 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /** \file * \ingroup wm diff --git a/source/blender/windowmanager/message_bus/wm_message_bus.h b/source/blender/windowmanager/message_bus/wm_message_bus.h index a93a7bbcea7..c46f5d6df72 100644 --- a/source/blender/windowmanager/message_bus/wm_message_bus.h +++ b/source/blender/windowmanager/message_bus/wm_message_bus.h @@ -1,18 +1,4 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /** \file * \ingroup wm diff --git a/source/blender/windowmanager/wm.h b/source/blender/windowmanager/wm.h index e67b1581875..172a879e118 100644 --- a/source/blender/windowmanager/wm.h +++ b/source/blender/windowmanager/wm.h @@ -1,21 +1,5 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2007 Blender Foundation. - * All rights reserved. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright 2007 Blender Foundation. All rights reserved. */ /** \file * \ingroup wm @@ -90,16 +74,8 @@ void wm_gesture_draw(struct wmWindow *win); /** * Tweak and line gestures. */ -int wm_gesture_evaluate(wmGesture *gesture, const struct wmEvent *event); void wm_gesture_tag_redraw(struct wmWindow *win); -/* wm_gesture_ops.c */ - -/** - * Standard tweak, called after window handlers passed on event. - */ -void wm_tweakevent_test(bContext *C, const wmEvent *event, int action); - /* wm_jobs.c */ /** diff --git a/source/blender/windowmanager/wm_cursors.h b/source/blender/windowmanager/wm_cursors.h index d1694454490..b5f8e4fb53d 100644 --- a/source/blender/windowmanager/wm_cursors.h +++ b/source/blender/windowmanager/wm_cursors.h @@ -1,21 +1,5 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright 2001-2002 NaN Holding BV. All rights reserved. */ /** \file * \ingroup wm diff --git a/source/blender/windowmanager/wm_draw.h b/source/blender/windowmanager/wm_draw.h index 4997361b485..3351fa2c637 100644 --- a/source/blender/windowmanager/wm_draw.h +++ b/source/blender/windowmanager/wm_draw.h @@ -1,21 +1,5 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2007 Blender Foundation. - * All rights reserved. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright 2007 Blender Foundation. All rights reserved. */ /** \file * \ingroup wm diff --git a/source/blender/windowmanager/wm_event_system.h b/source/blender/windowmanager/wm_event_system.h index 925be8ab183..edbfe0202de 100644 --- a/source/blender/windowmanager/wm_event_system.h +++ b/source/blender/windowmanager/wm_event_system.h @@ -1,21 +1,5 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2007 Blender Foundation. - * All rights reserved. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright 2007 Blender Foundation. All rights reserved. */ /** \file * \ingroup wm @@ -199,6 +183,7 @@ void wm_dropbox_free(void); */ void wm_drags_exit(wmWindowManager *wm, wmWindow *win); void wm_drop_prepare(bContext *C, wmDrag *drag, wmDropBox *drop); +void wm_drop_end(bContext *C, wmDrag *drag, wmDropBox *drop); /** * Called in inner handler loop, region context. */ diff --git a/source/blender/windowmanager/wm_event_types.h b/source/blender/windowmanager/wm_event_types.h index a6685e97c4f..d5c8c5022cc 100644 --- a/source/blender/windowmanager/wm_event_types.h +++ b/source/blender/windowmanager/wm_event_types.h @@ -1,18 +1,4 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /** \file * \ingroup wm @@ -60,7 +46,7 @@ enum { /* ********** Start of Input devices. ********** */ - /* MOUSE : 0x000x, 0x001x */ + /* MOUSE: 0x000x, 0x001x */ LEFTMOUSE = 0x0001, MIDDLEMOUSE = 0x0002, RIGHTMOUSE = 0x0003, @@ -71,7 +57,7 @@ enum { /* More mouse buttons - can't use 9 and 10 here (wheel) */ BUTTON6MOUSE = 0x0012, BUTTON7MOUSE = 0x0013, - /* Extra trackpad gestures */ + /* Extra track-pad gestures. */ MOUSEPAN = 0x000e, MOUSEZOOM = 0x000f, MOUSEROTATE = 0x0010, @@ -339,16 +325,6 @@ enum { /* NOTE: these values are saved in key-map files, do not change them but just add new ones. */ - /* Tweak events: - * Sent as additional event with the mouse coordinates - * from where the initial click was placed. */ - - /* Tweak events for L M R mouse-buttons. */ - EVT_TWEAK_L = 0x5002, /* 20482 */ - EVT_TWEAK_M = 0x5003, /* 20483 */ - EVT_TWEAK_R = 0x5004, /* 20484 */ - /* 0x5010 (and lower) should be left to add other tweak types in the future. */ - /* 0x5011 is taken, see EVT_ACTIONZONE_FULLSCREEN */ /* Misc Blender internals: 0x502x */ @@ -408,9 +384,6 @@ enum { BUTTON6MOUSE, \ BUTTON7MOUSE)) -/** Test whether the event is tweak event. */ -#define ISTWEAK(event_type) ((event_type) >= EVT_TWEAK_L && (event_type) <= EVT_TWEAK_R) - /** Test whether the event is a NDOF event. */ #define ISNDOF(event_type) ((event_type) >= _NDOF_MIN && (event_type) <= _NDOF_MAX) @@ -422,15 +395,6 @@ enum { ((ISKEYBOARD(event_type) || ISMOUSE(event_type) || ISNDOF(event_type)) && \ (ISKEYMODIFIER(event_type) == false)) -/* Internal helpers. */ -#define _VA_IS_EVENT_MOD2(v, a) (CHECK_TYPE_INLINE(v, wmEvent *), ((v)->a)) -#define _VA_IS_EVENT_MOD3(v, a, b) (_VA_IS_EVENT_MOD2(v, a) || ((v)->b)) -#define _VA_IS_EVENT_MOD4(v, a, b, c) (_VA_IS_EVENT_MOD3(v, a, b) || ((v)->c)) -#define _VA_IS_EVENT_MOD5(v, a, b, c, d) (_VA_IS_EVENT_MOD4(v, a, b, c) || ((v)->d)) - -/** Reusable `IS_EVENT_MOD(event, shift, ctrl, alt, oskey)` macro. */ -#define IS_EVENT_MOD(...) VA_NARGS_CALL_OVERLOAD(_VA_IS_EVENT_MOD, __VA_ARGS__) - enum eEventType_Mask { /** #ISKEYMODIFIER */ EVT_TYPE_MASK_KEYBOARD_MODIFIER = (1 << 0), @@ -446,14 +410,11 @@ enum eEventType_Mask { EVT_TYPE_MASK_MOUSE = (1 << 5), /** #ISNDOF */ EVT_TYPE_MASK_NDOF = (1 << 6), - /** #ISTWEAK */ - EVT_TYPE_MASK_TWEAK = (1 << 7), /** #IS_EVENT_ACTIONZONE */ - EVT_TYPE_MASK_ACTIONZONE = (1 << 8), + EVT_TYPE_MASK_ACTIONZONE = (1 << 7), }; #define EVT_TYPE_MASK_ALL \ - (EVT_TYPE_MASK_KEYBOARD | EVT_TYPE_MASK_MOUSE | EVT_TYPE_MASK_NDOF | EVT_TYPE_MASK_TWEAK | \ - EVT_TYPE_MASK_ACTIONZONE) + (EVT_TYPE_MASK_KEYBOARD | EVT_TYPE_MASK_MOUSE | EVT_TYPE_MASK_NDOF | EVT_TYPE_MASK_ACTIONZONE) #define EVT_TYPE_MASK_HOTKEY_INCLUDE \ (EVT_TYPE_MASK_KEYBOARD | EVT_TYPE_MASK_MOUSE | EVT_TYPE_MASK_NDOF) @@ -468,18 +429,6 @@ bool WM_event_type_mask_test(int event_type, enum eEventType_Mask mask); * \{ */ /* Gestures */ -/* NOTE: these values are saved in keymap files, do not change them but just add new ones */ -enum { - /* Value of tweaks and line gestures. #KM_ANY (-1) works for this case too. */ - EVT_GESTURE_N = 1, - EVT_GESTURE_NE = 2, - EVT_GESTURE_E = 3, - EVT_GESTURE_SE = 4, - EVT_GESTURE_S = 5, - EVT_GESTURE_SW = 6, - EVT_GESTURE_W = 7, - EVT_GESTURE_NW = 8, -}; /* File select */ enum { diff --git a/source/blender/windowmanager/wm_files.h b/source/blender/windowmanager/wm_files.h index e63afb2ed2f..1c09f861c6c 100644 --- a/source/blender/windowmanager/wm_files.h +++ b/source/blender/windowmanager/wm_files.h @@ -1,21 +1,5 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2007 Blender Foundation. - * All rights reserved. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright 2007 Blender Foundation. All rights reserved. */ /** \file * \ingroup wm diff --git a/source/blender/windowmanager/wm_surface.h b/source/blender/windowmanager/wm_surface.h index e924b1e47ad..c94a195a976 100644 --- a/source/blender/windowmanager/wm_surface.h +++ b/source/blender/windowmanager/wm_surface.h @@ -1,18 +1,4 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /** \file * \ingroup wm diff --git a/source/blender/windowmanager/wm_window.h b/source/blender/windowmanager/wm_window.h index b003a4f92e7..67557768413 100644 --- a/source/blender/windowmanager/wm_window.h +++ b/source/blender/windowmanager/wm_window.h @@ -1,21 +1,5 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2007 Blender Foundation. - * All rights reserved. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright 2007 Blender Foundation. All rights reserved. */ /** \file * \ingroup wm diff --git a/source/blender/windowmanager/xr/intern/wm_xr.c b/source/blender/windowmanager/xr/intern/wm_xr.c index 36bd03ed3ea..e46af0657a5 100644 --- a/source/blender/windowmanager/xr/intern/wm_xr.c +++ b/source/blender/windowmanager/xr/intern/wm_xr.c @@ -1,18 +1,4 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /** \file * \ingroup wm diff --git a/source/blender/windowmanager/xr/intern/wm_xr_action.c b/source/blender/windowmanager/xr/intern/wm_xr_action.c index b5a606b4298..6750e7a7d77 100644 --- a/source/blender/windowmanager/xr/intern/wm_xr_action.c +++ b/source/blender/windowmanager/xr/intern/wm_xr_action.c @@ -1,18 +1,4 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /** \file * \ingroup wm @@ -70,8 +56,7 @@ static wmXrActionSet *action_set_find(wmXrData *xr, const char *action_set_name) static wmXrAction *action_create(const char *action_name, eXrActionType type, - unsigned int count_subaction_paths, - const char **subaction_paths, + const ListBase *user_paths, wmOperatorType *ot, IDProperty *op_properties, const char *haptic_name, @@ -87,15 +72,16 @@ static wmXrAction *action_create(const char *action_name, strcpy(action->name, action_name); action->type = type; - const unsigned int count = count_subaction_paths; + const unsigned int count = (unsigned int)BLI_listbase_count(user_paths); + unsigned int subaction_idx = 0; action->count_subaction_paths = count; action->subaction_paths = MEM_mallocN(sizeof(*action->subaction_paths) * count, "XrAction_SubactionPaths"); - for (unsigned int i = 0; i < count; ++i) { - action->subaction_paths[i] = MEM_mallocN(strlen(subaction_paths[i]) + 1, - "XrAction_SubactionPath"); - strcpy(action->subaction_paths[i], subaction_paths[i]); + LISTBASE_FOREACH_INDEX (XrUserPath *, user_path, user_paths, subaction_idx) { + action->subaction_paths[subaction_idx] = MEM_mallocN(strlen(user_path->path) + 1, + "XrAction_SubactionPath"); + strcpy(action->subaction_paths[subaction_idx], user_path->path); } size_t size; @@ -154,10 +140,9 @@ static void action_destroy(void *val) MEM_SAFE_FREE(action->name); - const unsigned int count = action->count_subaction_paths; char **subaction_paths = action->subaction_paths; if (subaction_paths) { - for (unsigned int i = 0; i < count; ++i) { + for (unsigned int i = 0; i < action->count_subaction_paths; ++i) { MEM_SAFE_FREE(subaction_paths[i]); } MEM_freeN(subaction_paths); @@ -228,8 +213,7 @@ bool WM_xr_action_create(wmXrData *xr, const char *action_set_name, const char *action_name, eXrActionType type, - unsigned int count_subaction_paths, - const char **subaction_paths, + const ListBase *user_paths, wmOperatorType *ot, IDProperty *op_properties, const char *haptic_name, @@ -246,8 +230,7 @@ bool WM_xr_action_create(wmXrData *xr, wmXrAction *action = action_create(action_name, type, - count_subaction_paths, - subaction_paths, + user_paths, ot, op_properties, haptic_name, @@ -258,10 +241,20 @@ bool WM_xr_action_create(wmXrData *xr, action_flag, haptic_flag); + const unsigned int count = (unsigned int)BLI_listbase_count(user_paths); + unsigned int subaction_idx = 0; + + char **subaction_paths = MEM_calloc_arrayN( + count, sizeof(*subaction_paths), "XrAction_SubactionPathPointers"); + + LISTBASE_FOREACH_INDEX (XrUserPath *, user_path, user_paths, subaction_idx) { + subaction_paths[subaction_idx] = (char *)user_path->path; + } + GHOST_XrActionInfo info = { .name = action_name, - .count_subaction_paths = count_subaction_paths, - .subaction_paths = subaction_paths, + .count_subaction_paths = count, + .subaction_paths = (const char **)subaction_paths, .states = action->states, .float_thresholds = action->float_thresholds, .axis_flags = (int16_t *)action->axis_flags, @@ -287,11 +280,11 @@ bool WM_xr_action_create(wmXrData *xr, break; } - if (!GHOST_XrCreateActions(xr->runtime->context, action_set_name, 1, &info)) { - return false; - } + const bool success = GHOST_XrCreateActions(xr->runtime->context, action_set_name, 1, &info); - return true; + MEM_freeN(subaction_paths); + + return success; } void WM_xr_action_destroy(wmXrData *xr, const char *action_set_name, const char *action_name) @@ -337,19 +330,29 @@ bool WM_xr_action_binding_create(wmXrData *xr, const char *action_set_name, const char *action_name, const char *profile_path, - unsigned int count_subaction_paths, - const char **subaction_paths, - const char **component_paths, + const ListBase *user_paths, + const ListBase *component_paths, const float *float_thresholds, const eXrAxisFlag *axis_flags, const struct wmXrPose *poses) { + const unsigned int count = (unsigned int)BLI_listbase_count(user_paths); + BLI_assert(count == (unsigned int)BLI_listbase_count(component_paths)); + GHOST_XrActionBindingInfo *binding_infos = MEM_calloc_arrayN( - count_subaction_paths, sizeof(*binding_infos), __func__); + count, sizeof(*binding_infos), "XrActionBinding_Infos"); + + char **subaction_paths = MEM_calloc_arrayN( + count, sizeof(*subaction_paths), "XrActionBinding_SubactionPathPointers"); - for (unsigned int i = 0; i < count_subaction_paths; ++i) { + for (unsigned int i = 0; i < count; ++i) { GHOST_XrActionBindingInfo *binding_info = &binding_infos[i]; - binding_info->component_path = component_paths[i]; + const XrUserPath *user_path = BLI_findlink(user_paths, i); + const XrComponentPath *component_path = BLI_findlink(component_paths, i); + + subaction_paths[i] = (char *)user_path->path; + + binding_info->component_path = component_path->path; if (float_thresholds) { binding_info->float_threshold = float_thresholds[i]; } @@ -365,15 +368,18 @@ bool WM_xr_action_binding_create(wmXrData *xr, GHOST_XrActionProfileInfo profile_info = { .action_name = action_name, .profile_path = profile_path, - .count_subaction_paths = count_subaction_paths, - .subaction_paths = subaction_paths, + .count_subaction_paths = count, + .subaction_paths = (const char **)subaction_paths, .bindings = binding_infos, }; - bool ret = GHOST_XrCreateActionBindings(xr->runtime->context, action_set_name, 1, &profile_info); + const bool success = GHOST_XrCreateActionBindings( + xr->runtime->context, action_set_name, 1, &profile_info); + MEM_freeN(subaction_paths); MEM_freeN(binding_infos); - return ret; + + return success; } void WM_xr_action_binding_destroy(wmXrData *xr, diff --git a/source/blender/windowmanager/xr/intern/wm_xr_actionmap.c b/source/blender/windowmanager/xr/intern/wm_xr_actionmap.c index 076f279ccbb..8a1982fa8b5 100644 --- a/source/blender/windowmanager/xr/intern/wm_xr_actionmap.c +++ b/source/blender/windowmanager/xr/intern/wm_xr_actionmap.c @@ -1,18 +1,4 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /** \file * \ingroup wm @@ -117,6 +103,12 @@ static XrActionMapBinding *wm_xr_actionmap_binding_copy(XrActionMapBinding *amb_ XrActionMapBinding *amb_dst = MEM_dupallocN(amb_src); amb_dst->prev = amb_dst->next = NULL; + BLI_listbase_clear(&amb_dst->component_paths); + LISTBASE_FOREACH (XrComponentPath *, path, &amb_src->component_paths) { + XrComponentPath *path_new = MEM_dupallocN(path); + BLI_addtail(&amb_dst->component_paths, path_new); + } + return amb_dst; } @@ -132,11 +124,17 @@ XrActionMapBinding *WM_xr_actionmap_binding_add_copy(XrActionMapItem *ami, return amb_dst; } +static void wm_xr_actionmap_binding_clear(XrActionMapBinding *amb) +{ + BLI_freelistN(&amb->component_paths); +} + bool WM_xr_actionmap_binding_remove(XrActionMapItem *ami, XrActionMapBinding *amb) { int idx = BLI_findindex(&ami->bindings, amb); if (idx != -1) { + wm_xr_actionmap_binding_clear(amb); BLI_freelinkN(&ami->bindings, amb); if (idx <= ami->selbinding) { @@ -169,12 +167,6 @@ XrActionMapBinding *WM_xr_actionmap_binding_find(XrActionMapItem *ami, const cha * Item in an XR action map, that maps an XR event to an operator, pose, or haptic output. * \{ */ -static void wm_xr_actionmap_item_bindings_clear(XrActionMapItem *ami) -{ - BLI_freelistN(&ami->bindings); - ami->selbinding = 0; -} - static void wm_xr_actionmap_item_properties_set(XrActionMapItem *ami) { WM_operator_properties_alloc(&(ami->op_properties_ptr), &(ami->op_properties), ami->op); @@ -194,6 +186,19 @@ static void wm_xr_actionmap_item_properties_free(XrActionMapItem *ami) } } +static void wm_xr_actionmap_item_clear(XrActionMapItem *ami) +{ + LISTBASE_FOREACH (XrActionMapBinding *, amb, &ami->bindings) { + wm_xr_actionmap_binding_clear(amb); + } + BLI_freelistN(&ami->bindings); + ami->selbinding = 0; + + wm_xr_actionmap_item_properties_free(ami); + + BLI_freelistN(&ami->user_paths); +} + void WM_xr_actionmap_item_properties_update_ot(XrActionMapItem *ami) { switch (ami->type) { @@ -319,6 +324,12 @@ static XrActionMapItem *wm_xr_actionmap_item_copy(XrActionMapItem *ami_src) ami_dst->op_properties_ptr = NULL; } + BLI_listbase_clear(&ami_dst->user_paths); + LISTBASE_FOREACH (XrUserPath *, path, &ami_src->user_paths) { + XrUserPath *path_new = MEM_dupallocN(path); + BLI_addtail(&ami_dst->user_paths, path_new); + } + return ami_dst; } @@ -338,8 +349,7 @@ bool WM_xr_actionmap_item_remove(XrActionMap *actionmap, XrActionMapItem *ami) int idx = BLI_findindex(&actionmap->items, ami); if (idx != -1) { - wm_xr_actionmap_item_bindings_clear(ami); - wm_xr_actionmap_item_properties_free(ami); + wm_xr_actionmap_item_clear(ami); BLI_freelinkN(&actionmap->items, ami); if (idx <= actionmap->selitem) { @@ -494,12 +504,9 @@ XrActionMap *WM_xr_actionmap_find(wmXrRuntimeData *runtime, const char *name) void WM_xr_actionmap_clear(XrActionMap *actionmap) { LISTBASE_FOREACH (XrActionMapItem *, ami, &actionmap->items) { - wm_xr_actionmap_item_bindings_clear(ami); - wm_xr_actionmap_item_properties_free(ami); + wm_xr_actionmap_item_clear(ami); } - BLI_freelistN(&actionmap->items); - actionmap->selitem = 0; } @@ -508,9 +515,7 @@ void WM_xr_actionmaps_clear(wmXrRuntimeData *runtime) LISTBASE_FOREACH (XrActionMap *, am, &runtime->actionmaps) { WM_xr_actionmap_clear(am); } - BLI_freelistN(&runtime->actionmaps); - runtime->actactionmap = runtime->selactionmap = 0; } diff --git a/source/blender/windowmanager/xr/intern/wm_xr_draw.c b/source/blender/windowmanager/xr/intern/wm_xr_draw.c index 5d0163af5e1..303ecca17f0 100644 --- a/source/blender/windowmanager/xr/intern/wm_xr_draw.c +++ b/source/blender/windowmanager/xr/intern/wm_xr_draw.c @@ -1,18 +1,4 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /** \file * \ingroup wm diff --git a/source/blender/windowmanager/xr/intern/wm_xr_intern.h b/source/blender/windowmanager/xr/intern/wm_xr_intern.h index e2368901757..9480104150a 100644 --- a/source/blender/windowmanager/xr/intern/wm_xr_intern.h +++ b/source/blender/windowmanager/xr/intern/wm_xr_intern.h @@ -1,18 +1,4 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /** \file * \ingroup wm @@ -128,12 +114,8 @@ typedef struct wmXrDrawData { typedef struct wmXrController { struct wmXrController *next, *prev; - /** OpenXR path identifier. Length is dependent on OpenXR's XR_MAX_PATH_LENGTH (256). - This subaction path will later be combined with a component path, and that combined path should - also have a max of XR_MAX_PATH_LENGTH (e.g. subaction_path = /user/hand/left, component_path = - /input/trigger/value, interaction_path = /user/hand/left/input/trigger/value). - */ - char subaction_path[64]; + /** OpenXR user path identifier. */ + char subaction_path[64]; /* XR_MAX_USER_PATH_LENGTH */ /** Pose (in world space) that represents the user's hand when holding the controller. */ GHOST_XrPose grip_pose; diff --git a/source/blender/windowmanager/xr/intern/wm_xr_operators.c b/source/blender/windowmanager/xr/intern/wm_xr_operators.c index 9c2eaefd61c..54800a5cd35 100644 --- a/source/blender/windowmanager/xr/intern/wm_xr_operators.c +++ b/source/blender/windowmanager/xr/intern/wm_xr_operators.c @@ -1,18 +1,4 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /** \file * \ingroup wm diff --git a/source/blender/windowmanager/xr/intern/wm_xr_session.c b/source/blender/windowmanager/xr/intern/wm_xr_session.c index bad735ee598..dfeaeae196c 100644 --- a/source/blender/windowmanager/xr/intern/wm_xr_session.c +++ b/source/blender/windowmanager/xr/intern/wm_xr_session.c @@ -1,18 +1,4 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /** \file * \ingroup wm @@ -1202,8 +1188,9 @@ void wm_xr_session_actions_update(wmWindowManager *wm) &state->viewer_pose, settings->base_scale * state->nav_scale, state->viewer_viewmat); } - int ret = GHOST_XrSyncActions(xr_context, active_action_set ? active_action_set->name : NULL); - if (!ret) { + const bool synced = GHOST_XrSyncActions(xr_context, + active_action_set ? active_action_set->name : NULL); + if (!synced) { return; } diff --git a/source/blender/windowmanager/xr/wm_xr.h b/source/blender/windowmanager/xr/wm_xr.h index caba6038c56..0d7d8f70525 100644 --- a/source/blender/windowmanager/xr/wm_xr.h +++ b/source/blender/windowmanager/xr/wm_xr.h @@ -1,18 +1,4 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /** \file * \ingroup wm |