2011-02-17 05:57:18 +00:00
|
|
|
/*
|
2007-12-24 18:27:28 +00:00
|
|
|
* ***** 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,
|
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.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Contributor(s): Blender Foundation
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
2012-02-17 18:59:41 +00:00
|
|
|
#ifndef __WM_API_H__
|
|
|
|
#define __WM_API_H__
|
2007-12-24 18:27:28 +00:00
|
|
|
|
2011-02-17 05:57:18 +00:00
|
|
|
/** \file WM_api.h
|
|
|
|
* \ingroup wm
|
|
|
|
*
|
|
|
|
* \page wmpage windowmanager
|
|
|
|
* \section wmabout About windowmanager
|
|
|
|
* \ref wm handles events received from \ref GHOST and manages
|
|
|
|
* the screens, areas and input for Blender
|
|
|
|
* \section wmnote NOTE
|
|
|
|
* \todo document
|
|
|
|
*/
|
|
|
|
|
2007-12-24 18:27:28 +00:00
|
|
|
/* dna-savable wmStructs here */
|
|
|
|
#include "DNA_windowmanager_types.h"
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
#include "WM_keymap.h"
|
2013-09-01 15:01:15 +00:00
|
|
|
#include "BLI_compiler_attrs.h"
|
2007-12-24 18:27:28 +00:00
|
|
|
|
2010-10-05 00:05:14 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2007-12-24 18:27:28 +00:00
|
|
|
struct bContext;
|
2008-12-16 20:03:28 +00:00
|
|
|
struct IDProperty;
|
2007-12-24 18:27:28 +00:00
|
|
|
struct wmEvent;
|
|
|
|
struct wmEventHandler;
|
2008-01-19 17:54:05 +00:00
|
|
|
struct wmGesture;
|
2.5
Added WM Jobs manager
- WM can manage threaded jobs for you; just provide a couple
of components to get it work:
- customdata, free callback for it
- timer step, notifier code
- start callback, update callback
- Once started, each job runs an own timer, and will for
every time step check necessary updates, or close the
job when ready.
- No drawing happens in jobs, that's for notifiers!
- Every job stores an owner pointer, and based on this owner
it will prevent multiple jobs to enter the stack.
Instead it will re-use a running job, signal it to stop
and allow caller to re-initialize it even.
- Check new wm_jobs.c for more explanation. Jobs API is still
under construction.
Fun: BLI_addtail(&wm->jobs, steve); :)
Put Node shader previews back using wmJobs
- Preview calculating is now fully threaded (1 thread still)
- Thanks to new event system + notifiers, you can see
previews update even while dragging sliders!
- Currently it only starts when you change a node setting.
Warning: the thread render shares Node data, so don't delete
nodes while it renders! This topic is on the todo to make safe.
Also:
- bug in region initialize (do_versions) showed channel list in
node editor wrong.
- flagged the channel list 'hidden' now, it was really in the
way! This is for later to work on anyway.
- recoded Render API callbacks so it gets handlers passed on,
no globals to use anymore, remember?
- previewrender code gets now so much nicer! Will remove a lot
of stuff from code soon.
2009-01-22 14:59:49 +00:00
|
|
|
struct wmJob;
|
|
|
|
struct wmNotifier;
|
2009-12-24 16:10:26 +00:00
|
|
|
struct wmOperatorType;
|
|
|
|
struct wmOperator;
|
2008-11-18 13:51:02 +00:00
|
|
|
struct rcti;
|
2009-01-01 20:44:40 +00:00
|
|
|
struct PointerRNA;
|
2012-12-18 14:11:19 +00:00
|
|
|
struct PropertyRNA;
|
2.5
Modal keymaps.
I've tried to make it as simple as possible, yet still using sufficient facilities to enable self-documenting UIs, saving/reading in files, and proper Python support.
The simplicity is: the 'modal keymap' just checks an event, uses event matching similarly to other keymap matching, and if there's a match it changes the event type, and sets the event value to what the modal keymap has defined. The event values are being defined using EnumPropertyItem structs, so the UI will be able to show all options in self-documenting way.
This system also allows to still handle hardcoded own events.
Tech doc:
1) define keymap
- Create map with unique name, WM_modalkeymap_add()
- Give map property definitions (EnumPropertyItem *)
This only for UI, so user can get information on available options
2) items
- WM_modalkeymap_add_item(): give it an enum value for events
3) activate
- In keymap definition code, assign the modal keymap to operatortype
WM_modalkeymap_assign()
4) event manager
- The event handler will check for modal keymap, if so:
- If the modal map has a match:
- Sets event->type to EVT_MODAL_MAP
- Sets event->val to the enum value
5) modal handler
- If event type is EVT_MODAL_MAP:
- Check event->val, handle it
- Other events can just be handled still
Two examples added in the code:
editors/transform/transform.c: transform_modal_keymap()
editors/screen/screen_ops.c: keymap_modal_set()
Also: to support 'key release' the define KM_RELEASE now is officially
used in event manager, this is not '0', so don't check key events with
the old convention if(event->val) but use if(event->val==KM_PRESS)
2009-07-21 11:03:07 +00:00
|
|
|
struct EnumPropertyItem;
|
2009-10-08 19:06:32 +00:00
|
|
|
struct MenuType;
|
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
|
|
|
struct wmDropBox;
|
|
|
|
struct wmDrag;
|
|
|
|
struct ImBuf;
|
2012-12-23 13:57:09 +00:00
|
|
|
struct ImageFormatData;
|
2013-05-13 13:32:42 +00:00
|
|
|
struct ARegion;
|
2007-12-24 18:27:28 +00:00
|
|
|
|
2.5
Added WM Jobs manager
- WM can manage threaded jobs for you; just provide a couple
of components to get it work:
- customdata, free callback for it
- timer step, notifier code
- start callback, update callback
- Once started, each job runs an own timer, and will for
every time step check necessary updates, or close the
job when ready.
- No drawing happens in jobs, that's for notifiers!
- Every job stores an owner pointer, and based on this owner
it will prevent multiple jobs to enter the stack.
Instead it will re-use a running job, signal it to stop
and allow caller to re-initialize it even.
- Check new wm_jobs.c for more explanation. Jobs API is still
under construction.
Fun: BLI_addtail(&wm->jobs, steve); :)
Put Node shader previews back using wmJobs
- Preview calculating is now fully threaded (1 thread still)
- Thanks to new event system + notifiers, you can see
previews update even while dragging sliders!
- Currently it only starts when you change a node setting.
Warning: the thread render shares Node data, so don't delete
nodes while it renders! This topic is on the todo to make safe.
Also:
- bug in region initialize (do_versions) showed channel list in
node editor wrong.
- flagged the channel list 'hidden' now, it was really in the
way! This is for later to work on anyway.
- recoded Render API callbacks so it gets handlers passed on,
no globals to use anymore, remember?
- previewrender code gets now so much nicer! Will remove a lot
of stuff from code soon.
2009-01-22 14:59:49 +00:00
|
|
|
typedef struct wmJob wmJob;
|
|
|
|
|
2009-01-02 14:11:18 +00:00
|
|
|
/* general API */
|
2012-08-11 22:12:32 +00:00
|
|
|
void WM_init_state_size_set (int stax, int stay, int sizx, int sizy);
|
2012-08-11 21:35:24 +00:00
|
|
|
void WM_init_state_fullscreen_set(void);
|
|
|
|
void WM_init_state_normal_set(void);
|
2013-04-04 02:05:11 +00:00
|
|
|
void WM_init_native_pixels(bool do_it);
|
2007-12-24 18:27:28 +00:00
|
|
|
|
2011-02-19 12:05:20 +00:00
|
|
|
void WM_init (struct bContext *C, int argc, const char **argv);
|
2011-09-20 12:22:19 +00:00
|
|
|
void WM_exit_ext (struct bContext *C, const short do_python);
|
2012-09-20 01:02:39 +00:00
|
|
|
|
2013-09-01 15:01:15 +00:00
|
|
|
void WM_exit (struct bContext *C) ATTR_NORETURN;
|
2012-09-20 01:02:39 +00:00
|
|
|
|
2013-09-01 15:01:15 +00:00
|
|
|
void WM_main (struct bContext *C) ATTR_NORETURN;
|
2007-12-24 18:27:28 +00:00
|
|
|
|
2013-04-04 02:05:11 +00:00
|
|
|
bool WM_init_game (struct bContext *C);
|
2009-11-23 13:58:55 +00:00
|
|
|
void WM_init_splash (struct bContext *C);
|
|
|
|
|
2009-11-11 04:08:09 +00:00
|
|
|
|
|
|
|
void WM_check (struct bContext *C);
|
|
|
|
|
2009-07-24 12:43:59 +00:00
|
|
|
struct wmWindow *WM_window_open (struct bContext *C, struct rcti *rect);
|
|
|
|
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
int WM_window_pixels_x (struct wmWindow *win);
|
|
|
|
int WM_window_pixels_y (struct wmWindow *win);
|
|
|
|
|
2013-05-28 01:15:59 +00:00
|
|
|
/* defines for 'type' WM_window_open_temp */
|
2009-07-24 12:43:59 +00:00
|
|
|
#define WM_WINDOW_RENDER 0
|
|
|
|
#define WM_WINDOW_USERPREFS 1
|
2013-05-28 01:15:59 +00:00
|
|
|
// #define WM_WINDOW_FILESEL 2 // UNUSED
|
2009-07-24 12:43:59 +00:00
|
|
|
|
|
|
|
void WM_window_open_temp (struct bContext *C, struct rcti *position, int type);
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
|
|
|
|
/* returns true if draw method is triple buffer */
|
2013-04-04 02:05:11 +00:00
|
|
|
bool WM_is_draw_triple(struct wmWindow *win);
|
2009-07-24 12:43:59 +00:00
|
|
|
|
|
|
|
|
2008-11-18 13:51:02 +00:00
|
|
|
|
2007-12-24 18:27:28 +00:00
|
|
|
/* files */
|
2013-06-18 18:11:52 +00:00
|
|
|
void WM_file_autoexec_init(const char *filepath);
|
2012-08-11 21:35:24 +00:00
|
|
|
void WM_file_read(struct bContext *C, const char *filepath, struct ReportList *reports);
|
|
|
|
void WM_autosave_init(struct wmWindowManager *wm);
|
2013-04-13 12:03:20 +00:00
|
|
|
void WM_recover_last_session(struct bContext *C, struct ReportList *reports);
|
2007-12-24 18:27:28 +00:00
|
|
|
|
|
|
|
/* mouse cursors */
|
2013-09-06 22:34:29 +00:00
|
|
|
void WM_cursor_set(struct wmWindow *win, int curs);
|
|
|
|
void WM_cursor_modal_set(struct wmWindow *win, int curs);
|
|
|
|
void WM_cursor_modal_restore(struct wmWindow *win);
|
2013-04-04 02:05:11 +00:00
|
|
|
void WM_cursor_wait (bool val);
|
2013-04-04 15:16:29 +00:00
|
|
|
void WM_cursor_grab_enable(struct wmWindow *win, bool wrap, bool hide, int bounds[4]);
|
2012-09-22 13:23:12 +00:00
|
|
|
void WM_cursor_grab_disable(struct wmWindow *win, int mouse_ungrab_xy[2]);
|
2012-08-11 21:35:24 +00:00
|
|
|
void WM_cursor_time (struct wmWindow *win, int nr);
|
2007-12-24 18:27:28 +00:00
|
|
|
|
2012-02-29 15:00:37 +00:00
|
|
|
void *WM_paint_cursor_activate(struct wmWindowManager *wm,
|
|
|
|
int (*poll)(struct bContext *C),
|
|
|
|
void (*draw)(struct bContext *C, int, int, void *customdata),
|
|
|
|
void *customdata);
|
|
|
|
|
2.5
Vertex Paint back!
Added WM level "paint cursor" system, which manages a custom painting
cursor for tools or modes.
- Activate it with WM_paint_cursor_activate(). That function wants two
callbacks, a poll(C) to check whether there's a cursor in given context
and ARegion, and a draw(C, x, y) which gets called when appropriate.
- While paintcursor is active, the WM handles necessary redrawing events
for all regions, also to nicely clear the cursor on region exit.
- WM_paint_cursor_activate returns a handle, which you have to use to
end the paint cursor. This handle also means you can register as many
custom cursors as you want.
At the moment, vertex paint mode registers only a mousemove handler,
all other events are still normally handled. This is stuff for the
future todo.
2009-01-09 13:55:45 +00:00
|
|
|
void WM_paint_cursor_end(struct wmWindowManager *wm, void *handle);
|
2013-05-13 13:32:42 +00:00
|
|
|
void WM_paint_cursor_tag_redraw(struct wmWindow *win, struct ARegion *ar);
|
2009-11-11 08:32:29 +00:00
|
|
|
|
|
|
|
void WM_cursor_warp (struct wmWindow *win, int x, int y);
|
2013-01-16 19:22:15 +00:00
|
|
|
float WM_cursor_pressure (const struct wmWindow *win);
|
2.5
Vertex Paint back!
Added WM level "paint cursor" system, which manages a custom painting
cursor for tools or modes.
- Activate it with WM_paint_cursor_activate(). That function wants two
callbacks, a poll(C) to check whether there's a cursor in given context
and ARegion, and a draw(C, x, y) which gets called when appropriate.
- While paintcursor is active, the WM handles necessary redrawing events
for all regions, also to nicely clear the cursor on region exit.
- WM_paint_cursor_activate returns a handle, which you have to use to
end the paint cursor. This handle also means you can register as many
custom cursors as you want.
At the moment, vertex paint mode registers only a mousemove handler,
all other events are still normally handled. This is stuff for the
future todo.
2009-01-09 13:55:45 +00:00
|
|
|
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
/* event map */
|
Keymap conflict detection operator.
Takes into account the hierarchical structures of keymaps as well as wildcards (KM_ANY) in event definitions, user remaps (emulate numpad, action/select mouse buttons, ...) and event values that overlap (click, press and release)
For now, doesn't do anything other than print conflicts in the console.
As a result, I cleaned up a lot of keymaps that had double definitions, moved some keymap items in more appropriate places, fixed wrong definitions and removed kmi that were added for testing a long long time ago.
Out of all the remaining conflicts, after removing obvious non-issues, here's what remains: http://www.pasteall.org/9898
2009-12-17 22:14:43 +00:00
|
|
|
int WM_userdef_event_map(int kmitype);
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
|
2008-12-16 07:32:12 +00:00
|
|
|
/* handlers */
|
2008-12-08 15:02:57 +00:00
|
|
|
|
2009-09-17 21:36:02 +00:00
|
|
|
struct wmEventHandler *WM_event_add_keymap_handler(ListBase *handlers, wmKeyMap *keymap);
|
2008-12-10 13:56:54 +00:00
|
|
|
/* boundbox, optional subwindow boundbox for offset */
|
2009-09-17 21:36:02 +00:00
|
|
|
struct wmEventHandler *WM_event_add_keymap_handler_bb(ListBase *handlers, wmKeyMap *keymap, rcti *bb, rcti *swinbb);
|
2009-01-23 14:43:25 +00:00
|
|
|
/* priority not implemented, it adds in begin */
|
2009-09-17 21:36:02 +00:00
|
|
|
struct wmEventHandler *WM_event_add_keymap_handler_priority(ListBase *handlers, wmKeyMap *keymap, int priority);
|
2008-12-10 13:56:54 +00:00
|
|
|
|
2009-09-17 21:36:02 +00:00
|
|
|
void WM_event_remove_keymap_handler(ListBase *handlers, wmKeyMap *keymap);
|
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
|
|
|
|
2012-12-20 00:29:31 +00:00
|
|
|
struct wmEventHandler *WM_event_add_ui_handler(
|
2013-09-04 03:30:41 +00:00
|
|
|
const struct bContext *C, ListBase *handlers,
|
|
|
|
int (*func)(struct bContext *C, const struct wmEvent *event, void *userdata),
|
|
|
|
void (*remove)(struct bContext *C, void *userdata), void *userdata);
|
2012-12-20 00:29:31 +00:00
|
|
|
|
2008-12-15 19:19:39 +00:00
|
|
|
void WM_event_remove_ui_handler(ListBase *handlers,
|
2013-02-01 01:01:20 +00:00
|
|
|
int (*func)(struct bContext *C, const struct wmEvent *event, void *userdata),
|
2012-12-14 04:38:52 +00:00
|
|
|
void (*remove)(struct bContext *C, void *userdata),
|
2013-04-04 15:16:29 +00:00
|
|
|
void *userdata, const bool postpone);
|
2010-01-12 23:30:19 +00:00
|
|
|
void WM_event_remove_area_handler(struct ListBase *handlers, void *area);
|
2013-05-17 13:54:44 +00:00
|
|
|
void WM_event_free_ui_handler_all(struct bContext *C, ListBase *handlers,
|
|
|
|
int (*func)(struct bContext *C, const struct wmEvent *event, void *userdata),
|
|
|
|
void (*remove)(struct bContext *C, void *userdata));
|
UI: don't use operators anymore for handling user interface events, but rather
a special UI handler which makes the code clearer. This UI handler is attached
to the region along with other handlers, and also gets a callback when all
handlers for the region are removed to ensure things are properly cleaned up.
This should fix XXX's in the UI code related to events and context switching.
Most of the changes are in interface_handlers.c, which was renamed from
interface_ops.c, to convert operators to the UI handler. UI code notes:
* uiBeginBlock/uiEndBlock/uiFreeBlocks now takes a context argument, this is
required to properly cancel things like timers or tooltips when the region
gets removed.
* UI_add_region_handlers will add the region level UI handlers, to be used
when adding keymap handlers etc. This replaces the UI keymap.
* When the UI code starts a modal interaction (number sliding, text editing,
opening a menu, ..), it will add an UI handler at the window level which
will block events.
Windowmanager changes:
* Added an UI handler next to the existing keymap and operator modal handlers.
It has an event handling and remove callback, and like operator modal handlers
will remember the area and region if it is registered at the window level.
* Removed the MESSAGE event.
* Operator cancel and UI handler remove callbacks now get the
window/area/region restored in the context, like the operator modal and UI
handler event callbacks.
* Regions now receive MOUSEMOVE events for the mouse going outside of the
region. This was already happening for areas, but UI buttons are at the region
level so we need it there.
Issues:
* Tooltips and menus stay open when switching to another window, and button
highlight doesn't work without moving the mouse first when Blender starts up.
I tried using some events like Q_FIRSTTIME, WINTHAW, but those don't seem to
arrive..
* Timeline header buttons seem to be moving one pixel or so sometimes when
interacting with them.
* Seems not due to this commit, but UI and keymap handlers are leaking. It
seems that handlers are being added to regions in all screens, also in regions
of areas that are not visible, but these handlers are not removed. Probably
there should only be handlers in visible regions?
2008-12-10 04:36:33 +00:00
|
|
|
|
2009-09-18 12:43:36 +00:00
|
|
|
struct wmEventHandler *WM_event_add_modal_handler(struct bContext *C, struct wmOperator *op);
|
2008-12-19 14:14:43 +00:00
|
|
|
void WM_event_remove_handlers(struct bContext *C, ListBase *handlers);
|
Various changes made in the process of working on the UI code:
* Added functions to generate Timer events. There was some unfinished code to
create one timer per window, this replaces that with a way to let operators
or other handlers add/remove their own timers as needed. This is currently
delivered as an event with the timer handle, perhaps this should be a notifier
instead? Also includes some fixes in ghost for timer events that were not
delivered in time, due to passing negative timeout.
* Added a Message event, which is a generic event that can be added by any
operator. This is used in the UI code to communicate the results of opened
blocks. Again, this may be better as a notifier.
* These two events should not be blocked as they are intended for a specific
operator or handler, so there were exceptions added for this, which is one
of the reasons they might work better as notifiers, but currently these
things can't listen to notifier yet.
* Added an option to events to indicate if the customdata should be freed or
not.
* Added a free() callback for area regions, and added a free function for
area regions in blenkernel since it was already there for screens and areas.
* Added ED_screen/area/region_exit functions to clean up things like operators
and handlers when they are closed.
* Added screen level regions, these will draw over areas boundaries, with the
last created region on top. These are useful for tooltips, menus, etc, and
are not saved to file. It's using the same ARegion struct as areas to avoid
code duplication, but perhaps that should be renamed then. Note that redraws
currently go correct, because only full window redraws are used, for partial
redraws without any frontbuffer drawing, the window manager needs to get
support for compositing subwindows.
* Minor changes in the subwindow code to retrieve the matrix, and moved
setlinestyle to glutil.c.
* Reversed argument order in WM_event_add/remove_keymap_handler to be consistent
with modal_handler.
* Operators can now block events but not necessarily cancel/finish.
* Modal operators are now stored in a list in the window/area/region they were
created in. This means for example that when a transform operator is invoked
from a region but registers a handler at the window level (since mouse motion
across areas should work), it will still get removed when the region is closed
while the operator is running.
2008-11-11 15:18:21 +00:00
|
|
|
|
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
|
|
|
struct wmEventHandler *WM_event_add_dropbox_handler(ListBase *handlers, ListBase *dropboxes);
|
|
|
|
|
|
|
|
/* mouse */
|
2008-12-19 14:14:43 +00:00
|
|
|
void WM_event_add_mousemove(struct bContext *C);
|
2013-03-13 09:03:46 +00:00
|
|
|
int WM_modal_tweak_exit(const struct wmEvent *event, int tweak_event);
|
2008-01-07 18:03:41 +00:00
|
|
|
|
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
|
|
|
/* notifiers */
|
2009-10-07 21:39:24 +00:00
|
|
|
void WM_event_add_notifier(const struct bContext *C, unsigned int type, void *reference);
|
|
|
|
void WM_main_add_notifier(unsigned int type, void *reference);
|
2013-04-08 13:03:04 +00:00
|
|
|
void WM_main_remove_notifier_reference(const void *reference);
|
2008-01-07 18:03:41 +00:00
|
|
|
|
2013-07-03 20:37:07 +00:00
|
|
|
/* reports */
|
|
|
|
void WM_report(const struct bContext *C, ReportType type, const char *message);
|
2013-09-01 15:01:15 +00:00
|
|
|
void WM_reportf(const struct bContext *C, ReportType type, const char *format, ...) ATTR_PRINTF_FORMAT(3, 4);
|
2013-07-03 20:37:07 +00:00
|
|
|
|
2013-02-11 10:01:32 +00:00
|
|
|
void wm_event_add(struct wmWindow *win, const struct wmEvent *event_to_add);
|
2013-07-29 08:29:04 +00:00
|
|
|
void wm_event_init_from_window(struct wmWindow *win, struct wmEvent *event);
|
|
|
|
|
2.5 getting-back-into-coding commit :)
- cleaned up join and split operations. Most noticable is operator callback
design, which should make a design based on user-less exec() first, then
wrap invoke() and modal() around it. The exec() should be callable with
only Context and properties.
- split now works again; and inversed as previously, if you drag from a
triangle (action zone) inside area it subdivides area as expected.
- dragging from triangle outside area, over an edge, joins areas
- split has been simplified, it had too many options... it could just work
simpler (now)
- 'action zone' now is an operator itself, a widget sending an ACTIONZONE event,
which can be handled by others (so other gestures can be added in action zone
too)
Still evaluating:
- context gets set where?
- code structure confuses... what are proper functions for operators?
- what is WM... should low level screen stuff more there?
- when do you send event, notifier?
- files grow to large, will clean
Oh yeah and docs, docs, docs. Coming! :)
2008-11-17 18:54:03 +00:00
|
|
|
|
2008-12-26 13:29:47 +00:00
|
|
|
/* at maximum, every timestep seconds it triggers event_type events */
|
2009-10-20 13:58:53 +00:00
|
|
|
struct wmTimer *WM_event_add_timer(struct wmWindowManager *wm, struct wmWindow *win, int event_type, double timestep);
|
|
|
|
void WM_event_remove_timer(struct wmWindowManager *wm, struct wmWindow *win, struct wmTimer *timer);
|
|
|
|
void WM_event_timer_sleep(struct wmWindowManager *wm, struct wmWindow *win, struct wmTimer *timer, int dosleep);
|
2008-01-07 18:03:41 +00:00
|
|
|
|
2008-12-24 18:06:51 +00:00
|
|
|
/* operator api, default callbacks */
|
|
|
|
/* invoke callback, uses enum property named "type" */
|
2013-03-13 09:03:46 +00:00
|
|
|
int WM_operator_view3d_distance_invoke(struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
|
2013-09-16 04:04:44 +00:00
|
|
|
int WM_operator_smooth_viewtx_get(const struct wmOperator *op);
|
2013-03-13 09:03:46 +00:00
|
|
|
int WM_menu_invoke (struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
|
|
|
|
int WM_enum_search_invoke(struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
|
2008-12-24 18:06:51 +00:00
|
|
|
/* invoke callback, confirm menu + exec */
|
2013-03-13 09:03:46 +00:00
|
|
|
int WM_operator_confirm (struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
|
2010-06-14 03:52:10 +00:00
|
|
|
/* invoke callback, file selector "filepath" unset + exec */
|
2013-03-13 09:03:46 +00:00
|
|
|
int WM_operator_filesel (struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
|
2013-06-18 15:30:51 +00:00
|
|
|
bool WM_operator_filesel_ensure_ext_imtype(wmOperator *op, const struct ImageFormatData *im_format);
|
2008-12-24 18:06:51 +00:00
|
|
|
/* poll callback, context checks */
|
2007-12-24 18:27:28 +00:00
|
|
|
int WM_operator_winactive (struct bContext *C);
|
2009-04-01 14:02:06 +00:00
|
|
|
/* invoke callback, exec + redo popup */
|
2013-03-13 09:03:46 +00:00
|
|
|
int WM_operator_props_popup_call(struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
|
|
|
|
int WM_operator_props_popup (struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
|
2013-03-26 07:29:01 +00:00
|
|
|
int WM_operator_props_dialog_popup(struct bContext *C, struct wmOperator *op, int width, int height);
|
2009-04-01 14:02:06 +00:00
|
|
|
int WM_operator_redo_popup (struct bContext *C, struct wmOperator *op);
|
2010-03-20 18:03:59 +00:00
|
|
|
int WM_operator_ui_popup (struct bContext *C, struct wmOperator *op, int width, int height);
|
2007-12-24 18:27:28 +00:00
|
|
|
|
2010-12-03 17:05:21 +00:00
|
|
|
int WM_operator_confirm_message(struct bContext *C, struct wmOperator *op, const char *message);
|
2009-10-10 12:29:11 +00:00
|
|
|
|
2008-12-24 18:06:51 +00:00
|
|
|
/* operator api */
|
2008-12-24 14:52:17 +00:00
|
|
|
void WM_operator_free (struct wmOperator *op);
|
2013-04-30 03:44:03 +00:00
|
|
|
void WM_operator_type_set(struct wmOperator *op, struct wmOperatorType *ot);
|
2011-05-18 10:56:26 +00:00
|
|
|
void WM_operator_stack_clear(struct wmWindowManager *wm);
|
2013-01-22 06:16:49 +00:00
|
|
|
void WM_operator_handlers_clear(wmWindowManager *wm, struct wmOperatorType *ot);
|
2009-06-26 15:48:09 +00:00
|
|
|
|
2013-04-30 03:44:03 +00:00
|
|
|
struct wmOperatorType *WM_operatortype_find(const char *idname, bool quiet);
|
2012-08-12 21:46:35 +00:00
|
|
|
struct GHashIterator *WM_operatortype_iter(void);
|
2013-01-09 03:30:15 +00:00
|
|
|
void WM_operatortype_append(void (*opfunc)(struct wmOperatorType *));
|
|
|
|
void WM_operatortype_append_ptr(void (*opfunc)(struct wmOperatorType *, void *), void *userdata);
|
|
|
|
void WM_operatortype_append_macro_ptr(void (*opfunc)(struct wmOperatorType *, void *), void *userdata);
|
python operators (in bpy_opwrapper.*)
This means you can define an operator in python that is called from C or Python - like any other operator.
Python functions for invoke and exec can be registered with an operator name.
keywords are read from the python exec() function, then used to create operator properties. The default python values are used to set the property type and defaults.
def exec(size=2.0, text="blah"): ...
is equivalent to...
prop = RNA_def_property(ot->srna, "size", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_default(prop, 2.0f);
prop = RNA_def_property(ot->srna, "size", PROP_STRING, PROP_NONE);
RNA_def_property_string_default(prop, "blah");
TODO -
* make use of events
* return OPERATOR_CANCELLED/OPERATOR_FINISHED.. etc
* add support for array args
* more testing
2008-12-27 14:52:49 +00:00
|
|
|
int WM_operatortype_remove(const char *idname);
|
2007-12-24 18:27:28 +00:00
|
|
|
|
2012-05-05 19:26:53 +00:00
|
|
|
struct wmOperatorType *WM_operatortype_append_macro(const char *idname, const char *name, const char *description, int flag);
|
2009-12-24 16:10:26 +00:00
|
|
|
struct wmOperatorTypeMacro *WM_operatortype_macro_define(struct wmOperatorType *ot, const char *idname);
|
2.5
Operator goodies!
--- Macro operators
Operators now can consist of multiple operators. Such a macro operator
is identical and behaves identical to other opererators. Macros can
also be constructed of macros even! Currently only hardcoded macros are
implemented, this to solve combined operators such as 'add duplicate' or
'extrude' (both want a transform appended).
Usage is simple:
- WM_operatortype_append_macro() : add new operatortype, name, flags
- WM_operatortype_macro_define() : add existing operator to macro
(Note: macro_define will also allow properties to be set, doesnt work
right now)
On converting the macro wmOperatorType to a real operator, it makes a
list of all operators, and the standard macro callbacks (exec, invoke,
modal, poll) just will use all.
Important note; switching to a modal operator only works as last in the
chain now!
Macros implemented for duplicate, extrude and rip. Tool menu works fine
for it, also the redo hotkey F4 works properly.
--- Operator redo fix
The operators use the undo system to switch back, but this could give
errors if other actions added undo pushes (buttons, outliner). Now the
redo for operator searches back for the correct undo level.
This fixes issues with many redos.
Note for brecht: removed the ED_undo_push for buttons... it was called
on *every* button now, which is probably too much? For example, using
the 'toolbar' redo also caused this...
2009-07-29 17:56:38 +00:00
|
|
|
|
|
|
|
|
2009-09-18 13:02:20 +00:00
|
|
|
int WM_operator_poll (struct bContext *C, struct wmOperatorType *ot);
|
2012-06-27 21:41:17 +00:00
|
|
|
int WM_operator_poll_context(struct bContext *C, struct wmOperatorType *ot, short context);
|
2008-12-24 14:52:17 +00:00
|
|
|
int WM_operator_call (struct bContext *C, struct wmOperator *op);
|
2011-12-12 18:52:18 +00:00
|
|
|
int WM_operator_call_notest(struct bContext *C, struct wmOperator *op);
|
2009-02-01 12:00:00 +00:00
|
|
|
int WM_operator_repeat (struct bContext *C, struct wmOperator *op);
|
2010-12-15 04:06:19 +00:00
|
|
|
int WM_operator_repeat_check(const struct bContext *C, struct wmOperator *op);
|
2012-06-27 21:41:17 +00:00
|
|
|
int WM_operator_name_call (struct bContext *C, const char *opstring, short context, struct PointerRNA *properties);
|
|
|
|
int WM_operator_call_py(struct bContext *C, struct wmOperatorType *ot, short context, struct PointerRNA *properties, struct ReportList *reports, short is_undo);
|
2009-01-01 20:44:40 +00:00
|
|
|
|
2009-10-12 12:54:08 +00:00
|
|
|
void WM_operator_properties_alloc(struct PointerRNA **ptr, struct IDProperty **properties, const char *opstring); /* used for keymap and macro items */
|
2013-04-04 02:05:11 +00:00
|
|
|
void WM_operator_properties_sanitize(struct PointerRNA *ptr, const bool no_context); /* make props context sensitive or not */
|
|
|
|
int WM_operator_properties_default(struct PointerRNA *ptr, const bool do_update);
|
2012-01-11 19:33:14 +00:00
|
|
|
void WM_operator_properties_reset(struct wmOperator *op);
|
2009-01-01 20:44:40 +00:00
|
|
|
void WM_operator_properties_create(struct PointerRNA *ptr, const char *opstring);
|
2009-11-24 16:19:15 +00:00
|
|
|
void WM_operator_properties_create_ptr(struct PointerRNA *ptr, struct wmOperatorType *ot);
|
2009-01-01 20:44:40 +00:00
|
|
|
void WM_operator_properties_free(struct PointerRNA *ptr);
|
2012-01-24 18:18:51 +00:00
|
|
|
void WM_operator_properties_filesel(struct wmOperatorType *ot, int filter, short type, short action, short flag, short display);
|
2012-08-08 20:38:55 +00:00
|
|
|
void WM_operator_properties_border(struct wmOperatorType *ot);
|
|
|
|
void WM_operator_properties_border_to_rcti(struct wmOperator *op, struct rcti *rect);
|
2013-03-19 23:17:44 +00:00
|
|
|
void WM_operator_properties_gesture_border(struct wmOperatorType *ot, bool extend);
|
2012-05-28 05:45:19 +00:00
|
|
|
void WM_operator_properties_mouse_select(struct wmOperatorType *ot);
|
2013-07-04 18:58:00 +00:00
|
|
|
void WM_operator_properties_gesture_straightline(struct wmOperatorType *ot, int cursor);
|
2009-12-24 16:10:26 +00:00
|
|
|
void WM_operator_properties_select_all(struct wmOperatorType *ot);
|
2013-05-16 00:07:01 +00:00
|
|
|
void WM_operator_properties_select_action(struct wmOperatorType *ot, int default_action);
|
2009-11-29 22:16:29 +00:00
|
|
|
|
2013-04-04 02:05:11 +00:00
|
|
|
bool WM_operator_check_ui_enabled(const struct bContext *C, const char *idname);
|
2011-05-23 10:14:07 +00:00
|
|
|
wmOperator *WM_operator_last_redo(const struct bContext *C);
|
|
|
|
|
2013-04-04 02:05:11 +00:00
|
|
|
bool WM_operator_last_properties_init(struct wmOperator *op);
|
|
|
|
bool WM_operator_last_properties_store(struct wmOperator *op);
|
2012-03-21 06:33:31 +00:00
|
|
|
|
2009-11-29 22:16:29 +00:00
|
|
|
/* MOVE THIS SOMEWHERE ELSE */
|
|
|
|
#define SEL_TOGGLE 0
|
|
|
|
#define SEL_SELECT 1
|
|
|
|
#define SEL_DESELECT 2
|
|
|
|
#define SEL_INVERT 3
|
2.5: gesture code in WM
- Simplified and cleaned previous border code
It was a bit too complex, too many data manipulations
Original idea was to have WM API calls to manage border, circle, lines,
lasso, etc. This now means that WM provides callbacks for custom operators,
so it's very easy to make them. Check bottom of screen_edit.c for an
example.
Currently two borders were coded; with and without cross hair.
Press Bkey in any area-region to test it (note: time window has wrong matrix!)
Some specs to note:
- gestures are in region space, and draw 'over'. That latter still needs some
work when we do real composites.
- only the active region is redrawn.
- on todo is the generic gesture engine for 'tweak' or like how currently grab
gestures in Blender work. These will be configurable per area-region, and WM
then will send the proper "Gesture Event" with properties (N, S, E, W, etc)
to which you then can assign operators. Such events will be generated with low
priority, so other handlers who swallowed mouse events have preference.
2008-11-19 13:16:05 +00:00
|
|
|
|
2010-07-01 19:28:45 +00:00
|
|
|
|
|
|
|
/* flags for WM_operator_properties_filesel */
|
|
|
|
#define WM_FILESEL_RELPATH (1 << 0)
|
|
|
|
|
|
|
|
#define WM_FILESEL_DIRECTORY (1 << 1)
|
|
|
|
#define WM_FILESEL_FILENAME (1 << 2)
|
|
|
|
#define WM_FILESEL_FILEPATH (1 << 3)
|
2011-08-12 03:53:26 +00:00
|
|
|
#define WM_FILESEL_FILES (1 << 4)
|
2010-07-01 19:28:45 +00:00
|
|
|
|
|
|
|
|
2012-03-09 00:41:09 +00:00
|
|
|
/* operator as a python command (resultuing string must be freed) */
|
2009-08-16 14:43:08 +00:00
|
|
|
char *WM_operator_pystring(struct bContext *C, struct wmOperatorType *ot, struct PointerRNA *opptr, int all_args);
|
2012-12-18 14:11:19 +00:00
|
|
|
char *WM_prop_pystring_assign(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, int index);
|
2009-07-18 19:42:13 +00:00
|
|
|
void WM_operator_bl_idname(char *to, const char *from);
|
|
|
|
void WM_operator_py_idname(char *to, const char *from);
|
2008-12-26 03:56:52 +00:00
|
|
|
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
/* *************** uilist types ******************** */
|
|
|
|
void WM_uilisttype_init(void);
|
2013-04-04 02:05:11 +00:00
|
|
|
struct uiListType *WM_uilisttype_find(const char *idname, bool quiet);
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
int WM_uilisttype_add(struct uiListType *ult);
|
|
|
|
void WM_uilisttype_freelink(struct uiListType *ult);
|
|
|
|
void WM_uilisttype_free(void);
|
|
|
|
|
2009-10-08 19:06:32 +00:00
|
|
|
/* *************** menu types ******************** */
|
2012-08-11 21:35:24 +00:00
|
|
|
void WM_menutype_init(void);
|
2013-04-04 02:05:11 +00:00
|
|
|
struct MenuType *WM_menutype_find(const char *idname, bool quiet);
|
2012-08-26 11:35:43 +00:00
|
|
|
int WM_menutype_add(struct MenuType *mt);
|
|
|
|
void WM_menutype_freelink(struct MenuType *mt);
|
2012-08-11 21:35:24 +00:00
|
|
|
void WM_menutype_free(void);
|
2009-10-08 19:06:32 +00:00
|
|
|
|
2008-12-21 16:24:19 +00:00
|
|
|
/* default operator callbacks for border/circle/lasso */
|
2013-03-13 09:03:46 +00:00
|
|
|
int WM_border_select_invoke (struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
|
|
|
|
int WM_border_select_modal (struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
|
2011-06-06 11:04:54 +00:00
|
|
|
int WM_border_select_cancel(struct bContext *C, struct wmOperator *op);
|
2013-03-13 09:03:46 +00:00
|
|
|
int WM_gesture_circle_invoke(struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
|
|
|
|
int WM_gesture_circle_modal(struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
|
2011-06-06 11:04:54 +00:00
|
|
|
int WM_gesture_circle_cancel(struct bContext *C, struct wmOperator *op);
|
2013-03-13 09:03:46 +00:00
|
|
|
int WM_gesture_lines_invoke(struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
|
|
|
|
int WM_gesture_lines_modal(struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
|
2011-06-06 11:04:54 +00:00
|
|
|
int WM_gesture_lines_cancel(struct bContext *C, struct wmOperator *op);
|
2013-03-13 09:03:46 +00:00
|
|
|
int WM_gesture_lasso_invoke(struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
|
|
|
|
int WM_gesture_lasso_modal(struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
|
2011-06-06 11:04:54 +00:00
|
|
|
int WM_gesture_lasso_cancel(struct bContext *C, struct wmOperator *op);
|
2012-10-05 15:44:11 +00:00
|
|
|
const int (*WM_gesture_lasso_path_to_array(struct bContext *C, struct wmOperator *op, int *mcords_tot))[2];
|
2013-03-13 09:03:46 +00:00
|
|
|
int WM_gesture_straightline_invoke(struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
|
|
|
|
int WM_gesture_straightline_modal(struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
|
2011-06-06 11:04:54 +00:00
|
|
|
int WM_gesture_straightline_cancel(struct bContext *C, struct wmOperator *op);
|
Various changes made in the process of working on the UI code:
* Added functions to generate Timer events. There was some unfinished code to
create one timer per window, this replaces that with a way to let operators
or other handlers add/remove their own timers as needed. This is currently
delivered as an event with the timer handle, perhaps this should be a notifier
instead? Also includes some fixes in ghost for timer events that were not
delivered in time, due to passing negative timeout.
* Added a Message event, which is a generic event that can be added by any
operator. This is used in the UI code to communicate the results of opened
blocks. Again, this may be better as a notifier.
* These two events should not be blocked as they are intended for a specific
operator or handler, so there were exceptions added for this, which is one
of the reasons they might work better as notifiers, but currently these
things can't listen to notifier yet.
* Added an option to events to indicate if the customdata should be freed or
not.
* Added a free() callback for area regions, and added a free function for
area regions in blenkernel since it was already there for screens and areas.
* Added ED_screen/area/region_exit functions to clean up things like operators
and handlers when they are closed.
* Added screen level regions, these will draw over areas boundaries, with the
last created region on top. These are useful for tooltips, menus, etc, and
are not saved to file. It's using the same ARegion struct as areas to avoid
code duplication, but perhaps that should be renamed then. Note that redraws
currently go correct, because only full window redraws are used, for partial
redraws without any frontbuffer drawing, the window manager needs to get
support for compositing subwindows.
* Minor changes in the subwindow code to retrieve the matrix, and moved
setlinestyle to glutil.c.
* Reversed argument order in WM_event_add/remove_keymap_handler to be consistent
with modal_handler.
* Operators can now block events but not necessarily cancel/finish.
* Modal operators are now stored in a list in the window/area/region they were
created in. This means for example that when a transform operator is invoked
from a region but registers a handler at the window level (since mouse motion
across areas should work), it will still get removed when the region is closed
while the operator is running.
2008-11-11 15:18:21 +00:00
|
|
|
|
2008-01-19 17:54:05 +00:00
|
|
|
/* Gesture manager API */
|
2013-03-13 09:03:46 +00:00
|
|
|
struct wmGesture *WM_gesture_new(struct bContext *C, const struct wmEvent *event, int type);
|
2.5: gesture code in WM
- Simplified and cleaned previous border code
It was a bit too complex, too many data manipulations
Original idea was to have WM API calls to manage border, circle, lines,
lasso, etc. This now means that WM provides callbacks for custom operators,
so it's very easy to make them. Check bottom of screen_edit.c for an
example.
Currently two borders were coded; with and without cross hair.
Press Bkey in any area-region to test it (note: time window has wrong matrix!)
Some specs to note:
- gestures are in region space, and draw 'over'. That latter still needs some
work when we do real composites.
- only the active region is redrawn.
- on todo is the generic gesture engine for 'tweak' or like how currently grab
gestures in Blender work. These will be configurable per area-region, and WM
then will send the proper "Gesture Event" with properties (N, S, E, W, etc)
to which you then can assign operators. Such events will be generated with low
priority, so other handlers who swallowed mouse events have preference.
2008-11-19 13:16:05 +00:00
|
|
|
void WM_gesture_end(struct bContext *C, struct wmGesture *gesture);
|
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
|
|
|
void WM_gestures_remove(struct bContext *C);
|
2008-01-19 17:54:05 +00:00
|
|
|
|
2009-02-16 12:14:04 +00:00
|
|
|
/* fileselecting support */
|
|
|
|
void WM_event_add_fileselect(struct bContext *C, struct wmOperator *op);
|
2013-03-15 19:56:29 +00:00
|
|
|
void WM_event_fileselect_event(struct wmWindowManager *wm, void *ophandle, int eventval);
|
2011-10-21 08:16:15 +00:00
|
|
|
#ifndef NDEBUG
|
2013-03-03 03:29:57 +00:00
|
|
|
void WM_event_print(const struct wmEvent *event);
|
2011-10-21 08:16:15 +00:00
|
|
|
#endif
|
2009-02-16 12:14:04 +00:00
|
|
|
|
2013-01-30 12:22:02 +00:00
|
|
|
void WM_operator_region_active_win_set(struct bContext *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
|
|
|
/* drag and drop */
|
|
|
|
struct wmDrag *WM_event_start_drag(struct bContext *C, int icon, int type, void *poin, double value);
|
|
|
|
void WM_event_drag_image(struct wmDrag *, struct ImBuf *, float scale, int sx, int sy);
|
|
|
|
|
2013-03-13 09:03:46 +00:00
|
|
|
struct wmDropBox *WM_dropbox_add(ListBase *lb, const char *idname, int (*poll)(struct bContext *, struct wmDrag *, const struct wmEvent *event),
|
2012-12-13 01:00:21 +00:00
|
|
|
void (*copy)(struct wmDrag *, struct wmDropBox *));
|
2010-12-03 17:05:21 +00:00
|
|
|
ListBase *WM_dropboxmap_find(const char *idname, int spaceid, int regionid);
|
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
|
|
|
|
2010-02-01 15:32:55 +00:00
|
|
|
/* Set a subwindow active in pixelspace view, with optional scissor subset */
|
2.5: WM Compositing
* Triple Buffer is now more complete:
- Proper handling of window resize, duplicate, etc.
- It now uses 3x3 textures (or less) if the power of two sizes
do not match well. That still has a worst case wast of 23.4%,
but better than 300%.
- It can also use the ARB/NV/EXT_texture_rectangle extension
now, which may be supported on hardware that does not support
ARB_texture_non_power_of_two.
- Gesture, menu and brushe redraws now require no redraws at all
from the area regions. So even on a high poly scene just moving
the paint cursor or opening a menu should be fast.
* Testing can be done by setting the "Window Draw Method" in the
User Preferences in the outliner. "Overlap" is still default,
since "Triple Buffer" has not been tested on computers other than
mine, would like to avoid crashing Blender on startup in case
there is a common bug, but it's ready for testing now.
- For reference "Full" draws the full window each time.
- "Triple Buffer" should work for both swap copy and swap exchange
systems, the latter still need the -E command line option for
"Overlap".
- Resizing and going fullscreen still gives flicker here but no
more than "Full" drawing.
* Partial Redraw was added. ED_region_tag_redraw_partial takes a
rect in window coordinates to define a subarea of the region.
On region draw it will then set glScissor to a smaller area, and
ar->drawrct will always be set to either the partial or full
window rect. The latter can then be used for clipping in the 3D
view or clipping interface drawing. Neither is implemented yet.
2009-01-23 03:52:52 +00:00
|
|
|
void wmSubWindowSet (struct wmWindow *win, int swinid);
|
2013-08-05 04:52:27 +00:00
|
|
|
void wmSubWindowScissorSet (struct wmWindow *win, int swinid, const struct rcti *srct, bool srct_pad);
|
2008-12-19 14:14:43 +00:00
|
|
|
|
2010-02-01 15:32:55 +00:00
|
|
|
/* OpenGL utilities with safety check + working in modelview matrix mode */
|
2008-12-19 14:14:43 +00:00
|
|
|
void wmFrustum (float x1, float x2, float y1, float y2, float n, float f);
|
|
|
|
void wmOrtho (float x1, float x2, float y1, float y2, float n, float f);
|
|
|
|
void wmOrtho2 (float x1, float x2, float y1, float y2);
|
2008-01-01 15:53:38 +00:00
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
/* utilities */
|
2012-08-11 21:35:24 +00:00
|
|
|
void WM_framebuffer_index_set(int index);
|
2008-12-30 13:16:14 +00:00
|
|
|
int WM_framebuffer_to_index(unsigned int col);
|
2007-12-24 18:27:28 +00:00
|
|
|
|
2.5
Added WM Jobs manager
- WM can manage threaded jobs for you; just provide a couple
of components to get it work:
- customdata, free callback for it
- timer step, notifier code
- start callback, update callback
- Once started, each job runs an own timer, and will for
every time step check necessary updates, or close the
job when ready.
- No drawing happens in jobs, that's for notifiers!
- Every job stores an owner pointer, and based on this owner
it will prevent multiple jobs to enter the stack.
Instead it will re-use a running job, signal it to stop
and allow caller to re-initialize it even.
- Check new wm_jobs.c for more explanation. Jobs API is still
under construction.
Fun: BLI_addtail(&wm->jobs, steve); :)
Put Node shader previews back using wmJobs
- Preview calculating is now fully threaded (1 thread still)
- Thanks to new event system + notifiers, you can see
previews update even while dragging sliders!
- Currently it only starts when you change a node setting.
Warning: the thread render shares Node data, so don't delete
nodes while it renders! This topic is on the todo to make safe.
Also:
- bug in region initialize (do_versions) showed channel list in
node editor wrong.
- flagged the channel list 'hidden' now, it was really in the
way! This is for later to work on anyway.
- recoded Render API callbacks so it gets handlers passed on,
no globals to use anymore, remember?
- previewrender code gets now so much nicer! Will remove a lot
of stuff from code soon.
2009-01-22 14:59:49 +00:00
|
|
|
/* threaded Jobs Manager */
|
2012-08-15 09:42:06 +00:00
|
|
|
enum {
|
|
|
|
WM_JOB_PRIORITY = (1 << 0),
|
|
|
|
WM_JOB_EXCL_RENDER = (1 << 1),
|
|
|
|
WM_JOB_PROGRESS = (1 << 2),
|
|
|
|
WM_JOB_SUSPEND = (1 << 3)
|
|
|
|
};
|
|
|
|
|
2012-11-06 15:54:04 +00:00
|
|
|
/* identifying jobs by owner alone is unreliable, this isnt saved, order can change (keep 0 for 'any') */
|
2012-08-15 09:42:06 +00:00
|
|
|
enum {
|
2012-11-06 15:54:04 +00:00
|
|
|
WM_JOB_TYPE_ANY = 0,
|
2012-08-15 09:42:06 +00:00
|
|
|
WM_JOB_TYPE_COMPOSITE,
|
|
|
|
WM_JOB_TYPE_RENDER,
|
|
|
|
WM_JOB_TYPE_RENDER_PREVIEW, /* UI preview */
|
|
|
|
WM_JOB_TYPE_SCREENCAST,
|
|
|
|
WM_JOB_TYPE_OBJECT_SIM_OCEAN,
|
2012-08-15 10:03:29 +00:00
|
|
|
WM_JOB_TYPE_OBJECT_SIM_FLUID,
|
2012-08-15 09:42:06 +00:00
|
|
|
WM_JOB_TYPE_OBJECT_BAKE_TEXTURE,
|
|
|
|
WM_JOB_TYPE_FILESEL_THUMBNAIL,
|
|
|
|
WM_JOB_TYPE_CLIP_BUILD_PROXY,
|
|
|
|
WM_JOB_TYPE_CLIP_TRACK_MARKERS,
|
|
|
|
WM_JOB_TYPE_CLIP_SOLVE_CAMERA,
|
2013-03-20 17:03:20 +00:00
|
|
|
WM_JOB_TYPE_CLIP_PREFETCH,
|
2012-08-15 09:42:06 +00:00
|
|
|
WM_JOB_TYPE_SEQ_BUILD_PROXY,
|
|
|
|
/* add as needed, screencast, seq proxy build
|
|
|
|
* if having hard coded values is a problem */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct wmJob *WM_jobs_get(struct wmWindowManager *wm, struct wmWindow *win, void *owner, const char *name, int flag, int job_type);
|
|
|
|
|
|
|
|
int WM_jobs_test(struct wmWindowManager *wm, void *owner, int job_type);
|
2010-05-27 08:22:16 +00:00
|
|
|
float WM_jobs_progress(struct wmWindowManager *wm, void *owner);
|
2012-08-12 21:46:35 +00:00
|
|
|
char *WM_jobs_name(struct wmWindowManager *wm, void *owner);
|
2013-08-28 19:22:48 +00:00
|
|
|
void *WM_jobs_customdata(struct wmWindowManager *wm, void *owner);
|
2009-01-27 17:12:40 +00:00
|
|
|
|
2012-07-31 23:06:12 +00:00
|
|
|
int WM_jobs_is_running(struct wmJob *);
|
2012-08-12 21:46:35 +00:00
|
|
|
void *WM_jobs_customdata_get(struct wmJob *);
|
2012-08-11 21:35:24 +00:00
|
|
|
void WM_jobs_customdata_set(struct wmJob *, void *customdata, void (*free)(void *));
|
2012-07-31 23:06:12 +00:00
|
|
|
void WM_jobs_timer(struct wmJob *, double timestep, unsigned int note, unsigned int endnote);
|
|
|
|
void WM_jobs_callbacks(struct wmJob *,
|
|
|
|
void (*startjob)(void *, short *, short *, float *),
|
|
|
|
void (*initjob)(void *),
|
|
|
|
void (*update)(void *),
|
|
|
|
void (*endjob)(void *));
|
2.5
Added WM Jobs manager
- WM can manage threaded jobs for you; just provide a couple
of components to get it work:
- customdata, free callback for it
- timer step, notifier code
- start callback, update callback
- Once started, each job runs an own timer, and will for
every time step check necessary updates, or close the
job when ready.
- No drawing happens in jobs, that's for notifiers!
- Every job stores an owner pointer, and based on this owner
it will prevent multiple jobs to enter the stack.
Instead it will re-use a running job, signal it to stop
and allow caller to re-initialize it even.
- Check new wm_jobs.c for more explanation. Jobs API is still
under construction.
Fun: BLI_addtail(&wm->jobs, steve); :)
Put Node shader previews back using wmJobs
- Preview calculating is now fully threaded (1 thread still)
- Thanks to new event system + notifiers, you can see
previews update even while dragging sliders!
- Currently it only starts when you change a node setting.
Warning: the thread render shares Node data, so don't delete
nodes while it renders! This topic is on the todo to make safe.
Also:
- bug in region initialize (do_versions) showed channel list in
node editor wrong.
- flagged the channel list 'hidden' now, it was really in the
way! This is for later to work on anyway.
- recoded Render API callbacks so it gets handlers passed on,
no globals to use anymore, remember?
- previewrender code gets now so much nicer! Will remove a lot
of stuff from code soon.
2009-01-22 14:59:49 +00:00
|
|
|
|
2009-06-07 11:12:35 +00:00
|
|
|
void WM_jobs_start(struct wmWindowManager *wm, struct wmJob *);
|
2010-07-04 19:58:52 +00:00
|
|
|
void WM_jobs_stop(struct wmWindowManager *wm, void *owner, void *startjob);
|
2010-12-03 01:52:28 +00:00
|
|
|
void WM_jobs_kill(struct wmWindowManager *wm, void *owner, void (*)(void *, short int *, short int *, float *));
|
2012-10-29 17:41:19 +00:00
|
|
|
void WM_jobs_kill_all(struct wmWindowManager *wm);
|
2012-11-28 09:36:23 +00:00
|
|
|
void WM_jobs_kill_all_except(struct wmWindowManager *wm, void *owner);
|
|
|
|
void WM_jobs_kill_type(struct wmWindowManager *wm, int job_type);
|
|
|
|
|
2011-11-29 15:26:46 +00:00
|
|
|
int WM_jobs_has_running(struct wmWindowManager *wm);
|
|
|
|
|
2013-07-08 17:56:51 +00:00
|
|
|
void WM_job_main_thread_lock_acquire(struct wmJob *job);
|
|
|
|
void WM_job_main_thread_lock_release(struct wmJob *job);
|
|
|
|
|
2.5: Text Editor back.
There was very little structure in this code, using many globals
and duplicated code. Now it should be better structured. Most
things should work, the main parts that are not back yet are the
python plugins and markers. Notes:
* Blenfont is used for drawing the text, nicely anti-aliased.
* A monospace truetype font was added, since that is needed for
the text editor. It's Bitstream Vera Sans Mono. This is the
default gnome terminal font, but it doesn't fit entirely well
with the other font I think, can be changed easily of course.
* Clipboard copy/cut/paste now always uses the system clipboard,
the code for the own cut buffer was removed.
* The interface buttons should support copy/cut/paste again now
as well.
* WM_clipboard_text_get/WM_clipboard_text_set were added to the
windowmanager code.
* Find panel is now a kind of second header, instead of a panel.
This needs especially a way to start editing the text field
immediately on open still.
* Operators are independent of the actual space when possible,
was a bit of puzzling but got it solved nice with notifiers,
and some lazy init for syntax highlight in the drawing code.
* RNA was created for the text editor space and used for buttons.
* Operators:
* New, Open, Reload, Save, Save As, Make Internal
* Run Script, Refresh Pyconstraints
* Copy, Cut, Paste
* Convert Whitespace, Uncomment, Comment, Indent, Unindent
* Line Break, Insert
* Next Marker, Previous Marker, Clear All Markers, Mark All
* Select Line, Select All
* Jump, Move, Move Select, Delete, Toggle Overwrite
* Scroll, Scroll Bar, Set Cursor, Line Number
* Find and Replace, Find, Replace, Find Set Selected,
Replace Set Selected
* To 3D Object
* Resolve Conflict
2009-02-28 23:33:35 +00:00
|
|
|
/* clipboard */
|
2012-08-12 21:46:35 +00:00
|
|
|
char *WM_clipboard_text_get(int selection);
|
|
|
|
void WM_clipboard_text_set(char *buf, int selection);
|
2.5: Text Editor back.
There was very little structure in this code, using many globals
and duplicated code. Now it should be better structured. Most
things should work, the main parts that are not back yet are the
python plugins and markers. Notes:
* Blenfont is used for drawing the text, nicely anti-aliased.
* A monospace truetype font was added, since that is needed for
the text editor. It's Bitstream Vera Sans Mono. This is the
default gnome terminal font, but it doesn't fit entirely well
with the other font I think, can be changed easily of course.
* Clipboard copy/cut/paste now always uses the system clipboard,
the code for the own cut buffer was removed.
* The interface buttons should support copy/cut/paste again now
as well.
* WM_clipboard_text_get/WM_clipboard_text_set were added to the
windowmanager code.
* Find panel is now a kind of second header, instead of a panel.
This needs especially a way to start editing the text field
immediately on open still.
* Operators are independent of the actual space when possible,
was a bit of puzzling but got it solved nice with notifiers,
and some lazy init for syntax highlight in the drawing code.
* RNA was created for the text editor space and used for buttons.
* Operators:
* New, Open, Reload, Save, Save As, Make Internal
* Run Script, Refresh Pyconstraints
* Copy, Cut, Paste
* Convert Whitespace, Uncomment, Comment, Indent, Unindent
* Line Break, Insert
* Next Marker, Previous Marker, Clear All Markers, Mark All
* Select Line, Select All
* Jump, Move, Move Select, Delete, Toggle Overwrite
* Scroll, Scroll Bar, Set Cursor, Line Number
* Find and Replace, Find, Replace, Find Set Selected,
Replace Set Selected
* To 3D Object
* Resolve Conflict
2009-02-28 23:33:35 +00:00
|
|
|
|
2010-06-01 20:21:40 +00:00
|
|
|
/* progress */
|
|
|
|
void WM_progress_set(struct wmWindow *win, float progress);
|
|
|
|
void WM_progress_clear(struct wmWindow *win);
|
|
|
|
|
2011-12-05 16:37:31 +00:00
|
|
|
/* Draw (for screenshot) */
|
|
|
|
void WM_redraw_windows(struct bContext *C);
|
|
|
|
|
2012-09-15 01:52:28 +00:00
|
|
|
void WM_main_playanim(int argc, const char **argv);
|
|
|
|
|
2011-02-14 03:15:55 +00:00
|
|
|
/* debugging only, convenience function to write on crash */
|
|
|
|
int write_crash_blend(void);
|
|
|
|
|
2010-10-05 00:05:14 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-02-17 18:59:41 +00:00
|
|
|
#endif /* __WM_API_H__ */
|
2007-12-24 18:27:28 +00:00
|
|
|
|