2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2007-12-24 18:27:28 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
2018-06-01 18:19:39 +02:00
|
|
|
* of the License, or (at your option) any later version.
|
2007-12-24 18:27:28 +00:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2007-12-24 18:27:28 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2007 Blender Foundation.
|
|
|
|
* All rights reserved.
|
|
|
|
*/
|
2011-02-25 14:04:21 +00:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
* \ingroup wm
|
2011-02-25 14:04:21 +00:00
|
|
|
*/
|
|
|
|
|
2012-02-17 18:59:41 +00:00
|
|
|
#ifndef __WM_EVENT_SYSTEM_H__
|
|
|
|
#define __WM_EVENT_SYSTEM_H__
|
2007-12-24 18:27:28 +00:00
|
|
|
|
|
|
|
/* return value of handler-operator call */
|
2012-10-21 05:46:41 +00:00
|
|
|
#define WM_HANDLER_CONTINUE 0
|
|
|
|
#define WM_HANDLER_BREAK 1
|
|
|
|
#define WM_HANDLER_HANDLED 2
|
|
|
|
#define WM_HANDLER_MODAL 4 /* MODAL|BREAK means unhandled */
|
2007-12-24 18:27:28 +00:00
|
|
|
|
Lots of stuff; couldn't commit in parts because of refactor work.
* Changes in interface/ module
This commit brings back the way how buttons/menus work under control
of WM event system. The previous implementation extended usage of
handlers and operators in an interesting but confusing way. Better to
try it first according the design specs. :)
Most obviously:
- modal-handler operators are not stored anymore in regions/areas/windows.
such modal handlers own their operator, and should remove it themselves.
- removed code to move handlers from one queue to another.
(needs review with brecht!)
- WM fix: the API call to remove a modal handler got removed. This was a
dangerous thing anyway, and you should leave that to the event system.
Now, if a handler modal() call gets a cancel/finish return, it frees
itself in event system. WM_event_remove_modal_handler was a confusing
call anyway!
Todo:
- allow button-activate to refresh after using button
- re-enable arrow keys for menus
(do both after commit)
- review return values of operator callbacks in interface_ops.c
* Fixes in WM system
- Freeing areas/regions/windows, also on quit, now correctly closes
running modal handlers
- On starting a modal handler, the handler now stores previous area
and region context, so they send proper notifiers etc.
* Other fixes
- Area-split operator had bug, wrong minimal size checking. This
solves error when trying to split a very narrow area.
- removed DNA_USHORT_FIX from screen_types.h, gave warning
- operators didn't get ID name copied when activated, needed for
later re-use or saving.
2008-12-02 14:22:52 +00:00
|
|
|
struct ARegion;
|
2019-01-28 21:08:24 +11:00
|
|
|
struct ScrArea;
|
2007-12-24 18:27:28 +00:00
|
|
|
|
2018-09-24 18:46:51 +02:00
|
|
|
/* wmKeyMap is in DNA_windowmanager.h, it's saveable */
|
2007-12-24 18:27:28 +00:00
|
|
|
|
2019-02-19 12:59:05 +11:00
|
|
|
/** Custom types for handlers, for signaling, freeing */
|
|
|
|
enum eWM_EventHandlerType {
|
2019-02-19 16:13:47 +11:00
|
|
|
WM_HANDLER_TYPE_GIZMO = 1,
|
2019-02-19 13:57:11 +11:00
|
|
|
WM_HANDLER_TYPE_UI,
|
2019-02-19 15:18:56 +11:00
|
|
|
WM_HANDLER_TYPE_OP,
|
2019-02-19 15:32:01 +11:00
|
|
|
WM_HANDLER_TYPE_DROPBOX,
|
2019-02-19 16:09:14 +11:00
|
|
|
WM_HANDLER_TYPE_KEYMAP,
|
2019-02-19 12:59:05 +11:00
|
|
|
};
|
|
|
|
|
2007-12-24 18:27:28 +00:00
|
|
|
typedef struct wmEventHandler {
|
|
|
|
struct wmEventHandler *next, *prev;
|
2012-10-21 05:46:41 +00:00
|
|
|
|
2019-02-19 12:59:05 +11:00
|
|
|
enum eWM_EventHandlerType type;
|
2015-06-01 16:40:43 +10:00
|
|
|
char flag; /* WM_HANDLER_BLOCKING, ... */
|
2012-10-21 05:46:41 +00:00
|
|
|
|
2019-02-19 16:09:14 +11:00
|
|
|
/** Optional local and windowspace bb. */
|
|
|
|
const rcti *bblocal, *bbwin;
|
|
|
|
} wmEventHandler;
|
|
|
|
|
2019-02-20 15:42:37 +11:00
|
|
|
/** Run after the keymap item runs. */
|
|
|
|
struct wmEventHandler_KeymapPost {
|
|
|
|
void (*post_fn)(wmKeyMap *keymap, wmKeyMapItem *kmi, void *user_data);
|
|
|
|
void *user_data;
|
|
|
|
};
|
|
|
|
|
|
|
|
/** Support for a getter function that looks up the keymap each access. */
|
|
|
|
struct wmEventHandler_KeymapDynamic {
|
|
|
|
wmEventHandler_KeymapDynamicFn *keymap_fn;
|
|
|
|
void *user_data;
|
|
|
|
};
|
|
|
|
|
2019-02-19 16:09:14 +11:00
|
|
|
/** #WM_HANDLER_TYPE_KEYMAP */
|
|
|
|
typedef struct wmEventHandler_Keymap {
|
2019-02-20 09:43:29 +11:00
|
|
|
wmEventHandler head;
|
2019-02-19 16:09:14 +11:00
|
|
|
|
|
|
|
/** Pointer to builtin/custom keymaps (never NULL). */
|
|
|
|
wmKeyMap *keymap;
|
2019-02-20 15:42:37 +11:00
|
|
|
|
|
|
|
struct wmEventHandler_KeymapPost post;
|
|
|
|
struct wmEventHandler_KeymapDynamic dynamic;
|
2019-02-20 14:29:29 +11:00
|
|
|
|
2018-05-22 14:00:44 +02:00
|
|
|
struct bToolRef *keymap_tool;
|
2019-02-19 16:09:14 +11:00
|
|
|
} wmEventHandler_Keymap;
|
2007-12-24 18:27:28 +00:00
|
|
|
|
2019-02-19 12:59:05 +11:00
|
|
|
/** #WM_HANDLER_TYPE_GIZMO */
|
|
|
|
typedef struct wmEventHandler_Gizmo {
|
2019-02-20 09:43:29 +11:00
|
|
|
wmEventHandler head;
|
2019-02-19 12:59:05 +11:00
|
|
|
|
|
|
|
/** Gizmo handler (never NULL). */
|
|
|
|
struct wmGizmoMap *gizmo_map;
|
|
|
|
} wmEventHandler_Gizmo;
|
2007-12-24 18:27:28 +00:00
|
|
|
|
2019-02-19 13:57:11 +11:00
|
|
|
/** #WM_HANDLER_TYPE_UI */
|
|
|
|
typedef struct wmEventHandler_UI {
|
2019-02-20 09:43:29 +11:00
|
|
|
wmEventHandler head;
|
2019-02-19 13:57:11 +11:00
|
|
|
|
|
|
|
wmUIHandlerFunc handle_fn; /* callback receiving events */
|
|
|
|
wmUIHandlerRemoveFunc remove_fn; /* callback when handler is removed */
|
|
|
|
void *user_data; /* user data pointer */
|
|
|
|
|
|
|
|
/** Store context for this handler for derived/modal handlers. */
|
|
|
|
struct {
|
|
|
|
struct ScrArea *area;
|
|
|
|
struct ARegion *region;
|
|
|
|
struct ARegion *menu;
|
|
|
|
} context;
|
|
|
|
} wmEventHandler_UI;
|
|
|
|
|
2019-02-19 15:18:56 +11:00
|
|
|
/** #WM_HANDLER_TYPE_OP */
|
|
|
|
typedef struct wmEventHandler_Op {
|
2019-02-20 09:43:29 +11:00
|
|
|
wmEventHandler head;
|
2019-02-19 15:18:56 +11:00
|
|
|
|
|
|
|
/** Operator can be NULL. */
|
|
|
|
wmOperator *op;
|
|
|
|
|
|
|
|
/** Hack, special case for file-select. */
|
|
|
|
bool is_fileselect;
|
|
|
|
|
|
|
|
/** Store context for this handler for derived/modal handlers. */
|
|
|
|
struct {
|
|
|
|
struct ScrArea *area;
|
|
|
|
struct ARegion *region;
|
|
|
|
short region_type;
|
|
|
|
} context;
|
|
|
|
} wmEventHandler_Op;
|
|
|
|
|
2019-02-19 15:32:01 +11:00
|
|
|
/** #WM_HANDLER_TYPE_DROPBOX */
|
|
|
|
typedef struct wmEventHandler_Dropbox {
|
2019-02-20 09:43:29 +11:00
|
|
|
wmEventHandler head;
|
2019-02-19 15:32:01 +11:00
|
|
|
|
|
|
|
/** Never NULL. */
|
|
|
|
ListBase *dropboxes;
|
|
|
|
} wmEventHandler_Dropbox;
|
2019-02-19 15:18:56 +11:00
|
|
|
|
2008-12-08 15:02:57 +00:00
|
|
|
/* wm_event_system.c */
|
2012-10-21 05:46:41 +00:00
|
|
|
void wm_event_free_all (wmWindow *win);
|
|
|
|
void wm_event_free (wmEvent *event);
|
|
|
|
void wm_event_free_handler (wmEventHandler *handler);
|
2007-12-24 18:27:28 +00:00
|
|
|
|
2012-10-21 05:46:41 +00:00
|
|
|
/* goes over entire hierarchy: events -> window -> screen -> area -> region */
|
|
|
|
void wm_event_do_handlers (bContext *C);
|
2008-01-07 18:03:41 +00:00
|
|
|
|
2012-10-21 05:46:41 +00:00
|
|
|
void wm_event_add_ghostevent (wmWindowManager *wm, wmWindow *win, int type, int time, void *customdata);
|
2007-12-24 18:27:28 +00:00
|
|
|
|
2018-07-05 15:30:56 +02:00
|
|
|
void wm_event_do_depsgraph(bContext *C);
|
2017-08-25 20:26:52 +10:00
|
|
|
void wm_event_do_refresh_wm_and_depsgraph(bContext *C);
|
|
|
|
void wm_event_do_notifiers(bContext *C);
|
2007-12-24 18:27:28 +00:00
|
|
|
|
2018-11-20 15:35:59 +03:00
|
|
|
float wm_pressure_curve(float raw_pressure);
|
|
|
|
|
2008-12-08 15:02:57 +00:00
|
|
|
/* wm_keymap.c */
|
|
|
|
|
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 18:18:21 +00:00
|
|
|
/* wm_dropbox.c */
|
2012-10-21 05:46:41 +00:00
|
|
|
void wm_dropbox_free(void);
|
2017-10-14 17:29:54 +11:00
|
|
|
void wm_drags_check_ops(bContext *C, const wmEvent *event);
|
2012-10-21 05:46:41 +00:00
|
|
|
void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect);
|
2008-12-08 15:02:57 +00:00
|
|
|
|
2012-02-17 18:59:41 +00:00
|
|
|
#endif /* __WM_EVENT_SYSTEM_H__ */
|