2008-01-07 18:03:41 +00:00
|
|
|
/**
|
|
|
|
* $Id:
|
|
|
|
*
|
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2008 Blender Foundation.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
2009-02-15 13:09:19 +00:00
|
|
|
#include <math.h>
|
2009-10-28 18:03:04 +00:00
|
|
|
#include <string.h>
|
2010-01-06 04:08:06 +00:00
|
|
|
#include <stddef.h>
|
2009-10-28 18:03:04 +00:00
|
|
|
|
|
|
|
#include <GL/glew.h>
|
2009-02-15 13:09:19 +00:00
|
|
|
|
2008-01-07 18:03:41 +00:00
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
#include "BLI_math.h"
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
#include "BLI_blenlib.h"
|
|
|
|
#include "BLI_editVert.h"
|
2009-07-24 13:34:45 +00:00
|
|
|
#include "BLI_dlrbTree.h"
|
2008-01-07 18:03:41 +00:00
|
|
|
|
2009-02-04 17:40:50 +00:00
|
|
|
#include "DNA_armature_types.h"
|
|
|
|
#include "DNA_image_types.h"
|
2009-07-03 15:23:33 +00:00
|
|
|
#include "DNA_lattice_types.h"
|
2009-02-04 17:40:50 +00:00
|
|
|
#include "DNA_object_types.h"
|
|
|
|
#include "DNA_mesh_types.h"
|
|
|
|
#include "DNA_curve_types.h"
|
|
|
|
#include "DNA_scene_types.h"
|
2009-07-29 12:35:09 +00:00
|
|
|
#include "DNA_meta_types.h"
|
2009-10-28 18:03:04 +00:00
|
|
|
#include "DNA_view3d_types.h"
|
2009-02-04 17:40:50 +00:00
|
|
|
|
|
|
|
#include "BKE_blender.h"
|
2009-07-17 02:43:15 +00:00
|
|
|
#include "BKE_colortools.h"
|
2008-12-18 02:56:48 +00:00
|
|
|
#include "BKE_context.h"
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
#include "BKE_customdata.h"
|
2009-02-04 17:40:50 +00:00
|
|
|
#include "BKE_global.h"
|
|
|
|
#include "BKE_image.h"
|
2009-02-04 11:52:16 +00:00
|
|
|
#include "BKE_idprop.h"
|
2008-01-07 18:03:41 +00:00
|
|
|
#include "BKE_library.h"
|
|
|
|
#include "BKE_main.h"
|
2009-04-20 15:06:46 +00:00
|
|
|
#include "BKE_mesh.h"
|
2009-02-05 01:12:47 +00:00
|
|
|
#include "BKE_multires.h"
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
#include "BKE_report.h"
|
2009-08-15 16:43:03 +00:00
|
|
|
#include "BKE_scene.h"
|
2008-01-07 18:03:41 +00:00
|
|
|
#include "BKE_screen.h"
|
|
|
|
#include "BKE_utildefines.h"
|
2009-08-09 21:16:39 +00:00
|
|
|
#include "BKE_sound.h"
|
2009-10-28 18:03:04 +00:00
|
|
|
#include "BKE_writeavi.h"
|
2008-01-07 18:03:41 +00:00
|
|
|
|
|
|
|
#include "WM_api.h"
|
|
|
|
#include "WM_types.h"
|
|
|
|
|
2008-12-31 18:52:15 +00:00
|
|
|
#include "ED_util.h"
|
2008-01-07 18:03:41 +00:00
|
|
|
#include "ED_screen.h"
|
2009-03-30 07:28:37 +00:00
|
|
|
#include "ED_mesh.h"
|
2009-07-02 03:32:57 +00:00
|
|
|
#include "ED_object.h"
|
2008-11-19 16:28:11 +00:00
|
|
|
#include "ED_screen_types.h"
|
2009-07-24 13:34:45 +00:00
|
|
|
#include "ED_keyframes_draw.h"
|
2009-10-28 18:03:04 +00:00
|
|
|
#include "ED_view3d.h"
|
2008-01-07 18:03:41 +00:00
|
|
|
|
2009-02-04 17:40:50 +00:00
|
|
|
#include "RE_pipeline.h"
|
|
|
|
#include "IMB_imbuf.h"
|
|
|
|
#include "IMB_imbuf_types.h"
|
|
|
|
|
2008-11-21 19:14:38 +00:00
|
|
|
#include "RNA_access.h"
|
|
|
|
#include "RNA_define.h"
|
|
|
|
|
2009-01-15 18:28:40 +00:00
|
|
|
#include "UI_interface.h"
|
2009-01-25 20:22:05 +00:00
|
|
|
#include "UI_resources.h"
|
2009-01-15 18:28:40 +00:00
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
#include "GPU_extensions.h"
|
|
|
|
|
2009-07-24 12:43:59 +00:00
|
|
|
#include "wm_window.h"
|
|
|
|
|
2008-01-07 18:03:41 +00:00
|
|
|
#include "screen_intern.h" /* own module include */
|
|
|
|
|
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
|
|
|
#define KM_MODAL_CANCEL 1
|
|
|
|
#define KM_MODAL_APPLY 2
|
|
|
|
#define KM_MODAL_STEP10 3
|
|
|
|
#define KM_MODAL_STEP10_OFF 4
|
|
|
|
|
2009-12-17 17:05:28 +00:00
|
|
|
#if defined(__APPLE__) && (PARALLEL == 1) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 2)
|
|
|
|
/* ************** libgomp (Apple gcc 4.2.1) TLS bug workaround *************** */
|
|
|
|
#include <pthread.h>
|
|
|
|
extern pthread_key_t gomp_tls_key;
|
|
|
|
static void *thread_tls_data;
|
|
|
|
#endif
|
2008-11-19 16:28:11 +00:00
|
|
|
/* ************** Exported Poll tests ********************** */
|
2008-01-10 17:38:17 +00:00
|
|
|
|
2009-02-19 23:53:40 +00:00
|
|
|
int ED_operator_regionactive(bContext *C)
|
|
|
|
{
|
|
|
|
if(CTX_wm_window(C)==NULL) return 0;
|
|
|
|
if(CTX_wm_screen(C)==NULL) return 0;
|
|
|
|
if(CTX_wm_region(C)==NULL) return 0;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
int ED_operator_areaactive(bContext *C)
|
|
|
|
{
|
2008-12-18 02:56:48 +00:00
|
|
|
if(CTX_wm_window(C)==NULL) return 0;
|
|
|
|
if(CTX_wm_screen(C)==NULL) return 0;
|
|
|
|
if(CTX_wm_area(C)==NULL) return 0;
|
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
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2008-01-07 18:03:41 +00:00
|
|
|
int ED_operator_screenactive(bContext *C)
|
|
|
|
{
|
2008-12-18 02:56:48 +00:00
|
|
|
if(CTX_wm_window(C)==NULL) return 0;
|
|
|
|
if(CTX_wm_screen(C)==NULL) return 0;
|
2008-01-07 18:03:41 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
/* when mouse is over area-edge */
|
2008-01-10 17:38:17 +00:00
|
|
|
int ED_operator_screen_mainwinactive(bContext *C)
|
2008-01-07 18:03:41 +00:00
|
|
|
{
|
2008-12-18 02:56:48 +00:00
|
|
|
if(CTX_wm_window(C)==NULL) return 0;
|
|
|
|
if(CTX_wm_screen(C)==NULL) return 0;
|
|
|
|
if (CTX_wm_screen(C)->subwinactive!=CTX_wm_screen(C)->mainwin) return 0;
|
2008-01-10 17:38:17 +00:00
|
|
|
return 1;
|
2008-01-07 18:03:41 +00:00
|
|
|
}
|
|
|
|
|
2009-01-01 14:57:04 +00:00
|
|
|
int ED_operator_scene_editable(bContext *C)
|
|
|
|
{
|
|
|
|
Scene *scene= CTX_data_scene(C);
|
|
|
|
if(scene && scene->id.lib==NULL)
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-12-26 19:07:31 +00:00
|
|
|
static int ed_spacetype_test(bContext *C, int type)
|
|
|
|
{
|
|
|
|
if(ED_operator_areaactive(C)) {
|
|
|
|
SpaceLink *sl= (SpaceLink *)CTX_wm_space_data(C);
|
|
|
|
return sl && (sl->spacetype == type);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ED_operator_view3d_active(bContext *C)
|
|
|
|
{
|
|
|
|
return ed_spacetype_test(C, SPACE_VIEW3D);
|
|
|
|
}
|
|
|
|
|
|
|
|
int ED_operator_timeline_active(bContext *C)
|
|
|
|
{
|
|
|
|
return ed_spacetype_test(C, SPACE_TIME);
|
|
|
|
}
|
|
|
|
|
|
|
|
int ED_operator_outliner_active(bContext *C)
|
|
|
|
{
|
2009-03-26 14:05:33 +00:00
|
|
|
return ed_spacetype_test(C, SPACE_OUTLINER);
|
2008-12-26 19:07:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int ED_operator_file_active(bContext *C)
|
|
|
|
{
|
|
|
|
return ed_spacetype_test(C, SPACE_FILE);
|
|
|
|
}
|
|
|
|
|
|
|
|
int ED_operator_action_active(bContext *C)
|
|
|
|
{
|
|
|
|
return ed_spacetype_test(C, SPACE_ACTION);
|
|
|
|
}
|
|
|
|
|
|
|
|
int ED_operator_buttons_active(bContext *C)
|
|
|
|
{
|
|
|
|
return ed_spacetype_test(C, SPACE_BUTS);
|
|
|
|
}
|
|
|
|
|
|
|
|
int ED_operator_node_active(bContext *C)
|
|
|
|
{
|
2009-07-28 16:33:02 +00:00
|
|
|
SpaceNode *snode= CTX_wm_space_node(C);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-07-28 16:33:02 +00:00
|
|
|
if(snode && snode->edittree)
|
|
|
|
return 1;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-02-10 15:51:33 +00:00
|
|
|
return 0;
|
2008-12-26 19:07:31 +00:00
|
|
|
}
|
|
|
|
|
NLA SoC: Operators for 'tweaking' strip actions (TAB-Key for both)
In this commit, I've introduced the mechanism by which actions already referenced by strips used in the NLA can be edited (or 'tweaked'). To use, simply select a strip you wish to edit, and hit that TAB key to start tweaking that strip's action, and hit TAB again once you're done.
What happens when you enter 'tweak mode':
1) The action of the active strip temporarily becomes the 'active action' of the AnimData block. You are now able to edit this in one of the Animation Editors (DopeSheet/Action, Graph Editors) as per normal (i.e. sliding keyframes around, inserting keyframes, etc.). The 'action-line' will therefore get drawn immediately above the active track containing the active strip, so that it's clear that that's what we're editing.
2) All the NLA-tracks (and all the strips within them) that occur after the track that the active strip lived in get disabled while you're in tweakmode. This is equivalent to travelling back to an earlier state in a construction history stack.
3) The active NLA track also gets disabled while in tweakmode, since it would otherwise interfere with the correct functioning of the tweaking for the action of interest.
4) The 'real' active action (i.e. the one displaced by the active strip's action) gets put into temp storage, and will be restored after you exit tweakmode.
5) Any strips which also reference the action being tweaked will get highlighted in red shading to indicate that you may be making some changes to the action which you don't really want to make for the other users too.
Please note though, that this is only a rough prototype of this functionality, with some niceties still to come. i.e.:
* NLA-tracks after the active track should still get drawn above the 'tweaking action line', but perhaps with different appearance?
* Various tools will still need awareness of this to prevent corrupting operations from taking place. How to proceed is still undecided...
* When exiting tweak-mode, the strip the action came from still needs some form of syncing with the modified action... there are a few tricky issues here that will need to be solved
* Evaluation code doesn't totally take this into account yet...
---
Also, fixed a number of bugs with various code (notably selection, and also a few drawing bugs)
2009-06-05 05:18:07 +00:00
|
|
|
// XXX rename
|
2008-12-26 19:07:31 +00:00
|
|
|
int ED_operator_ipo_active(bContext *C)
|
|
|
|
{
|
|
|
|
return ed_spacetype_test(C, SPACE_IPO);
|
|
|
|
}
|
|
|
|
|
|
|
|
int ED_operator_sequencer_active(bContext *C)
|
|
|
|
{
|
|
|
|
return ed_spacetype_test(C, SPACE_SEQ);
|
|
|
|
}
|
|
|
|
|
2009-02-04 17:40:50 +00:00
|
|
|
int ED_operator_image_active(bContext *C)
|
|
|
|
{
|
|
|
|
return ed_spacetype_test(C, SPACE_IMAGE);
|
|
|
|
}
|
|
|
|
|
NLA SoC: Operators for 'tweaking' strip actions (TAB-Key for both)
In this commit, I've introduced the mechanism by which actions already referenced by strips used in the NLA can be edited (or 'tweaked'). To use, simply select a strip you wish to edit, and hit that TAB key to start tweaking that strip's action, and hit TAB again once you're done.
What happens when you enter 'tweak mode':
1) The action of the active strip temporarily becomes the 'active action' of the AnimData block. You are now able to edit this in one of the Animation Editors (DopeSheet/Action, Graph Editors) as per normal (i.e. sliding keyframes around, inserting keyframes, etc.). The 'action-line' will therefore get drawn immediately above the active track containing the active strip, so that it's clear that that's what we're editing.
2) All the NLA-tracks (and all the strips within them) that occur after the track that the active strip lived in get disabled while you're in tweakmode. This is equivalent to travelling back to an earlier state in a construction history stack.
3) The active NLA track also gets disabled while in tweakmode, since it would otherwise interfere with the correct functioning of the tweaking for the action of interest.
4) The 'real' active action (i.e. the one displaced by the active strip's action) gets put into temp storage, and will be restored after you exit tweakmode.
5) Any strips which also reference the action being tweaked will get highlighted in red shading to indicate that you may be making some changes to the action which you don't really want to make for the other users too.
Please note though, that this is only a rough prototype of this functionality, with some niceties still to come. i.e.:
* NLA-tracks after the active track should still get drawn above the 'tweaking action line', but perhaps with different appearance?
* Various tools will still need awareness of this to prevent corrupting operations from taking place. How to proceed is still undecided...
* When exiting tweak-mode, the strip the action came from still needs some form of syncing with the modified action... there are a few tricky issues here that will need to be solved
* Evaluation code doesn't totally take this into account yet...
---
Also, fixed a number of bugs with various code (notably selection, and also a few drawing bugs)
2009-06-05 05:18:07 +00:00
|
|
|
int ED_operator_nla_active(bContext *C)
|
|
|
|
{
|
|
|
|
return ed_spacetype_test(C, SPACE_NLA);
|
|
|
|
}
|
|
|
|
|
2009-06-16 13:09:36 +00:00
|
|
|
int ED_operator_logic_active(bContext *C)
|
|
|
|
{
|
|
|
|
return ed_spacetype_test(C, SPACE_LOGIC);
|
|
|
|
}
|
|
|
|
|
2009-01-01 13:15:35 +00:00
|
|
|
int ED_operator_object_active(bContext *C)
|
|
|
|
{
|
|
|
|
return NULL != CTX_data_active_object(C);
|
|
|
|
}
|
|
|
|
|
2009-12-04 06:33:01 +00:00
|
|
|
int ED_operator_object_active_editable(bContext *C)
|
|
|
|
{
|
|
|
|
Object *ob=CTX_data_active_object(C);
|
|
|
|
return ((ob != NULL) && !(ob->id.lib));
|
|
|
|
}
|
|
|
|
|
2009-01-01 13:15:35 +00:00
|
|
|
int ED_operator_editmesh(bContext *C)
|
|
|
|
{
|
|
|
|
Object *obedit= CTX_data_edit_object(C);
|
|
|
|
if(obedit && obedit->type==OB_MESH)
|
|
|
|
return NULL != ((Mesh *)obedit->data)->edit_mesh;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-12-06 17:38:39 +00:00
|
|
|
int ED_operator_editmesh_view3d(bContext *C)
|
|
|
|
{
|
|
|
|
return ED_operator_editmesh(C) && ED_operator_view3d_active(C);
|
|
|
|
}
|
|
|
|
|
2009-02-01 18:07:02 +00:00
|
|
|
int ED_operator_editarmature(bContext *C)
|
|
|
|
{
|
|
|
|
Object *obedit= CTX_data_edit_object(C);
|
|
|
|
if(obedit && obedit->type==OB_ARMATURE)
|
|
|
|
return NULL != ((bArmature *)obedit->data)->edbo;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ED_operator_posemode(bContext *C)
|
|
|
|
{
|
|
|
|
Object *obact= CTX_data_active_object(C);
|
2009-02-09 01:27:44 +00:00
|
|
|
Object *obedit= CTX_data_edit_object(C);
|
|
|
|
|
|
|
|
if ((obact != obedit) && (obact) && (obact->type==OB_ARMATURE))
|
2009-08-16 03:24:23 +00:00
|
|
|
return (obact->mode & OB_MODE_POSE)!=0;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-02-01 18:07:02 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
int ED_operator_uvedit(bContext *C)
|
|
|
|
{
|
|
|
|
Object *obedit= CTX_data_edit_object(C);
|
|
|
|
EditMesh *em= NULL;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
if(obedit && obedit->type==OB_MESH)
|
2009-04-11 08:26:51 +00:00
|
|
|
em= BKE_mesh_get_editmesh((Mesh *)obedit->data);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-03-30 07:28:37 +00:00
|
|
|
if(em && (em->faces.first) && (CustomData_has_layer(&em->fdata, CD_MTFACE))) {
|
2009-04-11 08:26:51 +00:00
|
|
|
BKE_mesh_end_editmesh(obedit->data, em);
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
return 1;
|
2009-03-30 07:28:37 +00:00
|
|
|
}
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-06-02 18:10:06 +00:00
|
|
|
if(obedit)
|
|
|
|
BKE_mesh_end_editmesh(obedit->data, em);
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-02-07 01:27:46 +00:00
|
|
|
int ED_operator_uvmap(bContext *C)
|
|
|
|
{
|
|
|
|
Object *obedit= CTX_data_edit_object(C);
|
|
|
|
EditMesh *em= NULL;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-02-07 01:27:46 +00:00
|
|
|
if(obedit && obedit->type==OB_MESH)
|
2009-04-11 08:26:51 +00:00
|
|
|
em= BKE_mesh_get_editmesh((Mesh *)obedit->data);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-03-30 07:28:37 +00:00
|
|
|
if(em && (em->faces.first)) {
|
2009-04-11 08:26:51 +00:00
|
|
|
BKE_mesh_end_editmesh(obedit->data, em);
|
2009-02-07 01:27:46 +00:00
|
|
|
return 1;
|
2009-03-30 07:28:37 +00:00
|
|
|
}
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-06-02 16:40:15 +00:00
|
|
|
if(obedit)
|
|
|
|
BKE_mesh_end_editmesh(obedit->data, em);
|
2009-02-07 01:27:46 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2.5: Most curve/surface editmode operators back:
* Hide, Reveal
* Separate, Duplicate, Delete
* Set Weight, Set Radius, Set Spline Type, Set Handle Type, Set Smooth
* Tilt, Clear Tilt
* Smooth, Smooth Radius
* De(select) First, De(select) Last, De(select) All, Select Inverse,
Select Linked, Select Control Point Row, Select Next, Select Previous,
Select More, Select Less, Select Random, Select Every Nth
* Switch Direction, Subdivide, Make Segment, Spin, Extrude, Toggle Cyclic
* Specials Menu
Not working correct yet:
* Add Vertex (ctrl click)
* Add Menu
2009-02-12 22:12:21 +00:00
|
|
|
int ED_operator_editsurfcurve(bContext *C)
|
2009-01-01 13:15:35 +00:00
|
|
|
{
|
|
|
|
Object *obedit= CTX_data_edit_object(C);
|
2.5: Most curve/surface editmode operators back:
* Hide, Reveal
* Separate, Duplicate, Delete
* Set Weight, Set Radius, Set Spline Type, Set Handle Type, Set Smooth
* Tilt, Clear Tilt
* Smooth, Smooth Radius
* De(select) First, De(select) Last, De(select) All, Select Inverse,
Select Linked, Select Control Point Row, Select Next, Select Previous,
Select More, Select Less, Select Random, Select Every Nth
* Switch Direction, Subdivide, Make Segment, Spin, Extrude, Toggle Cyclic
* Specials Menu
Not working correct yet:
* Add Vertex (ctrl click)
* Add Menu
2009-02-12 22:12:21 +00:00
|
|
|
if(obedit && ELEM(obedit->type, OB_CURVE, OB_SURF))
|
|
|
|
return NULL != ((Curve *)obedit->data)->editnurb;
|
2009-01-01 13:15:35 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2008-12-26 19:07:31 +00:00
|
|
|
|
|
|
|
|
2.5: Most curve/surface editmode operators back:
* Hide, Reveal
* Separate, Duplicate, Delete
* Set Weight, Set Radius, Set Spline Type, Set Handle Type, Set Smooth
* Tilt, Clear Tilt
* Smooth, Smooth Radius
* De(select) First, De(select) Last, De(select) All, Select Inverse,
Select Linked, Select Control Point Row, Select Next, Select Previous,
Select More, Select Less, Select Random, Select Every Nth
* Switch Direction, Subdivide, Make Segment, Spin, Extrude, Toggle Cyclic
* Specials Menu
Not working correct yet:
* Add Vertex (ctrl click)
* Add Menu
2009-02-12 22:12:21 +00:00
|
|
|
int ED_operator_editcurve(bContext *C)
|
|
|
|
{
|
|
|
|
Object *obedit= CTX_data_edit_object(C);
|
|
|
|
if(obedit && obedit->type==OB_CURVE)
|
|
|
|
return NULL != ((Curve *)obedit->data)->editnurb;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ED_operator_editsurf(bContext *C)
|
|
|
|
{
|
|
|
|
Object *obedit= CTX_data_edit_object(C);
|
|
|
|
if(obedit && obedit->type==OB_SURF)
|
|
|
|
return NULL != ((Curve *)obedit->data)->editnurb;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2.5: Text edit mode operators back. Took me a while getting
them nicely repeatable, and splitting up the big edit_text
operator into individual operator so it's all nicely scriptable,
documented, configurable, etc..
* Insert Text, Line Break, Insert Lorem
* Toggle Case, Set Case, Toggle Style, Set Style, Set Material
* Copy Text, Cut Text, Paste Text, Paste File, Paste Buffer
* Move, Move Select, Delete
* Change Spacing, Change Character
Notes
* Text (datablock) to Object doesn't work yet, will need to
implement text editor context for that.
* Some shortcut keys don't work because screen/wm overrides them,
ctrl+x, ctrl+left/right. That override goes top down which works
well for some cases, but here we need to override in the other
direction.
* There's no unicode support in RNA, or the user interface code
for that matter, but text strings can contain these characters.
At the moment it stores a UTF-8 string in char arrays, which is
supposed to be nicely compatible with ascii. Seems reasonable to
add support for UTF-8 in the interface code, python bindings, ..
eventually?
2009-02-17 19:55:20 +00:00
|
|
|
int ED_operator_editfont(bContext *C)
|
|
|
|
{
|
|
|
|
Object *obedit= CTX_data_edit_object(C);
|
|
|
|
if(obedit && obedit->type==OB_FONT)
|
|
|
|
return NULL != ((Curve *)obedit->data)->editfont;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-07-03 15:23:33 +00:00
|
|
|
int ED_operator_editlattice(bContext *C)
|
|
|
|
{
|
|
|
|
Object *obedit= CTX_data_edit_object(C);
|
|
|
|
if(obedit && obedit->type==OB_LATTICE)
|
|
|
|
return NULL != ((Lattice *)obedit->data)->editlatt;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-07-29 12:35:09 +00:00
|
|
|
int ED_operator_editmball(bContext *C)
|
|
|
|
{
|
|
|
|
Object *obedit= CTX_data_edit_object(C);
|
|
|
|
if(obedit && obedit->type==OB_MBALL)
|
|
|
|
return NULL != ((MetaBall *)obedit->data)->editelems;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
/* *************************** action zone operator ************************** */
|
|
|
|
|
|
|
|
/* operator state vars used:
|
2009-12-10 09:25:30 +00:00
|
|
|
none
|
|
|
|
|
|
|
|
functions:
|
|
|
|
|
|
|
|
apply() set actionzone event
|
|
|
|
|
|
|
|
exit() free customdata
|
|
|
|
|
|
|
|
callbacks:
|
|
|
|
|
|
|
|
exec() never used
|
|
|
|
|
|
|
|
invoke() check if in zone
|
|
|
|
add customdata, put mouseco and area in it
|
|
|
|
add modal handler
|
|
|
|
|
|
|
|
modal() accept modal events while doing it
|
|
|
|
call apply() with gesture info, active window, nonactive window
|
|
|
|
call exit() and remove handler when LMB confirm
|
|
|
|
|
|
|
|
*/
|
2008-11-19 16:28:11 +00:00
|
|
|
|
|
|
|
typedef struct sActionzoneData {
|
|
|
|
ScrArea *sa1, *sa2;
|
|
|
|
AZone *az;
|
2009-03-05 23:19:44 +00:00
|
|
|
int x, y, gesture_dir, modifier;
|
2008-11-19 16:28:11 +00:00
|
|
|
} sActionzoneData;
|
|
|
|
|
|
|
|
/* used by other operators too */
|
|
|
|
static ScrArea *screen_areahascursor(bScreen *scr, int x, int y)
|
|
|
|
{
|
|
|
|
ScrArea *sa= NULL;
|
|
|
|
sa= scr->areabase.first;
|
|
|
|
while(sa) {
|
|
|
|
if(BLI_in_rcti(&sa->totrct, x, y)) break;
|
|
|
|
sa= sa->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
return sa;
|
|
|
|
}
|
|
|
|
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
/* quick poll to save operators to be created and handled */
|
|
|
|
static int actionzone_area_poll(bContext *C)
|
|
|
|
{
|
|
|
|
wmWindow *win= CTX_wm_window(C);
|
|
|
|
ScrArea *sa= CTX_wm_area(C);
|
|
|
|
|
|
|
|
if(sa && win) {
|
|
|
|
AZone *az;
|
|
|
|
int x= win->eventstate->x;
|
|
|
|
int y= win->eventstate->y;
|
|
|
|
|
|
|
|
for(az= sa->actionzones.first; az; az= az->next)
|
|
|
|
if(BLI_in_rcti(&az->rect, x, y))
|
2009-12-10 09:25:30 +00:00
|
|
|
return 1;
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2008-11-19 16:28:11 +00:00
|
|
|
|
2008-12-15 16:54:47 +00:00
|
|
|
AZone *is_in_area_actionzone(ScrArea *sa, int x, int y)
|
2008-11-19 16:28:11 +00:00
|
|
|
{
|
|
|
|
AZone *az= NULL;
|
|
|
|
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
for(az= sa->actionzones.first; az; az= az->next) {
|
|
|
|
if(BLI_in_rcti(&az->rect, x, y)) {
|
|
|
|
if(az->type == AZONE_AREA) {
|
2009-11-10 20:43:45 +00:00
|
|
|
if(isect_point_tri_v2_int(az->x1, az->y1, az->x2, az->y2, x, y))
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if(az->type == AZONE_REGION) {
|
2009-09-12 23:56:30 +00:00
|
|
|
break;
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
}
|
2008-11-19 16:28:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return az;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void actionzone_exit(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
if(op->customdata)
|
|
|
|
MEM_freeN(op->customdata);
|
|
|
|
op->customdata= NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* send EVT_ACTIONZONE event */
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
static void actionzone_apply(bContext *C, wmOperator *op, int type)
|
2008-11-19 16:28:11 +00:00
|
|
|
{
|
|
|
|
wmEvent event;
|
2008-12-18 02:56:48 +00:00
|
|
|
wmWindow *win= CTX_wm_window(C);
|
2009-03-05 23:19:44 +00:00
|
|
|
sActionzoneData *sad= op->customdata;
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
|
2009-03-05 23:19:44 +00:00
|
|
|
sad->modifier= RNA_int_get(op->ptr, "modifier");
|
2008-11-19 16:28:11 +00:00
|
|
|
|
2008-12-18 02:56:48 +00:00
|
|
|
event= *(win->eventstate); /* XXX huh huh? make api call */
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
if(type==AZONE_AREA)
|
|
|
|
event.type= EVT_ACTIONZONE_AREA;
|
|
|
|
else
|
|
|
|
event.type= EVT_ACTIONZONE_REGION;
|
2008-11-19 16:28:11 +00:00
|
|
|
event.customdata= op->customdata;
|
|
|
|
event.customdatafree= TRUE;
|
|
|
|
op->customdata= NULL;
|
|
|
|
|
2008-12-18 02:56:48 +00:00
|
|
|
wm_event_add(win, &event);
|
2008-11-19 16:28:11 +00:00
|
|
|
}
|
|
|
|
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
static int actionzone_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
|
|
|
{
|
|
|
|
AZone *az= is_in_area_actionzone(CTX_wm_area(C), event->x, event->y);
|
|
|
|
sActionzoneData *sad;
|
|
|
|
|
|
|
|
/* quick escape */
|
|
|
|
if(az==NULL)
|
|
|
|
return OPERATOR_PASS_THROUGH;
|
|
|
|
|
|
|
|
/* ok we do the actionzone */
|
|
|
|
sad= op->customdata= MEM_callocN(sizeof(sActionzoneData), "sActionzoneData");
|
|
|
|
sad->sa1= CTX_wm_area(C);
|
|
|
|
sad->az= az;
|
|
|
|
sad->x= event->x; sad->y= event->y;
|
|
|
|
|
|
|
|
/* region azone directly reacts on mouse clicks */
|
|
|
|
if(sad->az->type==AZONE_REGION) {
|
|
|
|
actionzone_apply(C, op, AZONE_REGION);
|
|
|
|
actionzone_exit(C, op);
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* add modal handler */
|
2009-09-18 12:43:36 +00:00
|
|
|
WM_event_add_modal_handler(C, op);
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
|
|
|
|
return OPERATOR_RUNNING_MODAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
static int actionzone_modal(bContext *C, wmOperator *op, wmEvent *event)
|
|
|
|
{
|
|
|
|
sActionzoneData *sad= op->customdata;
|
|
|
|
int deltax, deltay;
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
int mindelta= sad->az->type==AZONE_REGION?1:12;
|
2008-11-19 16:28:11 +00:00
|
|
|
|
|
|
|
switch(event->type) {
|
|
|
|
case MOUSEMOVE:
|
|
|
|
/* calculate gesture direction */
|
|
|
|
deltax= (event->x - sad->x);
|
|
|
|
deltay= (event->y - sad->y);
|
|
|
|
|
|
|
|
if(deltay > ABS(deltax))
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
sad->gesture_dir= 'n';
|
2008-11-19 16:28:11 +00:00
|
|
|
else if(deltax > ABS(deltay))
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
sad->gesture_dir= 'e';
|
2008-11-19 16:28:11 +00:00
|
|
|
else if(deltay < -ABS(deltax))
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
sad->gesture_dir= 's';
|
2008-11-19 16:28:11 +00:00
|
|
|
else
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
sad->gesture_dir= 'w';
|
2008-11-19 16:28:11 +00:00
|
|
|
|
|
|
|
/* gesture is large enough? */
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
if(ABS(deltax) > mindelta || ABS(deltay) > mindelta) {
|
2008-11-19 16:28:11 +00:00
|
|
|
|
|
|
|
/* second area, for join */
|
2008-12-18 02:56:48 +00:00
|
|
|
sad->sa2= screen_areahascursor(CTX_wm_screen(C), event->x, event->y);
|
2008-11-19 16:28:11 +00:00
|
|
|
/* apply sends event */
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
actionzone_apply(C, op, sad->az->type);
|
2008-11-19 16:28:11 +00:00
|
|
|
actionzone_exit(C, op);
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
2009-12-10 09:25:30 +00:00
|
|
|
break;
|
2008-11-19 16:28:11 +00:00
|
|
|
case ESCKEY:
|
|
|
|
actionzone_exit(C, op);
|
|
|
|
return OPERATOR_CANCELLED;
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
case LEFTMOUSE:
|
|
|
|
actionzone_exit(C, op);
|
|
|
|
return OPERATOR_CANCELLED;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return OPERATOR_RUNNING_MODAL;
|
|
|
|
}
|
|
|
|
|
2009-07-24 12:43:59 +00:00
|
|
|
static void SCREEN_OT_actionzone(wmOperatorType *ot)
|
2008-11-19 16:28:11 +00:00
|
|
|
{
|
|
|
|
/* identifiers */
|
|
|
|
ot->name= "Handle area action zones";
|
2009-10-07 12:19:47 +00:00
|
|
|
ot->description= "Handle area action zones for mouse actions/gestures.";
|
2008-12-26 11:11:21 +00:00
|
|
|
ot->idname= "SCREEN_OT_actionzone";
|
2008-11-19 16:28:11 +00:00
|
|
|
|
|
|
|
ot->invoke= actionzone_invoke;
|
|
|
|
ot->modal= actionzone_modal;
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
ot->poll= actionzone_area_poll;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-07-11 14:51:13 +00:00
|
|
|
ot->flag= OPTYPE_BLOCKING;
|
|
|
|
|
2009-03-05 23:19:44 +00:00
|
|
|
RNA_def_int(ot->srna, "modifier", 0, 0, 2, "modifier", "modifier state", 0, 2);
|
2008-11-19 16:28:11 +00:00
|
|
|
}
|
|
|
|
|
2009-03-11 20:22:06 +00:00
|
|
|
/* ************** swap area operator *********************************** */
|
2008-11-19 16:28:11 +00:00
|
|
|
|
2009-03-11 20:22:06 +00:00
|
|
|
/* operator state vars used:
|
2009-12-10 09:25:30 +00:00
|
|
|
sa1 start area
|
|
|
|
sa2 area to swap with
|
|
|
|
|
|
|
|
functions:
|
|
|
|
|
|
|
|
init() set custom data for operator, based on actionzone event custom data
|
|
|
|
|
|
|
|
cancel() cancel the operator
|
|
|
|
|
|
|
|
exit() cleanup, send notifier
|
|
|
|
|
|
|
|
callbacks:
|
|
|
|
|
|
|
|
invoke() gets called on shift+lmb drag in actionzone
|
|
|
|
call init(), add handler
|
|
|
|
|
|
|
|
modal() accept modal events while doing it
|
|
|
|
|
|
|
|
*/
|
2009-03-11 20:22:06 +00:00
|
|
|
|
|
|
|
typedef struct sAreaSwapData {
|
|
|
|
ScrArea *sa1, *sa2;
|
|
|
|
} sAreaSwapData;
|
|
|
|
|
|
|
|
static int area_swap_init(bContext *C, wmOperator *op, wmEvent *event)
|
|
|
|
{
|
|
|
|
sAreaSwapData *sd= NULL;
|
|
|
|
sActionzoneData *sad= event->customdata;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-03-11 20:22:06 +00:00
|
|
|
if(sad==NULL || sad->sa1==NULL)
|
2009-12-10 09:25:30 +00:00
|
|
|
return 0;
|
2009-03-11 20:22:06 +00:00
|
|
|
|
|
|
|
sd= MEM_callocN(sizeof(sAreaSwapData), "sAreaSwapData");
|
|
|
|
sd->sa1= sad->sa1;
|
|
|
|
sd->sa2= sad->sa2;
|
|
|
|
op->customdata= sd;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-03-11 20:22:06 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void area_swap_exit(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
if(op->customdata)
|
|
|
|
MEM_freeN(op->customdata);
|
|
|
|
op->customdata= NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int area_swap_cancel(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
area_swap_exit(C, op);
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int area_swap_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
|
|
|
{
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-03-11 20:22:06 +00:00
|
|
|
if(!area_swap_init(C, op, event))
|
|
|
|
return OPERATOR_PASS_THROUGH;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-03-11 20:22:06 +00:00
|
|
|
/* add modal handler */
|
|
|
|
WM_cursor_modal(CTX_wm_window(C), BC_SWAPAREA_CURSOR);
|
2009-09-18 12:43:36 +00:00
|
|
|
WM_event_add_modal_handler(C, op);
|
2009-03-11 20:22:06 +00:00
|
|
|
|
|
|
|
return OPERATOR_RUNNING_MODAL;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-03-11 20:22:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int area_swap_modal(bContext *C, wmOperator *op, wmEvent *event)
|
|
|
|
{
|
|
|
|
sActionzoneData *sad= op->customdata;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-03-11 20:22:06 +00:00
|
|
|
switch(event->type) {
|
|
|
|
case MOUSEMOVE:
|
|
|
|
/* second area, for join */
|
|
|
|
sad->sa2= screen_areahascursor(CTX_wm_screen(C), event->x, event->y);
|
|
|
|
break;
|
|
|
|
case LEFTMOUSE: /* release LMB */
|
2009-09-24 10:35:04 +00:00
|
|
|
if(event->val==KM_RELEASE) {
|
2009-09-14 20:48:05 +00:00
|
|
|
if(!sad->sa2 || sad->sa1 == sad->sa2) {
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-03-11 20:22:06 +00:00
|
|
|
return area_swap_cancel(C, op);
|
|
|
|
}
|
|
|
|
ED_area_swapspace(C, sad->sa1, sad->sa2);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-03-11 20:22:06 +00:00
|
|
|
area_swap_exit(C, op);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-03-11 20:22:06 +00:00
|
|
|
WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-03-11 20:22:06 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
break;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-03-11 20:22:06 +00:00
|
|
|
case ESCKEY:
|
|
|
|
return area_swap_cancel(C, op);
|
|
|
|
}
|
|
|
|
return OPERATOR_RUNNING_MODAL;
|
|
|
|
}
|
|
|
|
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
static void SCREEN_OT_area_swap(wmOperatorType *ot)
|
2009-03-11 20:22:06 +00:00
|
|
|
{
|
|
|
|
ot->name= "Swap areas";
|
2009-10-07 12:19:47 +00:00
|
|
|
ot->description= "Swap selected areas screen positions.";
|
2009-03-11 20:22:06 +00:00
|
|
|
ot->idname= "SCREEN_OT_area_swap";
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-03-11 20:22:06 +00:00
|
|
|
ot->invoke= area_swap_invoke;
|
|
|
|
ot->modal= area_swap_modal;
|
|
|
|
ot->poll= ED_operator_areaactive;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-07-11 14:51:13 +00:00
|
|
|
ot->flag= OPTYPE_BLOCKING;
|
2009-03-11 20:22:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* *********** Duplicate area as new window operator ****************** */
|
2008-11-19 16:28:11 +00:00
|
|
|
|
|
|
|
/* operator callback */
|
2009-03-11 20:22:06 +00:00
|
|
|
static int area_dupli_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
2008-11-19 16:28:11 +00:00
|
|
|
{
|
2008-12-18 02:56:48 +00:00
|
|
|
wmWindow *newwin, *win;
|
|
|
|
bScreen *newsc, *sc;
|
|
|
|
ScrArea *sa;
|
2008-11-19 16:28:11 +00:00
|
|
|
rcti rect;
|
|
|
|
|
2008-12-18 02:56:48 +00:00
|
|
|
win= CTX_wm_window(C);
|
|
|
|
sc= CTX_wm_screen(C);
|
2009-06-04 14:32:10 +00:00
|
|
|
sa= CTX_wm_area(C);
|
|
|
|
|
|
|
|
/* XXX hrmf! */
|
|
|
|
if(event->type==EVT_ACTIONZONE_AREA) {
|
|
|
|
sActionzoneData *sad= event->customdata;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-06-04 14:32:10 +00:00
|
|
|
if(sad==NULL)
|
|
|
|
return OPERATOR_PASS_THROUGH;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-06-04 14:32:10 +00:00
|
|
|
sa= sad->sa1;
|
|
|
|
}
|
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
/* poll() checks area context, but we don't accept full-area windows */
|
2009-03-11 20:22:06 +00:00
|
|
|
if(sc->full != SCREENNORMAL) {
|
2009-06-04 14:32:10 +00:00
|
|
|
if(event->type==EVT_ACTIONZONE_AREA)
|
|
|
|
actionzone_exit(C, op);
|
2008-11-19 16:28:11 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
2009-03-11 20:22:06 +00:00
|
|
|
}
|
2008-11-19 16:28:11 +00:00
|
|
|
|
|
|
|
/* adds window to WM */
|
2008-12-18 02:56:48 +00:00
|
|
|
rect= sa->totrct;
|
|
|
|
BLI_translate_rcti(&rect, win->posx, win->posy);
|
|
|
|
newwin= WM_window_open(C, &rect);
|
2008-11-19 16:28:11 +00:00
|
|
|
|
|
|
|
/* allocs new screen and adds to newly created window, using window size */
|
2009-07-24 12:43:59 +00:00
|
|
|
newsc= ED_screen_add(newwin, CTX_data_scene(C), sc->id.name+2);
|
2008-12-18 19:41:36 +00:00
|
|
|
newwin->screen= newsc;
|
2008-11-19 16:28:11 +00:00
|
|
|
|
|
|
|
/* copy area to new screen */
|
2008-12-18 02:56:48 +00:00
|
|
|
area_copy_data((ScrArea *)newsc->areabase.first, sa, 0);
|
2008-11-19 16:28:11 +00:00
|
|
|
|
|
|
|
/* screen, areas init */
|
2008-12-27 16:09:56 +00:00
|
|
|
WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-06-04 14:32:10 +00:00
|
|
|
if(event->type==EVT_ACTIONZONE_AREA)
|
|
|
|
actionzone_exit(C, op);
|
2008-11-19 16:28:11 +00:00
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
static void SCREEN_OT_area_dupli(wmOperatorType *ot)
|
2008-11-19 16:28:11 +00:00
|
|
|
{
|
2009-03-05 23:19:44 +00:00
|
|
|
ot->name= "Duplicate Area into New Window";
|
2009-10-07 12:19:47 +00:00
|
|
|
ot->description= "Duplicate selected area into new window.";
|
2009-03-11 20:22:06 +00:00
|
|
|
ot->idname= "SCREEN_OT_area_dupli";
|
2008-11-19 16:28:11 +00:00
|
|
|
|
2009-03-11 20:22:06 +00:00
|
|
|
ot->invoke= area_dupli_invoke;
|
2008-11-19 16:28:11 +00:00
|
|
|
ot->poll= ED_operator_areaactive;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ************** move area edge operator *********************************** */
|
|
|
|
|
|
|
|
/* operator state vars used:
|
2009-12-10 09:25:30 +00:00
|
|
|
x, y mouse coord near edge
|
|
|
|
delta movement of edge
|
|
|
|
|
|
|
|
functions:
|
|
|
|
|
|
|
|
init() set default property values, find edge based on mouse coords, test
|
|
|
|
if the edge can be moved, select edges, calculate min and max movement
|
|
|
|
|
|
|
|
apply() apply delta on selection
|
|
|
|
|
|
|
|
exit() cleanup, send notifier
|
|
|
|
|
|
|
|
cancel() cancel moving
|
|
|
|
|
|
|
|
callbacks:
|
|
|
|
|
|
|
|
exec() execute without any user interaction, based on properties
|
|
|
|
call init(), apply(), exit()
|
|
|
|
|
|
|
|
invoke() gets called on mouse click near edge
|
|
|
|
call init(), add handler
|
|
|
|
|
|
|
|
modal() accept modal events while doing it
|
|
|
|
call apply() with delta motion
|
|
|
|
call exit() and remove handler
|
|
|
|
|
|
|
|
*/
|
2008-11-19 16:28:11 +00:00
|
|
|
|
|
|
|
typedef struct sAreaMoveData {
|
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
|
|
|
int bigger, smaller, origval, step;
|
2008-11-19 16:28:11 +00:00
|
|
|
char dir;
|
|
|
|
} sAreaMoveData;
|
|
|
|
|
|
|
|
/* helper call to move area-edge, sets limits */
|
|
|
|
static void area_move_set_limits(bScreen *sc, int dir, int *bigger, int *smaller)
|
|
|
|
{
|
|
|
|
ScrArea *sa;
|
|
|
|
|
|
|
|
/* we check all areas and test for free space with MINSIZE */
|
|
|
|
*bigger= *smaller= 100000;
|
|
|
|
|
|
|
|
for(sa= sc->areabase.first; sa; sa= sa->next) {
|
|
|
|
if(dir=='h') {
|
|
|
|
int y1= sa->v2->vec.y - sa->v1->vec.y-AREAMINY;
|
|
|
|
|
|
|
|
/* if top or down edge selected, test height */
|
|
|
|
if(sa->v1->flag && sa->v4->flag)
|
|
|
|
*bigger= MIN2(*bigger, y1);
|
|
|
|
else if(sa->v2->flag && sa->v3->flag)
|
|
|
|
*smaller= MIN2(*smaller, y1);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
int x1= sa->v4->vec.x - sa->v1->vec.x-AREAMINX;
|
|
|
|
|
|
|
|
/* if left or right edge selected, test width */
|
|
|
|
if(sa->v1->flag && sa->v2->flag)
|
|
|
|
*bigger= MIN2(*bigger, x1);
|
|
|
|
else if(sa->v3->flag && sa->v4->flag)
|
|
|
|
*smaller= MIN2(*smaller, x1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* validate selection inside screen, set variables OK */
|
|
|
|
/* return 0: init failed */
|
|
|
|
static int area_move_init (bContext *C, wmOperator *op)
|
|
|
|
{
|
2008-12-18 02:56:48 +00:00
|
|
|
bScreen *sc= CTX_wm_screen(C);
|
2008-11-19 16:28:11 +00:00
|
|
|
ScrEdge *actedge;
|
|
|
|
sAreaMoveData *md;
|
|
|
|
int x, y;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
/* required properties */
|
2008-11-24 15:51:55 +00:00
|
|
|
x= RNA_int_get(op->ptr, "x");
|
|
|
|
y= RNA_int_get(op->ptr, "y");
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
/* setup */
|
2008-12-18 02:56:48 +00:00
|
|
|
actedge= screen_find_active_scredge(sc, x, y);
|
2008-11-19 16:28:11 +00:00
|
|
|
if(actedge==NULL) return 0;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
md= MEM_callocN(sizeof(sAreaMoveData), "sAreaMoveData");
|
|
|
|
op->customdata= md;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
md->dir= scredge_is_horizontal(actedge)?'h':'v';
|
|
|
|
if(md->dir=='h') md->origval= actedge->v1->vec.y;
|
|
|
|
else md->origval= actedge->v1->vec.x;
|
|
|
|
|
2008-12-18 02:56:48 +00:00
|
|
|
select_connected_scredge(sc, actedge);
|
2008-11-19 16:28:11 +00:00
|
|
|
/* now all vertices with 'flag==1' are the ones that can be moved. */
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2008-12-18 02:56:48 +00:00
|
|
|
area_move_set_limits(sc, md->dir, &md->bigger, &md->smaller);
|
2008-11-19 16:28:11 +00:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* moves selected screen edge amount of delta, used by split & move */
|
|
|
|
static void area_move_apply_do(bContext *C, int origval, int delta, int dir, int bigger, int smaller)
|
|
|
|
{
|
2008-12-18 02:56:48 +00:00
|
|
|
wmWindow *win= CTX_wm_window(C);
|
|
|
|
bScreen *sc= CTX_wm_screen(C);
|
2008-11-19 16:28:11 +00:00
|
|
|
ScrVert *v1;
|
|
|
|
|
|
|
|
delta= CLAMPIS(delta, -smaller, bigger);
|
|
|
|
|
2008-12-18 02:56:48 +00:00
|
|
|
for (v1= sc->vertbase.first; v1; v1= v1->next) {
|
2008-11-19 16:28:11 +00:00
|
|
|
if (v1->flag) {
|
|
|
|
/* that way a nice AREAGRID */
|
2008-12-18 02:56:48 +00:00
|
|
|
if((dir=='v') && v1->vec.x>0 && v1->vec.x<win->sizex-1) {
|
2008-11-19 16:28:11 +00:00
|
|
|
v1->vec.x= origval + delta;
|
|
|
|
if(delta != bigger && delta != -smaller) v1->vec.x-= (v1->vec.x % AREAGRID);
|
|
|
|
}
|
2008-12-18 02:56:48 +00:00
|
|
|
if((dir=='h') && v1->vec.y>0 && v1->vec.y<win->sizey-1) {
|
2008-11-19 16:28:11 +00:00
|
|
|
v1->vec.y= origval + delta;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
v1->vec.y+= AREAGRID-1;
|
|
|
|
v1->vec.y-= (v1->vec.y % AREAGRID);
|
|
|
|
|
|
|
|
/* prevent too small top header */
|
2008-12-18 02:56:48 +00:00
|
|
|
if(v1->vec.y > win->sizey-AREAMINY)
|
|
|
|
v1->vec.y= win->sizey-AREAMINY;
|
2008-11-19 16:28:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2008-12-27 16:09:56 +00:00
|
|
|
WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL);
|
2008-11-19 16:28:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void area_move_apply(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
sAreaMoveData *md= op->customdata;
|
|
|
|
int delta;
|
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
delta= RNA_int_get(op->ptr, "delta");
|
2008-11-19 16:28:11 +00:00
|
|
|
area_move_apply_do(C, md->origval, delta, md->dir, md->bigger, md->smaller);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void area_move_exit(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
if(op->customdata)
|
|
|
|
MEM_freeN(op->customdata);
|
|
|
|
op->customdata= NULL;
|
|
|
|
|
|
|
|
/* this makes sure aligned edges will result in aligned grabbing */
|
2008-12-18 02:56:48 +00:00
|
|
|
removedouble_scrverts(CTX_wm_screen(C));
|
|
|
|
removedouble_scredges(CTX_wm_screen(C));
|
2008-11-19 16:28:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int area_move_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
if(!area_move_init(C, op))
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
|
|
area_move_apply(C, op);
|
|
|
|
area_move_exit(C, op);
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* interaction callback */
|
|
|
|
static int area_move_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
|
|
|
{
|
2008-11-24 15:51:55 +00:00
|
|
|
RNA_int_set(op->ptr, "x", event->x);
|
|
|
|
RNA_int_set(op->ptr, "y", event->y);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
if(!area_move_init(C, op))
|
|
|
|
return OPERATOR_PASS_THROUGH;
|
|
|
|
|
|
|
|
/* add temp handler */
|
2009-09-18 12:43:36 +00:00
|
|
|
WM_event_add_modal_handler(C, op);
|
2008-11-19 16:28:11 +00:00
|
|
|
|
|
|
|
return OPERATOR_RUNNING_MODAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int area_move_cancel(bContext *C, wmOperator *op)
|
|
|
|
{
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2008-11-24 15:51:55 +00:00
|
|
|
RNA_int_set(op->ptr, "delta", 0);
|
2008-11-19 16:28:11 +00:00
|
|
|
area_move_apply(C, op);
|
|
|
|
area_move_exit(C, op);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* modal callback for while moving edges */
|
|
|
|
static int area_move_modal(bContext *C, wmOperator *op, wmEvent *event)
|
|
|
|
{
|
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
|
|
|
sAreaMoveData *md= op->customdata;
|
2008-11-19 16:28:11 +00:00
|
|
|
int delta, x, y;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
/* execute the events */
|
|
|
|
switch(event->type) {
|
|
|
|
case MOUSEMOVE:
|
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
|
|
|
|
|
|
|
x= RNA_int_get(op->ptr, "x");
|
|
|
|
y= RNA_int_get(op->ptr, "y");
|
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
delta= (md->dir == 'v')? event->x - x: event->y - y;
|
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
|
|
|
if(md->step) delta= delta - (delta % md->step);
|
2008-11-24 15:51:55 +00:00
|
|
|
RNA_int_set(op->ptr, "delta", delta);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
area_move_apply(C, op);
|
|
|
|
break;
|
|
|
|
|
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
|
|
|
case EVT_MODAL_MAP:
|
2008-11-19 16:28:11 +00:00
|
|
|
|
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
|
|
|
switch (event->val) {
|
|
|
|
case KM_MODAL_APPLY:
|
|
|
|
area_move_exit(C, op);
|
|
|
|
return OPERATOR_FINISHED;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
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
|
|
|
case KM_MODAL_CANCEL:
|
|
|
|
return area_move_cancel(C, op);
|
|
|
|
|
|
|
|
case KM_MODAL_STEP10:
|
|
|
|
md->step= 10;
|
|
|
|
break;
|
|
|
|
case KM_MODAL_STEP10_OFF:
|
|
|
|
md->step= 0;
|
|
|
|
break;
|
|
|
|
}
|
2008-11-19 16:28:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return OPERATOR_RUNNING_MODAL;
|
|
|
|
}
|
|
|
|
|
2009-07-24 12:43:59 +00:00
|
|
|
static void SCREEN_OT_area_move(wmOperatorType *ot)
|
2008-11-19 16:28:11 +00:00
|
|
|
{
|
|
|
|
/* identifiers */
|
|
|
|
ot->name= "Move area edges";
|
2009-10-07 12:19:47 +00:00
|
|
|
ot->description= "Move selected area edges.";
|
2008-12-26 11:11:21 +00:00
|
|
|
ot->idname= "SCREEN_OT_area_move";
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
ot->exec= area_move_exec;
|
|
|
|
ot->invoke= area_move_invoke;
|
|
|
|
ot->cancel= area_move_cancel;
|
|
|
|
ot->modal= area_move_modal;
|
|
|
|
ot->poll= ED_operator_screen_mainwinactive; /* when mouse is over area-edge */
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-07-11 14:51:13 +00:00
|
|
|
ot->flag= OPTYPE_BLOCKING;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2008-11-21 19:14:38 +00:00
|
|
|
/* rna */
|
2009-01-16 23:53:11 +00:00
|
|
|
RNA_def_int(ot->srna, "x", 0, INT_MIN, INT_MAX, "X", "", INT_MIN, INT_MAX);
|
|
|
|
RNA_def_int(ot->srna, "y", 0, INT_MIN, INT_MAX, "Y", "", INT_MIN, INT_MAX);
|
|
|
|
RNA_def_int(ot->srna, "delta", 0, INT_MIN, INT_MAX, "Delta", "", INT_MIN, INT_MAX);
|
2008-11-19 16:28:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ************** split area operator *********************************** */
|
|
|
|
|
|
|
|
/*
|
2009-12-10 09:25:30 +00:00
|
|
|
operator state vars:
|
|
|
|
fac spit point
|
|
|
|
dir direction 'v' or 'h'
|
|
|
|
|
|
|
|
operator customdata:
|
|
|
|
area pointer to (active) area
|
|
|
|
x, y last used mouse pos
|
|
|
|
(more, see below)
|
|
|
|
|
|
|
|
functions:
|
|
|
|
|
|
|
|
init() set default property values, find area based on context
|
|
|
|
|
|
|
|
apply() split area based on state vars
|
|
|
|
|
|
|
|
exit() cleanup, send notifier
|
|
|
|
|
|
|
|
cancel() remove duplicated area
|
|
|
|
|
|
|
|
callbacks:
|
|
|
|
|
|
|
|
exec() execute without any user interaction, based on state vars
|
|
|
|
call init(), apply(), exit()
|
|
|
|
|
|
|
|
invoke() gets called on mouse click in action-widget
|
|
|
|
call init(), add modal handler
|
|
|
|
call apply() with initial motion
|
|
|
|
|
|
|
|
modal() accept modal events while doing it
|
|
|
|
call move-areas code with delta motion
|
|
|
|
call exit() or cancel() and remove handler
|
|
|
|
|
|
|
|
*/
|
2008-11-19 16:28:11 +00:00
|
|
|
|
|
|
|
#define SPLIT_STARTED 1
|
|
|
|
#define SPLIT_PROGRESS 2
|
|
|
|
|
|
|
|
typedef struct sAreaSplitData
|
2009-12-10 09:25:30 +00:00
|
|
|
{
|
|
|
|
int x, y; /* last used mouse position */
|
|
|
|
|
|
|
|
int origval; /* for move areas */
|
|
|
|
int bigger, smaller; /* constraints for moving new edge */
|
|
|
|
int delta; /* delta move edge */
|
|
|
|
int origmin, origsize; /* to calculate fac, for property storage */
|
|
|
|
|
|
|
|
ScrEdge *nedge; /* new edge */
|
|
|
|
ScrArea *sarea; /* start area */
|
|
|
|
ScrArea *narea; /* new area */
|
|
|
|
} sAreaSplitData;
|
2008-11-19 16:28:11 +00:00
|
|
|
|
|
|
|
/* generic init, no UI stuff here */
|
|
|
|
static int area_split_init(bContext *C, wmOperator *op)
|
|
|
|
{
|
2008-12-18 02:56:48 +00:00
|
|
|
ScrArea *sa= CTX_wm_area(C);
|
2008-11-19 16:28:11 +00:00
|
|
|
sAreaSplitData *sd;
|
|
|
|
int dir;
|
|
|
|
|
|
|
|
/* required context */
|
2008-12-18 02:56:48 +00:00
|
|
|
if(sa==NULL) return 0;
|
2008-11-19 16:28:11 +00:00
|
|
|
|
|
|
|
/* required properties */
|
2009-01-16 23:53:11 +00:00
|
|
|
dir= RNA_enum_get(op->ptr, "direction");
|
2008-11-19 16:28:11 +00:00
|
|
|
|
|
|
|
/* minimal size */
|
2008-12-18 02:56:48 +00:00
|
|
|
if(dir=='v' && sa->winx < 2*AREAMINX) return 0;
|
|
|
|
if(dir=='h' && sa->winy < 2*AREAMINY) return 0;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
/* custom data */
|
|
|
|
sd= (sAreaSplitData*)MEM_callocN(sizeof (sAreaSplitData), "op_area_split");
|
|
|
|
op->customdata= sd;
|
|
|
|
|
2008-12-18 02:56:48 +00:00
|
|
|
sd->sarea= sa;
|
|
|
|
sd->origsize= dir=='v' ? sa->winx:sa->winy;
|
|
|
|
sd->origmin = dir=='v' ? sa->totrct.xmin:sa->totrct.ymin;
|
2008-11-19 16:28:11 +00:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* with sa as center, sb is located at: 0=W, 1=N, 2=E, 3=S */
|
|
|
|
/* used with split operator */
|
|
|
|
static ScrEdge *area_findsharededge(bScreen *screen, ScrArea *sa, ScrArea *sb)
|
|
|
|
{
|
|
|
|
ScrVert *sav1= sa->v1;
|
|
|
|
ScrVert *sav2= sa->v2;
|
|
|
|
ScrVert *sav3= sa->v3;
|
|
|
|
ScrVert *sav4= sa->v4;
|
|
|
|
ScrVert *sbv1= sb->v1;
|
|
|
|
ScrVert *sbv2= sb->v2;
|
|
|
|
ScrVert *sbv3= sb->v3;
|
|
|
|
ScrVert *sbv4= sb->v4;
|
|
|
|
|
|
|
|
if(sav1==sbv4 && sav2==sbv3) { /* sa to right of sb = W */
|
|
|
|
return screen_findedge(screen, sav1, sav2);
|
|
|
|
}
|
|
|
|
else if(sav2==sbv1 && sav3==sbv4) { /* sa to bottom of sb = N */
|
|
|
|
return screen_findedge(screen, sav2, sav3);
|
|
|
|
}
|
|
|
|
else if(sav3==sbv2 && sav4==sbv1) { /* sa to left of sb = E */
|
|
|
|
return screen_findedge(screen, sav3, sav4);
|
|
|
|
}
|
|
|
|
else if(sav1==sbv2 && sav4==sbv3) { /* sa on top of sb = S*/
|
|
|
|
return screen_findedge(screen, sav1, sav4);
|
|
|
|
}
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
/* do the split, return success */
|
|
|
|
static int area_split_apply(bContext *C, wmOperator *op)
|
2008-11-19 16:28:11 +00:00
|
|
|
{
|
2008-12-18 02:56:48 +00:00
|
|
|
bScreen *sc= CTX_wm_screen(C);
|
2008-11-19 16:28:11 +00:00
|
|
|
sAreaSplitData *sd= (sAreaSplitData *)op->customdata;
|
|
|
|
float fac;
|
|
|
|
int dir;
|
|
|
|
|
2009-01-16 23:53:11 +00:00
|
|
|
fac= RNA_float_get(op->ptr, "factor");
|
|
|
|
dir= RNA_enum_get(op->ptr, "direction");
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2008-12-18 02:56:48 +00:00
|
|
|
sd->narea= area_split(CTX_wm_window(C), sc, sd->sarea, dir, fac);
|
2008-11-19 16:28:11 +00:00
|
|
|
|
|
|
|
if(sd->narea) {
|
|
|
|
ScrVert *sv;
|
|
|
|
|
2008-12-18 02:56:48 +00:00
|
|
|
sd->nedge= area_findsharededge(sc, sd->sarea, sd->narea);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
/* select newly created edge, prepare for moving edge */
|
2008-12-18 02:56:48 +00:00
|
|
|
for(sv= sc->vertbase.first; sv; sv= sv->next)
|
2008-11-19 16:28:11 +00:00
|
|
|
sv->flag = 0;
|
|
|
|
|
|
|
|
sd->nedge->v1->flag= 1;
|
|
|
|
sd->nedge->v2->flag= 1;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
if(dir=='h') sd->origval= sd->nedge->v1->vec.y;
|
|
|
|
else sd->origval= sd->nedge->v1->vec.x;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2008-12-27 16:09:56 +00:00
|
|
|
WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL);
|
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
|
|
|
|
|
|
|
return 1;
|
2008-11-19 16:28:11 +00:00
|
|
|
}
|
|
|
|
|
Lots of stuff; couldn't commit in parts because of refactor work.
* Changes in interface/ module
This commit brings back the way how buttons/menus work under control
of WM event system. The previous implementation extended usage of
handlers and operators in an interesting but confusing way. Better to
try it first according the design specs. :)
Most obviously:
- modal-handler operators are not stored anymore in regions/areas/windows.
such modal handlers own their operator, and should remove it themselves.
- removed code to move handlers from one queue to another.
(needs review with brecht!)
- WM fix: the API call to remove a modal handler got removed. This was a
dangerous thing anyway, and you should leave that to the event system.
Now, if a handler modal() call gets a cancel/finish return, it frees
itself in event system. WM_event_remove_modal_handler was a confusing
call anyway!
Todo:
- allow button-activate to refresh after using button
- re-enable arrow keys for menus
(do both after commit)
- review return values of operator callbacks in interface_ops.c
* Fixes in WM system
- Freeing areas/regions/windows, also on quit, now correctly closes
running modal handlers
- On starting a modal handler, the handler now stores previous area
and region context, so they send proper notifiers etc.
* Other fixes
- Area-split operator had bug, wrong minimal size checking. This
solves error when trying to split a very narrow area.
- removed DNA_USHORT_FIX from screen_types.h, gave warning
- operators didn't get ID name copied when activated, needed for
later re-use or saving.
2008-12-02 14:22:52 +00:00
|
|
|
return 0;
|
2008-11-19 16:28:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void area_split_exit(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
if (op->customdata) {
|
|
|
|
MEM_freeN(op->customdata);
|
|
|
|
op->customdata = NULL;
|
|
|
|
}
|
|
|
|
|
2008-12-27 16:09:56 +00:00
|
|
|
WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
/* this makes sure aligned edges will result in aligned grabbing */
|
2008-12-18 02:56:48 +00:00
|
|
|
removedouble_scrverts(CTX_wm_screen(C));
|
|
|
|
removedouble_scredges(CTX_wm_screen(C));
|
2008-11-19 16:28:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* UI callback, adds new handler */
|
|
|
|
static int area_split_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
|
|
|
{
|
|
|
|
sAreaSplitData *sd;
|
|
|
|
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
if(event->type==EVT_ACTIONZONE_AREA) {
|
2008-11-19 16:28:11 +00:00
|
|
|
sActionzoneData *sad= event->customdata;
|
|
|
|
int dir;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-03-05 23:19:44 +00:00
|
|
|
if(sad->modifier>0) {
|
|
|
|
return OPERATOR_PASS_THROUGH;
|
|
|
|
}
|
2008-11-19 16:28:11 +00:00
|
|
|
|
2009-05-21 17:13:50 +00:00
|
|
|
/* no full window splitting allowed */
|
|
|
|
if(CTX_wm_area(C)->full)
|
|
|
|
return OPERATOR_PASS_THROUGH;
|
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
/* verify *sad itself */
|
|
|
|
if(sad==NULL || sad->sa1==NULL || sad->az==NULL)
|
|
|
|
return OPERATOR_PASS_THROUGH;
|
|
|
|
|
|
|
|
/* is this our *sad? if areas not equal it should be passed on */
|
2008-12-18 02:56:48 +00:00
|
|
|
if(CTX_wm_area(C)!=sad->sa1 || sad->sa1!=sad->sa2)
|
2008-11-19 16:28:11 +00:00
|
|
|
return OPERATOR_PASS_THROUGH;
|
|
|
|
|
|
|
|
/* prepare operator state vars */
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
if(sad->gesture_dir=='n' || sad->gesture_dir=='s') {
|
2008-11-19 16:28:11 +00:00
|
|
|
dir= 'h';
|
2009-01-16 23:53:11 +00:00
|
|
|
RNA_float_set(op->ptr, "factor", ((float)(event->x - sad->sa1->v1->vec.x)) / (float)sad->sa1->winx);
|
2008-11-19 16:28:11 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
dir= 'v';
|
2009-01-16 23:53:11 +00:00
|
|
|
RNA_float_set(op->ptr, "factor", ((float)(event->y - sad->sa1->v1->vec.y)) / (float)sad->sa1->winy);
|
2008-11-19 16:28:11 +00:00
|
|
|
}
|
2009-01-16 23:53:11 +00:00
|
|
|
RNA_enum_set(op->ptr, "direction", dir);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
/* general init, also non-UI case, adds customdata, sets area and defaults */
|
|
|
|
if(!area_split_init(C, op))
|
|
|
|
return OPERATOR_PASS_THROUGH;
|
|
|
|
|
|
|
|
sd= (sAreaSplitData *)op->customdata;
|
|
|
|
|
|
|
|
sd->x= event->x;
|
|
|
|
sd->y= event->y;
|
|
|
|
|
|
|
|
/* do the split */
|
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
|
|
|
if(area_split_apply(C, op)) {
|
2008-12-18 02:56:48 +00:00
|
|
|
area_move_set_limits(CTX_wm_screen(C), dir, &sd->bigger, &sd->smaller);
|
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
|
|
|
|
|
|
|
/* add temp handler for edge move or cancel */
|
2009-09-18 12:43:36 +00:00
|
|
|
WM_event_add_modal_handler(C, op);
|
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
|
|
|
|
|
|
|
return OPERATOR_RUNNING_MODAL;
|
|
|
|
}
|
2008-11-19 16:28:11 +00:00
|
|
|
|
|
|
|
}
|
2008-11-24 10:45:36 +00:00
|
|
|
else {
|
|
|
|
/* nonmodal for now */
|
|
|
|
return op->type->exec(C, op);
|
|
|
|
}
|
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
return OPERATOR_PASS_THROUGH;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* function to be called outside UI context, or for redo */
|
|
|
|
static int area_split_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
|
|
|
|
if(!area_split_init(C, op))
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
|
|
area_split_apply(C, op);
|
|
|
|
area_split_exit(C, op);
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int area_split_cancel(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
sAreaSplitData *sd= (sAreaSplitData *)op->customdata;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2008-12-18 02:56:48 +00:00
|
|
|
if (screen_area_join(C, CTX_wm_screen(C), sd->sarea, sd->narea)) {
|
|
|
|
if (CTX_wm_area(C) == sd->narea) {
|
|
|
|
CTX_wm_area_set(C, NULL);
|
2008-12-18 19:41:36 +00:00
|
|
|
CTX_wm_region_set(C, NULL);
|
2008-11-19 16:28:11 +00:00
|
|
|
}
|
|
|
|
sd->narea = NULL;
|
|
|
|
}
|
|
|
|
area_split_exit(C, op);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int area_split_modal(bContext *C, wmOperator *op, wmEvent *event)
|
|
|
|
{
|
|
|
|
sAreaSplitData *sd= (sAreaSplitData *)op->customdata;
|
2008-12-03 19:33:42 +00:00
|
|
|
float fac;
|
2008-11-19 16:28:11 +00:00
|
|
|
int dir;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
/* execute the events */
|
|
|
|
switch(event->type) {
|
|
|
|
case MOUSEMOVE:
|
2009-01-16 23:53:11 +00:00
|
|
|
dir= RNA_enum_get(op->ptr, "direction");
|
2008-11-19 16:28:11 +00:00
|
|
|
|
|
|
|
sd->delta= (dir == 'v')? event->x - sd->origval: event->y - sd->origval;
|
|
|
|
area_move_apply_do(C, sd->origval, sd->delta, dir, sd->bigger, sd->smaller);
|
|
|
|
|
2008-12-03 19:33:42 +00:00
|
|
|
fac= (dir == 'v') ? event->x-sd->origmin : event->y-sd->origmin;
|
2009-01-16 23:53:11 +00:00
|
|
|
RNA_float_set(op->ptr, "factor", fac / (float)sd->origsize);
|
2008-12-03 19:33:42 +00:00
|
|
|
|
2008-12-27 16:09:56 +00:00
|
|
|
WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL);
|
2008-11-19 16:28:11 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LEFTMOUSE:
|
2009-09-24 10:35:04 +00:00
|
|
|
if(event->val==KM_RELEASE) { /* mouse up */
|
2008-11-19 16:28:11 +00:00
|
|
|
area_split_exit(C, op);
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case RIGHTMOUSE: /* cancel operation */
|
|
|
|
case ESCKEY:
|
|
|
|
return area_split_cancel(C, op);
|
|
|
|
}
|
|
|
|
|
|
|
|
return OPERATOR_RUNNING_MODAL;
|
|
|
|
}
|
|
|
|
|
2008-12-09 15:59:43 +00:00
|
|
|
static EnumPropertyItem prop_direction_items[] = {
|
2009-12-10 09:25:30 +00:00
|
|
|
{'h', "HORIZONTAL", 0, "Horizontal", ""},
|
|
|
|
{'v', "VERTICAL", 0, "Vertical", ""},
|
|
|
|
{0, NULL, 0, NULL, NULL}};
|
2008-12-09 15:59:43 +00:00
|
|
|
|
2009-07-24 12:43:59 +00:00
|
|
|
static void SCREEN_OT_area_split(wmOperatorType *ot)
|
2008-11-19 16:28:11 +00:00
|
|
|
{
|
|
|
|
ot->name = "Split area";
|
2009-10-07 12:19:47 +00:00
|
|
|
ot->description= "Split selected area into new windows.";
|
2008-12-26 11:11:21 +00:00
|
|
|
ot->idname = "SCREEN_OT_area_split";
|
2008-11-19 16:28:11 +00:00
|
|
|
|
|
|
|
ot->exec= area_split_exec;
|
|
|
|
ot->invoke= area_split_invoke;
|
|
|
|
ot->modal= area_split_modal;
|
|
|
|
|
2008-11-24 10:45:36 +00:00
|
|
|
ot->poll= ED_operator_areaactive;
|
2009-09-12 19:11:34 +00:00
|
|
|
ot->flag= OPTYPE_BLOCKING;
|
2008-12-03 19:33:42 +00:00
|
|
|
|
2008-11-21 19:14:38 +00:00
|
|
|
/* rna */
|
2009-01-16 23:53:11 +00:00
|
|
|
RNA_def_enum(ot->srna, "direction", prop_direction_items, 'h', "Direction", "");
|
|
|
|
RNA_def_float(ot->srna, "factor", 0.5f, 0.0, 1.0, "Factor", "", 0.0, 1.0);
|
2008-11-19 16:28:11 +00:00
|
|
|
}
|
|
|
|
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* ************** scale region edge operator *********************************** */
|
|
|
|
|
|
|
|
typedef struct RegionMoveData {
|
2009-09-12 23:56:30 +00:00
|
|
|
AZone *az;
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
ARegion *ar;
|
2009-09-12 23:56:30 +00:00
|
|
|
ScrArea *sa;
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
int bigger, smaller, origval;
|
|
|
|
int origx, origy;
|
2009-12-10 09:25:30 +00:00
|
|
|
int maxsize;
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
char edge;
|
|
|
|
|
|
|
|
} RegionMoveData;
|
|
|
|
|
2009-12-10 09:25:30 +00:00
|
|
|
|
|
|
|
static int area_max_regionsize(ScrArea *sa, ARegion *scalear, char edge)
|
|
|
|
{
|
|
|
|
ARegion *ar;
|
|
|
|
int dist;
|
|
|
|
|
|
|
|
if(edge=='l' || edge=='r') {
|
|
|
|
dist = sa->totrct.xmax - sa->totrct.xmin;
|
|
|
|
} else { /* t, b */
|
|
|
|
dist = sa->totrct.ymax - sa->totrct.ymin;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* subtractwidth of regions on opposite side
|
|
|
|
* prevents dragging regions into other opposite regions */
|
|
|
|
for (ar=sa->regionbase.first; ar; ar=ar->next)
|
|
|
|
{
|
|
|
|
if (scalear->alignment == RGN_ALIGN_TOP && ar->alignment == RGN_ALIGN_BOTTOM)
|
|
|
|
dist -= ar->winy;
|
|
|
|
else if (scalear->alignment == RGN_ALIGN_BOTTOM && ar->alignment == RGN_ALIGN_TOP)
|
|
|
|
dist -= ar->winy;
|
|
|
|
else if (scalear->alignment == RGN_ALIGN_LEFT && ar->alignment == RGN_ALIGN_RIGHT)
|
|
|
|
dist -= ar->winx;
|
|
|
|
else if (scalear->alignment == RGN_ALIGN_RIGHT && ar->alignment == RGN_ALIGN_LEFT)
|
|
|
|
dist -= ar->winx;
|
|
|
|
}
|
|
|
|
|
|
|
|
return dist;
|
|
|
|
}
|
|
|
|
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
static int region_scale_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
|
|
|
{
|
|
|
|
sActionzoneData *sad= event->customdata;
|
2009-12-10 03:07:04 +00:00
|
|
|
AZone *az;
|
|
|
|
|
2009-12-10 05:05:04 +00:00
|
|
|
if(event->type!=EVT_ACTIONZONE_REGION) {
|
2009-12-10 03:07:04 +00:00
|
|
|
BKE_report(op->reports, RPT_ERROR, "Can only scale region size from an action zone");
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
az = sad->az;
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
|
|
|
|
if(az->ar) {
|
|
|
|
RegionMoveData *rmd= MEM_callocN(sizeof(RegionMoveData), "RegionMoveData");
|
|
|
|
|
|
|
|
op->customdata= rmd;
|
|
|
|
|
2009-09-12 23:56:30 +00:00
|
|
|
rmd->az = az;
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
rmd->ar= az->ar;
|
2009-09-12 23:56:30 +00:00
|
|
|
rmd->sa = sad->sa1;
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
rmd->edge= az->edge;
|
|
|
|
rmd->origx= event->x;
|
|
|
|
rmd->origy= event->y;
|
2009-12-10 09:25:30 +00:00
|
|
|
rmd->maxsize = area_max_regionsize(rmd->sa, rmd->ar, rmd->edge);
|
|
|
|
if(rmd->edge=='l' || rmd->edge=='r') {
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
rmd->origval= rmd->ar->type->minsizex;
|
2009-12-10 09:25:30 +00:00
|
|
|
} else {
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
rmd->origval= rmd->ar->type->minsizey;
|
2009-12-10 09:25:30 +00:00
|
|
|
}
|
|
|
|
CLAMP(rmd->maxsize, 0, 1000);
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
|
|
|
|
/* add temp handler */
|
2009-09-18 12:43:36 +00:00
|
|
|
WM_event_add_modal_handler(C, op);
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
|
|
|
|
return OPERATOR_RUNNING_MODAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int region_scale_modal(bContext *C, wmOperator *op, wmEvent *event)
|
|
|
|
{
|
|
|
|
RegionMoveData *rmd= op->customdata;
|
|
|
|
int delta;
|
|
|
|
|
|
|
|
/* execute the events */
|
|
|
|
switch(event->type) {
|
|
|
|
case MOUSEMOVE:
|
|
|
|
|
|
|
|
if(rmd->edge=='l' || rmd->edge=='r') {
|
|
|
|
delta= event->x - rmd->origx;
|
|
|
|
if(rmd->edge=='l') delta= -delta;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
rmd->ar->type->minsizex= rmd->origval + delta;
|
2009-12-10 09:25:30 +00:00
|
|
|
CLAMP(rmd->ar->type->minsizex, 0, rmd->maxsize);
|
|
|
|
|
2009-09-12 23:56:30 +00:00
|
|
|
if(rmd->ar->type->minsizex < 24) {
|
|
|
|
rmd->ar->type->minsizex= rmd->origval;
|
2009-09-14 19:12:29 +00:00
|
|
|
if(!(rmd->ar->flag & RGN_FLAG_HIDDEN))
|
|
|
|
ED_region_toggle_hidden(C, rmd->ar);
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
}
|
2009-09-14 19:12:29 +00:00
|
|
|
else if(rmd->ar->flag & RGN_FLAG_HIDDEN)
|
|
|
|
ED_region_toggle_hidden(C, rmd->ar);
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
delta= event->y - rmd->origy;
|
|
|
|
if(rmd->edge=='b') delta= -delta;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
rmd->ar->type->minsizey= rmd->origval + delta;
|
2009-12-10 09:25:30 +00:00
|
|
|
CLAMP(rmd->ar->type->minsizey, 0, rmd->maxsize);
|
|
|
|
|
2009-09-12 23:56:30 +00:00
|
|
|
if(rmd->ar->type->minsizey < 24) {
|
|
|
|
rmd->ar->type->minsizey= rmd->origval;
|
2009-09-14 19:12:29 +00:00
|
|
|
if(!(rmd->ar->flag & RGN_FLAG_HIDDEN))
|
|
|
|
ED_region_toggle_hidden(C, rmd->ar);
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
}
|
2009-09-14 19:12:29 +00:00
|
|
|
else if(rmd->ar->flag & RGN_FLAG_HIDDEN)
|
|
|
|
ED_region_toggle_hidden(C, rmd->ar);
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LEFTMOUSE:
|
2009-09-24 10:35:04 +00:00
|
|
|
if(event->val==KM_RELEASE) {
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
|
|
|
|
if(ABS(event->x - rmd->origx) < 2 && ABS(event->y - rmd->origy) < 2) {
|
2009-09-21 01:32:37 +00:00
|
|
|
if(rmd->ar->flag & RGN_FLAG_HIDDEN) {
|
|
|
|
ED_region_toggle_hidden(C, rmd->ar);
|
|
|
|
WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL);
|
|
|
|
}
|
|
|
|
}
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
MEM_freeN(op->customdata);
|
|
|
|
op->customdata = NULL;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ESCKEY:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
return OPERATOR_RUNNING_MODAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void SCREEN_OT_region_scale(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
|
|
|
ot->name= "Scale Region Size";
|
2009-10-07 12:19:47 +00:00
|
|
|
ot->description= "Scale selected area.";
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
ot->idname= "SCREEN_OT_region_scale";
|
|
|
|
|
|
|
|
ot->invoke= region_scale_invoke;
|
|
|
|
ot->modal= region_scale_modal;
|
|
|
|
|
|
|
|
ot->poll= ED_operator_areaactive;
|
2009-07-11 14:51:13 +00:00
|
|
|
|
|
|
|
ot->flag= OPTYPE_BLOCKING;
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-12-17 16:21:14 +00:00
|
|
|
/* ************** frame change operator ***************************** */
|
|
|
|
|
|
|
|
/* function to be called outside UI context, or for redo */
|
|
|
|
static int frame_offset_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
int delta;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2008-12-17 16:21:14 +00:00
|
|
|
delta = RNA_int_get(op->ptr, "delta");
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2008-12-18 02:56:48 +00:00
|
|
|
CTX_data_scene(C)->r.cfra += delta;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2008-12-27 16:09:56 +00:00
|
|
|
WM_event_add_notifier(C, NC_SCENE|ND_FRAME, CTX_data_scene(C));
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2008-12-17 16:21:14 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
2009-07-24 12:43:59 +00:00
|
|
|
static void SCREEN_OT_frame_offset(wmOperatorType *ot)
|
2008-12-17 16:21:14 +00:00
|
|
|
{
|
|
|
|
ot->name = "Frame Offset";
|
2008-12-26 11:11:21 +00:00
|
|
|
ot->idname = "SCREEN_OT_frame_offset";
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2008-12-17 16:21:14 +00:00
|
|
|
ot->exec= frame_offset_exec;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2008-12-17 16:21:14 +00:00
|
|
|
ot->poll= ED_operator_screenactive;
|
2009-02-19 16:22:07 +00:00
|
|
|
ot->flag= 0;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2008-12-17 16:21:14 +00:00
|
|
|
/* rna */
|
2009-01-16 23:53:11 +00:00
|
|
|
RNA_def_int(ot->srna, "delta", 0, INT_MIN, INT_MAX, "Delta", "", INT_MIN, INT_MAX);
|
2008-12-17 16:21:14 +00:00
|
|
|
}
|
|
|
|
|
2009-08-02 07:08:51 +00:00
|
|
|
|
|
|
|
/* function to be called outside UI context, or for redo */
|
|
|
|
static int frame_jump_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
Scene *scene= CTX_data_scene(C);
|
|
|
|
|
|
|
|
if (RNA_boolean_get(op->ptr, "end"))
|
|
|
|
CFRA= PEFRA;
|
|
|
|
else
|
|
|
|
CFRA= PSFRA;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-08-02 07:08:51 +00:00
|
|
|
WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-08-02 07:08:51 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void SCREEN_OT_frame_jump(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
ot->name = "Jump to Endpoint";
|
2009-10-07 12:19:47 +00:00
|
|
|
ot->description= "Jump to first/last frame in frame range.";
|
2009-08-02 07:08:51 +00:00
|
|
|
ot->idname = "SCREEN_OT_frame_jump";
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-08-02 07:08:51 +00:00
|
|
|
ot->exec= frame_jump_exec;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-08-02 07:08:51 +00:00
|
|
|
ot->poll= ED_operator_screenactive;
|
|
|
|
ot->flag= 0;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-08-02 07:08:51 +00:00
|
|
|
/* rna */
|
|
|
|
RNA_def_boolean(ot->srna, "end", 0, "Last Frame", "Jump to the last frame of the frame range.");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-07-24 13:34:45 +00:00
|
|
|
/* ************** jump to keyframe operator ***************************** */
|
|
|
|
|
|
|
|
/* function to be called outside UI context, or for redo */
|
|
|
|
static int keyframe_jump_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
Scene *scene= CTX_data_scene(C);
|
|
|
|
Object *ob= CTX_data_active_object(C);
|
|
|
|
DLRBT_Tree keys;
|
|
|
|
ActKeyColumn *ak;
|
2009-11-15 11:20:44 +00:00
|
|
|
float cfra= (scene)? (float)(CFRA) : 0.0f;
|
2009-07-24 13:34:45 +00:00
|
|
|
short next= RNA_boolean_get(op->ptr, "next");
|
|
|
|
|
|
|
|
/* sanity checks */
|
|
|
|
if (scene == NULL)
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
|
|
/* init binarytree-list for getting keyframes */
|
|
|
|
BLI_dlrbTree_init(&keys);
|
|
|
|
|
|
|
|
/* populate tree with keyframe nodes */
|
|
|
|
if (scene && scene->adt)
|
|
|
|
scene_to_keylist(NULL, scene, &keys, NULL);
|
|
|
|
if (ob && ob->adt)
|
|
|
|
ob_to_keylist(NULL, ob, &keys, NULL);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-07-24 13:34:45 +00:00
|
|
|
/* build linked-list for searching */
|
|
|
|
BLI_dlrbTree_linkedlist_sync(&keys);
|
|
|
|
|
2009-11-15 11:20:44 +00:00
|
|
|
/* find matching keyframe in the right direction */
|
|
|
|
if (next)
|
|
|
|
ak= (ActKeyColumn *)BLI_dlrbTree_search_next(&keys, compare_ak_cfraPtr, &cfra);
|
|
|
|
else
|
|
|
|
ak= (ActKeyColumn *)BLI_dlrbTree_search_prev(&keys, compare_ak_cfraPtr, &cfra);
|
2009-07-24 13:34:45 +00:00
|
|
|
|
|
|
|
/* set the new frame (if keyframe found) */
|
2009-11-15 11:20:44 +00:00
|
|
|
if (ak)
|
|
|
|
CFRA= (int)ak->cfra;
|
|
|
|
else
|
|
|
|
BKE_report(op->reports, RPT_ERROR, "No more keyframes to jump to in this direction");
|
|
|
|
|
2009-07-24 13:34:45 +00:00
|
|
|
/* free temp stuff */
|
|
|
|
BLI_dlrbTree_free(&keys);
|
|
|
|
|
|
|
|
WM_event_add_notifier(C, NC_SCENE|ND_FRAME, CTX_data_scene(C));
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-07-24 13:34:45 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void SCREEN_OT_keyframe_jump(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
ot->name = "Jump to Keyframe";
|
2009-10-07 12:19:47 +00:00
|
|
|
ot->description= "Jump to previous/next keyframe.";
|
2009-07-24 13:34:45 +00:00
|
|
|
ot->idname = "SCREEN_OT_keyframe_jump";
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-07-24 13:34:45 +00:00
|
|
|
ot->exec= keyframe_jump_exec;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-07-24 13:34:45 +00:00
|
|
|
ot->poll= ED_operator_screenactive;
|
|
|
|
ot->flag= 0;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-07-24 13:34:45 +00:00
|
|
|
/* rna */
|
|
|
|
RNA_def_boolean(ot->srna, "next", 1, "Next Keyframe", "");
|
|
|
|
}
|
|
|
|
|
2008-12-17 17:33:45 +00:00
|
|
|
/* ************** switch screen operator ***************************** */
|
|
|
|
|
|
|
|
|
|
|
|
/* function to be called outside UI context, or for redo */
|
|
|
|
static int screen_set_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
2008-12-18 02:56:48 +00:00
|
|
|
bScreen *screen= CTX_wm_screen(C);
|
2009-02-08 12:16:35 +00:00
|
|
|
ScrArea *sa= CTX_wm_area(C);
|
2009-02-07 19:37:29 +00:00
|
|
|
int tot= BLI_countlist(&CTX_data_main(C)->screen);
|
2008-12-17 17:33:45 +00:00
|
|
|
int delta= RNA_int_get(op->ptr, "delta");
|
|
|
|
|
2009-12-08 07:12:06 +00:00
|
|
|
/* return to previous state before switching screens */
|
2009-02-08 12:16:35 +00:00
|
|
|
if(sa && sa->full)
|
2009-12-08 07:12:06 +00:00
|
|
|
ED_screen_full_restore(C, sa);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2008-12-17 17:33:45 +00:00
|
|
|
if(delta==1) {
|
2009-02-07 19:37:29 +00:00
|
|
|
while(tot--) {
|
|
|
|
screen= screen->id.next;
|
|
|
|
if(screen==NULL) screen= CTX_data_main(C)->screen.first;
|
|
|
|
if(screen->winid==0 && screen->full==0)
|
|
|
|
break;
|
|
|
|
}
|
2008-12-17 17:33:45 +00:00
|
|
|
}
|
|
|
|
else if(delta== -1) {
|
2009-02-07 19:37:29 +00:00
|
|
|
while(tot--) {
|
|
|
|
screen= screen->id.prev;
|
|
|
|
if(screen==NULL) screen= CTX_data_main(C)->screen.last;
|
|
|
|
if(screen->winid==0 && screen->full==0)
|
|
|
|
break;
|
|
|
|
}
|
2008-12-17 17:33:45 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
screen= NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(screen) {
|
2009-02-07 19:37:29 +00:00
|
|
|
ED_screen_set(C, screen);
|
2008-12-17 17:33:45 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
|
|
|
|
2009-07-24 12:43:59 +00:00
|
|
|
static void SCREEN_OT_screen_set(wmOperatorType *ot)
|
2008-12-17 17:33:45 +00:00
|
|
|
{
|
|
|
|
ot->name = "Set Screen";
|
2009-10-07 12:19:47 +00:00
|
|
|
ot->description= "Cycle through available screens.";
|
2008-12-26 11:11:21 +00:00
|
|
|
ot->idname = "SCREEN_OT_screen_set";
|
2008-12-17 17:33:45 +00:00
|
|
|
|
|
|
|
ot->exec= screen_set_exec;
|
|
|
|
ot->poll= ED_operator_screenactive;
|
|
|
|
|
|
|
|
/* rna */
|
2009-01-16 23:53:11 +00:00
|
|
|
RNA_def_int(ot->srna, "delta", 0, INT_MIN, INT_MAX, "Delta", "", INT_MIN, INT_MAX);
|
2008-12-17 17:33:45 +00:00
|
|
|
}
|
|
|
|
|
2008-12-17 19:40:19 +00:00
|
|
|
/* ************** screen full-area operator ***************************** */
|
|
|
|
|
|
|
|
|
|
|
|
/* function to be called outside UI context, or for redo */
|
|
|
|
static int screen_full_area_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
2009-10-26 11:43:27 +00:00
|
|
|
ed_screen_fullarea(C, CTX_wm_window(C), CTX_wm_area(C));
|
2008-12-17 19:40:19 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
2009-07-24 12:43:59 +00:00
|
|
|
static void SCREEN_OT_screen_full_area(wmOperatorType *ot)
|
2008-12-17 19:40:19 +00:00
|
|
|
{
|
2009-09-26 16:43:20 +00:00
|
|
|
ot->name = "Toggle Full Screen";
|
2009-10-07 12:19:47 +00:00
|
|
|
ot->description= "Toggle display selected area as fullscreen.";
|
2008-12-26 11:11:21 +00:00
|
|
|
ot->idname = "SCREEN_OT_screen_full_area";
|
2008-12-17 19:40:19 +00:00
|
|
|
|
|
|
|
ot->exec= screen_full_area_exec;
|
2009-02-08 12:16:35 +00:00
|
|
|
ot->poll= ED_operator_areaactive;
|
2009-02-19 16:22:07 +00:00
|
|
|
ot->flag= 0;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2008-12-17 19:40:19 +00:00
|
|
|
}
|
|
|
|
|
2008-12-17 17:33:45 +00:00
|
|
|
|
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
/* ************** join area operator ********************************************** */
|
|
|
|
|
|
|
|
/* operator state vars used:
|
2009-12-10 09:25:30 +00:00
|
|
|
x1, y1 mouse coord in first area, which will disappear
|
|
|
|
x2, y2 mouse coord in 2nd area, which will become joined
|
|
|
|
|
|
|
|
functions:
|
|
|
|
|
|
|
|
init() find edge based on state vars
|
|
|
|
test if the edge divides two areas,
|
|
|
|
store active and nonactive area,
|
|
|
|
|
|
|
|
apply() do the actual join
|
|
|
|
|
|
|
|
exit() cleanup, send notifier
|
|
|
|
|
|
|
|
callbacks:
|
|
|
|
|
|
|
|
exec() calls init, apply, exit
|
|
|
|
|
|
|
|
invoke() sets mouse coords in x,y
|
|
|
|
call init()
|
|
|
|
add modal handler
|
|
|
|
|
|
|
|
modal() accept modal events while doing it
|
|
|
|
call apply() with active window and nonactive window
|
|
|
|
call exit() and remove handler when LMB confirm
|
|
|
|
|
|
|
|
*/
|
2008-11-19 16:28:11 +00:00
|
|
|
|
|
|
|
typedef struct sAreaJoinData
|
2009-12-10 09:25:30 +00:00
|
|
|
{
|
|
|
|
ScrArea *sa1; /* first area to be considered */
|
|
|
|
ScrArea *sa2; /* second area to be considered */
|
|
|
|
ScrArea *scr; /* designed for removal */
|
|
|
|
|
|
|
|
} sAreaJoinData;
|
2008-11-19 16:28:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* validate selection inside screen, set variables OK */
|
|
|
|
/* return 0: init failed */
|
|
|
|
/* XXX todo: find edge based on (x,y) and set other area? */
|
|
|
|
static int area_join_init(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
ScrArea *sa1, *sa2;
|
|
|
|
sAreaJoinData* jd= NULL;
|
|
|
|
int x1, y1;
|
|
|
|
int x2, y2;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
/* required properties, make negative to get return 0 if not set by caller */
|
2008-11-24 15:51:55 +00:00
|
|
|
x1= RNA_int_get(op->ptr, "x1");
|
|
|
|
y1= RNA_int_get(op->ptr, "y1");
|
|
|
|
x2= RNA_int_get(op->ptr, "x2");
|
|
|
|
y2= RNA_int_get(op->ptr, "y2");
|
2008-11-19 16:28:11 +00:00
|
|
|
|
2008-12-18 02:56:48 +00:00
|
|
|
sa1 = screen_areahascursor(CTX_wm_screen(C), x1, y1);
|
|
|
|
sa2 = screen_areahascursor(CTX_wm_screen(C), x2, y2);
|
2008-11-19 16:28:11 +00:00
|
|
|
if(sa1==NULL || sa2==NULL || sa1==sa2)
|
|
|
|
return 0;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
jd = (sAreaJoinData*)MEM_callocN(sizeof (sAreaJoinData), "op_area_join");
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
jd->sa1 = sa1;
|
|
|
|
jd->sa1->flag |= AREA_FLAG_DRAWJOINFROM;
|
|
|
|
jd->sa2 = sa2;
|
|
|
|
jd->sa2->flag |= AREA_FLAG_DRAWJOINTO;
|
|
|
|
|
|
|
|
op->customdata= jd;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* apply the join of the areas (space types) */
|
|
|
|
static int area_join_apply(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
sAreaJoinData *jd = (sAreaJoinData *)op->customdata;
|
|
|
|
if (!jd) return 0;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2008-12-18 02:56:48 +00:00
|
|
|
if(!screen_area_join(C, CTX_wm_screen(C), jd->sa1, jd->sa2)){
|
2008-11-19 16:28:11 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2008-12-18 02:56:48 +00:00
|
|
|
if (CTX_wm_area(C) == jd->sa2) {
|
|
|
|
CTX_wm_area_set(C, NULL);
|
2008-12-18 19:41:36 +00:00
|
|
|
CTX_wm_region_set(C, NULL);
|
2008-11-19 16:28:11 +00:00
|
|
|
}
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* finish operation */
|
|
|
|
static void area_join_exit(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
if (op->customdata) {
|
|
|
|
MEM_freeN(op->customdata);
|
|
|
|
op->customdata = NULL;
|
|
|
|
}
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
/* this makes sure aligned edges will result in aligned grabbing */
|
2008-12-18 02:56:48 +00:00
|
|
|
removedouble_scredges(CTX_wm_screen(C));
|
|
|
|
removenotused_scredges(CTX_wm_screen(C));
|
|
|
|
removenotused_scrverts(CTX_wm_screen(C));
|
2008-11-19 16:28:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int area_join_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
if(!area_join_init(C, op))
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
|
|
area_join_apply(C, op);
|
|
|
|
area_join_exit(C, op);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* interaction callback */
|
|
|
|
static int area_join_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
|
|
|
{
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
if(event->type==EVT_ACTIONZONE_AREA) {
|
2008-11-19 16:28:11 +00:00
|
|
|
sActionzoneData *sad= event->customdata;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-03-05 23:19:44 +00:00
|
|
|
if(sad->modifier>0) {
|
|
|
|
return OPERATOR_PASS_THROUGH;
|
|
|
|
}
|
2008-11-19 16:28:11 +00:00
|
|
|
|
|
|
|
/* verify *sad itself */
|
|
|
|
if(sad==NULL || sad->sa1==NULL || sad->sa2==NULL)
|
|
|
|
return OPERATOR_PASS_THROUGH;
|
|
|
|
|
|
|
|
/* is this our *sad? if areas equal it should be passed on */
|
|
|
|
if(sad->sa1==sad->sa2)
|
|
|
|
return OPERATOR_PASS_THROUGH;
|
|
|
|
|
|
|
|
/* prepare operator state vars */
|
2008-11-24 15:51:55 +00:00
|
|
|
RNA_int_set(op->ptr, "x1", sad->x);
|
|
|
|
RNA_int_set(op->ptr, "y1", sad->y);
|
|
|
|
RNA_int_set(op->ptr, "x2", event->x);
|
|
|
|
RNA_int_set(op->ptr, "y2", event->y);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
if(!area_join_init(C, op))
|
|
|
|
return OPERATOR_PASS_THROUGH;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
/* add temp handler */
|
2009-09-18 12:43:36 +00:00
|
|
|
WM_event_add_modal_handler(C, op);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
return OPERATOR_RUNNING_MODAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return OPERATOR_PASS_THROUGH;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int area_join_cancel(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
sAreaJoinData *jd = (sAreaJoinData *)op->customdata;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
if (jd->sa1) {
|
|
|
|
jd->sa1->flag &= ~AREA_FLAG_DRAWJOINFROM;
|
|
|
|
jd->sa1->flag &= ~AREA_FLAG_DRAWJOINTO;
|
|
|
|
}
|
|
|
|
if (jd->sa2) {
|
|
|
|
jd->sa2->flag &= ~AREA_FLAG_DRAWJOINFROM;
|
|
|
|
jd->sa2->flag &= ~AREA_FLAG_DRAWJOINTO;
|
|
|
|
}
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2008-12-27 16:09:56 +00:00
|
|
|
WM_event_add_notifier(C, NC_WINDOW, NULL);
|
2008-11-19 16:28:11 +00:00
|
|
|
|
|
|
|
area_join_exit(C, op);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* modal callback while selecting area (space) that will be removed */
|
|
|
|
static int area_join_modal(bContext *C, wmOperator *op, wmEvent *event)
|
|
|
|
{
|
2008-12-18 02:56:48 +00:00
|
|
|
bScreen *sc= CTX_wm_screen(C);
|
2008-11-19 16:28:11 +00:00
|
|
|
sAreaJoinData *jd = (sAreaJoinData *)op->customdata;
|
|
|
|
|
|
|
|
/* execute the events */
|
|
|
|
switch(event->type) {
|
|
|
|
|
|
|
|
case MOUSEMOVE:
|
2009-12-10 09:25:30 +00:00
|
|
|
{
|
|
|
|
ScrArea *sa = screen_areahascursor(sc, event->x, event->y);
|
|
|
|
int dir;
|
|
|
|
|
|
|
|
if (sa) {
|
|
|
|
if (jd->sa1 != sa) {
|
|
|
|
dir = area_getorientation(sc, jd->sa1, sa);
|
|
|
|
if (dir >= 0) {
|
|
|
|
if (jd->sa2) jd->sa2->flag &= ~AREA_FLAG_DRAWJOINTO;
|
|
|
|
jd->sa2 = sa;
|
|
|
|
jd->sa2->flag |= AREA_FLAG_DRAWJOINTO;
|
2008-11-19 16:28:11 +00:00
|
|
|
}
|
|
|
|
else {
|
2009-12-10 09:25:30 +00:00
|
|
|
/* we are not bordering on the previously selected area
|
|
|
|
we check if area has common border with the one marked for removal
|
|
|
|
in this case we can swap areas.
|
|
|
|
*/
|
|
|
|
dir = area_getorientation(sc, sa, jd->sa2);
|
|
|
|
if (dir >= 0) {
|
2008-11-19 16:28:11 +00:00
|
|
|
if (jd->sa1) jd->sa1->flag &= ~AREA_FLAG_DRAWJOINFROM;
|
|
|
|
if (jd->sa2) jd->sa2->flag &= ~AREA_FLAG_DRAWJOINTO;
|
|
|
|
jd->sa1 = jd->sa2;
|
|
|
|
jd->sa2 = sa;
|
|
|
|
if (jd->sa1) jd->sa1->flag |= AREA_FLAG_DRAWJOINFROM;
|
|
|
|
if (jd->sa2) jd->sa2->flag |= AREA_FLAG_DRAWJOINTO;
|
|
|
|
}
|
|
|
|
else {
|
2009-12-10 09:25:30 +00:00
|
|
|
if (jd->sa2) jd->sa2->flag &= ~AREA_FLAG_DRAWJOINTO;
|
|
|
|
jd->sa2 = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
WM_event_add_notifier(C, NC_WINDOW, NULL);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* we are back in the area previously selected for keeping
|
|
|
|
* we swap the areas if possible to allow user to choose */
|
|
|
|
if (jd->sa2 != NULL) {
|
|
|
|
if (jd->sa1) jd->sa1->flag &= ~AREA_FLAG_DRAWJOINFROM;
|
|
|
|
if (jd->sa2) jd->sa2->flag &= ~AREA_FLAG_DRAWJOINTO;
|
|
|
|
jd->sa1 = jd->sa2;
|
|
|
|
jd->sa2 = sa;
|
|
|
|
if (jd->sa1) jd->sa1->flag |= AREA_FLAG_DRAWJOINFROM;
|
|
|
|
if (jd->sa2) jd->sa2->flag |= AREA_FLAG_DRAWJOINTO;
|
|
|
|
dir = area_getorientation(sc, jd->sa1, jd->sa2);
|
|
|
|
if (dir < 0) {
|
|
|
|
printf("oops, didn't expect that!\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
dir = area_getorientation(sc, jd->sa1, sa);
|
|
|
|
if (dir >= 0) {
|
|
|
|
if (jd->sa2) jd->sa2->flag &= ~AREA_FLAG_DRAWJOINTO;
|
|
|
|
jd->sa2 = sa;
|
|
|
|
jd->sa2->flag |= AREA_FLAG_DRAWJOINTO;
|
2008-11-19 16:28:11 +00:00
|
|
|
}
|
|
|
|
}
|
2009-12-10 09:25:30 +00:00
|
|
|
WM_event_add_notifier(C, NC_WINDOW, NULL);
|
2008-11-19 16:28:11 +00:00
|
|
|
}
|
|
|
|
}
|
2009-12-10 09:25:30 +00:00
|
|
|
}
|
2008-11-19 16:28:11 +00:00
|
|
|
break;
|
|
|
|
case LEFTMOUSE:
|
2009-09-24 10:35:04 +00:00
|
|
|
if(event->val==KM_RELEASE) {
|
2008-11-19 16:28:11 +00:00
|
|
|
area_join_apply(C, op);
|
2008-12-27 16:09:56 +00:00
|
|
|
WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL);
|
2008-11-19 16:28:11 +00:00
|
|
|
area_join_exit(C, op);
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
break;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-12-04 01:21:55 +00:00
|
|
|
case RIGHTMOUSE:
|
2008-11-19 16:28:11 +00:00
|
|
|
case ESCKEY:
|
|
|
|
return area_join_cancel(C, op);
|
|
|
|
}
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
return OPERATOR_RUNNING_MODAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Operator for joining two areas (space types) */
|
2009-07-24 12:43:59 +00:00
|
|
|
static void SCREEN_OT_area_join(wmOperatorType *ot)
|
2008-11-19 16:28:11 +00:00
|
|
|
{
|
|
|
|
/* identifiers */
|
|
|
|
ot->name= "Join area";
|
2009-10-07 12:19:47 +00:00
|
|
|
ot->description= "Join selected areas into new window.";
|
2008-12-26 11:11:21 +00:00
|
|
|
ot->idname= "SCREEN_OT_area_join";
|
2008-11-19 16:28:11 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
ot->exec= area_join_exec;
|
|
|
|
ot->invoke= area_join_invoke;
|
|
|
|
ot->modal= area_join_modal;
|
2009-02-08 12:16:35 +00:00
|
|
|
ot->poll= ED_operator_areaactive;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-07-11 14:51:13 +00:00
|
|
|
ot->flag= OPTYPE_BLOCKING;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2008-11-21 19:14:38 +00:00
|
|
|
/* rna */
|
2009-01-16 23:53:11 +00:00
|
|
|
RNA_def_int(ot->srna, "x1", -100, INT_MIN, INT_MAX, "X 1", "", INT_MIN, INT_MAX);
|
|
|
|
RNA_def_int(ot->srna, "y1", -100, INT_MIN, INT_MAX, "Y 1", "", INT_MIN, INT_MAX);
|
|
|
|
RNA_def_int(ot->srna, "x2", -100, INT_MIN, INT_MAX, "X 2", "", INT_MIN, INT_MAX);
|
|
|
|
RNA_def_int(ot->srna, "y2", -100, INT_MIN, INT_MAX, "Y 2", "", INT_MIN, INT_MAX);
|
2008-11-19 16:28:11 +00:00
|
|
|
}
|
|
|
|
|
2008-12-03 19:33:42 +00:00
|
|
|
/* ************** repeat last operator ***************************** */
|
|
|
|
|
|
|
|
static int repeat_last_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
2008-12-18 02:56:48 +00:00
|
|
|
wmOperator *lastop= CTX_wm_manager(C)->operators.last;
|
2008-12-03 19:33:42 +00:00
|
|
|
|
2009-02-01 12:00:00 +00:00
|
|
|
if(lastop)
|
|
|
|
WM_operator_repeat(C, lastop);
|
2008-12-03 19:33:42 +00:00
|
|
|
|
2009-01-31 19:40:40 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
2008-12-03 19:33:42 +00:00
|
|
|
}
|
|
|
|
|
2009-07-24 12:43:59 +00:00
|
|
|
static void SCREEN_OT_repeat_last(wmOperatorType *ot)
|
2008-12-03 19:33:42 +00:00
|
|
|
{
|
|
|
|
/* identifiers */
|
|
|
|
ot->name= "Repeat Last";
|
2009-10-07 12:19:47 +00:00
|
|
|
ot->description= "Repeat last action.";
|
2008-12-26 11:11:21 +00:00
|
|
|
ot->idname= "SCREEN_OT_repeat_last";
|
2008-12-03 19:33:42 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
ot->exec= repeat_last_exec;
|
|
|
|
|
|
|
|
ot->poll= ED_operator_screenactive;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2009-01-15 18:28:40 +00:00
|
|
|
static int repeat_history_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
|
|
|
{
|
|
|
|
wmWindowManager *wm= CTX_wm_manager(C);
|
|
|
|
wmOperator *lastop;
|
2009-04-22 18:39:44 +00:00
|
|
|
uiPopupMenu *pup;
|
|
|
|
uiLayout *layout;
|
2009-01-15 18:28:40 +00:00
|
|
|
int items, i;
|
|
|
|
|
|
|
|
items= BLI_countlist(&wm->operators);
|
|
|
|
if(items==0)
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
UI: Layout Engine
* Buttons are now created first, and after that the layout is computed.
This means the layout engine now works at button level, and makes it
easier to write templates. Otherwise you had to store all info and
create the buttons later.
* Added interface_templates.c as a separate file to put templates in.
These can contain regular buttons, and can be put in a Free layout,
which means you can specify manual coordinates, but still get nested
correct inside other layouts.
* API was changed to allow better nesting. Previously items were added
in the last added layout specifier, i.e. one level up in the layout
hierarchy. This doesn't work well in always, so now when creating things
like rows or columns it always returns a layout which you have to add
the items in. All py scripts were updated to follow this.
* Computing the layout now goes in two passes, first estimating the
required width/height of all nested layouts, and then in the second
pass using the results of that to decide on the actual locations.
* Enum and array buttons now follow the direction of the layout, i.e.
they are vertical or horizontal depending if they are in a column or row.
* Color properties now get a color picker, and only get the additional
RGB sliders with Expand=True.
* File/directory string properties now get a button next to them for
opening the file browse, though this is not implemented yet.
* Layout items can now be aligned, set align=True when creating a column,
row, etc.
* Buttons now get a minimum width of one icon (avoids squashing icon
buttons).
* Moved some more space variables into Style.
2009-05-15 11:19:59 +00:00
|
|
|
pup= uiPupMenuBegin(C, op->type->name, 0);
|
2009-04-22 18:39:44 +00:00
|
|
|
layout= uiPupMenuLayout(pup);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-01-15 18:28:40 +00:00
|
|
|
for (i=items-1, lastop= wm->operators.last; lastop; lastop= lastop->prev, i--)
|
2009-04-22 18:39:44 +00:00
|
|
|
uiItemIntO(layout, lastop->type->name, 0, op->type->idname, "index", i);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-04-22 18:39:44 +00:00
|
|
|
uiPupMenuEnd(C, pup);
|
2009-01-15 18:28:40 +00:00
|
|
|
|
2009-02-04 11:52:16 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
2009-01-15 18:28:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int repeat_history_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
wmWindowManager *wm= CTX_wm_manager(C);
|
|
|
|
|
|
|
|
op= BLI_findlink(&wm->operators, RNA_int_get(op->ptr, "index"));
|
|
|
|
if(op) {
|
|
|
|
/* let's put it as last operator in list */
|
|
|
|
BLI_remlink(&wm->operators, op);
|
|
|
|
BLI_addtail(&wm->operators, op);
|
|
|
|
|
2009-02-01 12:00:00 +00:00
|
|
|
WM_operator_repeat(C, op);
|
2009-01-15 18:28:40 +00:00
|
|
|
}
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-01-15 18:28:40 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
2009-07-24 12:43:59 +00:00
|
|
|
static void SCREEN_OT_repeat_history(wmOperatorType *ot)
|
2009-01-15 18:28:40 +00:00
|
|
|
{
|
|
|
|
/* identifiers */
|
|
|
|
ot->name= "Repeat History";
|
2009-10-07 12:19:47 +00:00
|
|
|
ot->description= "Display menu for previous actions performed.";
|
2009-01-15 18:28:40 +00:00
|
|
|
ot->idname= "SCREEN_OT_repeat_history";
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
ot->invoke= repeat_history_invoke;
|
|
|
|
ot->exec= repeat_history_exec;
|
|
|
|
|
|
|
|
ot->poll= ED_operator_screenactive;
|
|
|
|
|
2009-01-16 23:53:11 +00:00
|
|
|
RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "", 0, 1000);
|
2009-01-15 18:28:40 +00:00
|
|
|
}
|
|
|
|
|
2009-02-04 11:52:16 +00:00
|
|
|
/* ********************** redo operator ***************************** */
|
|
|
|
|
|
|
|
static int redo_last_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
|
|
|
{
|
|
|
|
wmWindowManager *wm= CTX_wm_manager(C);
|
2009-02-19 16:22:07 +00:00
|
|
|
wmOperator *lastop;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-02-04 11:52:16 +00:00
|
|
|
/* only for operators that are registered and did an undo push */
|
2009-02-19 16:22:07 +00:00
|
|
|
for(lastop= wm->operators.last; lastop; lastop= lastop->prev)
|
|
|
|
if((lastop->type->flag & OPTYPE_REGISTER) && (lastop->type->flag & OPTYPE_UNDO))
|
|
|
|
break;
|
|
|
|
|
2009-04-01 14:02:06 +00:00
|
|
|
if(lastop)
|
|
|
|
WM_operator_redo_popup(C, lastop);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-02-04 11:52:16 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
|
|
|
|
2009-07-24 12:43:59 +00:00
|
|
|
static void SCREEN_OT_redo_last(wmOperatorType *ot)
|
2009-02-04 11:52:16 +00:00
|
|
|
{
|
|
|
|
/* identifiers */
|
|
|
|
ot->name= "Redo Last";
|
2009-10-07 12:19:47 +00:00
|
|
|
ot->description= "Display menu for last action performed.";
|
2009-02-04 11:52:16 +00:00
|
|
|
ot->idname= "SCREEN_OT_redo_last";
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
ot->invoke= redo_last_invoke;
|
|
|
|
|
|
|
|
ot->poll= ED_operator_screenactive;
|
|
|
|
}
|
|
|
|
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
/* ************** region four-split operator ***************************** */
|
|
|
|
|
|
|
|
/* insert a region in the area region list */
|
2009-12-04 00:49:02 +00:00
|
|
|
static int region_quadview_exec(bContext *C, wmOperator *op)
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
{
|
|
|
|
ARegion *ar= CTX_wm_region(C);
|
|
|
|
|
|
|
|
/* some rules... */
|
|
|
|
if(ar->regiontype!=RGN_TYPE_WINDOW)
|
|
|
|
BKE_report(op->reports, RPT_ERROR, "Only window region can be 4-splitted");
|
2009-01-20 18:31:11 +00:00
|
|
|
else if(ar->alignment==RGN_ALIGN_QSPLIT) {
|
|
|
|
ScrArea *sa= CTX_wm_area(C);
|
|
|
|
ARegion *arn;
|
|
|
|
|
|
|
|
/* keep current region */
|
|
|
|
ar->alignment= 0;
|
|
|
|
|
|
|
|
if(sa->spacetype==SPACE_VIEW3D) {
|
|
|
|
RegionView3D *rv3d= ar->regiondata;
|
|
|
|
rv3d->viewlock= 0;
|
2009-02-16 15:08:06 +00:00
|
|
|
rv3d->rflag &= ~RV3D_CLIPPING;
|
2009-01-20 18:31:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for(ar= sa->regionbase.first; ar; ar= arn) {
|
|
|
|
arn= ar->next;
|
|
|
|
if(ar->alignment==RGN_ALIGN_QSPLIT) {
|
|
|
|
ED_region_exit(C, ar);
|
|
|
|
BKE_area_region_free(sa->type, ar);
|
|
|
|
BLI_remlink(&sa->regionbase, ar);
|
|
|
|
MEM_freeN(ar);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL);
|
|
|
|
}
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
else if(ar->next)
|
|
|
|
BKE_report(op->reports, RPT_ERROR, "Only last region can be 4-splitted");
|
|
|
|
else {
|
|
|
|
ScrArea *sa= CTX_wm_area(C);
|
|
|
|
ARegion *newar;
|
|
|
|
int count;
|
|
|
|
|
|
|
|
ar->alignment= RGN_ALIGN_QSPLIT;
|
|
|
|
|
|
|
|
for(count=0; count<3; count++) {
|
|
|
|
newar= BKE_area_region_copy(sa->type, ar);
|
|
|
|
BLI_addtail(&sa->regionbase, newar);
|
|
|
|
}
|
|
|
|
|
2009-01-20 14:23:32 +00:00
|
|
|
/* lock views and set them */
|
|
|
|
if(sa->spacetype==SPACE_VIEW3D) {
|
|
|
|
RegionView3D *rv3d;
|
|
|
|
|
|
|
|
rv3d= ar->regiondata;
|
2009-10-27 02:54:25 +00:00
|
|
|
rv3d->viewlock= RV3D_LOCKED; rv3d->view= RV3D_VIEW_FRONT; rv3d->persp= RV3D_ORTHO;
|
2009-01-20 14:23:32 +00:00
|
|
|
|
|
|
|
ar= ar->next;
|
|
|
|
rv3d= ar->regiondata;
|
2009-10-27 02:54:25 +00:00
|
|
|
rv3d->viewlock= RV3D_LOCKED; rv3d->view= RV3D_VIEW_TOP; rv3d->persp= RV3D_ORTHO;
|
2009-01-20 14:23:32 +00:00
|
|
|
|
|
|
|
ar= ar->next;
|
|
|
|
rv3d= ar->regiondata;
|
2009-10-27 02:54:25 +00:00
|
|
|
rv3d->viewlock= RV3D_LOCKED; rv3d->view= RV3D_VIEW_RIGHT; rv3d->persp= RV3D_ORTHO;
|
2009-01-20 14:23:32 +00:00
|
|
|
|
|
|
|
ar= ar->next;
|
|
|
|
rv3d= ar->regiondata;
|
2009-10-27 02:54:25 +00:00
|
|
|
rv3d->view= RV3D_VIEW_CAMERA; rv3d->persp= RV3D_CAMOB;
|
2009-01-20 14:23:32 +00:00
|
|
|
}
|
|
|
|
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
2009-12-04 00:49:02 +00:00
|
|
|
static void SCREEN_OT_region_quadview(wmOperatorType *ot)
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
{
|
|
|
|
/* identifiers */
|
2009-09-26 16:43:20 +00:00
|
|
|
ot->name= "Toggle Quad View";
|
2009-10-07 12:19:47 +00:00
|
|
|
ot->description= "Split selected area into camera, front, right & top views.";
|
2009-12-04 00:49:02 +00:00
|
|
|
ot->idname= "SCREEN_OT_region_quadview";
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2009-12-10 09:25:30 +00:00
|
|
|
// ot->invoke= WM_operator_confirm;
|
2009-12-04 00:49:02 +00:00
|
|
|
ot->exec= region_quadview_exec;
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
ot->poll= ED_operator_areaactive;
|
2009-09-12 19:11:34 +00:00
|
|
|
ot->flag= 0;
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-12-15 11:59:42 +00:00
|
|
|
/* ************** region flip operator ***************************** */
|
|
|
|
|
|
|
|
/* flip a region alignment */
|
|
|
|
static int region_flip_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
2008-12-18 02:56:48 +00:00
|
|
|
ARegion *ar= CTX_wm_region(C);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-12-10 05:05:04 +00:00
|
|
|
if (!ar)
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
2008-12-18 02:56:48 +00:00
|
|
|
if(ar->alignment==RGN_ALIGN_TOP)
|
|
|
|
ar->alignment= RGN_ALIGN_BOTTOM;
|
|
|
|
else if(ar->alignment==RGN_ALIGN_BOTTOM)
|
|
|
|
ar->alignment= RGN_ALIGN_TOP;
|
|
|
|
else if(ar->alignment==RGN_ALIGN_LEFT)
|
|
|
|
ar->alignment= RGN_ALIGN_RIGHT;
|
|
|
|
else if(ar->alignment==RGN_ALIGN_RIGHT)
|
|
|
|
ar->alignment= RGN_ALIGN_LEFT;
|
2008-12-15 11:59:42 +00:00
|
|
|
|
2008-12-27 16:09:56 +00:00
|
|
|
WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL);
|
2008-12-15 11:59:42 +00:00
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
2009-01-25 20:22:05 +00:00
|
|
|
|
2009-07-24 12:43:59 +00:00
|
|
|
static void SCREEN_OT_region_flip(wmOperatorType *ot)
|
2008-12-15 11:59:42 +00:00
|
|
|
{
|
|
|
|
/* identifiers */
|
|
|
|
ot->name= "Flip Region";
|
2008-12-26 11:11:21 +00:00
|
|
|
ot->idname= "SCREEN_OT_region_flip";
|
2008-12-15 11:59:42 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
ot->exec= region_flip_exec;
|
|
|
|
|
|
|
|
ot->poll= ED_operator_areaactive;
|
2009-09-12 19:11:34 +00:00
|
|
|
ot->flag= 0;
|
2009-11-27 06:24:09 +00:00
|
|
|
}
|
|
|
|
|
2009-11-27 11:51:34 +00:00
|
|
|
/* ************** header flip operator ***************************** */
|
|
|
|
|
|
|
|
/* flip a header region alignment */
|
|
|
|
static int header_flip_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
ARegion *ar= CTX_wm_region(C);
|
|
|
|
|
|
|
|
/* find the header region
|
|
|
|
* - try context first, but upon failing, search all regions in area...
|
|
|
|
*/
|
|
|
|
if((ar == NULL) || (ar->regiontype != RGN_TYPE_HEADER)) {
|
|
|
|
ScrArea *sa= CTX_wm_area(C);
|
|
|
|
|
|
|
|
/* loop over all regions until a matching one is found */
|
|
|
|
for (ar= sa->regionbase.first; ar; ar= ar->next) {
|
|
|
|
if(ar->regiontype == RGN_TYPE_HEADER)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* don't do anything if no region */
|
|
|
|
if(ar == NULL)
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* copied from SCREEN_OT_region_flip */
|
|
|
|
if(ar->alignment==RGN_ALIGN_TOP)
|
|
|
|
ar->alignment= RGN_ALIGN_BOTTOM;
|
|
|
|
else if(ar->alignment==RGN_ALIGN_BOTTOM)
|
|
|
|
ar->alignment= RGN_ALIGN_TOP;
|
|
|
|
else if(ar->alignment==RGN_ALIGN_LEFT)
|
|
|
|
ar->alignment= RGN_ALIGN_RIGHT;
|
|
|
|
else if(ar->alignment==RGN_ALIGN_RIGHT)
|
|
|
|
ar->alignment= RGN_ALIGN_LEFT;
|
|
|
|
|
|
|
|
WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL);
|
|
|
|
printf("executed header region flip\n");
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void SCREEN_OT_header_flip(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
|
|
|
ot->name= "Flip Header Region";
|
|
|
|
ot->idname= "SCREEN_OT_header_flip";
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
ot->exec= header_flip_exec;
|
|
|
|
|
|
|
|
ot->poll= ED_operator_areaactive;
|
|
|
|
ot->flag= 0;
|
|
|
|
}
|
|
|
|
|
2009-11-27 06:24:09 +00:00
|
|
|
/* ************** header tools operator ***************************** */
|
|
|
|
|
|
|
|
static int header_toolbox_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
|
|
|
{
|
|
|
|
ScrArea *sa= CTX_wm_area(C);
|
|
|
|
ARegion *ar= CTX_wm_region(C);
|
|
|
|
uiPopupMenu *pup;
|
|
|
|
uiLayout *layout;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-11-27 06:24:09 +00:00
|
|
|
pup= uiPupMenuBegin(C, "Header", 0);
|
|
|
|
layout= uiPupMenuLayout(pup);
|
|
|
|
|
2009-11-27 11:51:34 +00:00
|
|
|
// XXX SCREEN_OT_region_flip doesn't work - gets wrong context for active region, so added custom operator
|
2009-11-27 06:24:09 +00:00
|
|
|
if (ar->alignment == RGN_ALIGN_TOP)
|
2009-11-27 11:51:34 +00:00
|
|
|
uiItemO(layout, "Flip to Bottom", 0, "SCREEN_OT_header_flip");
|
2009-11-27 06:24:09 +00:00
|
|
|
else
|
2009-11-27 11:51:34 +00:00
|
|
|
uiItemO(layout, "Flip to Top", 0, "SCREEN_OT_header_flip");
|
2009-11-27 06:24:09 +00:00
|
|
|
|
|
|
|
uiItemS(layout);
|
|
|
|
|
|
|
|
/* file browser should be fullscreen all the time, but other regions can be maximised/restored... */
|
|
|
|
if (sa->spacetype != SPACE_FILE) {
|
|
|
|
if (sa->full)
|
2010-01-05 03:06:02 +00:00
|
|
|
uiItemO(layout, "Tile Area", 0, "SCREEN_OT_screen_full_area");
|
2009-11-27 06:24:09 +00:00
|
|
|
else
|
2010-01-05 03:06:02 +00:00
|
|
|
uiItemO(layout, "Maximize Area", 0, "SCREEN_OT_screen_full_area");
|
2009-11-27 06:24:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
uiPupMenuEnd(C, pup);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-11-27 06:24:09 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
2009-01-25 20:22:05 +00:00
|
|
|
|
2009-11-27 06:24:09 +00:00
|
|
|
void SCREEN_OT_header_toolbox(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
|
|
|
ot->name= "Header Toolbox";
|
|
|
|
ot->description="Display header region toolbox";
|
|
|
|
ot->idname= "SCREEN_OT_header_toolbox";
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
ot->invoke= header_toolbox_invoke;
|
2008-12-15 11:59:42 +00:00
|
|
|
}
|
|
|
|
|
2.5
Animation playback back in control. And non-blocking still!
- Play follows the "Playback" options in TimeLine menu.
Only the region 'windows' are drawn, not headers, toolbars,
channel views, etc.
The option "Buttons Window" also redraws property regions.
- The Timeline header always redraws, this to denote at least
progressing frame numbers
- For now: if you choose to play 3D views, it also redraws
the TimeLine. Seems to be good convention, but probably
better to add menu option for it?
- Fun test: while playback, change Playback options, works OK!
- New: top header button shows animation play status, and allows
to stop playback
- New: Animation stop/start operator. Assigned to ALT+A. It has
no options yet; just plays active region + all 3D windows now.
Options will follow, based on reviews.
Also ESC won't work for now, just press ALT+A again.
2009-05-21 13:33:04 +00:00
|
|
|
/* ****************** anim player, with timer ***************** */
|
2008-12-21 19:58:25 +00:00
|
|
|
|
2.5
Animation playback back in control. And non-blocking still!
- Play follows the "Playback" options in TimeLine menu.
Only the region 'windows' are drawn, not headers, toolbars,
channel views, etc.
The option "Buttons Window" also redraws property regions.
- The Timeline header always redraws, this to denote at least
progressing frame numbers
- For now: if you choose to play 3D views, it also redraws
the TimeLine. Seems to be good convention, but probably
better to add menu option for it?
- Fun test: while playback, change Playback options, works OK!
- New: top header button shows animation play status, and allows
to stop playback
- New: Animation stop/start operator. Assigned to ALT+A. It has
no options yet; just plays active region + all 3D windows now.
Options will follow, based on reviews.
Also ESC won't work for now, just press ALT+A again.
2009-05-21 13:33:04 +00:00
|
|
|
static int match_region_with_redraws(int spacetype, int regiontype, int redraws)
|
|
|
|
{
|
|
|
|
if(regiontype==RGN_TYPE_WINDOW) {
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2.5
Animation playback back in control. And non-blocking still!
- Play follows the "Playback" options in TimeLine menu.
Only the region 'windows' are drawn, not headers, toolbars,
channel views, etc.
The option "Buttons Window" also redraws property regions.
- The Timeline header always redraws, this to denote at least
progressing frame numbers
- For now: if you choose to play 3D views, it also redraws
the TimeLine. Seems to be good convention, but probably
better to add menu option for it?
- Fun test: while playback, change Playback options, works OK!
- New: top header button shows animation play status, and allows
to stop playback
- New: Animation stop/start operator. Assigned to ALT+A. It has
no options yet; just plays active region + all 3D windows now.
Options will follow, based on reviews.
Also ESC won't work for now, just press ALT+A again.
2009-05-21 13:33:04 +00:00
|
|
|
switch (spacetype) {
|
|
|
|
case SPACE_VIEW3D:
|
|
|
|
if(redraws & TIME_ALL_3D_WIN)
|
|
|
|
return 1;
|
|
|
|
break;
|
|
|
|
case SPACE_IPO:
|
|
|
|
case SPACE_ACTION:
|
|
|
|
case SPACE_NLA:
|
|
|
|
if(redraws & TIME_ALL_ANIM_WIN)
|
|
|
|
return 1;
|
|
|
|
break;
|
|
|
|
case SPACE_TIME:
|
|
|
|
/* if only 1 window or 3d windows, we do timeline too */
|
|
|
|
if(redraws & (TIME_ALL_ANIM_WIN|TIME_REGION|TIME_ALL_3D_WIN))
|
|
|
|
return 1;
|
|
|
|
break;
|
|
|
|
case SPACE_BUTS:
|
|
|
|
if(redraws & TIME_ALL_BUTS_WIN)
|
|
|
|
return 1;
|
|
|
|
break;
|
|
|
|
case SPACE_SEQ:
|
|
|
|
if(redraws & (TIME_SEQ|TIME_ALL_ANIM_WIN))
|
|
|
|
return 1;
|
|
|
|
break;
|
2009-09-21 16:21:54 +00:00
|
|
|
case SPACE_NODE:
|
|
|
|
if(redraws & (TIME_NODES))
|
|
|
|
return 1;
|
|
|
|
break;
|
2.5
Animation playback back in control. And non-blocking still!
- Play follows the "Playback" options in TimeLine menu.
Only the region 'windows' are drawn, not headers, toolbars,
channel views, etc.
The option "Buttons Window" also redraws property regions.
- The Timeline header always redraws, this to denote at least
progressing frame numbers
- For now: if you choose to play 3D views, it also redraws
the TimeLine. Seems to be good convention, but probably
better to add menu option for it?
- Fun test: while playback, change Playback options, works OK!
- New: top header button shows animation play status, and allows
to stop playback
- New: Animation stop/start operator. Assigned to ALT+A. It has
no options yet; just plays active region + all 3D windows now.
Options will follow, based on reviews.
Also ESC won't work for now, just press ALT+A again.
2009-05-21 13:33:04 +00:00
|
|
|
case SPACE_IMAGE:
|
|
|
|
if(redraws & TIME_ALL_IMAGE_WIN)
|
|
|
|
return 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(regiontype==RGN_TYPE_UI) {
|
|
|
|
if(redraws & TIME_ALL_BUTS_WIN)
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else if(regiontype==RGN_TYPE_HEADER) {
|
|
|
|
if(spacetype==SPACE_TIME)
|
|
|
|
return 1;
|
|
|
|
}
|
2009-12-18 13:28:03 +00:00
|
|
|
else if (regiontype==RGN_TYPE_PREVIEW) {
|
|
|
|
switch (spacetype) {
|
|
|
|
case SPACE_SEQ:
|
|
|
|
if(redraws & (TIME_SEQ|TIME_ALL_ANIM_WIN))
|
|
|
|
return 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2.5
Animation playback back in control. And non-blocking still!
- Play follows the "Playback" options in TimeLine menu.
Only the region 'windows' are drawn, not headers, toolbars,
channel views, etc.
The option "Buttons Window" also redraws property regions.
- The Timeline header always redraws, this to denote at least
progressing frame numbers
- For now: if you choose to play 3D views, it also redraws
the TimeLine. Seems to be good convention, but probably
better to add menu option for it?
- Fun test: while playback, change Playback options, works OK!
- New: top header button shows animation play status, and allows
to stop playback
- New: Animation stop/start operator. Assigned to ALT+A. It has
no options yet; just plays active region + all 3D windows now.
Options will follow, based on reviews.
Also ESC won't work for now, just press ALT+A again.
2009-05-21 13:33:04 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int screen_animation_step(bContext *C, wmOperator *op, wmEvent *event)
|
2008-12-21 19:58:25 +00:00
|
|
|
{
|
2008-12-22 12:57:53 +00:00
|
|
|
bScreen *screen= CTX_wm_screen(C);
|
2008-12-21 19:58:25 +00:00
|
|
|
|
2008-12-22 12:57:53 +00:00
|
|
|
if(screen->animtimer==event->customdata) {
|
2008-12-21 19:58:25 +00:00
|
|
|
Scene *scene= CTX_data_scene(C);
|
2.5
Animation playback back in control. And non-blocking still!
- Play follows the "Playback" options in TimeLine menu.
Only the region 'windows' are drawn, not headers, toolbars,
channel views, etc.
The option "Buttons Window" also redraws property regions.
- The Timeline header always redraws, this to denote at least
progressing frame numbers
- For now: if you choose to play 3D views, it also redraws
the TimeLine. Seems to be good convention, but probably
better to add menu option for it?
- Fun test: while playback, change Playback options, works OK!
- New: top header button shows animation play status, and allows
to stop playback
- New: Animation stop/start operator. Assigned to ALT+A. It has
no options yet; just plays active region + all 3D windows now.
Options will follow, based on reviews.
Also ESC won't work for now, just press ALT+A again.
2009-05-21 13:33:04 +00:00
|
|
|
wmTimer *wt= screen->animtimer;
|
|
|
|
ScreenAnimData *sad= wt->customdata;
|
|
|
|
ScrArea *sa;
|
2009-08-16 20:37:22 +00:00
|
|
|
int sync;
|
2009-11-10 09:50:39 +00:00
|
|
|
|
2009-08-16 20:37:22 +00:00
|
|
|
/* sync, don't sync, or follow scene setting */
|
2009-08-16 22:49:17 +00:00
|
|
|
if(sad->flag & ANIMPLAY_FLAG_SYNC) sync= 1;
|
|
|
|
else if(sad->flag & ANIMPLAY_FLAG_NO_SYNC) sync= 0;
|
2009-09-20 14:00:00 +00:00
|
|
|
else sync= (scene->audio.flag & AUDIO_SYNC);
|
2008-12-21 19:58:25 +00:00
|
|
|
|
2009-08-16 20:37:22 +00:00
|
|
|
if(sync) {
|
|
|
|
/* skip frames */
|
2009-02-15 13:09:19 +00:00
|
|
|
int step = floor(wt->duration * FPS);
|
2009-08-16 20:37:22 +00:00
|
|
|
if(sad->flag & ANIMPLAY_FLAG_REVERSE) // XXX does this option work with audio?
|
2009-07-07 07:29:21 +00:00
|
|
|
scene->r.cfra -= step;
|
|
|
|
else
|
|
|
|
scene->r.cfra += step;
|
2009-02-15 13:09:19 +00:00
|
|
|
wt->duration -= ((float)step)/FPS;
|
|
|
|
}
|
2009-07-07 07:29:21 +00:00
|
|
|
else {
|
2009-08-16 20:37:22 +00:00
|
|
|
/* one frame +/- */
|
|
|
|
if(sad->flag & ANIMPLAY_FLAG_REVERSE)
|
2009-07-07 07:29:21 +00:00
|
|
|
scene->r.cfra--;
|
|
|
|
else
|
|
|
|
scene->r.cfra++;
|
|
|
|
}
|
2008-12-21 23:39:52 +00:00
|
|
|
|
2009-07-31 07:43:47 +00:00
|
|
|
/* reset 'jumped' flag before checking if we need to jump... */
|
|
|
|
sad->flag &= ~ANIMPLAY_FLAG_JUMPED;
|
|
|
|
|
|
|
|
if (sad->flag & ANIMPLAY_FLAG_REVERSE) {
|
|
|
|
/* jump back to end? */
|
2009-07-07 07:29:21 +00:00
|
|
|
if (scene->r.psfra) {
|
2009-07-31 07:43:47 +00:00
|
|
|
if (scene->r.cfra < scene->r.psfra) {
|
2009-07-07 07:29:21 +00:00
|
|
|
scene->r.cfra= scene->r.pefra;
|
2009-07-31 07:43:47 +00:00
|
|
|
sad->flag |= ANIMPLAY_FLAG_JUMPED;
|
|
|
|
}
|
2009-07-07 07:29:21 +00:00
|
|
|
}
|
|
|
|
else {
|
2009-07-31 07:43:47 +00:00
|
|
|
if (scene->r.cfra < scene->r.sfra) {
|
2009-07-07 07:29:21 +00:00
|
|
|
scene->r.cfra= scene->r.efra;
|
2009-07-31 07:43:47 +00:00
|
|
|
sad->flag |= ANIMPLAY_FLAG_JUMPED;
|
|
|
|
}
|
2009-07-07 07:29:21 +00:00
|
|
|
}
|
2008-12-22 12:57:53 +00:00
|
|
|
}
|
|
|
|
else {
|
2009-07-31 07:43:47 +00:00
|
|
|
/* jump back to start? */
|
2009-07-07 07:29:21 +00:00
|
|
|
if (scene->r.psfra) {
|
2009-07-31 07:43:47 +00:00
|
|
|
if (scene->r.cfra > scene->r.pefra) {
|
2009-07-07 07:29:21 +00:00
|
|
|
scene->r.cfra= scene->r.psfra;
|
2009-07-31 07:43:47 +00:00
|
|
|
sad->flag |= ANIMPLAY_FLAG_JUMPED;
|
|
|
|
}
|
2009-07-07 07:29:21 +00:00
|
|
|
}
|
|
|
|
else {
|
2009-07-31 07:43:47 +00:00
|
|
|
if (scene->r.cfra > scene->r.efra) {
|
2009-07-07 07:29:21 +00:00
|
|
|
scene->r.cfra= scene->r.sfra;
|
2009-07-31 07:43:47 +00:00
|
|
|
sad->flag |= ANIMPLAY_FLAG_JUMPED;
|
|
|
|
}
|
2009-07-07 07:29:21 +00:00
|
|
|
}
|
2008-12-22 12:57:53 +00:00
|
|
|
}
|
2009-11-10 09:50:39 +00:00
|
|
|
|
2.5
Animation playback back in control. And non-blocking still!
- Play follows the "Playback" options in TimeLine menu.
Only the region 'windows' are drawn, not headers, toolbars,
channel views, etc.
The option "Buttons Window" also redraws property regions.
- The Timeline header always redraws, this to denote at least
progressing frame numbers
- For now: if you choose to play 3D views, it also redraws
the TimeLine. Seems to be good convention, but probably
better to add menu option for it?
- Fun test: while playback, change Playback options, works OK!
- New: top header button shows animation play status, and allows
to stop playback
- New: Animation stop/start operator. Assigned to ALT+A. It has
no options yet; just plays active region + all 3D windows now.
Options will follow, based on reviews.
Also ESC won't work for now, just press ALT+A again.
2009-05-21 13:33:04 +00:00
|
|
|
/* since we follow drawflags, we can't send notifier but tag regions ourselves */
|
2009-12-16 19:49:33 +00:00
|
|
|
|
2.5
Animation playback back in control. And non-blocking still!
- Play follows the "Playback" options in TimeLine menu.
Only the region 'windows' are drawn, not headers, toolbars,
channel views, etc.
The option "Buttons Window" also redraws property regions.
- The Timeline header always redraws, this to denote at least
progressing frame numbers
- For now: if you choose to play 3D views, it also redraws
the TimeLine. Seems to be good convention, but probably
better to add menu option for it?
- Fun test: while playback, change Playback options, works OK!
- New: top header button shows animation play status, and allows
to stop playback
- New: Animation stop/start operator. Assigned to ALT+A. It has
no options yet; just plays active region + all 3D windows now.
Options will follow, based on reviews.
Also ESC won't work for now, just press ALT+A again.
2009-05-21 13:33:04 +00:00
|
|
|
ED_update_for_newframe(C, 1);
|
2009-11-10 09:50:39 +00:00
|
|
|
|
2009-08-09 21:16:39 +00:00
|
|
|
sound_update_playing(C);
|
2009-12-16 19:49:33 +00:00
|
|
|
|
2.5
Animation playback back in control. And non-blocking still!
- Play follows the "Playback" options in TimeLine menu.
Only the region 'windows' are drawn, not headers, toolbars,
channel views, etc.
The option "Buttons Window" also redraws property regions.
- The Timeline header always redraws, this to denote at least
progressing frame numbers
- For now: if you choose to play 3D views, it also redraws
the TimeLine. Seems to be good convention, but probably
better to add menu option for it?
- Fun test: while playback, change Playback options, works OK!
- New: top header button shows animation play status, and allows
to stop playback
- New: Animation stop/start operator. Assigned to ALT+A. It has
no options yet; just plays active region + all 3D windows now.
Options will follow, based on reviews.
Also ESC won't work for now, just press ALT+A again.
2009-05-21 13:33:04 +00:00
|
|
|
for(sa= screen->areabase.first; sa; sa= sa->next) {
|
|
|
|
ARegion *ar;
|
|
|
|
for(ar= sa->regionbase.first; ar; ar= ar->next) {
|
|
|
|
if(ar==sad->ar)
|
|
|
|
ED_region_tag_redraw(ar);
|
|
|
|
else
|
|
|
|
if(match_region_with_redraws(sa->spacetype, ar->regiontype, sad->redraws))
|
|
|
|
ED_region_tag_redraw(ar);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-10 09:50:39 +00:00
|
|
|
/* recalculate the timestep for the timer now that we've finished calculating this,
|
|
|
|
* since the frames-per-second value may have been changed
|
|
|
|
*/
|
|
|
|
// TODO: this may make evaluation a bit slower if the value doesn't change... any way to avoid this?
|
|
|
|
wt->timestep= (1.0/FPS);
|
|
|
|
|
2008-12-21 19:58:25 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
return OPERATOR_PASS_THROUGH;
|
|
|
|
}
|
|
|
|
|
2.5
Animation playback back in control. And non-blocking still!
- Play follows the "Playback" options in TimeLine menu.
Only the region 'windows' are drawn, not headers, toolbars,
channel views, etc.
The option "Buttons Window" also redraws property regions.
- The Timeline header always redraws, this to denote at least
progressing frame numbers
- For now: if you choose to play 3D views, it also redraws
the TimeLine. Seems to be good convention, but probably
better to add menu option for it?
- Fun test: while playback, change Playback options, works OK!
- New: top header button shows animation play status, and allows
to stop playback
- New: Animation stop/start operator. Assigned to ALT+A. It has
no options yet; just plays active region + all 3D windows now.
Options will follow, based on reviews.
Also ESC won't work for now, just press ALT+A again.
2009-05-21 13:33:04 +00:00
|
|
|
static void SCREEN_OT_animation_step(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
|
|
|
ot->name= "Animation Step";
|
2009-10-07 12:19:47 +00:00
|
|
|
ot->description= "Step through animation by position.";
|
2.5
Animation playback back in control. And non-blocking still!
- Play follows the "Playback" options in TimeLine menu.
Only the region 'windows' are drawn, not headers, toolbars,
channel views, etc.
The option "Buttons Window" also redraws property regions.
- The Timeline header always redraws, this to denote at least
progressing frame numbers
- For now: if you choose to play 3D views, it also redraws
the TimeLine. Seems to be good convention, but probably
better to add menu option for it?
- Fun test: while playback, change Playback options, works OK!
- New: top header button shows animation play status, and allows
to stop playback
- New: Animation stop/start operator. Assigned to ALT+A. It has
no options yet; just plays active region + all 3D windows now.
Options will follow, based on reviews.
Also ESC won't work for now, just press ALT+A again.
2009-05-21 13:33:04 +00:00
|
|
|
ot->idname= "SCREEN_OT_animation_step";
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
ot->invoke= screen_animation_step;
|
|
|
|
|
|
|
|
ot->poll= ED_operator_screenactive;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ****************** anim player, starts or ends timer ***************** */
|
|
|
|
|
|
|
|
/* toggle operator */
|
|
|
|
static int screen_animation_play(bContext *C, wmOperator *op, wmEvent *event)
|
|
|
|
{
|
|
|
|
bScreen *screen= CTX_wm_screen(C);
|
|
|
|
|
|
|
|
if(screen->animtimer) {
|
2009-11-27 04:14:56 +00:00
|
|
|
/* stop playback now */
|
2009-08-16 20:37:22 +00:00
|
|
|
ED_screen_animation_timer(C, 0, 0, 0);
|
2009-08-09 21:16:39 +00:00
|
|
|
sound_stop_all(C);
|
2.5
Animation playback back in control. And non-blocking still!
- Play follows the "Playback" options in TimeLine menu.
Only the region 'windows' are drawn, not headers, toolbars,
channel views, etc.
The option "Buttons Window" also redraws property regions.
- The Timeline header always redraws, this to denote at least
progressing frame numbers
- For now: if you choose to play 3D views, it also redraws
the TimeLine. Seems to be good convention, but probably
better to add menu option for it?
- Fun test: while playback, change Playback options, works OK!
- New: top header button shows animation play status, and allows
to stop playback
- New: Animation stop/start operator. Assigned to ALT+A. It has
no options yet; just plays active region + all 3D windows now.
Options will follow, based on reviews.
Also ESC won't work for now, just press ALT+A again.
2009-05-21 13:33:04 +00:00
|
|
|
}
|
|
|
|
else {
|
2009-08-02 11:05:13 +00:00
|
|
|
ScrArea *sa= CTX_wm_area(C);
|
2009-07-07 07:29:21 +00:00
|
|
|
int mode= (RNA_boolean_get(op->ptr, "reverse")) ? -1 : 1;
|
2009-08-16 20:37:22 +00:00
|
|
|
int sync= -1;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-08-16 20:37:22 +00:00
|
|
|
if(RNA_property_is_set(op->ptr, "sync"))
|
|
|
|
sync= (RNA_boolean_get(op->ptr, "sync"));
|
2009-07-07 07:29:21 +00:00
|
|
|
|
2009-08-02 11:05:13 +00:00
|
|
|
/* timeline gets special treatment since it has it's own menu for determining redraws */
|
|
|
|
if ((sa) && (sa->spacetype == SPACE_TIME)) {
|
|
|
|
SpaceTime *stime= (SpaceTime *)sa->spacedata.first;
|
2.5
Animation playback back in control. And non-blocking still!
- Play follows the "Playback" options in TimeLine menu.
Only the region 'windows' are drawn, not headers, toolbars,
channel views, etc.
The option "Buttons Window" also redraws property regions.
- The Timeline header always redraws, this to denote at least
progressing frame numbers
- For now: if you choose to play 3D views, it also redraws
the TimeLine. Seems to be good convention, but probably
better to add menu option for it?
- Fun test: while playback, change Playback options, works OK!
- New: top header button shows animation play status, and allows
to stop playback
- New: Animation stop/start operator. Assigned to ALT+A. It has
no options yet; just plays active region + all 3D windows now.
Options will follow, based on reviews.
Also ESC won't work for now, just press ALT+A again.
2009-05-21 13:33:04 +00:00
|
|
|
|
2009-08-16 20:37:22 +00:00
|
|
|
ED_screen_animation_timer(C, stime->redraws, sync, mode);
|
2009-08-02 11:05:13 +00:00
|
|
|
|
|
|
|
/* update region if TIME_REGION was set, to leftmost 3d window */
|
2009-12-08 17:23:48 +00:00
|
|
|
ED_screen_animation_timer_update(screen, stime->redraws);
|
2009-08-02 11:05:13 +00:00
|
|
|
}
|
|
|
|
else {
|
2009-10-08 12:33:51 +00:00
|
|
|
int redraws = TIME_REGION|TIME_ALL_3D_WIN;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-10-08 12:33:51 +00:00
|
|
|
/* XXX - would like a better way to deal with this situation - Campbell */
|
|
|
|
if((sa) && (sa->spacetype == SPACE_SEQ)) {
|
|
|
|
redraws |= TIME_SEQ;
|
|
|
|
}
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-10-08 12:33:51 +00:00
|
|
|
ED_screen_animation_timer(C, redraws, sync, mode);
|
2009-08-02 11:05:13 +00:00
|
|
|
|
|
|
|
if(screen->animtimer) {
|
|
|
|
wmTimer *wt= screen->animtimer;
|
|
|
|
ScreenAnimData *sad= wt->customdata;
|
|
|
|
|
|
|
|
sad->ar= CTX_wm_region(C);
|
|
|
|
}
|
2.5
Animation playback back in control. And non-blocking still!
- Play follows the "Playback" options in TimeLine menu.
Only the region 'windows' are drawn, not headers, toolbars,
channel views, etc.
The option "Buttons Window" also redraws property regions.
- The Timeline header always redraws, this to denote at least
progressing frame numbers
- For now: if you choose to play 3D views, it also redraws
the TimeLine. Seems to be good convention, but probably
better to add menu option for it?
- Fun test: while playback, change Playback options, works OK!
- New: top header button shows animation play status, and allows
to stop playback
- New: Animation stop/start operator. Assigned to ALT+A. It has
no options yet; just plays active region + all 3D windows now.
Options will follow, based on reviews.
Also ESC won't work for now, just press ALT+A again.
2009-05-21 13:33:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
2009-07-24 12:43:59 +00:00
|
|
|
static void SCREEN_OT_animation_play(wmOperatorType *ot)
|
2008-12-21 19:58:25 +00:00
|
|
|
{
|
|
|
|
/* identifiers */
|
2009-09-26 16:43:20 +00:00
|
|
|
ot->name= "Play Animation";
|
2009-10-07 12:19:47 +00:00
|
|
|
ot->description= "Play animation.";
|
2008-12-26 11:11:21 +00:00
|
|
|
ot->idname= "SCREEN_OT_animation_play";
|
2008-12-21 19:58:25 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
ot->invoke= screen_animation_play;
|
|
|
|
|
|
|
|
ot->poll= ED_operator_screenactive;
|
|
|
|
|
2009-07-07 07:29:21 +00:00
|
|
|
RNA_def_boolean(ot->srna, "reverse", 0, "Play in Reverse", "Animation is played backwards");
|
2009-08-16 20:37:22 +00:00
|
|
|
RNA_def_boolean(ot->srna, "sync", 0, "Sync", "Drop frames to maintain framerate and stay in sync with audio.");
|
2008-12-21 19:58:25 +00:00
|
|
|
}
|
2008-12-09 15:59:43 +00:00
|
|
|
|
2009-10-09 21:50:33 +00:00
|
|
|
static int screen_animation_cancel(bContext *C, wmOperator *op, wmEvent *event)
|
|
|
|
{
|
|
|
|
bScreen *screen= CTX_wm_screen(C);
|
|
|
|
|
2009-11-27 04:14:56 +00:00
|
|
|
if(screen->animtimer) {
|
|
|
|
ScreenAnimData *sad= screen->animtimer->customdata;
|
|
|
|
Scene *scene= CTX_data_scene(C);
|
|
|
|
|
|
|
|
/* reset current frame before stopping, and just send a notifier to deal with the rest
|
|
|
|
* (since playback still needs to be stopped)
|
|
|
|
*/
|
|
|
|
scene->r.cfra= sad->sfra;
|
|
|
|
WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene);
|
|
|
|
|
|
|
|
/* call the other "toggling" operator to clean up now */
|
2009-10-09 21:50:33 +00:00
|
|
|
return screen_animation_play(C, op, event);
|
2009-11-27 04:14:56 +00:00
|
|
|
}
|
2009-10-09 21:50:33 +00:00
|
|
|
|
|
|
|
return OPERATOR_PASS_THROUGH;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void SCREEN_OT_animation_cancel(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
|
|
|
ot->name= "Cancel Animation";
|
2009-11-27 04:14:56 +00:00
|
|
|
ot->description= "Cancel animation, returning to the original frame.";
|
2009-10-09 21:50:33 +00:00
|
|
|
ot->idname= "SCREEN_OT_animation_cancel";
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
ot->invoke= screen_animation_cancel;
|
|
|
|
|
|
|
|
ot->poll= ED_operator_screenactive;
|
|
|
|
}
|
|
|
|
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
/* ************** border select operator (template) ***************************** */
|
2008-11-19 16:28:11 +00:00
|
|
|
|
|
|
|
/* operator state vars used: (added by default WM callbacks)
|
2009-12-10 09:25:30 +00:00
|
|
|
xmin, ymin
|
|
|
|
xmax, ymax
|
|
|
|
|
|
|
|
customdata: the wmGesture pointer
|
|
|
|
|
|
|
|
callbacks:
|
|
|
|
|
|
|
|
exec() has to be filled in by user
|
|
|
|
|
|
|
|
invoke() default WM function
|
|
|
|
adds modal handler
|
|
|
|
|
|
|
|
modal() default WM function
|
|
|
|
accept modal events while doing it, calls exec(), handles ESC and border drawing
|
|
|
|
|
|
|
|
poll() has to be filled in by user for context
|
|
|
|
*/
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
#if 0
|
2008-11-19 16:28:11 +00:00
|
|
|
static int border_select_do(bContext *C, wmOperator *op)
|
|
|
|
{
|
2008-11-24 15:51:55 +00:00
|
|
|
int event_type= RNA_int_get(op->ptr, "event_type");
|
2008-11-24 10:45:36 +00:00
|
|
|
|
|
|
|
if(event_type==LEFTMOUSE)
|
|
|
|
printf("border select do select\n");
|
|
|
|
else if(event_type==RIGHTMOUSE)
|
|
|
|
printf("border select deselect\n");
|
|
|
|
else
|
|
|
|
printf("border select do something\n");
|
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2009-07-24 12:43:59 +00:00
|
|
|
static void SCREEN_OT_border_select(wmOperatorType *ot)
|
2008-11-19 16:28:11 +00:00
|
|
|
{
|
|
|
|
/* identifiers */
|
|
|
|
ot->name= "Border select";
|
2008-12-26 11:11:21 +00:00
|
|
|
ot->idname= "SCREEN_OT_border_select";
|
2008-11-19 16:28:11 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
ot->exec= border_select_do;
|
|
|
|
ot->invoke= WM_border_select_invoke;
|
|
|
|
ot->modal= WM_border_select_modal;
|
|
|
|
|
|
|
|
ot->poll= ED_operator_areaactive;
|
2008-11-24 10:45:36 +00:00
|
|
|
|
|
|
|
/* rna */
|
2009-01-16 23:53:11 +00:00
|
|
|
RNA_def_int(ot->srna, "event_type", 0, INT_MIN, INT_MAX, "Event Type", "", INT_MIN, INT_MAX);
|
|
|
|
RNA_def_int(ot->srna, "xmin", 0, INT_MIN, INT_MAX, "X Min", "", INT_MIN, INT_MAX);
|
|
|
|
RNA_def_int(ot->srna, "xmax", 0, INT_MIN, INT_MAX, "X Max", "", INT_MIN, INT_MAX);
|
|
|
|
RNA_def_int(ot->srna, "ymin", 0, INT_MIN, INT_MAX, "Y Min", "", INT_MIN, INT_MAX);
|
|
|
|
RNA_def_int(ot->srna, "ymax", 0, INT_MIN, INT_MAX, "Y Max", "", INT_MIN, INT_MAX);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
}
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
#endif
|
2008-11-19 16:28:11 +00:00
|
|
|
|
2009-02-04 17:40:50 +00:00
|
|
|
/* ****************************** render invoking ***************** */
|
|
|
|
|
|
|
|
/* set callbacks, exported to sequence render too.
|
2009-12-10 09:25:30 +00:00
|
|
|
Only call in foreground (UI) renders. */
|
2009-02-04 17:40:50 +00:00
|
|
|
|
|
|
|
/* returns biggest area that is not uv/image editor. Note that it uses buttons */
|
|
|
|
/* window as the last possible alternative. */
|
|
|
|
static ScrArea *biggest_non_image_area(bContext *C)
|
|
|
|
{
|
|
|
|
bScreen *sc= CTX_wm_screen(C);
|
|
|
|
ScrArea *sa, *big= NULL;
|
|
|
|
int size, maxsize= 0, bwmaxsize= 0;
|
|
|
|
short foundwin= 0;
|
|
|
|
|
|
|
|
for(sa= sc->areabase.first; sa; sa= sa->next) {
|
2009-05-20 16:23:55 +00:00
|
|
|
if(sa->winx > 30 && sa->winy > 30) {
|
2009-02-04 17:40:50 +00:00
|
|
|
size= sa->winx*sa->winy;
|
|
|
|
if(sa->spacetype == SPACE_BUTS) {
|
|
|
|
if(foundwin == 0 && size > bwmaxsize) {
|
|
|
|
bwmaxsize= size;
|
|
|
|
big= sa;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(sa->spacetype != SPACE_IMAGE && size > maxsize) {
|
|
|
|
maxsize= size;
|
|
|
|
big= sa;
|
|
|
|
foundwin= 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return big;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ScrArea *biggest_area(bContext *C)
|
|
|
|
{
|
|
|
|
bScreen *sc= CTX_wm_screen(C);
|
|
|
|
ScrArea *sa, *big= NULL;
|
|
|
|
int size, maxsize= 0;
|
|
|
|
|
|
|
|
for(sa= sc->areabase.first; sa; sa= sa->next) {
|
|
|
|
size= sa->winx*sa->winy;
|
|
|
|
if(size > maxsize) {
|
|
|
|
maxsize= size;
|
|
|
|
big= sa;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return big;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static ScrArea *find_area_showing_r_result(bContext *C)
|
|
|
|
{
|
2009-10-20 21:13:42 +00:00
|
|
|
wmWindowManager *wm= CTX_wm_manager(C);
|
|
|
|
wmWindow *win;
|
2009-10-21 10:56:31 +00:00
|
|
|
ScrArea *sa = NULL;
|
2009-02-04 17:40:50 +00:00
|
|
|
SpaceImage *sima;
|
|
|
|
|
|
|
|
/* find an imagewindow showing render result */
|
2009-10-20 21:13:42 +00:00
|
|
|
for(win=wm->windows.first; win; win=win->next) {
|
|
|
|
for(sa=win->screen->areabase.first; sa; sa= sa->next) {
|
|
|
|
if(sa->spacetype==SPACE_IMAGE) {
|
|
|
|
sima= sa->spacedata.first;
|
|
|
|
if(sima->image && sima->image->type==IMA_TYPE_R_RESULT)
|
|
|
|
break;
|
|
|
|
}
|
2009-02-04 17:40:50 +00:00
|
|
|
}
|
|
|
|
}
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-02-04 17:40:50 +00:00
|
|
|
return sa;
|
|
|
|
}
|
|
|
|
|
2.5: Render
* UI layout for scene buttons has quite some changes, I tried to
better organize things according to the pipeline, and also showing
important properties by default, and collapsing less important ones.
Some changes compared to 2.4x:
* Panorama is now a Camera property.
* Sequence and Compositing are now enabled by default, but will only
do something when there is a node tree using nodes, or a strip in the
sequence editor.
* Enabling Full Sample now automatically enables Save Buffers too.
* Stamp option to include info in file is removed, it now simply always
does this if one of the stamp infos is enabled.
* Xvid, H.264 and Ogg Theora are now directly in the file format menu,
but still using FFMPEG. Unfortunately Ogg is broken at the moment
(also in 2.4x), so that's disabled. And Xvid crashes on 64bit linux,
maybe solvable by upgrading extern/xvidcore/, using ubuntu libs makes
it work.
* Organized file format menu by image/movie types.
Added:
* Render layers RNA wrapped, operatorized, layouted.
* FFMPEG format/codec options are now working.
Defaults changed:
* Compositing & Sequencer enabled.
* Tiles set to 8x8.
* Time/Date/Frame/Scene/Camera/Filename enabled for stamp.
2009-07-13 19:09:13 +00:00
|
|
|
static ScrArea *find_area_image_empty(bContext *C)
|
|
|
|
{
|
|
|
|
bScreen *sc= CTX_wm_screen(C);
|
|
|
|
ScrArea *sa;
|
|
|
|
SpaceImage *sima;
|
|
|
|
|
|
|
|
/* find an imagewindow showing render result */
|
|
|
|
for(sa=sc->areabase.first; sa; sa= sa->next) {
|
|
|
|
if(sa->spacetype==SPACE_IMAGE) {
|
|
|
|
sima= sa->spacedata.first;
|
|
|
|
if(!sima->image)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return sa;
|
|
|
|
}
|
|
|
|
|
2009-07-16 04:45:52 +00:00
|
|
|
#if 0 // XXX not used
|
2.5: Render
* UI layout for scene buttons has quite some changes, I tried to
better organize things according to the pipeline, and also showing
important properties by default, and collapsing less important ones.
Some changes compared to 2.4x:
* Panorama is now a Camera property.
* Sequence and Compositing are now enabled by default, but will only
do something when there is a node tree using nodes, or a strip in the
sequence editor.
* Enabling Full Sample now automatically enables Save Buffers too.
* Stamp option to include info in file is removed, it now simply always
does this if one of the stamp infos is enabled.
* Xvid, H.264 and Ogg Theora are now directly in the file format menu,
but still using FFMPEG. Unfortunately Ogg is broken at the moment
(also in 2.4x), so that's disabled. And Xvid crashes on 64bit linux,
maybe solvable by upgrading extern/xvidcore/, using ubuntu libs makes
it work.
* Organized file format menu by image/movie types.
Added:
* Render layers RNA wrapped, operatorized, layouted.
* FFMPEG format/codec options are now working.
Defaults changed:
* Compositing & Sequencer enabled.
* Tiles set to 8x8.
* Time/Date/Frame/Scene/Camera/Filename enabled for stamp.
2009-07-13 19:09:13 +00:00
|
|
|
static ScrArea *find_empty_image_area(bContext *C)
|
|
|
|
{
|
|
|
|
bScreen *sc= CTX_wm_screen(C);
|
|
|
|
ScrArea *sa;
|
|
|
|
SpaceImage *sima;
|
|
|
|
|
|
|
|
/* find an imagewindow showing render result */
|
|
|
|
for(sa=sc->areabase.first; sa; sa= sa->next) {
|
|
|
|
if(sa->spacetype==SPACE_IMAGE) {
|
|
|
|
sima= sa->spacedata.first;
|
|
|
|
if(!sima->image)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return sa;
|
|
|
|
}
|
2009-07-16 04:45:52 +00:00
|
|
|
#endif // XXX not used
|
2.5: Render
* UI layout for scene buttons has quite some changes, I tried to
better organize things according to the pipeline, and also showing
important properties by default, and collapsing less important ones.
Some changes compared to 2.4x:
* Panorama is now a Camera property.
* Sequence and Compositing are now enabled by default, but will only
do something when there is a node tree using nodes, or a strip in the
sequence editor.
* Enabling Full Sample now automatically enables Save Buffers too.
* Stamp option to include info in file is removed, it now simply always
does this if one of the stamp infos is enabled.
* Xvid, H.264 and Ogg Theora are now directly in the file format menu,
but still using FFMPEG. Unfortunately Ogg is broken at the moment
(also in 2.4x), so that's disabled. And Xvid crashes on 64bit linux,
maybe solvable by upgrading extern/xvidcore/, using ubuntu libs makes
it work.
* Organized file format menu by image/movie types.
Added:
* Render layers RNA wrapped, operatorized, layouted.
* FFMPEG format/codec options are now working.
Defaults changed:
* Compositing & Sequencer enabled.
* Tiles set to 8x8.
* Time/Date/Frame/Scene/Camera/Filename enabled for stamp.
2009-07-13 19:09:13 +00:00
|
|
|
|
2009-07-24 12:43:59 +00:00
|
|
|
/* new window uses x,y to set position */
|
|
|
|
static void screen_set_image_output(bContext *C, int mx, int my)
|
2009-02-04 17:40:50 +00:00
|
|
|
{
|
2009-10-26 11:43:27 +00:00
|
|
|
wmWindow *win= CTX_wm_window(C);
|
2009-07-10 16:55:49 +00:00
|
|
|
Scene *scene= CTX_data_scene(C);
|
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
|
|
|
ScrArea *sa= NULL;
|
2009-02-04 17:40:50 +00:00
|
|
|
SpaceImage *sima;
|
|
|
|
|
2009-07-24 12:43:59 +00:00
|
|
|
if(scene->r.displaymode==R_OUTPUT_WINDOW) {
|
|
|
|
rcti rect;
|
|
|
|
int sizex, sizey;
|
|
|
|
|
|
|
|
sizex= 10 + (scene->r.xsch*scene->r.size)/100;
|
|
|
|
sizey= 40 + (scene->r.ysch*scene->r.size)/100;
|
|
|
|
|
|
|
|
/* arbitrary... miniature image window views don't make much sense */
|
|
|
|
if(sizex < 320) sizex= 320;
|
|
|
|
if(sizey < 256) sizey= 256;
|
|
|
|
|
|
|
|
/* XXX some magic to calculate postition */
|
2009-10-26 11:43:27 +00:00
|
|
|
rect.xmin= mx + win->posx - sizex/2;
|
|
|
|
rect.ymin= my + win->posy - sizey/2;
|
2009-07-24 12:43:59 +00:00
|
|
|
rect.xmax= rect.xmin + sizex;
|
|
|
|
rect.ymax= rect.ymin + sizey;
|
|
|
|
|
|
|
|
/* changes context! */
|
|
|
|
WM_window_open_temp(C, &rect, WM_WINDOW_RENDER);
|
|
|
|
|
|
|
|
sa= CTX_wm_area(C);
|
|
|
|
}
|
|
|
|
else if(scene->r.displaymode==R_OUTPUT_SCREEN) {
|
2009-07-10 16:55:49 +00:00
|
|
|
/* this function returns with changed context */
|
|
|
|
ED_screen_full_newspace(C, CTX_wm_area(C), SPACE_IMAGE);
|
|
|
|
sa= CTX_wm_area(C);
|
|
|
|
}
|
2009-02-04 17:40:50 +00:00
|
|
|
|
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
|
|
|
if(!sa) {
|
2009-07-10 16:55:49 +00:00
|
|
|
sa= find_area_showing_r_result(C);
|
2.5: Render
* UI layout for scene buttons has quite some changes, I tried to
better organize things according to the pipeline, and also showing
important properties by default, and collapsing less important ones.
Some changes compared to 2.4x:
* Panorama is now a Camera property.
* Sequence and Compositing are now enabled by default, but will only
do something when there is a node tree using nodes, or a strip in the
sequence editor.
* Enabling Full Sample now automatically enables Save Buffers too.
* Stamp option to include info in file is removed, it now simply always
does this if one of the stamp infos is enabled.
* Xvid, H.264 and Ogg Theora are now directly in the file format menu,
but still using FFMPEG. Unfortunately Ogg is broken at the moment
(also in 2.4x), so that's disabled. And Xvid crashes on 64bit linux,
maybe solvable by upgrading extern/xvidcore/, using ubuntu libs makes
it work.
* Organized file format menu by image/movie types.
Added:
* Render layers RNA wrapped, operatorized, layouted.
* FFMPEG format/codec options are now working.
Defaults changed:
* Compositing & Sequencer enabled.
* Tiles set to 8x8.
* Time/Date/Frame/Scene/Camera/Filename enabled for stamp.
2009-07-13 19:09:13 +00:00
|
|
|
if(sa==NULL)
|
|
|
|
sa= find_area_image_empty(C);
|
2009-07-10 16:55:49 +00:00
|
|
|
|
|
|
|
if(sa==NULL) {
|
|
|
|
/* find largest open non-image area */
|
|
|
|
sa= biggest_non_image_area(C);
|
|
|
|
if(sa) {
|
|
|
|
ED_area_newspace(C, sa, SPACE_IMAGE);
|
2009-02-04 17:40:50 +00:00
|
|
|
sima= sa->spacedata.first;
|
|
|
|
|
|
|
|
/* makes ESC go back to prev space */
|
|
|
|
sima->flag |= SI_PREVSPACE;
|
|
|
|
}
|
2009-07-10 16:55:49 +00:00
|
|
|
else {
|
|
|
|
/* use any area of decent size */
|
|
|
|
sa= biggest_area(C);
|
|
|
|
if(sa->spacetype!=SPACE_IMAGE) {
|
|
|
|
// XXX newspace(sa, SPACE_IMAGE);
|
|
|
|
sima= sa->spacedata.first;
|
|
|
|
|
|
|
|
/* makes ESC go back to prev space */
|
|
|
|
sima->flag |= SI_PREVSPACE;
|
|
|
|
}
|
|
|
|
}
|
2009-02-04 17:40:50 +00:00
|
|
|
}
|
2009-07-10 16:55:49 +00:00
|
|
|
}
|
2009-02-04 17:40:50 +00:00
|
|
|
sima= sa->spacedata.first;
|
|
|
|
|
|
|
|
/* get the correct image, and scale it */
|
|
|
|
sima->image= BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result");
|
|
|
|
|
2009-12-10 09:25:30 +00:00
|
|
|
// if(G.displaymode==2) { // XXX
|
|
|
|
if(sa->full) {
|
|
|
|
sima->flag |= SI_FULLWINDOW|SI_PREVSPACE;
|
|
|
|
|
|
|
|
// ed_screen_fullarea(C, win, sa);
|
|
|
|
}
|
|
|
|
// }
|
2009-02-04 17:40:50 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* executes blocking render */
|
|
|
|
static int screen_render_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
Scene *scene= CTX_data_scene(C);
|
|
|
|
Render *re= RE_GetRender(scene->id.name);
|
|
|
|
|
|
|
|
if(re==NULL) {
|
|
|
|
re= RE_NewRender(scene->id.name);
|
|
|
|
}
|
|
|
|
RE_test_break_cb(re, NULL, (int (*)(void *)) blender_test_break);
|
|
|
|
|
2.5: Render/Game Engine
An engine to use for output can now be selected an influences what
shows in the buttons window, only showing relevant data. The idea
behind this is to make it more clear what is supported where, make
the system more pluggable for external render/game engines, and save
space hiding stuff that is not relevant anyway.
* Top header now has an engine menu, to choose between the blender
render engine, game engine, and other future external engines.
* If the game engine is enabled, the buttons window should show
only properties that work in the game engine, and similarly for
the render engine.
* Moved panels from the logic space and game tabs to the physics,
scene and world tabs instead, and removed the game tab.
* Materials and textures tabs should eventually become game
specific too, to better show what is supported.
2009-07-23 21:50:40 +00:00
|
|
|
if(RNA_boolean_get(op->ptr, "animation"))
|
2009-12-22 12:01:32 +00:00
|
|
|
RE_BlenderAnim(re, scene, scene->r.sfra, scene->r.efra, scene->r.frame_step, op->reports);
|
2009-02-04 17:40:50 +00:00
|
|
|
else
|
2010-01-06 00:09:07 +00:00
|
|
|
RE_BlenderFrame(re, scene, NULL, scene->r.cfra);
|
2009-02-04 17:40:50 +00:00
|
|
|
|
|
|
|
// no redraw needed, we leave state as we entered it
|
|
|
|
ED_update_for_newframe(C, 1);
|
|
|
|
|
|
|
|
WM_event_add_notifier(C, NC_SCENE|ND_RENDER_RESULT, scene);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-02-04 17:40:50 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct RenderJob {
|
|
|
|
Scene *scene;
|
|
|
|
Render *re;
|
|
|
|
wmWindow *win;
|
2010-01-06 00:09:07 +00:00
|
|
|
SceneRenderLayer *srl;
|
2009-02-04 17:40:50 +00:00
|
|
|
int anim;
|
2009-02-05 19:28:28 +00:00
|
|
|
Image *image;
|
|
|
|
ImageUser iuser;
|
2009-02-04 17:40:50 +00:00
|
|
|
short *stop;
|
|
|
|
short *do_update;
|
2009-12-22 12:01:32 +00:00
|
|
|
ReportList *reports;
|
2009-02-04 17:40:50 +00:00
|
|
|
} RenderJob;
|
|
|
|
|
|
|
|
static void render_freejob(void *rjv)
|
|
|
|
{
|
|
|
|
RenderJob *rj= rjv;
|
|
|
|
|
|
|
|
MEM_freeN(rj);
|
|
|
|
}
|
|
|
|
|
2009-07-10 16:55:49 +00:00
|
|
|
/* str is IMA_RW_MAXTEXT in size */
|
|
|
|
static void make_renderinfo_string(RenderStats *rs, Scene *scene, char *str)
|
|
|
|
{
|
|
|
|
char info_time_str[32]; // used to be extern to header_info.c
|
|
|
|
uintptr_t mem_in_use, mmap_in_use;
|
|
|
|
float megs_used_memory, mmap_used_memory;
|
|
|
|
char *spos= str;
|
|
|
|
|
|
|
|
mem_in_use= MEM_get_memory_in_use();
|
|
|
|
mmap_in_use= MEM_get_mapped_memory_in_use();
|
|
|
|
|
|
|
|
megs_used_memory= (mem_in_use-mmap_in_use)/(1024.0*1024.0);
|
|
|
|
mmap_used_memory= (mmap_in_use)/(1024.0*1024.0);
|
|
|
|
|
|
|
|
if(scene->lay & 0xFF000000)
|
|
|
|
spos+= sprintf(spos, "Localview | ");
|
|
|
|
else if(scene->r.scemode & R_SINGLE_LAYER)
|
|
|
|
spos+= sprintf(spos, "Single Layer | ");
|
|
|
|
|
2009-07-21 20:28:32 +00:00
|
|
|
if(rs->statstr) {
|
|
|
|
spos+= sprintf(spos, "%s ", rs->statstr);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
spos+= sprintf(spos, "Fra:%d Ve:%d Fa:%d ", (scene->r.cfra), rs->totvert, rs->totface);
|
|
|
|
if(rs->tothalo) spos+= sprintf(spos, "Ha:%d ", rs->tothalo);
|
|
|
|
if(rs->totstrand) spos+= sprintf(spos, "St:%d ", rs->totstrand);
|
|
|
|
spos+= sprintf(spos, "La:%d Mem:%.2fM (%.2fM) ", rs->totlamp, megs_used_memory, mmap_used_memory);
|
|
|
|
|
|
|
|
if(rs->curfield)
|
|
|
|
spos+= sprintf(spos, "Field %d ", rs->curfield);
|
|
|
|
if(rs->curblur)
|
|
|
|
spos+= sprintf(spos, "Blur %d ", rs->curblur);
|
|
|
|
}
|
2009-07-10 16:55:49 +00:00
|
|
|
|
|
|
|
BLI_timestr(rs->lastframetime, info_time_str);
|
|
|
|
spos+= sprintf(spos, "Time:%s ", info_time_str);
|
|
|
|
|
2009-07-21 20:28:32 +00:00
|
|
|
if(rs->infostr && rs->infostr[0])
|
2009-07-10 16:55:49 +00:00
|
|
|
spos+= sprintf(spos, "| %s ", rs->infostr);
|
|
|
|
|
|
|
|
/* very weak... but 512 characters is quite safe */
|
|
|
|
if(spos >= str+IMA_RW_MAXTEXT)
|
|
|
|
printf("WARNING! renderwin text beyond limit \n");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void image_renderinfo_cb(void *rjv, RenderStats *rs)
|
|
|
|
{
|
|
|
|
RenderJob *rj= rjv;
|
|
|
|
|
|
|
|
/* malloc OK here, stats_draw is not in tile threads */
|
|
|
|
if(rj->image->render_text==NULL)
|
|
|
|
rj->image->render_text= MEM_callocN(IMA_RW_MAXTEXT, "rendertext");
|
|
|
|
|
|
|
|
make_renderinfo_string(rs, rj->scene, rj->image->render_text);
|
|
|
|
|
|
|
|
/* make jobs timer to send notifier */
|
|
|
|
*(rj->do_update)= 1;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-07-10 16:55:49 +00:00
|
|
|
}
|
|
|
|
|
2009-02-04 17:40:50 +00:00
|
|
|
/* called inside thread! */
|
2009-10-28 18:03:04 +00:00
|
|
|
static void image_buffer_rect_update(Scene *scene, RenderResult *rr, ImBuf *ibuf, volatile rcti *renrect)
|
2009-02-04 17:40:50 +00:00
|
|
|
{
|
2009-02-05 19:28:28 +00:00
|
|
|
float x1, y1, *rectf= NULL;
|
|
|
|
int ymin, ymax, xmin, xmax;
|
|
|
|
int rymin, rxmin;
|
|
|
|
char *rectc;
|
|
|
|
|
|
|
|
/* if renrect argument, we only refresh scanlines */
|
|
|
|
if(renrect) {
|
|
|
|
/* if ymax==recty, rendering of layer is ready, we should not draw, other things happen... */
|
|
|
|
if(rr->renlay==NULL || renrect->ymax>=rr->recty)
|
|
|
|
return;
|
2009-02-04 17:40:50 +00:00
|
|
|
|
2009-02-05 19:28:28 +00:00
|
|
|
/* xmin here is first subrect x coord, xmax defines subrect width */
|
2009-02-14 18:31:19 +00:00
|
|
|
xmin = renrect->xmin + rr->crop;
|
|
|
|
xmax = renrect->xmax - xmin - rr->crop;
|
2009-02-05 19:28:28 +00:00
|
|
|
if (xmax<2) return;
|
2009-02-04 17:40:50 +00:00
|
|
|
|
2009-02-14 18:31:19 +00:00
|
|
|
ymin= renrect->ymin + rr->crop;
|
|
|
|
ymax= renrect->ymax - ymin - rr->crop;
|
2009-02-05 19:28:28 +00:00
|
|
|
if(ymax<2)
|
|
|
|
return;
|
|
|
|
renrect->ymin= renrect->ymax;
|
2009-02-14 18:31:19 +00:00
|
|
|
|
2009-02-05 19:28:28 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
xmin = ymin = rr->crop;
|
|
|
|
xmax = rr->rectx - 2*rr->crop;
|
|
|
|
ymax = rr->recty - 2*rr->crop;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* xmin ymin is in tile coords. transform to ibuf */
|
|
|
|
rxmin= rr->tilerect.xmin + xmin;
|
|
|
|
if(rxmin >= ibuf->x) return;
|
|
|
|
rymin= rr->tilerect.ymin + ymin;
|
|
|
|
if(rymin >= ibuf->y) return;
|
|
|
|
|
|
|
|
if(rxmin + xmax > ibuf->x)
|
|
|
|
xmax= ibuf->x - rxmin;
|
|
|
|
if(rymin + ymax > ibuf->y)
|
|
|
|
ymax= ibuf->y - rymin;
|
2009-02-14 16:43:02 +00:00
|
|
|
|
2009-02-05 19:28:28 +00:00
|
|
|
if(xmax < 1 || ymax < 1) return;
|
|
|
|
|
|
|
|
/* find current float rect for display, first case is after composit... still weak */
|
|
|
|
if(rr->rectf)
|
|
|
|
rectf= rr->rectf;
|
|
|
|
else {
|
|
|
|
if(rr->rect32)
|
|
|
|
return;
|
|
|
|
else {
|
|
|
|
if(rr->renlay==NULL || rr->renlay->rectf==NULL) return;
|
|
|
|
rectf= rr->renlay->rectf;
|
2009-02-04 17:40:50 +00:00
|
|
|
}
|
|
|
|
}
|
2009-02-05 19:28:28 +00:00
|
|
|
if(rectf==NULL) return;
|
|
|
|
|
|
|
|
rectf+= 4*(rr->rectx*ymin + xmin);
|
|
|
|
rectc= (char *)(ibuf->rect + ibuf->x*rymin + rxmin);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-07-17 02:43:15 +00:00
|
|
|
/* XXX make nice consistent functions for this */
|
2009-10-28 18:03:04 +00:00
|
|
|
if (scene && (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT)) {
|
2009-07-17 02:43:15 +00:00
|
|
|
for(y1= 0; y1<ymax; y1++) {
|
|
|
|
float *rf= rectf;
|
|
|
|
float srgb[3];
|
|
|
|
char *rc= rectc;
|
|
|
|
|
|
|
|
/* XXX temp. because crop offset */
|
|
|
|
if( rectc >= (char *)(ibuf->rect)) {
|
|
|
|
for(x1= 0; x1<xmax; x1++, rf += 4, rc+=4) {
|
|
|
|
srgb[0]= linearrgb_to_srgb(rf[0]);
|
|
|
|
srgb[1]= linearrgb_to_srgb(rf[1]);
|
|
|
|
srgb[2]= linearrgb_to_srgb(rf[2]);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-07-17 02:43:15 +00:00
|
|
|
rc[0]= FTOCHAR(srgb[0]);
|
|
|
|
rc[1]= FTOCHAR(srgb[1]);
|
|
|
|
rc[2]= FTOCHAR(srgb[2]);
|
|
|
|
rc[3]= FTOCHAR(rf[3]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
rectf += 4*rr->rectx;
|
|
|
|
rectc += 4*ibuf->x;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for(y1= 0; y1<ymax; y1++) {
|
|
|
|
float *rf= rectf;
|
|
|
|
char *rc= rectc;
|
|
|
|
|
|
|
|
/* XXX temp. because crop offset */
|
|
|
|
if( rectc >= (char *)(ibuf->rect)) {
|
|
|
|
for(x1= 0; x1<xmax; x1++, rf += 4, rc+=4) {
|
|
|
|
rc[0]= FTOCHAR(rf[0]);
|
|
|
|
rc[1]= FTOCHAR(rf[1]);
|
|
|
|
rc[2]= FTOCHAR(rf[2]);
|
|
|
|
rc[3]= FTOCHAR(rf[3]);
|
|
|
|
}
|
2009-02-14 16:43:02 +00:00
|
|
|
}
|
2009-07-17 02:43:15 +00:00
|
|
|
rectf += 4*rr->rectx;
|
|
|
|
rectc += 4*ibuf->x;
|
2009-02-05 19:28:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-04 17:40:50 +00:00
|
|
|
}
|
|
|
|
|
2009-09-30 18:18:32 +00:00
|
|
|
static void image_rect_update(void *rjv, RenderResult *rr, volatile rcti *renrect)
|
|
|
|
{
|
|
|
|
RenderJob *rj= rjv;
|
|
|
|
ImBuf *ibuf;
|
|
|
|
void *lock;
|
|
|
|
|
|
|
|
ibuf= BKE_image_acquire_ibuf(rj->image, &rj->iuser, &lock);
|
2009-10-28 18:03:04 +00:00
|
|
|
if(ibuf) {
|
|
|
|
image_buffer_rect_update(rj->scene, rr, ibuf, renrect);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
/* make jobs timer to send notifier */
|
|
|
|
*(rj->do_update)= 1;
|
|
|
|
}
|
2009-09-30 18:18:32 +00:00
|
|
|
BKE_image_release_ibuf(rj->image, lock);
|
|
|
|
}
|
|
|
|
|
2009-02-04 17:40:50 +00:00
|
|
|
static void render_startjob(void *rjv, short *stop, short *do_update)
|
|
|
|
{
|
|
|
|
RenderJob *rj= rjv;
|
|
|
|
|
|
|
|
rj->stop= stop;
|
|
|
|
rj->do_update= do_update;
|
|
|
|
|
2009-12-17 17:05:28 +00:00
|
|
|
#if defined(__APPLE__) && (PARALLEL == 1) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 2)
|
|
|
|
// Workaround for Apple gcc 4.2.1 omp vs background thread bug
|
|
|
|
pthread_setspecific (gomp_tls_key, thread_tls_data);
|
|
|
|
#endif
|
|
|
|
|
2009-02-04 17:40:50 +00:00
|
|
|
if(rj->anim)
|
2009-12-22 12:01:32 +00:00
|
|
|
RE_BlenderAnim(rj->re, rj->scene, rj->scene->r.sfra, rj->scene->r.efra, rj->scene->r.frame_step, rj->reports);
|
2009-02-04 17:40:50 +00:00
|
|
|
else
|
2010-01-06 00:09:07 +00:00
|
|
|
RE_BlenderFrame(rj->re, rj->scene, rj->srl, rj->scene->r.cfra);
|
2009-02-04 17:40:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* called by render, check job 'stop' value or the global */
|
|
|
|
static int render_breakjob(void *rjv)
|
|
|
|
{
|
|
|
|
RenderJob *rj= rjv;
|
|
|
|
|
|
|
|
if(G.afbreek)
|
|
|
|
return 1;
|
|
|
|
if(rj->stop && *(rj->stop))
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-02-19 10:21:17 +00:00
|
|
|
/* catch esc */
|
|
|
|
static int screen_render_modal(bContext *C, wmOperator *op, wmEvent *event)
|
|
|
|
{
|
|
|
|
/* no running blender, remove handler and pass through */
|
|
|
|
if(0==WM_jobs_test(CTX_wm_manager(C), CTX_data_scene(C)))
|
2009-12-10 09:25:30 +00:00
|
|
|
return OPERATOR_FINISHED|OPERATOR_PASS_THROUGH;
|
2009-02-19 10:21:17 +00:00
|
|
|
|
|
|
|
/* running render */
|
|
|
|
switch (event->type) {
|
|
|
|
case ESCKEY:
|
|
|
|
return OPERATOR_RUNNING_MODAL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return OPERATOR_PASS_THROUGH;
|
|
|
|
}
|
|
|
|
|
2009-02-04 17:40:50 +00:00
|
|
|
/* using context, starts job */
|
|
|
|
static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
|
|
|
{
|
|
|
|
/* new render clears all callbacks */
|
|
|
|
Scene *scene= CTX_data_scene(C);
|
2010-01-06 00:09:07 +00:00
|
|
|
SceneRenderLayer *srl=NULL;
|
2009-02-04 17:40:50 +00:00
|
|
|
Render *re;
|
|
|
|
wmJob *steve;
|
|
|
|
RenderJob *rj;
|
|
|
|
Image *ima;
|
|
|
|
|
2009-08-17 16:54:52 +00:00
|
|
|
/* only one render job at a time */
|
2009-02-04 17:40:50 +00:00
|
|
|
if(WM_jobs_test(CTX_wm_manager(C), scene))
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
2009-08-17 16:54:52 +00:00
|
|
|
/* stop all running jobs, currently previews frustrate Render */
|
|
|
|
WM_jobs_stop_all(CTX_wm_manager(C));
|
|
|
|
|
2009-02-04 17:40:50 +00:00
|
|
|
/* handle UI stuff */
|
|
|
|
WM_cursor_wait(1);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-02-05 01:12:47 +00:00
|
|
|
/* flush multires changes (for sculpt) */
|
|
|
|
multires_force_update(CTX_data_active_object(C));
|
2009-02-04 17:40:50 +00:00
|
|
|
|
2009-07-02 03:32:57 +00:00
|
|
|
/* get editmode results */
|
2009-11-28 22:45:47 +00:00
|
|
|
ED_object_exit_editmode(C, EM_FREEDATA|EM_DO_UNDO); /* 0 = does not exit editmode */
|
2009-07-02 03:32:57 +00:00
|
|
|
|
2009-02-04 17:40:50 +00:00
|
|
|
// store spare
|
|
|
|
// get view3d layer, local layer, make this nice api call to render
|
|
|
|
// store spare
|
|
|
|
|
|
|
|
/* ensure at least 1 area shows result */
|
2009-07-24 12:43:59 +00:00
|
|
|
screen_set_image_output(C, event->x, event->y);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2010-01-06 00:09:07 +00:00
|
|
|
/* single layer re-render */
|
|
|
|
if(RNA_property_is_set(op->ptr, "layer")) {
|
|
|
|
SceneRenderLayer *rl;
|
|
|
|
Scene *scn;
|
|
|
|
char scene_name[19], rl_name[RE_MAXNAME];
|
|
|
|
|
|
|
|
RNA_string_get(op->ptr, "layer", rl_name);
|
|
|
|
RNA_string_get(op->ptr, "scene", scene_name);
|
|
|
|
|
|
|
|
scn = (Scene *)BLI_findstring(&CTX_data_main(C)->scene, scene_name, offsetof(ID, name) + 2);
|
|
|
|
rl = (SceneRenderLayer *)BLI_findstring(&scene->r.layers, rl_name, offsetof(SceneRenderLayer, name));
|
|
|
|
|
|
|
|
if (scn && rl) {
|
|
|
|
scene = scn;
|
|
|
|
srl = rl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-04 17:40:50 +00:00
|
|
|
/* job custom data */
|
|
|
|
rj= MEM_callocN(sizeof(RenderJob), "render job");
|
|
|
|
rj->scene= scene;
|
|
|
|
rj->win= CTX_wm_window(C);
|
2010-01-06 00:09:07 +00:00
|
|
|
rj->srl = srl;
|
2.5: Render/Game Engine
An engine to use for output can now be selected an influences what
shows in the buttons window, only showing relevant data. The idea
behind this is to make it more clear what is supported where, make
the system more pluggable for external render/game engines, and save
space hiding stuff that is not relevant anyway.
* Top header now has an engine menu, to choose between the blender
render engine, game engine, and other future external engines.
* If the game engine is enabled, the buttons window should show
only properties that work in the game engine, and similarly for
the render engine.
* Moved panels from the logic space and game tabs to the physics,
scene and world tabs instead, and removed the game tab.
* Materials and textures tabs should eventually become game
specific too, to better show what is supported.
2009-07-23 21:50:40 +00:00
|
|
|
rj->anim= RNA_boolean_get(op->ptr, "animation");
|
2009-02-05 19:28:28 +00:00
|
|
|
rj->iuser.scene= scene;
|
|
|
|
rj->iuser.ok= 1;
|
2009-12-22 12:01:32 +00:00
|
|
|
rj->reports= op->reports;
|
2009-02-04 17:40:50 +00:00
|
|
|
|
|
|
|
/* setup job */
|
2009-09-30 18:18:32 +00:00
|
|
|
steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, WM_JOB_EXCL_RENDER|WM_JOB_PRIORITY);
|
2009-02-04 17:40:50 +00:00
|
|
|
WM_jobs_customdata(steve, rj, render_freejob);
|
|
|
|
WM_jobs_timer(steve, 0.2, NC_SCENE|ND_RENDER_RESULT, 0);
|
|
|
|
WM_jobs_callbacks(steve, render_startjob, NULL, NULL);
|
|
|
|
|
2009-12-17 17:05:28 +00:00
|
|
|
#if defined(__APPLE__) && (PARALLEL == 1) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 2)
|
|
|
|
// Workaround for Apple gcc 4.2.1 omp vs background thread bug
|
|
|
|
thread_tls_data = pthread_getspecific(gomp_tls_key);
|
|
|
|
#endif
|
|
|
|
|
2009-02-05 19:28:28 +00:00
|
|
|
/* get a render result image, and make sure it is empty */
|
2009-02-04 17:40:50 +00:00
|
|
|
ima= BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result");
|
|
|
|
BKE_image_signal(ima, NULL, IMA_SIGNAL_FREE);
|
2009-02-05 19:28:28 +00:00
|
|
|
rj->image= ima;
|
|
|
|
|
2009-02-04 17:40:50 +00:00
|
|
|
/* setup new render */
|
|
|
|
re= RE_NewRender(scene->id.name);
|
|
|
|
RE_test_break_cb(re, rj, render_breakjob);
|
|
|
|
RE_display_draw_cb(re, rj, image_rect_update);
|
2009-07-10 16:55:49 +00:00
|
|
|
RE_stats_draw_cb(re, rj, image_renderinfo_cb);
|
|
|
|
|
2009-02-04 17:40:50 +00:00
|
|
|
rj->re= re;
|
|
|
|
G.afbreek= 0;
|
|
|
|
|
|
|
|
// BKE_report in render!
|
|
|
|
// RE_error_cb(re, error_cb);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-06-07 11:12:35 +00:00
|
|
|
WM_jobs_start(CTX_wm_manager(C), steve);
|
2009-02-04 17:40:50 +00:00
|
|
|
|
|
|
|
WM_cursor_wait(0);
|
|
|
|
WM_event_add_notifier(C, NC_SCENE|ND_RENDER_RESULT, scene);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-02-19 10:21:17 +00:00
|
|
|
/* add modal handler for ESC */
|
2009-09-18 12:43:36 +00:00
|
|
|
WM_event_add_modal_handler(C, op);
|
2009-02-19 10:21:17 +00:00
|
|
|
|
|
|
|
return OPERATOR_RUNNING_MODAL;
|
2009-02-04 17:40:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* contextual render, using current scene, view3d? */
|
2009-07-24 12:43:59 +00:00
|
|
|
static void SCREEN_OT_render(wmOperatorType *ot)
|
2009-02-04 17:40:50 +00:00
|
|
|
{
|
|
|
|
/* identifiers */
|
|
|
|
ot->name= "Render";
|
2009-10-07 12:19:47 +00:00
|
|
|
ot->description= "Render active scene.";
|
2009-02-04 17:40:50 +00:00
|
|
|
ot->idname= "SCREEN_OT_render";
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
ot->invoke= screen_render_invoke;
|
2009-02-19 10:21:17 +00:00
|
|
|
ot->modal= screen_render_modal;
|
2009-02-04 17:40:50 +00:00
|
|
|
ot->exec= screen_render_exec;
|
|
|
|
|
|
|
|
ot->poll= ED_operator_screenactive;
|
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
RNA_def_boolean(ot->srna, "animation", 0, "Animation", "");
|
2010-01-06 00:09:07 +00:00
|
|
|
RNA_def_string(ot->srna, "layer", "", RE_MAXNAME, "Render Layer", "Single render layer to re-render");
|
|
|
|
RNA_def_string(ot->srna, "scene", "", 19, "Scene", "Re-render single layer in this scene");
|
2009-10-28 18:03:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ****************************** opengl render *************************** */
|
|
|
|
|
|
|
|
typedef struct OGLRender {
|
|
|
|
Render *re;
|
|
|
|
Scene *scene;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
View3D *v3d;
|
|
|
|
RegionView3D *rv3d;
|
|
|
|
ARegion *ar;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
Image *ima;
|
|
|
|
ImageUser iuser;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
GPUOffScreen *ofs;
|
|
|
|
int sizex, sizey;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-12-22 12:01:32 +00:00
|
|
|
ReportList *reports;
|
2009-10-28 18:03:04 +00:00
|
|
|
bMovieHandle *mh;
|
|
|
|
int cfrao, nfra;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
wmTimer *timer;
|
|
|
|
} OGLRender;
|
|
|
|
|
|
|
|
static void screen_opengl_render_apply(OGLRender *oglrender)
|
|
|
|
{
|
|
|
|
Scene *scene= oglrender->scene;
|
|
|
|
ARegion *ar= oglrender->ar;
|
|
|
|
View3D *v3d= oglrender->v3d;
|
|
|
|
RegionView3D *rv3d= oglrender->rv3d;
|
|
|
|
RenderResult *rr;
|
|
|
|
ImBuf *ibuf;
|
|
|
|
void *lock;
|
|
|
|
float winmat[4][4];
|
|
|
|
int sizex= oglrender->sizex;
|
|
|
|
int sizey= oglrender->sizey;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
/* bind */
|
|
|
|
GPU_offscreen_bind(oglrender->ofs);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
/* render 3d view */
|
|
|
|
if(rv3d->persp==RV3D_CAMOB && v3d->camera) {
|
|
|
|
RE_GetCameraWindow(oglrender->re, v3d->camera, scene->r.cfra, winmat);
|
|
|
|
ED_view3d_draw_offscreen(scene, v3d, ar, sizex, sizey, NULL, winmat);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ED_view3d_draw_offscreen(scene, v3d, ar, sizex, sizey, NULL, NULL);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
/* read in pixels & stamp */
|
|
|
|
rr= RE_AcquireResultRead(oglrender->re);
|
|
|
|
glReadPixels(0, 0, sizex, sizey, GL_RGBA, GL_FLOAT, rr->rectf);
|
|
|
|
if((scene->r.scemode & R_STAMP_INFO) && (scene->r.stamp & R_STAMP_DRAW))
|
|
|
|
BKE_stamp_buf(scene, (unsigned char *)rr->rect32, rr->rectf, rr->rectx, rr->recty, 3);
|
|
|
|
RE_ReleaseResult(oglrender->re);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
/* update byte from float buffer */
|
|
|
|
ibuf= BKE_image_acquire_ibuf(oglrender->ima, &oglrender->iuser, &lock);
|
|
|
|
if(ibuf) image_buffer_rect_update(NULL, rr, ibuf, NULL);
|
|
|
|
BKE_image_release_ibuf(oglrender->ima, lock);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
/* unbind */
|
|
|
|
GPU_offscreen_unbind(oglrender->ofs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int screen_opengl_render_init(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
/* new render clears all callbacks */
|
|
|
|
Scene *scene= CTX_data_scene(C);
|
|
|
|
RenderResult *rr;
|
|
|
|
GPUOffScreen *ofs;
|
|
|
|
OGLRender *oglrender;
|
|
|
|
int sizex, sizey;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
/* ensure we have a 3d view */
|
|
|
|
if(!ED_view3d_context_activate(C))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* only one render job at a time */
|
|
|
|
if(WM_jobs_test(CTX_wm_manager(C), scene))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* stop all running jobs, currently previews frustrate Render */
|
|
|
|
WM_jobs_stop_all(CTX_wm_manager(C));
|
|
|
|
|
|
|
|
/* handle UI stuff */
|
|
|
|
WM_cursor_wait(1);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
/* create offscreen buffer */
|
|
|
|
sizex= (scene->r.size*scene->r.xsch)/100;
|
|
|
|
sizey= (scene->r.size*scene->r.ysch)/100;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
view3d_operator_needs_opengl(C);
|
|
|
|
ofs= GPU_offscreen_create(sizex, sizey);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
if(!ofs) {
|
|
|
|
BKE_report(op->reports, RPT_ERROR, "Failed to create OpenGL offscreen buffer.");
|
|
|
|
return 0;
|
|
|
|
}
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
/* allocate opengl render */
|
|
|
|
oglrender= MEM_callocN(sizeof(OGLRender), "OGLRender");
|
|
|
|
op->customdata= oglrender;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
oglrender->ofs= ofs;
|
|
|
|
oglrender->sizex= sizex;
|
|
|
|
oglrender->sizey= sizey;
|
|
|
|
oglrender->scene= scene;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
oglrender->v3d= CTX_wm_view3d(C);
|
|
|
|
oglrender->ar= CTX_wm_region(C);
|
|
|
|
oglrender->rv3d= CTX_wm_region_view3d(C);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
/* create image and image user */
|
|
|
|
oglrender->ima= BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result");
|
|
|
|
BKE_image_signal(oglrender->ima, NULL, IMA_SIGNAL_FREE);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
oglrender->iuser.scene= scene;
|
|
|
|
oglrender->iuser.ok= 1;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
/* create render and render result */
|
|
|
|
oglrender->re= RE_NewRender(scene->id.name);
|
2010-01-06 00:09:07 +00:00
|
|
|
RE_InitState(oglrender->re, NULL, &scene->r, NULL, sizex, sizey, NULL);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
rr= RE_AcquireResultWrite(oglrender->re);
|
|
|
|
if(rr->rectf==NULL)
|
|
|
|
rr->rectf= MEM_mallocN(sizeof(float)*4*sizex*sizex, "32 bits rects");
|
|
|
|
RE_ReleaseResult(oglrender->re);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void screen_opengl_render_end(bContext *C, OGLRender *oglrender)
|
|
|
|
{
|
|
|
|
Scene *scene= oglrender->scene;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
if(oglrender->mh) {
|
|
|
|
if(BKE_imtype_is_movie(scene->r.imtype))
|
|
|
|
oglrender->mh->end_movie();
|
|
|
|
}
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
if(oglrender->timer) {
|
|
|
|
scene->r.cfra= oglrender->cfrao;
|
|
|
|
scene_update_for_newframe(scene, scene->lay);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), oglrender->timer);
|
|
|
|
}
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
WM_cursor_wait(0);
|
|
|
|
WM_event_add_notifier(C, NC_SCENE|ND_RENDER_RESULT, oglrender->scene);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
GPU_offscreen_free(oglrender->ofs);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
MEM_freeN(oglrender);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int screen_opengl_render_cancel(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
screen_opengl_render_end(C, op->customdata);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int screen_opengl_render_modal(bContext *C, wmOperator *op, wmEvent *event)
|
|
|
|
{
|
|
|
|
OGLRender *oglrender= op->customdata;
|
|
|
|
Scene *scene= oglrender->scene;
|
|
|
|
ImBuf *ibuf;
|
|
|
|
void *lock;
|
|
|
|
char name[FILE_MAXDIR+FILE_MAXFILE];
|
|
|
|
unsigned int lay;
|
|
|
|
int ok= 0;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
switch(event->type) {
|
|
|
|
case ESCKEY:
|
|
|
|
/* cancel */
|
|
|
|
screen_opengl_render_end(C, op->customdata);
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
case TIMER:
|
|
|
|
/* render frame? */
|
|
|
|
if(oglrender->timer == event->customdata)
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* nothing to do */
|
|
|
|
return OPERATOR_RUNNING_MODAL;
|
|
|
|
}
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
/* go to next frame */
|
|
|
|
while(CFRA<oglrender->nfra) {
|
|
|
|
if(scene->lay & 0xFF000000)
|
|
|
|
lay= scene->lay & 0xFF000000;
|
|
|
|
else
|
|
|
|
lay= scene->lay;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
scene_update_for_newframe(scene, lay);
|
|
|
|
CFRA++;
|
|
|
|
}
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
scene_update_for_newframe(scene, scene->lay);
|
2009-12-21 11:42:31 +00:00
|
|
|
|
|
|
|
if(oglrender->rv3d->persp==RV3D_CAMOB && oglrender->v3d->camera && oglrender->v3d->scenelock) {
|
|
|
|
/* since scene_update_for_newframe() is used rather
|
|
|
|
* then ED_update_for_newframe() the camera needs to be set */
|
|
|
|
Object *camera= scene_find_camera_switch(scene);
|
|
|
|
|
|
|
|
if(camera)
|
|
|
|
oglrender->v3d->camera= scene->camera= camera;
|
|
|
|
}
|
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
/* render into offscreen buffer */
|
|
|
|
screen_opengl_render_apply(oglrender);
|
|
|
|
|
|
|
|
/* save to disk */
|
|
|
|
ibuf= BKE_image_acquire_ibuf(oglrender->ima, &oglrender->iuser, &lock);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
if(ibuf) {
|
|
|
|
if(BKE_imtype_is_movie(scene->r.imtype)) {
|
2009-12-22 12:01:32 +00:00
|
|
|
ok= oglrender->mh->append_movie(&scene->r, CFRA, (int*)ibuf->rect, oglrender->sizex, oglrender->sizey, oglrender->reports);
|
|
|
|
if(ok)
|
|
|
|
printf("Append frame %d", scene->r.cfra);
|
2009-10-28 18:03:04 +00:00
|
|
|
}
|
|
|
|
else {
|
2010-01-08 13:52:38 +00:00
|
|
|
BKE_makepicstring(name, scene->r.pic, scene->r.cfra, scene->r.imtype, scene->r.scemode & R_EXTENSION);
|
2009-10-28 18:03:04 +00:00
|
|
|
ok= BKE_write_ibuf(scene, ibuf, name, scene->r.imtype, scene->r.subimtype, scene->r.quality);
|
|
|
|
|
|
|
|
if(ok==0) printf("write error: cannot save %s\n", name);
|
|
|
|
else printf("saved: %s", name);
|
|
|
|
}
|
|
|
|
}
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
BKE_image_release_ibuf(oglrender->ima, lock);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
/* movie stats prints have no line break */
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
/* go to next frame */
|
2009-11-10 04:56:55 +00:00
|
|
|
oglrender->nfra += scene->r.frame_step;
|
2009-10-28 18:03:04 +00:00
|
|
|
scene->r.cfra++;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
WM_event_add_notifier(C, NC_SCENE|ND_RENDER_RESULT, oglrender->scene);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
/* stop at the end or on error */
|
|
|
|
if(scene->r.cfra > EFRA || !ok) {
|
|
|
|
screen_opengl_render_end(C, op->customdata);
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
return OPERATOR_RUNNING_MODAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int screen_opengl_render_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
|
|
|
{
|
|
|
|
int anim= RNA_boolean_get(op->ptr, "animation");
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
if(!screen_opengl_render_init(C, op))
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
|
|
if(!anim) {
|
|
|
|
/* render image */
|
|
|
|
screen_opengl_render_apply(op->customdata);
|
|
|
|
screen_opengl_render_end(C, op->customdata);
|
|
|
|
screen_set_image_output(C, event->x, event->y);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* initialize animation */
|
|
|
|
OGLRender *oglrender;
|
|
|
|
Scene *scene;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
oglrender= op->customdata;
|
|
|
|
scene= oglrender->scene;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-12-22 12:01:32 +00:00
|
|
|
oglrender->reports= op->reports;
|
2009-10-28 18:03:04 +00:00
|
|
|
oglrender->mh= BKE_get_movie_handle(scene->r.imtype);
|
2009-12-22 12:01:32 +00:00
|
|
|
if(BKE_imtype_is_movie(scene->r.imtype)) {
|
|
|
|
if(!oglrender->mh->start_movie(scene, &scene->r, oglrender->sizex, oglrender->sizey, oglrender->reports)) {
|
|
|
|
screen_opengl_render_end(C, oglrender);
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
|
|
|
}
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
oglrender->cfrao= scene->r.cfra;
|
|
|
|
oglrender->nfra= SFRA;
|
|
|
|
scene->r.cfra= SFRA;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
WM_event_add_modal_handler(C, op);
|
|
|
|
oglrender->timer= WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER, 0.01f);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
screen_set_image_output(C, event->x, event->y);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
return OPERATOR_RUNNING_MODAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void SCREEN_OT_opengl_render(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
|
|
|
ot->name= "OpenGL Render";
|
|
|
|
ot->description= "OpenGL render active viewport.";
|
|
|
|
ot->idname= "SCREEN_OT_opengl_render";
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
ot->invoke= screen_opengl_render_invoke;
|
|
|
|
ot->modal= screen_opengl_render_modal;
|
|
|
|
ot->cancel= screen_opengl_render_cancel;
|
|
|
|
|
|
|
|
ot->poll= ED_operator_screenactive;
|
|
|
|
|
2.5: Render/Game Engine
An engine to use for output can now be selected an influences what
shows in the buttons window, only showing relevant data. The idea
behind this is to make it more clear what is supported where, make
the system more pluggable for external render/game engines, and save
space hiding stuff that is not relevant anyway.
* Top header now has an engine menu, to choose between the blender
render engine, game engine, and other future external engines.
* If the game engine is enabled, the buttons window should show
only properties that work in the game engine, and similarly for
the render engine.
* Moved panels from the logic space and game tabs to the physics,
scene and world tabs instead, and removed the game tab.
* Materials and textures tabs should eventually become game
specific too, to better show what is supported.
2009-07-23 21:50:40 +00:00
|
|
|
RNA_def_boolean(ot->srna, "animation", 0, "Animation", "");
|
2009-02-04 17:40:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* *********************** cancel render viewer *************** */
|
|
|
|
|
|
|
|
static int render_view_cancel_exec(bContext *C, wmOperator *unused)
|
|
|
|
{
|
2009-10-26 11:43:27 +00:00
|
|
|
wmWindow *win= CTX_wm_window(C);
|
2009-02-04 17:40:50 +00:00
|
|
|
ScrArea *sa= CTX_wm_area(C);
|
|
|
|
SpaceImage *sima= sa->spacedata.first;
|
|
|
|
|
2009-07-24 12:43:59 +00:00
|
|
|
/* test if we have a temp screen in front */
|
|
|
|
if(CTX_wm_window(C)->screen->full==SCREENTEMP) {
|
|
|
|
wm_window_lower(CTX_wm_window(C));
|
2009-10-09 21:50:33 +00:00
|
|
|
return OPERATOR_FINISHED;
|
2009-07-24 12:43:59 +00:00
|
|
|
}
|
|
|
|
/* determine if render already shows */
|
|
|
|
else if(sima->flag & SI_PREVSPACE) {
|
2009-02-04 17:40:50 +00:00
|
|
|
sima->flag &= ~SI_PREVSPACE;
|
2009-02-19 10:21:17 +00:00
|
|
|
|
|
|
|
if(sima->flag & SI_FULLWINDOW) {
|
|
|
|
sima->flag &= ~SI_FULLWINDOW;
|
2009-12-08 07:12:06 +00:00
|
|
|
ED_screen_full_prevspace(C, sa);
|
2009-02-19 10:21:17 +00:00
|
|
|
}
|
|
|
|
else
|
2009-12-08 07:12:06 +00:00
|
|
|
ED_area_prevspace(C, sa);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-10-09 21:50:33 +00:00
|
|
|
return OPERATOR_FINISHED;
|
2009-02-04 17:40:50 +00:00
|
|
|
}
|
|
|
|
else if(sima->flag & SI_FULLWINDOW) {
|
|
|
|
sima->flag &= ~SI_FULLWINDOW;
|
2009-10-26 11:43:27 +00:00
|
|
|
ed_screen_fullarea(C, win, sa);
|
2009-10-09 21:50:33 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-10-09 21:50:33 +00:00
|
|
|
return OPERATOR_PASS_THROUGH;
|
2009-02-04 17:40:50 +00:00
|
|
|
}
|
|
|
|
|
2009-07-24 12:43:59 +00:00
|
|
|
static void SCREEN_OT_render_view_cancel(struct wmOperatorType *ot)
|
2009-02-04 17:40:50 +00:00
|
|
|
{
|
|
|
|
/* identifiers */
|
|
|
|
ot->name= "Cancel Render View";
|
2009-10-07 12:19:47 +00:00
|
|
|
ot->description= "Cancel show render view.";
|
2009-02-04 17:40:50 +00:00
|
|
|
ot->idname= "SCREEN_OT_render_view_cancel";
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
ot->exec= render_view_cancel_exec;
|
|
|
|
ot->poll= ED_operator_image_active;
|
|
|
|
}
|
|
|
|
|
2009-07-10 16:55:49 +00:00
|
|
|
/* *********************** show render viewer *************** */
|
|
|
|
|
2009-07-24 12:43:59 +00:00
|
|
|
static int render_view_show_invoke(bContext *C, wmOperator *unused, wmEvent *event)
|
2009-07-10 16:55:49 +00:00
|
|
|
{
|
|
|
|
ScrArea *sa= find_area_showing_r_result(C);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-07-24 12:43:59 +00:00
|
|
|
/* test if we have a temp screen in front */
|
|
|
|
if(CTX_wm_window(C)->screen->full==SCREENTEMP) {
|
|
|
|
wm_window_lower(CTX_wm_window(C));
|
|
|
|
}
|
2009-07-10 16:55:49 +00:00
|
|
|
/* determine if render already shows */
|
2009-07-24 12:43:59 +00:00
|
|
|
else if(sa) {
|
2009-07-10 16:55:49 +00:00
|
|
|
SpaceImage *sima= sa->spacedata.first;
|
|
|
|
|
|
|
|
if(sima->flag & SI_PREVSPACE) {
|
|
|
|
sima->flag &= ~SI_PREVSPACE;
|
|
|
|
|
|
|
|
if(sima->flag & SI_FULLWINDOW) {
|
|
|
|
sima->flag &= ~SI_FULLWINDOW;
|
2009-12-08 07:12:06 +00:00
|
|
|
ED_screen_full_prevspace(C, sa);
|
2009-07-10 16:55:49 +00:00
|
|
|
}
|
|
|
|
else if(sima->next) {
|
|
|
|
ED_area_newspace(C, sa, sima->next->spacetype);
|
|
|
|
ED_area_tag_redraw(sa);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2009-07-24 12:43:59 +00:00
|
|
|
screen_set_image_output(C, event->x, event->y);
|
2009-07-10 16:55:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
2009-07-24 12:43:59 +00:00
|
|
|
static void SCREEN_OT_render_view_show(struct wmOperatorType *ot)
|
2009-07-10 16:55:49 +00:00
|
|
|
{
|
|
|
|
/* identifiers */
|
|
|
|
ot->name= "Show/Hide Render View";
|
2009-10-07 12:19:47 +00:00
|
|
|
ot->description= "Toggle show render view.";
|
2009-07-10 16:55:49 +00:00
|
|
|
ot->idname= "SCREEN_OT_render_view_show";
|
|
|
|
|
|
|
|
/* api callbacks */
|
2009-07-24 12:43:59 +00:00
|
|
|
ot->invoke= render_view_show_invoke;
|
|
|
|
ot->poll= ED_operator_screenactive;
|
|
|
|
}
|
|
|
|
|
2009-12-08 07:12:06 +00:00
|
|
|
/* *********************** generic fullscreen 'back' button *************** */
|
|
|
|
|
|
|
|
|
|
|
|
static int fullscreen_back_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
bScreen *screen = CTX_wm_screen(C);
|
|
|
|
ScrArea *sa=NULL;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-12-08 07:12:06 +00:00
|
|
|
/* search current screen for 'fullscreen' areas */
|
|
|
|
for (sa=screen->areabase.first; sa; sa=sa->next) {
|
|
|
|
if (sa->full) break;
|
|
|
|
}
|
|
|
|
if (!sa) {
|
|
|
|
BKE_report(op->reports, RPT_ERROR, "No fullscreen areas were found.");
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
ED_screen_full_restore(C, sa);
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void SCREEN_OT_back_to_previous(struct wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
|
|
|
ot->name= "Back to Previous Screen";
|
|
|
|
ot->description= "Revert back to the original screen layout, before fullscreen area overlay.";
|
|
|
|
ot->idname= "SCREEN_OT_back_to_previous";
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
ot->exec= fullscreen_back_exec;
|
|
|
|
ot->poll= ED_operator_screenactive;
|
|
|
|
}
|
|
|
|
|
2009-07-24 12:43:59 +00:00
|
|
|
/* *********** show user pref window ****** */
|
|
|
|
|
|
|
|
static int userpref_show_invoke(bContext *C, wmOperator *unused, wmEvent *event)
|
|
|
|
{
|
|
|
|
ScrArea *sa;
|
|
|
|
rcti rect;
|
|
|
|
int sizex, sizey;
|
|
|
|
|
2009-07-24 14:30:40 +00:00
|
|
|
sizex= 800;
|
2009-07-24 12:43:59 +00:00
|
|
|
sizey= 480;
|
|
|
|
|
|
|
|
/* some magic to calculate postition */
|
|
|
|
rect.xmin= event->x + CTX_wm_window(C)->posx - sizex/2;
|
|
|
|
rect.ymin= event->y + CTX_wm_window(C)->posy - sizey/2;
|
|
|
|
rect.xmax= rect.xmin + sizex;
|
|
|
|
rect.ymax= rect.ymin + sizey;
|
|
|
|
|
|
|
|
/* changes context! */
|
|
|
|
WM_window_open_temp(C, &rect, WM_WINDOW_USERPREFS);
|
|
|
|
|
|
|
|
sa= CTX_wm_area(C);
|
|
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void SCREEN_OT_userpref_show(struct wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
|
|
|
ot->name= "Show/Hide User Preferences";
|
2009-10-07 12:19:47 +00:00
|
|
|
ot->description= "Show/hide user preferences.";
|
2009-07-24 12:43:59 +00:00
|
|
|
ot->idname= "SCREEN_OT_userpref_show";
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
ot->invoke= userpref_show_invoke;
|
2009-07-10 16:55:49 +00:00
|
|
|
ot->poll= ED_operator_screenactive;
|
|
|
|
}
|
|
|
|
|
2009-08-15 16:43:03 +00:00
|
|
|
/********************* new screen operator *********************/
|
2009-07-10 16:55:49 +00:00
|
|
|
|
2009-08-15 16:43:03 +00:00
|
|
|
static int screen_new_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
wmWindow *win= CTX_wm_window(C);
|
|
|
|
bScreen *sc= CTX_wm_screen(C);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-08-15 16:43:03 +00:00
|
|
|
sc= ED_screen_duplicate(win, sc);
|
|
|
|
WM_event_add_notifier(C, NC_SCREEN|ND_SCREENBROWSE, sc);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-08-15 16:43:03 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SCREEN_OT_new(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
|
|
|
ot->name= "New Screen";
|
2009-10-07 12:19:47 +00:00
|
|
|
ot->description= "Add a new screen.";
|
2009-08-15 16:43:03 +00:00
|
|
|
ot->idname= "SCREEN_OT_new";
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
ot->exec= screen_new_exec;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-08-15 16:43:03 +00:00
|
|
|
/* flags */
|
|
|
|
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
|
|
|
}
|
|
|
|
|
|
|
|
/********************* delete screen operator *********************/
|
|
|
|
|
|
|
|
static int screen_delete_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
bScreen *sc= CTX_wm_screen(C);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-08-15 16:43:03 +00:00
|
|
|
WM_event_add_notifier(C, NC_SCREEN|ND_SCREENDELETE, sc);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-08-15 16:43:03 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SCREEN_OT_delete(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2009-10-07 12:19:47 +00:00
|
|
|
ot->name= "Delete Screen"; //was scene
|
|
|
|
ot->description= "Delete active screen.";
|
2009-08-15 16:43:03 +00:00
|
|
|
ot->idname= "SCREEN_OT_delete";
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
ot->exec= screen_delete_exec;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-08-15 16:43:03 +00:00
|
|
|
/* flags */
|
|
|
|
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
|
|
|
}
|
|
|
|
|
|
|
|
/********************* new scene operator *********************/
|
|
|
|
|
|
|
|
static int scene_new_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
Scene *newscene, *scene= CTX_data_scene(C);
|
|
|
|
Main *bmain= CTX_data_main(C);
|
|
|
|
int type= RNA_enum_get(op->ptr, "type");
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-08-15 16:43:03 +00:00
|
|
|
newscene= copy_scene(bmain, scene, type);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-08-15 16:43:03 +00:00
|
|
|
/* these can't be handled in blenkernel curently, so do them here */
|
|
|
|
if(type == SCE_COPY_LINK_DATA)
|
|
|
|
ED_object_single_users(newscene, 0);
|
|
|
|
else if(type == SCE_COPY_FULL)
|
|
|
|
ED_object_single_users(newscene, 1);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-08-15 16:43:03 +00:00
|
|
|
WM_event_add_notifier(C, NC_SCENE|ND_SCENEBROWSE, newscene);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-08-15 16:43:03 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SCENE_OT_new(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
static EnumPropertyItem type_items[]= {
|
|
|
|
{SCE_COPY_EMPTY, "EMPTY", 0, "Empty", "Add empty scene."},
|
|
|
|
{SCE_COPY_LINK_OB, "LINK_OBJECTS", 0, "Link Objects", "Link to the objects from the current scene."},
|
|
|
|
{SCE_COPY_LINK_DATA, "LINK_OBJECT_DATA", 0, "Link Object Data", "Copy objects linked to data from the current scene."},
|
|
|
|
{SCE_COPY_FULL, "FULL_COPY", 0, "Full Copy", "Make a full copy of the current scene."},
|
|
|
|
{0, NULL, 0, NULL, NULL}};
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-08-15 16:43:03 +00:00
|
|
|
/* identifiers */
|
|
|
|
ot->name= "New Scene";
|
2009-10-07 12:19:47 +00:00
|
|
|
ot->description= "Add new scene by type.";
|
2009-08-15 16:43:03 +00:00
|
|
|
ot->idname= "SCENE_OT_new";
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
ot->exec= scene_new_exec;
|
|
|
|
ot->invoke= WM_menu_invoke;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-08-15 16:43:03 +00:00
|
|
|
/* flags */
|
|
|
|
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-08-15 16:43:03 +00:00
|
|
|
/* properties */
|
2010-01-15 22:40:33 +00:00
|
|
|
ot->prop= RNA_def_enum(ot->srna, "type", type_items, 0, "Type", "");
|
2009-08-15 16:43:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/********************* delete scene operator *********************/
|
|
|
|
|
|
|
|
static int scene_delete_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
Scene *scene= CTX_data_scene(C);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2010-01-14 01:47:25 +00:00
|
|
|
WM_event_add_notifier(C, NC_SCENE|NA_REMOVED, scene);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-08-15 16:43:03 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SCENE_OT_delete(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
|
|
|
ot->name= "Delete Scene";
|
2009-10-07 12:19:47 +00:00
|
|
|
ot->description= "Delete active scene.";
|
2009-08-15 16:43:03 +00:00
|
|
|
ot->idname= "SCENE_OT_delete";
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
ot->exec= scene_delete_exec;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-08-15 16:43:03 +00:00
|
|
|
/* flags */
|
|
|
|
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
|
|
|
}
|
2009-02-04 17:40:50 +00:00
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
/* **************** Assigning operatortypes to global list, adding handlers **************** */
|
|
|
|
|
2.5 Branch
==========
* Changed wmOperatorType, removing init/exit callbacks and adding cancel
callback, removed default storage in favor of properties. Defined return
values for exec/invoke/modal/cancel.
* Don't allocate operator on the stack, and removed operator copy for
handlers. Now it frees based on return values from callbacks, and just
keeps a wmOperator on the heap. Also it now registers after the operator
is fully finished, to get the correct final properties.
* Changed OP_get_* functions to return 1 if the property is found and 0
otherwise, gives more readable code in my opinion. Added OP_verify_*
functions to quickly check if the property is available and set if it's
not, that's common for exec/invoke.
* Removed WM_operatortypelist_append in favor of WM_operatortype_append
which takes a function pointer instead of a list, avoids macro's and
duplicating code.
* Fix a crash where the handler would still be used while it was freed by
the operator.
* Spacetypes now have operatortypes() and keymap() callbacks to abstract
them a bit more.
* Renamed C->curarea to C->area for consistency. Removed View3D/View2D/
SpaceIpo from bContext, seems bad to keep these.
* Set context variables like window/screen/area/region to NULL again when
leaving that context, instead of leaving the pointers there.
* Added if(G.f & G_DEBUG) for many of the prints, makes output a bit
cleaner and easier to debug.
* Fixed priority of the editors/interface module in scons, would otherwise
give link errors.
* Added start of generic view2d api.
* Added space_time with some basic drawing and a single operator to change
the frame.
2008-06-11 10:10:31 +00:00
|
|
|
/* called in spacetypes.c */
|
2008-01-07 18:03:41 +00:00
|
|
|
void ED_operatortypes_screen(void)
|
|
|
|
{
|
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
|
|
|
/* generic UI stuff */
|
2008-12-26 11:11:21 +00:00
|
|
|
WM_operatortype_append(SCREEN_OT_actionzone);
|
|
|
|
WM_operatortype_append(SCREEN_OT_repeat_last);
|
2009-01-15 18:28:40 +00:00
|
|
|
WM_operatortype_append(SCREEN_OT_repeat_history);
|
2009-02-04 11:52:16 +00:00
|
|
|
WM_operatortype_append(SCREEN_OT_redo_last);
|
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-11-24 18:59:59 +00:00
|
|
|
/* screen tools */
|
2008-12-26 11:11:21 +00:00
|
|
|
WM_operatortype_append(SCREEN_OT_area_move);
|
|
|
|
WM_operatortype_append(SCREEN_OT_area_split);
|
|
|
|
WM_operatortype_append(SCREEN_OT_area_join);
|
2009-03-11 20:22:06 +00:00
|
|
|
WM_operatortype_append(SCREEN_OT_area_dupli);
|
|
|
|
WM_operatortype_append(SCREEN_OT_area_swap);
|
2009-12-04 00:49:02 +00:00
|
|
|
WM_operatortype_append(SCREEN_OT_region_quadview);
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
WM_operatortype_append(SCREEN_OT_region_scale);
|
2009-11-27 11:51:34 +00:00
|
|
|
WM_operatortype_append(SCREEN_OT_region_flip);
|
|
|
|
WM_operatortype_append(SCREEN_OT_header_flip);
|
2009-11-27 06:24:09 +00:00
|
|
|
WM_operatortype_append(SCREEN_OT_header_toolbox);
|
2008-12-26 11:11:21 +00:00
|
|
|
WM_operatortype_append(SCREEN_OT_screen_set);
|
|
|
|
WM_operatortype_append(SCREEN_OT_screen_full_area);
|
2009-12-08 07:12:06 +00:00
|
|
|
WM_operatortype_append(SCREEN_OT_back_to_previous);
|
2009-02-14 16:43:02 +00:00
|
|
|
WM_operatortype_append(SCREEN_OT_screenshot);
|
2009-02-14 18:31:19 +00:00
|
|
|
WM_operatortype_append(SCREEN_OT_screencast);
|
2009-07-24 12:43:59 +00:00
|
|
|
WM_operatortype_append(SCREEN_OT_userpref_show);
|
2008-12-17 17:33:45 +00:00
|
|
|
|
2008-12-17 16:21:14 +00:00
|
|
|
/*frame changes*/
|
2008-12-26 11:11:21 +00:00
|
|
|
WM_operatortype_append(SCREEN_OT_frame_offset);
|
2009-08-02 07:08:51 +00:00
|
|
|
WM_operatortype_append(SCREEN_OT_frame_jump);
|
2009-07-24 13:34:45 +00:00
|
|
|
WM_operatortype_append(SCREEN_OT_keyframe_jump);
|
|
|
|
|
2.5
Animation playback back in control. And non-blocking still!
- Play follows the "Playback" options in TimeLine menu.
Only the region 'windows' are drawn, not headers, toolbars,
channel views, etc.
The option "Buttons Window" also redraws property regions.
- The Timeline header always redraws, this to denote at least
progressing frame numbers
- For now: if you choose to play 3D views, it also redraws
the TimeLine. Seems to be good convention, but probably
better to add menu option for it?
- Fun test: while playback, change Playback options, works OK!
- New: top header button shows animation play status, and allows
to stop playback
- New: Animation stop/start operator. Assigned to ALT+A. It has
no options yet; just plays active region + all 3D windows now.
Options will follow, based on reviews.
Also ESC won't work for now, just press ALT+A again.
2009-05-21 13:33:04 +00:00
|
|
|
WM_operatortype_append(SCREEN_OT_animation_step);
|
2008-12-26 11:11:21 +00:00
|
|
|
WM_operatortype_append(SCREEN_OT_animation_play);
|
2009-10-09 21:50:33 +00:00
|
|
|
WM_operatortype_append(SCREEN_OT_animation_cancel);
|
2008-12-21 19:58:25 +00:00
|
|
|
|
2009-02-04 17:40:50 +00:00
|
|
|
/* render */
|
|
|
|
WM_operatortype_append(SCREEN_OT_render);
|
|
|
|
WM_operatortype_append(SCREEN_OT_render_view_cancel);
|
2009-07-10 16:55:49 +00:00
|
|
|
WM_operatortype_append(SCREEN_OT_render_view_show);
|
2009-10-28 18:03:04 +00:00
|
|
|
WM_operatortype_append(SCREEN_OT_opengl_render);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-08-15 16:43:03 +00:00
|
|
|
/* new/delete */
|
|
|
|
WM_operatortype_append(SCREEN_OT_new);
|
|
|
|
WM_operatortype_append(SCREEN_OT_delete);
|
|
|
|
WM_operatortype_append(SCENE_OT_new);
|
|
|
|
WM_operatortype_append(SCENE_OT_delete);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2008-11-24 18:59:59 +00:00
|
|
|
/* tools shared by more space types */
|
2008-12-31 18:52:15 +00:00
|
|
|
WM_operatortype_append(ED_OT_undo);
|
2009-02-04 17:40:50 +00:00
|
|
|
WM_operatortype_append(ED_OT_redo);
|
2008-11-24 18:59:59 +00:00
|
|
|
|
2008-01-07 18:03:41 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
static void keymap_modal_set(wmKeyConfig *keyconf)
|
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
|
|
|
{
|
|
|
|
static EnumPropertyItem modal_items[] = {
|
|
|
|
{KM_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""},
|
|
|
|
{KM_MODAL_APPLY, "APPLY", 0, "Apply", ""},
|
|
|
|
{KM_MODAL_STEP10, "STEP10", 0, "Steps on", ""},
|
|
|
|
{KM_MODAL_STEP10_OFF, "STEP10_OFF", 0, "Steps off", ""},
|
|
|
|
{0, NULL, 0, NULL, NULL}};
|
|
|
|
wmKeyMap *keymap;
|
|
|
|
|
|
|
|
/* Standard Modal keymap ------------------------------------------------ */
|
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
|
|
|
keymap= WM_modalkeymap_add(keyconf, "Standard Modal Map", modal_items);
|
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
|
|
|
|
|
|
|
WM_modalkeymap_add_item(keymap, ESCKEY, KM_PRESS, KM_ANY, 0, KM_MODAL_CANCEL);
|
|
|
|
WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_ANY, KM_ANY, 0, KM_MODAL_APPLY);
|
|
|
|
WM_modalkeymap_add_item(keymap, RETKEY, KM_PRESS, KM_ANY, 0, KM_MODAL_APPLY);
|
|
|
|
WM_modalkeymap_add_item(keymap, PADENTER, KM_PRESS, KM_ANY, 0, KM_MODAL_APPLY);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
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
|
|
|
WM_modalkeymap_add_item(keymap, LEFTCTRLKEY, KM_PRESS, KM_ANY, 0, KM_MODAL_STEP10);
|
|
|
|
WM_modalkeymap_add_item(keymap, LEFTCTRLKEY, KM_RELEASE, KM_ANY, 0, KM_MODAL_STEP10_OFF);
|
|
|
|
|
|
|
|
WM_modalkeymap_assign(keymap, "SCREEN_OT_area_move");
|
2009-12-10 09:25:30 +00:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2.5 Branch
==========
* Changed wmOperatorType, removing init/exit callbacks and adding cancel
callback, removed default storage in favor of properties. Defined return
values for exec/invoke/modal/cancel.
* Don't allocate operator on the stack, and removed operator copy for
handlers. Now it frees based on return values from callbacks, and just
keeps a wmOperator on the heap. Also it now registers after the operator
is fully finished, to get the correct final properties.
* Changed OP_get_* functions to return 1 if the property is found and 0
otherwise, gives more readable code in my opinion. Added OP_verify_*
functions to quickly check if the property is available and set if it's
not, that's common for exec/invoke.
* Removed WM_operatortypelist_append in favor of WM_operatortype_append
which takes a function pointer instead of a list, avoids macro's and
duplicating code.
* Fix a crash where the handler would still be used while it was freed by
the operator.
* Spacetypes now have operatortypes() and keymap() callbacks to abstract
them a bit more.
* Renamed C->curarea to C->area for consistency. Removed View3D/View2D/
SpaceIpo from bContext, seems bad to keep these.
* Set context variables like window/screen/area/region to NULL again when
leaving that context, instead of leaving the pointers there.
* Added if(G.f & G_DEBUG) for many of the prints, makes output a bit
cleaner and easier to debug.
* Fixed priority of the editors/interface module in scons, would otherwise
give link errors.
* Added start of generic view2d api.
* Added space_time with some basic drawing and a single operator to change
the frame.
2008-06-11 10:10:31 +00:00
|
|
|
/* called in spacetypes.c */
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
void ED_keymap_screen(wmKeyConfig *keyconf)
|
2008-01-07 18:03:41 +00:00
|
|
|
{
|
2009-09-17 21:36:02 +00:00
|
|
|
wmKeyMap *keymap;
|
2009-07-19 05:20:30 +00:00
|
|
|
|
2009-09-18 15:48:49 +00:00
|
|
|
/* Screen Editing ------------------------------------------------ */
|
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
|
|
|
keymap= WM_keymap_find(keyconf, "Screen Editing", 0, 0);
|
2009-01-23 14:43:25 +00:00
|
|
|
|
2009-03-05 23:19:44 +00:00
|
|
|
RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_actionzone", LEFTMOUSE, KM_PRESS, 0, 0)->ptr, "modifier", 0);
|
|
|
|
RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_actionzone", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "modifier", 1);
|
|
|
|
RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_actionzone", LEFTMOUSE, KM_PRESS, KM_ALT, 0)->ptr, "modifier", 2);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-02-14 16:43:02 +00:00
|
|
|
/* screen tools */
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
WM_keymap_verify_item(keymap, "SCREEN_OT_area_split", EVT_ACTIONZONE_AREA, 0, 0, 0);
|
|
|
|
WM_keymap_verify_item(keymap, "SCREEN_OT_area_join", EVT_ACTIONZONE_AREA, 0, 0, 0);
|
|
|
|
WM_keymap_verify_item(keymap, "SCREEN_OT_area_dupli", EVT_ACTIONZONE_AREA, 0, KM_SHIFT, 0);
|
|
|
|
WM_keymap_verify_item(keymap, "SCREEN_OT_area_swap", EVT_ACTIONZONE_AREA, 0, KM_ALT, 0);
|
|
|
|
WM_keymap_verify_item(keymap, "SCREEN_OT_region_scale", EVT_ACTIONZONE_REGION, 0, 0, 0);
|
2009-12-10 09:25:30 +00:00
|
|
|
/* area move after action zones */
|
2008-12-26 11:11:21 +00:00
|
|
|
WM_keymap_verify_item(keymap, "SCREEN_OT_area_move", LEFTMOUSE, KM_PRESS, 0, 0);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-11-27 06:24:09 +00:00
|
|
|
/* Header Editing ------------------------------------------------ */
|
|
|
|
keymap= WM_keymap_find(keyconf, "Header", 0, 0);
|
|
|
|
|
|
|
|
WM_keymap_add_item(keymap, "SCREEN_OT_header_toolbox", RIGHTMOUSE, KM_PRESS, 0, 0);
|
|
|
|
|
2009-09-18 15:48:49 +00:00
|
|
|
/* Screen General ------------------------------------------------ */
|
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
|
|
|
keymap= WM_keymap_find(keyconf, "Screen", 0, 0);
|
2009-09-18 15:48:49 +00:00
|
|
|
|
|
|
|
/* standard timers */
|
|
|
|
WM_keymap_add_item(keymap, "SCREEN_OT_animation_step", TIMER0, KM_ANY, KM_ANY, 0);
|
|
|
|
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
|
2008-12-26 11:11:21 +00:00
|
|
|
RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_screen_set", RIGHTARROWKEY, KM_PRESS, KM_CTRL, 0)->ptr, "delta", 1);
|
|
|
|
RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_screen_set", LEFTARROWKEY, KM_PRESS, KM_CTRL, 0)->ptr, "delta", -1);
|
|
|
|
WM_keymap_add_item(keymap, "SCREEN_OT_screen_full_area", UPARROWKEY, KM_PRESS, KM_CTRL, 0);
|
|
|
|
WM_keymap_add_item(keymap, "SCREEN_OT_screen_full_area", DOWNARROWKEY, KM_PRESS, KM_CTRL, 0);
|
2009-11-19 14:37:07 +00:00
|
|
|
WM_keymap_add_item(keymap, "SCREEN_OT_screen_full_area", SPACEKEY, KM_PRESS, KM_SHIFT, 0);
|
2009-02-14 16:43:02 +00:00
|
|
|
WM_keymap_add_item(keymap, "SCREEN_OT_screenshot", F3KEY, KM_PRESS, KM_CTRL, 0);
|
2009-02-14 18:31:19 +00:00
|
|
|
WM_keymap_add_item(keymap, "SCREEN_OT_screencast", F3KEY, KM_PRESS, KM_ALT, 0);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
|
|
|
/* tests */
|
2009-12-04 00:49:02 +00:00
|
|
|
WM_keymap_add_item(keymap, "SCREEN_OT_region_quadview", QKEY, KM_PRESS, KM_CTRL|KM_ALT, 0);
|
2009-01-15 18:28:40 +00:00
|
|
|
WM_keymap_verify_item(keymap, "SCREEN_OT_repeat_history", F3KEY, KM_PRESS, 0, 0);
|
2009-09-12 19:11:34 +00:00
|
|
|
WM_keymap_add_item(keymap, "SCREEN_OT_repeat_last", RKEY, KM_PRESS, KM_SHIFT, 0);
|
2009-11-27 06:24:09 +00:00
|
|
|
WM_keymap_verify_item(keymap, "SCREEN_OT_region_flip", F5KEY, KM_PRESS, 0, 0);
|
2009-02-04 11:52:16 +00:00
|
|
|
WM_keymap_verify_item(keymap, "SCREEN_OT_redo_last", F6KEY, KM_PRESS, 0, 0);
|
2009-11-13 11:10:29 +00:00
|
|
|
WM_keymap_verify_item(keymap, "WM_OT_reload_scripts", F8KEY, KM_PRESS, 0, 0);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-01-28 18:26:47 +00:00
|
|
|
/* files */
|
2009-09-04 04:29:54 +00:00
|
|
|
WM_keymap_add_item(keymap, "FILE_OT_execute", RETKEY, KM_PRESS, 0, 0);
|
2009-10-07 05:13:31 +00:00
|
|
|
WM_keymap_add_item(keymap, "FILE_OT_execute", PADENTER, KM_PRESS, 0, 0);
|
2009-02-14 14:25:48 +00:00
|
|
|
WM_keymap_add_item(keymap, "FILE_OT_cancel", ESCKEY, KM_PRESS, 0, 0);
|
2009-01-28 18:26:47 +00:00
|
|
|
|
2008-12-31 18:52:15 +00:00
|
|
|
/* undo */
|
2009-12-10 09:25:30 +00:00
|
|
|
#ifdef __APPLE__
|
2008-12-31 18:52:15 +00:00
|
|
|
WM_keymap_add_item(keymap, "ED_OT_undo", ZKEY, KM_PRESS, KM_OSKEY, 0);
|
|
|
|
WM_keymap_add_item(keymap, "ED_OT_redo", ZKEY, KM_PRESS, KM_SHIFT|KM_OSKEY, 0);
|
2009-12-10 09:25:30 +00:00
|
|
|
#endif
|
2009-09-09 19:43:05 +00:00
|
|
|
WM_keymap_add_item(keymap, "ED_OT_undo", ZKEY, KM_PRESS, KM_CTRL, 0);
|
|
|
|
WM_keymap_add_item(keymap, "ED_OT_redo", ZKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0);
|
|
|
|
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-02-04 17:40:50 +00:00
|
|
|
/* render */
|
|
|
|
WM_keymap_add_item(keymap, "SCREEN_OT_render", F12KEY, KM_PRESS, 0, 0);
|
2.5: Render/Game Engine
An engine to use for output can now be selected an influences what
shows in the buttons window, only showing relevant data. The idea
behind this is to make it more clear what is supported where, make
the system more pluggable for external render/game engines, and save
space hiding stuff that is not relevant anyway.
* Top header now has an engine menu, to choose between the blender
render engine, game engine, and other future external engines.
* If the game engine is enabled, the buttons window should show
only properties that work in the game engine, and similarly for
the render engine.
* Moved panels from the logic space and game tabs to the physics,
scene and world tabs instead, and removed the game tab.
* Materials and textures tabs should eventually become game
specific too, to better show what is supported.
2009-07-23 21:50:40 +00:00
|
|
|
RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_render", F12KEY, KM_PRESS, KM_CTRL, 0)->ptr, "animation", 1);
|
2009-02-04 17:40:50 +00:00
|
|
|
WM_keymap_add_item(keymap, "SCREEN_OT_render_view_cancel", ESCKEY, KM_PRESS, 0, 0);
|
2009-07-10 16:55:49 +00:00
|
|
|
WM_keymap_add_item(keymap, "SCREEN_OT_render_view_show", F11KEY, KM_PRESS, 0, 0);
|
2009-12-11 08:05:05 +00:00
|
|
|
WM_keymap_add_item(keymap, "SCREEN_OT_play_rendered_anim", F11KEY, KM_PRESS, KM_CTRL, 0);
|
2009-01-23 14:43:25 +00:00
|
|
|
|
2009-07-24 12:43:59 +00:00
|
|
|
/* user prefs */
|
2009-12-10 09:25:30 +00:00
|
|
|
#ifdef __APPLE__
|
2009-10-14 14:07:32 +00:00
|
|
|
WM_keymap_add_item(keymap, "SCREEN_OT_userpref_show", COMMAKEY, KM_PRESS, KM_OSKEY, 0);
|
2009-12-10 09:25:30 +00:00
|
|
|
#endif
|
2009-10-13 15:30:19 +00:00
|
|
|
WM_keymap_add_item(keymap, "SCREEN_OT_userpref_show", UKEY, KM_PRESS, KM_CTRL|KM_ALT, 0);
|
2009-09-09 19:43:05 +00:00
|
|
|
|
2009-07-24 12:43:59 +00:00
|
|
|
|
2009-07-19 05:20:30 +00:00
|
|
|
/* Anim Playback ------------------------------------------------ */
|
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
|
|
|
keymap= WM_keymap_find(keyconf, "Frames", 0, 0);
|
2009-07-19 05:20:30 +00:00
|
|
|
|
|
|
|
/* frame offsets */
|
2009-01-23 14:43:25 +00:00
|
|
|
RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_offset", UPARROWKEY, KM_PRESS, 0, 0)->ptr, "delta", 10);
|
|
|
|
RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_offset", DOWNARROWKEY, KM_PRESS, 0, 0)->ptr, "delta", -10);
|
|
|
|
RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_offset", LEFTARROWKEY, KM_PRESS, 0, 0)->ptr, "delta", -1);
|
|
|
|
RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_offset", RIGHTARROWKEY, KM_PRESS, 0, 0)->ptr, "delta", 1);
|
|
|
|
|
2010-01-04 00:39:55 +00:00
|
|
|
RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_offset", WHEELDOWNMOUSE, KM_PRESS, KM_ALT, 0)->ptr, "delta", 1);
|
|
|
|
RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_offset", WHEELUPMOUSE, KM_PRESS, KM_ALT, 0)->ptr, "delta", -1);
|
|
|
|
|
2009-08-02 07:08:51 +00:00
|
|
|
WM_keymap_add_item(keymap, "SCREEN_OT_frame_jump", DOWNARROWKEY, KM_PRESS, KM_SHIFT, 0);
|
2009-08-22 00:19:24 +00:00
|
|
|
RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_jump", RIGHTARROWKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "end", 1);
|
|
|
|
RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_jump", LEFTARROWKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "end", 0);
|
2009-08-02 07:08:51 +00:00
|
|
|
|
2009-07-24 13:34:45 +00:00
|
|
|
WM_keymap_add_item(keymap, "SCREEN_OT_keyframe_jump", PAGEUPKEY, KM_PRESS, KM_CTRL, 0);
|
|
|
|
RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_keyframe_jump", PAGEDOWNKEY, KM_PRESS, KM_CTRL, 0)->ptr, "next", 0);
|
|
|
|
|
2009-07-19 05:20:30 +00:00
|
|
|
/* play (forward and backwards) */
|
|
|
|
WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", AKEY, KM_PRESS, KM_ALT, 0);
|
2009-08-16 17:42:09 +00:00
|
|
|
WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", KKEY, KM_PRESS, 0, LKEY);
|
2009-07-19 05:20:30 +00:00
|
|
|
RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", AKEY, KM_PRESS, KM_ALT|KM_SHIFT, 0)->ptr, "reverse", 1);
|
2009-10-09 21:50:33 +00:00
|
|
|
WM_keymap_add_item(keymap, "SCREEN_OT_animation_cancel", ESCKEY, KM_PRESS, 0, 0);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
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
|
|
|
keymap_modal_set(keyconf);
|
2008-01-07 18:03:41 +00:00
|
|
|
}
|
|
|
|
|