2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2008-01-07 18:03:41 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2008-01-07 18:03:41 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2008 Blender Foundation.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
2011-02-27 20:29:51 +00:00
|
|
|
/** \file blender/editors/screen/screen_ops.c
|
|
|
|
* \ingroup edscr
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2009-02-15 13:09:19 +00:00
|
|
|
#include <math.h>
|
2009-10-28 18:03:04 +00:00
|
|
|
#include <string.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"
|
2009-07-24 13:34:45 +00:00
|
|
|
#include "BLI_dlrbTree.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2008-01-07 18:03:41 +00:00
|
|
|
|
2012-05-19 09:46:41 +00:00
|
|
|
#include "BLF_translation.h"
|
|
|
|
|
2009-02-04 17:40:50 +00:00
|
|
|
#include "DNA_armature_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_curve_types.h"
|
|
|
|
#include "DNA_scene_types.h"
|
2009-07-29 12:35:09 +00:00
|
|
|
#include "DNA_meta_types.h"
|
2012-02-19 22:17:30 +00:00
|
|
|
#include "DNA_mesh_types.h"
|
2012-06-04 16:42:58 +00:00
|
|
|
#include "DNA_mask_types.h"
|
2013-03-18 16:34:57 +00:00
|
|
|
#include "DNA_node_types.h"
|
2012-02-12 11:42:17 +00:00
|
|
|
#include "DNA_userdef_types.h"
|
2009-02-04 17:40:50 +00:00
|
|
|
|
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"
|
2011-04-07 15:48:33 +00:00
|
|
|
#include "BKE_global.h"
|
2008-01-07 18:03:41 +00:00
|
|
|
#include "BKE_main.h"
|
2009-05-23 03:24:15 +00:00
|
|
|
#include "BKE_mesh.h"
|
2013-03-18 16:34:57 +00:00
|
|
|
#include "BKE_node.h"
|
2011-09-14 01:48:55 +00:00
|
|
|
#include "BKE_object.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"
|
2013-04-13 20:31:52 +00:00
|
|
|
#include "BKE_editmesh.h"
|
2009-08-09 21:16:39 +00:00
|
|
|
#include "BKE_sound.h"
|
2012-06-04 16:42:58 +00:00
|
|
|
#include "BKE_mask.h"
|
2008-01-07 18:03:41 +00:00
|
|
|
|
|
|
|
#include "WM_api.h"
|
|
|
|
#include "WM_types.h"
|
|
|
|
|
2012-07-25 12:15:22 +00:00
|
|
|
#include "ED_armature.h"
|
|
|
|
#include "ED_clip.h"
|
2010-12-20 05:26:25 +00:00
|
|
|
#include "ED_image.h"
|
2012-07-25 12:15:22 +00:00
|
|
|
#include "ED_keyframes_draw.h"
|
2009-07-02 03:32:57 +00:00
|
|
|
#include "ED_object.h"
|
2012-07-25 12:15:22 +00:00
|
|
|
#include "ED_screen.h"
|
2008-11-19 16:28:11 +00:00
|
|
|
#include "ED_screen_types.h"
|
2012-07-25 12:15:22 +00:00
|
|
|
#include "ED_sequencer.h"
|
|
|
|
#include "ED_util.h"
|
2011-03-08 07:44:30 +00:00
|
|
|
#include "ED_view3d.h"
|
2009-02-04 17:40:50 +00:00
|
|
|
|
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"
|
2010-12-17 19:05:34 +00:00
|
|
|
#include "UI_resources.h"
|
2009-10-28 18:03:04 +00:00
|
|
|
|
2009-07-24 12:43:59 +00:00
|
|
|
#include "wm_window.h"
|
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
#include "screen_intern.h" /* own module include */
|
2008-01-07 18:03:41 +00:00
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
#define KM_MODAL_CANCEL 1
|
|
|
|
#define KM_MODAL_APPLY 2
|
|
|
|
#define KM_MODAL_STEP10 3
|
|
|
|
#define KM_MODAL_STEP10_OFF 4
|
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
|
|
|
|
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)
|
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
if (CTX_wm_window(C) == NULL) return 0;
|
|
|
|
if (CTX_wm_screen(C) == NULL) return 0;
|
|
|
|
if (CTX_wm_region(C) == NULL) return 0;
|
2009-02-19 23:53:40 +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
|
|
|
int ED_operator_areaactive(bContext *C)
|
|
|
|
{
|
2012-05-08 11:48:19 +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)
|
|
|
|
{
|
2012-05-08 11:48:19 +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;
|
|
|
|
}
|
|
|
|
|
2011-04-07 15:48:33 +00:00
|
|
|
/* XXX added this to prevent anim state to change during renders */
|
2011-05-10 13:11:36 +00:00
|
|
|
static int ED_operator_screenactive_norender(bContext *C)
|
2011-04-07 15:48:33 +00:00
|
|
|
{
|
2012-08-08 18:37:06 +00:00
|
|
|
if (G.is_rendering) return 0;
|
2012-05-08 11:48:19 +00:00
|
|
|
if (CTX_wm_window(C) == NULL) return 0;
|
|
|
|
if (CTX_wm_screen(C) == NULL) return 0;
|
2011-04-07 15:48:33 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-23 16:36:41 +00:00
|
|
|
static int screen_active_editable(bContext *C)
|
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ED_operator_screenactive(C)) {
|
2011-03-23 16:36:41 +00:00
|
|
|
/* no full window splitting allowed */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (CTX_wm_screen(C)->full != SCREENNORMAL)
|
2011-03-23 16:36:41 +00:00
|
|
|
return 0;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
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
|
|
|
/* 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
|
|
|
{
|
2012-12-14 16:10:46 +00:00
|
|
|
bScreen *screen;
|
2012-05-08 11:48:19 +00:00
|
|
|
if (CTX_wm_window(C) == NULL) return 0;
|
2012-12-14 16:10:46 +00:00
|
|
|
screen = CTX_wm_screen(C);
|
|
|
|
if (screen == NULL) return 0;
|
|
|
|
if (screen->subwinactive != screen->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)
|
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
if (scene && scene->id.lib == NULL)
|
2009-01-01 14:57:04 +00:00
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-11-12 17:35:51 +00:00
|
|
|
int ED_operator_objectmode(bContext *C)
|
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
Object *obact = CTX_data_active_object(C);
|
2010-11-12 17:35:51 +00:00
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
if (scene == NULL || scene->id.lib)
|
2010-11-12 17:35:51 +00:00
|
|
|
return 0;
|
2012-05-08 11:48:19 +00:00
|
|
|
if (CTX_data_edit_object(C) )
|
2010-11-12 17:35:51 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* add a check for ob->mode too? */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (obact && obact->mode)
|
2010-11-12 17:35:51 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-12-26 19:07:31 +00:00
|
|
|
static int ed_spacetype_test(bContext *C, int type)
|
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ED_operator_areaactive(C)) {
|
2012-05-08 11:48:19 +00:00
|
|
|
SpaceLink *sl = (SpaceLink *)CTX_wm_space_data(C);
|
2008-12-26 19:07:31 +00:00
|
|
|
return sl && (sl->spacetype == type);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ED_operator_view3d_active(bContext *C)
|
|
|
|
{
|
|
|
|
return ed_spacetype_test(C, SPACE_VIEW3D);
|
|
|
|
}
|
|
|
|
|
2010-09-27 10:44:46 +00:00
|
|
|
int ED_operator_region_view3d_active(bContext *C)
|
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (CTX_wm_region_view3d(C))
|
2010-09-27 12:21:23 +00:00
|
|
|
return TRUE;
|
2010-11-04 15:59:09 +00:00
|
|
|
|
2010-09-27 12:21:23 +00:00
|
|
|
CTX_wm_operator_poll_msg_set(C, "expected a view3d region");
|
2012-10-21 05:46:41 +00:00
|
|
|
return FALSE;
|
2010-09-27 10:44:46 +00:00
|
|
|
}
|
|
|
|
|
2010-11-04 15:59:09 +00:00
|
|
|
/* generic for any view2d which uses anim_ops */
|
|
|
|
int ED_operator_animview_active(bContext *C)
|
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ED_operator_areaactive(C)) {
|
2012-05-08 11:48:19 +00:00
|
|
|
SpaceLink *sl = (SpaceLink *)CTX_wm_space_data(C);
|
2011-11-01 19:48:45 +00:00
|
|
|
if (sl && (ELEM5(sl->spacetype, SPACE_SEQ, SPACE_ACTION, SPACE_NLA, SPACE_IPO, SPACE_TIME)))
|
2010-11-04 15:59:09 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2013-02-28 15:31:20 +00:00
|
|
|
CTX_wm_operator_poll_msg_set(C, "expected a timeline/animation area to be active");
|
2010-11-04 15:59:09 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-12-26 19:07:31 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2010-09-27 21:22:20 +00:00
|
|
|
int ED_operator_outliner_active_no_editobject(bContext *C)
|
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ed_spacetype_test(C, SPACE_OUTLINER)) {
|
2010-09-27 21:22:20 +00:00
|
|
|
Object *ob = ED_object_active_context(C);
|
2012-05-08 11:48:19 +00:00
|
|
|
Object *obedit = CTX_data_edit_object(C);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ob && ob == obedit)
|
2010-09-27 21:22:20 +00:00
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
SpaceNode *snode = CTX_wm_space_node(C);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2013-03-19 13:40:16 +00:00
|
|
|
if (snode && snode->edittree)
|
2009-07-28 16:33:02 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2013-06-05 19:06:33 +00:00
|
|
|
int ED_operator_node_editable(bContext *C)
|
|
|
|
{
|
|
|
|
SpaceNode *snode = CTX_wm_space_node(C);
|
|
|
|
|
|
|
|
if (snode && snode->edittree && snode->edittree->id.lib == NULL)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-10-20 20:20:02 +00:00
|
|
|
/* XXX rename */
|
2011-02-01 23:51:52 +00:00
|
|
|
int ED_operator_graphedit_active(bContext *C)
|
2008-12-26 19:07:31 +00:00
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2010-11-11 13:36:57 +00:00
|
|
|
int ED_operator_info_active(bContext *C)
|
|
|
|
{
|
|
|
|
return ed_spacetype_test(C, SPACE_INFO);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int ED_operator_console_active(bContext *C)
|
|
|
|
{
|
|
|
|
return ed_spacetype_test(C, SPACE_CONSOLE);
|
|
|
|
}
|
|
|
|
|
2012-11-21 03:33:34 +00:00
|
|
|
static int ed_object_hidden(Object *ob)
|
|
|
|
{
|
|
|
|
/* if hidden but in edit mode, we still display, can happen with animation */
|
|
|
|
return ((ob->restrictflag & OB_RESTRICT_VIEW) && !(ob->mode & OB_MODE_EDIT));
|
|
|
|
}
|
|
|
|
|
2009-01-01 13:15:35 +00:00
|
|
|
int ED_operator_object_active(bContext *C)
|
|
|
|
{
|
2010-09-06 22:10:51 +00:00
|
|
|
Object *ob = ED_object_active_context(C);
|
2012-11-21 03:33:34 +00:00
|
|
|
return ((ob != NULL) && !ed_object_hidden(ob));
|
2009-01-01 13:15:35 +00:00
|
|
|
}
|
|
|
|
|
2009-12-04 06:33:01 +00:00
|
|
|
int ED_operator_object_active_editable(bContext *C)
|
|
|
|
{
|
2010-03-31 00:55:01 +00:00
|
|
|
Object *ob = ED_object_active_context(C);
|
2012-11-21 03:33:34 +00:00
|
|
|
return ((ob != NULL) && !(ob->id.lib) && !ed_object_hidden(ob));
|
2009-12-04 06:33:01 +00:00
|
|
|
}
|
|
|
|
|
2010-11-04 15:59:09 +00:00
|
|
|
int ED_operator_object_active_editable_mesh(bContext *C)
|
|
|
|
{
|
|
|
|
Object *ob = ED_object_active_context(C);
|
2012-11-21 03:33:34 +00:00
|
|
|
return ((ob != NULL) && !(ob->id.lib) && !ed_object_hidden(ob) &&
|
2012-05-27 11:10:27 +00:00
|
|
|
(ob->type == OB_MESH) && !(((ID *)ob->data)->lib));
|
2009-12-04 06:33:01 +00:00
|
|
|
}
|
|
|
|
|
2011-03-15 08:38:08 +00:00
|
|
|
int ED_operator_object_active_editable_font(bContext *C)
|
|
|
|
{
|
|
|
|
Object *ob = ED_object_active_context(C);
|
2012-11-21 03:33:34 +00:00
|
|
|
return ((ob != NULL) && !(ob->id.lib) && !ed_object_hidden(ob) &&
|
2012-05-27 11:10:27 +00:00
|
|
|
(ob->type == OB_FONT));
|
2011-03-15 08:38:08 +00:00
|
|
|
}
|
|
|
|
|
2009-01-01 13:15:35 +00:00
|
|
|
int ED_operator_editmesh(bContext *C)
|
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
Object *obedit = CTX_data_edit_object(C);
|
|
|
|
if (obedit && obedit->type == OB_MESH)
|
2013-04-16 05:59:48 +00:00
|
|
|
return NULL != BKE_editmesh_from_object(obedit);
|
2009-01-01 13:15:35 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2010-09-27 05:44:15 +00:00
|
|
|
int ED_operator_editmesh_region_view3d(bContext *C)
|
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ED_operator_editmesh(C) && CTX_wm_region_view3d(C))
|
2010-10-08 11:33:10 +00:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
CTX_wm_operator_poll_msg_set(C, "expected a view3d region & editmesh");
|
|
|
|
return 0;
|
2010-09-27 05:44:15 +00:00
|
|
|
}
|
|
|
|
|
2009-02-01 18:07:02 +00:00
|
|
|
int ED_operator_editarmature(bContext *C)
|
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
Object *obedit = CTX_data_edit_object(C);
|
|
|
|
if (obedit && obedit->type == OB_ARMATURE)
|
2009-02-01 18:07:02 +00:00
|
|
|
return NULL != ((bArmature *)obedit->data)->edbo;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-09-06 23:10:01 +00:00
|
|
|
/**
|
|
|
|
* \brief check for pose mode (no mixed modes)
|
|
|
|
*
|
2013-02-06 14:02:19 +00:00
|
|
|
* We want to enable most pose operations in weight paint mode,
|
2012-09-06 23:10:01 +00:00
|
|
|
* when it comes to transforming bones, but managing bomes layers/groups
|
|
|
|
* can be left for pose mode only. (not weight paint mode)
|
|
|
|
*/
|
|
|
|
int ED_operator_posemode_exclusive(bContext *C)
|
|
|
|
{
|
|
|
|
Object *obact = CTX_data_active_object(C);
|
|
|
|
|
|
|
|
if (obact && !(obact->mode & OB_MODE_EDIT)) {
|
|
|
|
Object *obpose;
|
|
|
|
if ((obpose = BKE_object_pose_armature_get(obact))) {
|
|
|
|
if (obact == obpose) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-09-23 02:31:30 +00:00
|
|
|
/* allows for pinned pose objects to be used in the object buttons
|
|
|
|
* and the the non-active pose object to be used in the 3D view */
|
|
|
|
int ED_operator_posemode_context(bContext *C)
|
|
|
|
{
|
|
|
|
Object *obpose = ED_pose_object_from_context(C);
|
|
|
|
|
|
|
|
if (obpose && !(obpose->mode & OB_MODE_EDIT)) {
|
|
|
|
if (BKE_object_pose_context_check(obpose)) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-02-01 18:07:02 +00:00
|
|
|
int ED_operator_posemode(bContext *C)
|
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
Object *obact = CTX_data_active_object(C);
|
2010-10-14 03:57:15 +00:00
|
|
|
|
2010-11-30 19:12:17 +00:00
|
|
|
if (obact && !(obact->mode & OB_MODE_EDIT)) {
|
2010-10-14 03:57:15 +00:00
|
|
|
Object *obpose;
|
2012-05-08 11:48:19 +00:00
|
|
|
if ((obpose = BKE_object_pose_armature_get(obact))) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if ((obact == obpose) || (obact->mode & OB_MODE_WEIGHT_PAINT)) {
|
2010-10-14 03:57:15 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-01 18:07:02 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-12-20 05:26:25 +00:00
|
|
|
/* wrapper for ED_space_image_show_uvedit */
|
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)
|
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
SpaceImage *sima = CTX_wm_space_image(C);
|
|
|
|
Object *obedit = CTX_data_edit_object(C);
|
2010-12-20 05:26:25 +00:00
|
|
|
return ED_space_image_show_uvedit(sima, obedit);
|
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
|
|
|
}
|
|
|
|
|
2013-04-08 10:03:51 +00:00
|
|
|
int ED_operator_uvedit_space_image(bContext *C)
|
|
|
|
{
|
|
|
|
SpaceImage *sima = CTX_wm_space_image(C);
|
|
|
|
Object *obedit = CTX_data_edit_object(C);
|
|
|
|
return sima && ED_space_image_show_uvedit(sima, obedit);
|
|
|
|
}
|
|
|
|
|
2009-02-07 01:27:46 +00:00
|
|
|
int ED_operator_uvmap(bContext *C)
|
|
|
|
{
|
2012-03-02 12:09:49 +00:00
|
|
|
Object *obedit = CTX_data_edit_object(C);
|
|
|
|
BMEditMesh *em = NULL;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (obedit && obedit->type == OB_MESH) {
|
2013-04-16 05:59:48 +00:00
|
|
|
em = BKE_editmesh_from_object(obedit);
|
2012-03-02 12:09:49 +00:00
|
|
|
}
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (em && (em->bm->totface)) {
|
2012-03-02 12:09:49 +00:00
|
|
|
return TRUE;
|
2011-12-04 23:13:28 +00:00
|
|
|
}
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2012-03-02 12:09:49 +00:00
|
|
|
return FALSE;
|
2009-02-07 01:27:46 +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_editsurfcurve(bContext *C)
|
2009-01-01 13:15:35 +00:00
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
Object *obedit = CTX_data_edit_object(C);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (obedit && ELEM(obedit->type, OB_CURVE, OB_SURF))
|
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
|
|
|
return NULL != ((Curve *)obedit->data)->editnurb;
|
2009-01-01 13:15:35 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2008-12-26 19:07:31 +00:00
|
|
|
|
2010-11-21 18:50:53 +00:00
|
|
|
int ED_operator_editsurfcurve_region_view3d(bContext *C)
|
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ED_operator_editsurfcurve(C) && CTX_wm_region_view3d(C))
|
2010-11-21 18:50:53 +00:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
CTX_wm_operator_poll_msg_set(C, "expected a view3d region & editcurve");
|
|
|
|
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)
|
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
Object *obedit = CTX_data_edit_object(C);
|
|
|
|
if (obedit && obedit->type == OB_CURVE)
|
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
|
|
|
return NULL != ((Curve *)obedit->data)->editnurb;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-11-01 11:00:08 +00:00
|
|
|
int ED_operator_editcurve_3d(bContext *C)
|
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
Object *obedit = CTX_data_edit_object(C);
|
|
|
|
if (obedit && obedit->type == OB_CURVE) {
|
|
|
|
Curve *cu = (Curve *)obedit->data;
|
2011-11-01 11:00:08 +00:00
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
return (cu->flag & CU_3D) && (NULL != cu->editnurb);
|
2011-11-01 11:00:08 +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_editsurf(bContext *C)
|
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
Object *obedit = CTX_data_edit_object(C);
|
|
|
|
if (obedit && obedit->type == OB_SURF)
|
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
|
|
|
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)
|
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
Object *obedit = CTX_data_edit_object(C);
|
|
|
|
if (obedit && obedit->type == OB_FONT)
|
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
|
|
|
return NULL != ((Curve *)obedit->data)->editfont;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-07-03 15:23:33 +00:00
|
|
|
int ED_operator_editlattice(bContext *C)
|
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
Object *obedit = CTX_data_edit_object(C);
|
|
|
|
if (obedit && obedit->type == OB_LATTICE)
|
2009-07-03 15:23:33 +00:00
|
|
|
return NULL != ((Lattice *)obedit->data)->editlatt;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-07-29 12:35:09 +00:00
|
|
|
int ED_operator_editmball(bContext *C)
|
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
Object *obedit = CTX_data_edit_object(C);
|
|
|
|
if (obedit && obedit->type == OB_MBALL)
|
2009-07-29 12:35:09 +00:00
|
|
|
return NULL != ((MetaBall *)obedit->data)->editelems;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-06-04 16:42:58 +00:00
|
|
|
int ED_operator_mask(bContext *C)
|
|
|
|
{
|
2012-07-25 12:15:22 +00:00
|
|
|
ScrArea *sa = CTX_wm_area(C);
|
|
|
|
if (sa && sa->spacedata.first) {
|
|
|
|
switch (sa->spacetype) {
|
|
|
|
case SPACE_CLIP:
|
|
|
|
{
|
|
|
|
SpaceClip *sc = sa->spacedata.first;
|
|
|
|
return ED_space_clip_check_show_maskedit(sc);
|
|
|
|
}
|
|
|
|
case SPACE_SEQ:
|
|
|
|
{
|
|
|
|
SpaceSeq *sseq = sa->spacedata.first;
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
return ED_space_sequencer_check_show_maskedit(sseq, scene);
|
|
|
|
}
|
|
|
|
case SPACE_IMAGE:
|
|
|
|
{
|
|
|
|
SpaceImage *sima = sa->spacedata.first;
|
2012-07-31 14:16:27 +00:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
return ED_space_image_check_show_maskedit(scene, sima);
|
2012-07-25 12:15:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-06-04 16:42:58 +00:00
|
|
|
|
2012-07-25 12:15:22 +00:00
|
|
|
return FALSE;
|
2012-06-04 16:42:58 +00:00
|
|
|
}
|
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
/* *************************** action zone operator ************************** */
|
|
|
|
|
|
|
|
/* operator state vars used:
|
2012-03-03 16:31:46 +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
|
2009-12-10 09:25:30 +00:00
|
|
|
*/
|
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)
|
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
ScrArea *sa = NULL;
|
|
|
|
sa = scr->areabase.first;
|
2012-03-24 06:38:07 +00:00
|
|
|
while (sa) {
|
2012-08-23 18:25:45 +00:00
|
|
|
if (BLI_rcti_isect_pt(&sa->totrct, x, y)) break;
|
2012-05-08 11:48:19 +00:00
|
|
|
sa = sa->next;
|
2008-11-19 16:28:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
wmWindow *win = CTX_wm_window(C);
|
|
|
|
ScrArea *sa = CTX_wm_area(C);
|
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
|
|
|
|
2013-06-28 05:39:05 +00:00
|
|
|
if (sa && win && win->eventstate) {
|
|
|
|
const int *xy = &win->eventstate->x;
|
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
|
|
|
AZone *az;
|
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
for (az = sa->actionzones.first; az; az = az->next)
|
2013-06-28 05:39:05 +00:00
|
|
|
if (BLI_rcti_isect_pt_v(&az->rect, xy))
|
2009-12-10 09:25:30 +00:00
|
|
|
return 1;
|
2012-10-21 05:46:41 +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 0;
|
|
|
|
}
|
2008-11-19 16:28:11 +00:00
|
|
|
|
2012-07-11 18:17:48 +00:00
|
|
|
AZone *is_in_area_actionzone(ScrArea *sa, const int xy[2])
|
2008-11-19 16:28:11 +00:00
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
AZone *az = NULL;
|
2008-11-19 16:28:11 +00:00
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
for (az = sa->actionzones.first; az; az = az->next) {
|
2012-08-23 18:25:45 +00:00
|
|
|
if (BLI_rcti_isect_pt_v(&az->rect, xy)) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (az->type == AZONE_AREA) {
|
2011-02-06 17:36:42 +00:00
|
|
|
/* no triangle intersect but a hotspot circle based on corner */
|
2012-07-11 18:17:48 +00:00
|
|
|
int radius = (xy[0] - az->x1) * (xy[0] - az->x1) + (xy[1] - az->y1) * (xy[1] - az->y1);
|
2011-02-06 17:36:42 +00:00
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
if (radius <= AZONESPOT * AZONESPOT)
|
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;
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (az->type == AZONE_REGION) {
|
2009-09-16 17:43:09 +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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-10-14 12:24:08 +00:00
|
|
|
static void actionzone_exit(wmOperator *op)
|
2008-11-19 16:28:11 +00:00
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (op->customdata)
|
2008-11-19 16:28:11 +00:00
|
|
|
MEM_freeN(op->customdata);
|
2012-05-08 11:48:19 +00:00
|
|
|
op->customdata = NULL;
|
2008-11-19 16:28:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* 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;
|
2012-05-08 11:48:19 +00:00
|
|
|
wmWindow *win = CTX_wm_window(C);
|
|
|
|
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
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
sad->modifier = RNA_int_get(op->ptr, "modifier");
|
2008-11-19 16:28:11 +00:00
|
|
|
|
2013-07-29 08:29:04 +00:00
|
|
|
wm_event_init_from_window(win, &event);
|
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
if (type == AZONE_AREA)
|
|
|
|
event.type = EVT_ACTIONZONE_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
|
|
|
else
|
2012-05-08 11:48:19 +00:00
|
|
|
event.type = EVT_ACTIONZONE_REGION;
|
2012-10-26 16:17:48 +00:00
|
|
|
event.val = 0;
|
2012-05-08 11:48:19 +00:00
|
|
|
event.customdata = op->customdata;
|
|
|
|
event.customdatafree = TRUE;
|
|
|
|
op->customdata = NULL;
|
2008-11-19 16:28:11 +00:00
|
|
|
|
2008-12-18 02:56:48 +00:00
|
|
|
wm_event_add(win, &event);
|
2008-11-19 16:28:11 +00:00
|
|
|
}
|
|
|
|
|
2013-03-13 09:03:46 +00:00
|
|
|
static int actionzone_invoke(bContext *C, wmOperator *op, const wmEvent *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
|
|
|
{
|
2012-07-11 18:17:48 +00:00
|
|
|
AZone *az = is_in_area_actionzone(CTX_wm_area(C), &event->x);
|
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
|
|
|
sActionzoneData *sad;
|
|
|
|
|
|
|
|
/* quick escape */
|
2012-05-08 11:48:19 +00:00
|
|
|
if (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
|
|
|
return OPERATOR_PASS_THROUGH;
|
|
|
|
|
|
|
|
/* ok we do the actionzone */
|
2012-05-08 11:48:19 +00:00
|
|
|
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;
|
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
|
|
|
|
|
|
|
/* region azone directly reacts on mouse clicks */
|
2012-05-08 11:48:19 +00:00
|
|
|
if (sad->az->type == AZONE_REGION) {
|
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, AZONE_REGION);
|
2010-10-14 12:24:08 +00:00
|
|
|
actionzone_exit(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_FINISHED;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* add modal handler */
|
2009-10-22 23:22:05 +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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-03-13 09:03:46 +00:00
|
|
|
static int actionzone_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
2008-11-19 16:28:11 +00:00
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
sActionzoneData *sad = op->customdata;
|
2008-11-19 16:28:11 +00:00
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (event->type) {
|
2008-11-19 16:28:11 +00:00
|
|
|
case MOUSEMOVE:
|
2013-09-04 05:06:38 +00:00
|
|
|
{
|
2013-09-04 05:25:29 +00:00
|
|
|
bool is_gesture;
|
2013-09-04 05:06:38 +00:00
|
|
|
|
|
|
|
const int delta_x = (event->x - sad->x);
|
|
|
|
const int delta_y = (event->y - sad->y);
|
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
/* calculate gesture direction */
|
2013-09-04 05:06:38 +00:00
|
|
|
if (delta_y > ABS(delta_x))
|
2012-05-08 11:48:19 +00:00
|
|
|
sad->gesture_dir = 'n';
|
2013-09-04 05:06:38 +00:00
|
|
|
else if (delta_x > ABS(delta_y))
|
2012-05-08 11:48:19 +00:00
|
|
|
sad->gesture_dir = 'e';
|
2013-09-04 05:06:38 +00:00
|
|
|
else if (delta_y < -ABS(delta_x))
|
2012-05-08 11:48:19 +00:00
|
|
|
sad->gesture_dir = 's';
|
2008-11-19 16:28:11 +00:00
|
|
|
else
|
2012-05-08 11:48:19 +00:00
|
|
|
sad->gesture_dir = 'w';
|
2008-11-19 16:28:11 +00:00
|
|
|
|
2013-09-04 05:25:29 +00:00
|
|
|
if (sad->az->type == AZONE_AREA) {
|
|
|
|
/* once we drag outside the actionzone, register a gesture
|
|
|
|
* check we're not on an edge so join finds the other area */
|
|
|
|
is_gesture = ((is_in_area_actionzone(sad->sa1, &event->x) != sad->az) &&
|
|
|
|
(screen_find_active_scredge(CTX_wm_screen(C), event->x, event->y) == NULL));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
const int delta_min = 1;
|
|
|
|
is_gesture = (ABS(delta_x) > delta_min || ABS(delta_y) > delta_min);
|
|
|
|
}
|
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
/* gesture is large enough? */
|
2013-09-04 05:25:29 +00:00
|
|
|
if (is_gesture) {
|
|
|
|
/* second area, for join when (sa1 != sa2) */
|
2012-05-08 11:48:19 +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);
|
2010-10-14 12:24:08 +00:00
|
|
|
actionzone_exit(op);
|
2008-11-19 16:28:11 +00:00
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
2009-12-10 09:25:30 +00:00
|
|
|
break;
|
2013-09-04 05:06:38 +00:00
|
|
|
}
|
2008-11-19 16:28:11 +00:00
|
|
|
case ESCKEY:
|
2010-10-14 12:24:08 +00:00
|
|
|
actionzone_exit(op);
|
2008-11-19 16:28:11 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
2012-10-21 05:46:41 +00:00
|
|
|
case LEFTMOUSE:
|
2010-10-14 12:24:08 +00:00
|
|
|
actionzone_exit(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_CANCELLED;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return OPERATOR_RUNNING_MODAL;
|
|
|
|
}
|
|
|
|
|
2011-06-06 11:04:54 +00:00
|
|
|
static int actionzone_cancel(bContext *UNUSED(C), wmOperator *op)
|
|
|
|
{
|
|
|
|
actionzone_exit(op);
|
|
|
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
|
|
|
|
2009-07-24 12:43:59 +00:00
|
|
|
static void SCREEN_OT_actionzone(wmOperatorType *ot)
|
2008-11-19 16:28:11 +00:00
|
|
|
{
|
|
|
|
/* identifiers */
|
2013-01-27 07:23:58 +00:00
|
|
|
ot->name = "Handle Area Action Zones";
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->description = "Handle area action zones for mouse actions/gestures";
|
|
|
|
ot->idname = "SCREEN_OT_actionzone";
|
2008-11-19 16:28:11 +00:00
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->invoke = actionzone_invoke;
|
|
|
|
ot->modal = actionzone_modal;
|
|
|
|
ot->poll = actionzone_area_poll;
|
|
|
|
ot->cancel = actionzone_cancel;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->flag = OPTYPE_BLOCKING;
|
2009-07-11 14:51:13 +00:00
|
|
|
|
2011-10-20 07:56:04 +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:
|
2012-03-03 16:31:46 +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-12-10 09:25:30 +00:00
|
|
|
*/
|
2009-03-11 20:22:06 +00:00
|
|
|
|
|
|
|
typedef struct sAreaSwapData {
|
|
|
|
ScrArea *sa1, *sa2;
|
|
|
|
} sAreaSwapData;
|
|
|
|
|
2013-03-13 09:03:46 +00:00
|
|
|
static int area_swap_init(wmOperator *op, const wmEvent *event)
|
2009-03-11 20:22:06 +00:00
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
sAreaSwapData *sd = NULL;
|
|
|
|
sActionzoneData *sad = event->customdata;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2012-05-08 11:48:19 +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
|
|
|
|
2012-05-08 11:48:19 +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)
|
|
|
|
{
|
2010-04-06 08:11:37 +00:00
|
|
|
WM_cursor_restore(CTX_wm_window(C));
|
2012-03-24 06:38:07 +00:00
|
|
|
if (op->customdata)
|
2009-03-11 20:22:06 +00:00
|
|
|
MEM_freeN(op->customdata);
|
2012-05-08 11:48:19 +00:00
|
|
|
op->customdata = NULL;
|
2009-03-11 20:22:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int area_swap_cancel(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
area_swap_exit(C, op);
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
|
|
|
|
2013-03-13 09:03:46 +00:00
|
|
|
static int area_swap_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
2009-03-11 20:22:06 +00:00
|
|
|
{
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!area_swap_init(op, event))
|
2009-03-11 20:22:06 +00:00
|
|
|
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-10-22 23:22:05 +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
|
|
|
}
|
|
|
|
|
2013-03-13 09:03:46 +00:00
|
|
|
static int area_swap_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
2009-03-11 20:22:06 +00:00
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
sActionzoneData *sad = op->customdata;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (event->type) {
|
2009-03-11 20:22:06 +00:00
|
|
|
case MOUSEMOVE:
|
|
|
|
/* second area, for join */
|
2012-05-08 11:48:19 +00:00
|
|
|
sad->sa2 = screen_areahascursor(CTX_wm_screen(C), event->x, event->y);
|
2009-03-11 20:22:06 +00:00
|
|
|
break;
|
|
|
|
case LEFTMOUSE: /* release LMB */
|
2012-05-08 11:48:19 +00:00
|
|
|
if (event->val == KM_RELEASE) {
|
2012-03-24 06:38:07 +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);
|
|
|
|
}
|
2010-04-06 09:36:35 +00:00
|
|
|
|
2010-01-16 22:56:52 +00:00
|
|
|
ED_area_tag_redraw(sad->sa1);
|
|
|
|
ED_area_tag_redraw(sad->sa2);
|
|
|
|
|
2010-04-06 09:36:35 +00:00
|
|
|
ED_area_swapspace(C, sad->sa1, sad->sa2);
|
|
|
|
|
|
|
|
area_swap_exit(C, op);
|
|
|
|
|
2012-05-08 11:48:19 +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
|
|
|
{
|
2013-01-27 07:23:58 +00:00
|
|
|
ot->name = "Swap Areas";
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->description = "Swap selected areas screen positions";
|
|
|
|
ot->idname = "SCREEN_OT_area_swap";
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->invoke = area_swap_invoke;
|
|
|
|
ot->modal = area_swap_modal;
|
|
|
|
ot->poll = ED_operator_areaactive;
|
|
|
|
ot->cancel = area_swap_cancel;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2012-03-22 07:26:09 +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 */
|
2013-03-13 09:03:46 +00:00
|
|
|
static int area_dupli_invoke(bContext *C, wmOperator *op, const 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;
|
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
win = CTX_wm_window(C);
|
|
|
|
sc = CTX_wm_screen(C);
|
|
|
|
sa = CTX_wm_area(C);
|
2009-06-04 14:32:10 +00:00
|
|
|
|
|
|
|
/* XXX hrmf! */
|
2012-05-08 11:48:19 +00:00
|
|
|
if (event->type == EVT_ACTIONZONE_AREA) {
|
|
|
|
sActionzoneData *sad = event->customdata;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
if (sad == NULL)
|
2009-06-04 14:32:10 +00:00
|
|
|
return OPERATOR_PASS_THROUGH;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
sa = sad->sa1;
|
2009-06-04 14:32:10 +00:00
|
|
|
}
|
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
/* poll() checks area context, but we don't accept full-area windows */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sc->full != SCREENNORMAL) {
|
2012-05-08 11:48:19 +00:00
|
|
|
if (event->type == EVT_ACTIONZONE_AREA)
|
2010-10-14 12:24:08 +00:00
|
|
|
actionzone_exit(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 */
|
2012-05-08 11:48:19 +00:00
|
|
|
rect = sa->totrct;
|
2012-07-15 00:29:56 +00:00
|
|
|
BLI_rcti_translate(&rect, win->posx, win->posy);
|
2013-04-19 00:37:30 +00:00
|
|
|
rect.xmax = rect.xmin + BLI_rcti_size_x(&rect) / U.pixelsize;
|
|
|
|
rect.ymax = rect.ymin + BLI_rcti_size_y(&rect) / U.pixelsize;
|
2013-04-18 16:28:36 +00:00
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
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 */
|
2012-05-08 11:48:19 +00:00
|
|
|
newsc = ED_screen_add(newwin, CTX_data_scene(C), sc->id.name + 2);
|
|
|
|
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);
|
2010-07-25 01:39:47 +00:00
|
|
|
|
2010-01-16 22:56:52 +00:00
|
|
|
ED_area_tag_redraw((ScrArea *)newsc->areabase.first);
|
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
/* screen, areas init */
|
2012-05-08 11:48:19 +00:00
|
|
|
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
if (event->type == EVT_ACTIONZONE_AREA)
|
2010-10-14 12:24:08 +00:00
|
|
|
actionzone_exit(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
|
|
|
{
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Duplicate Area into New Window";
|
|
|
|
ot->description = "Duplicate selected area into new window";
|
|
|
|
ot->idname = "SCREEN_OT_area_dupli";
|
2008-11-19 16:28:11 +00:00
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->invoke = area_dupli_invoke;
|
|
|
|
ot->poll = ED_operator_areaactive;
|
2008-11-19 16:28:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ************** move area edge operator *********************************** */
|
|
|
|
|
|
|
|
/* operator state vars used:
|
2012-05-08 11:48:19 +00:00
|
|
|
* x, y mouse coord near edge
|
2012-03-03 16:31:46 +00:00
|
|
|
* 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
|
2009-12-10 09:25:30 +00:00
|
|
|
*/
|
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;
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
int areaminy = ED_area_headersize() + U.pixelsize; // pixelsize is used as area divider
|
2008-11-19 16:28:11 +00:00
|
|
|
|
|
|
|
/* we check all areas and test for free space with MINSIZE */
|
2012-05-08 11:48:19 +00:00
|
|
|
*bigger = *smaller = 100000;
|
2008-11-19 16:28:11 +00:00
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
for (sa = sc->areabase.first; sa; sa = sa->next) {
|
|
|
|
if (dir == 'h') {
|
|
|
|
int y1 = sa->v2->vec.y - sa->v1->vec.y - areaminy;
|
2008-11-19 16:28:11 +00:00
|
|
|
|
|
|
|
/* if top or down edge selected, test height */
|
2012-12-15 09:45:34 +00:00
|
|
|
if (sa->v1->editflag && sa->v4->editflag)
|
2012-10-24 05:06:40 +00:00
|
|
|
*bigger = min_ii(*bigger, y1);
|
2012-12-15 09:45:34 +00:00
|
|
|
else if (sa->v2->editflag && sa->v3->editflag)
|
2012-10-24 05:06:40 +00:00
|
|
|
*smaller = min_ii(*smaller, y1);
|
2008-11-19 16:28:11 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-05-08 11:48:19 +00:00
|
|
|
int x1 = sa->v4->vec.x - sa->v1->vec.x - AREAMINX;
|
2008-11-19 16:28:11 +00:00
|
|
|
|
|
|
|
/* if left or right edge selected, test width */
|
2012-12-15 09:45:34 +00:00
|
|
|
if (sa->v1->editflag && sa->v2->editflag)
|
2012-10-24 05:06:40 +00:00
|
|
|
*bigger = min_ii(*bigger, x1);
|
2012-12-15 09:45:34 +00:00
|
|
|
else if (sa->v3->editflag && sa->v4->editflag)
|
2012-10-24 05:06:40 +00:00
|
|
|
*smaller = min_ii(*smaller, x1);
|
2008-11-19 16:28:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* validate selection inside screen, set variables OK */
|
|
|
|
/* return 0: init failed */
|
2012-05-08 11:48:19 +00:00
|
|
|
static int area_move_init(bContext *C, wmOperator *op)
|
2008-11-19 16:28:11 +00:00
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
bScreen *sc = CTX_wm_screen(C);
|
2008-11-19 16:28:11 +00:00
|
|
|
ScrEdge *actedge;
|
|
|
|
sAreaMoveData *md;
|
2012-12-15 10:53:35 +00:00
|
|
|
ScrVert *v1;
|
2008-11-19 16:28:11 +00:00
|
|
|
int x, y;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
/* required properties */
|
2012-05-08 11:48:19 +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 */
|
2012-05-08 11:48:19 +00:00
|
|
|
actedge = screen_find_active_scredge(sc, x, y);
|
|
|
|
if (actedge == NULL) return 0;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
md = MEM_callocN(sizeof(sAreaMoveData), "sAreaMoveData");
|
|
|
|
op->customdata = md;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2012-05-08 11:48:19 +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-11-19 16:28:11 +00:00
|
|
|
|
2008-12-18 02:56:48 +00:00
|
|
|
select_connected_scredge(sc, actedge);
|
2012-12-15 10:53:35 +00:00
|
|
|
/* now all vertices with 'flag==1' are the ones that can be moved. Move this to editflag */
|
2012-12-15 16:22:18 +00:00
|
|
|
for (v1 = sc->vertbase.first; v1; v1 = v1->next)
|
|
|
|
v1->editflag = v1->flag;
|
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)
|
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
wmWindow *win = CTX_wm_window(C);
|
|
|
|
bScreen *sc = CTX_wm_screen(C);
|
2008-11-19 16:28:11 +00:00
|
|
|
ScrVert *v1;
|
2010-07-25 01:39:47 +00:00
|
|
|
ScrArea *sa;
|
2012-05-08 11:48:19 +00:00
|
|
|
int areaminy = ED_area_headersize() + 1;
|
2008-11-19 16:28:11 +00:00
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
delta = CLAMPIS(delta, -smaller, bigger);
|
2008-11-19 16:28:11 +00:00
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
for (v1 = sc->vertbase.first; v1; v1 = v1->next) {
|
2012-12-15 09:45:34 +00:00
|
|
|
if (v1->editflag) {
|
2008-11-19 16:28:11 +00:00
|
|
|
/* that way a nice AREAGRID */
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
if ((dir == 'v') && v1->vec.x > 0 && v1->vec.x < WM_window_pixels_x(win) - 1) {
|
2012-05-08 11:48:19 +00:00
|
|
|
v1->vec.x = origval + delta;
|
|
|
|
if (delta != bigger && delta != -smaller) v1->vec.x -= (v1->vec.x % AREAGRID);
|
2008-11-19 16:28:11 +00:00
|
|
|
}
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
if ((dir == 'h') && v1->vec.y > 0 && v1->vec.y < WM_window_pixels_y(win) - 1) {
|
2012-05-08 11:48:19 +00:00
|
|
|
v1->vec.y = origval + delta;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
v1->vec.y += AREAGRID - 1;
|
|
|
|
v1->vec.y -= (v1->vec.y % AREAGRID);
|
2008-11-19 16:28:11 +00:00
|
|
|
|
|
|
|
/* prevent too small top header */
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
if (v1->vec.y > WM_window_pixels_y(win) - areaminy)
|
|
|
|
v1->vec.y = WM_window_pixels_y(win) - areaminy;
|
2008-11-19 16:28:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-07-25 01:39:47 +00:00
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
for (sa = sc->areabase.first; sa; sa = sa->next) {
|
2012-12-15 09:45:34 +00:00
|
|
|
if (sa->v1->editflag || sa->v2->editflag || sa->v3->editflag || sa->v4->editflag)
|
2010-07-25 01:39:47 +00:00
|
|
|
ED_area_tag_redraw(sa);
|
2010-01-16 22:56:52 +00:00
|
|
|
}
|
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); /* redraw everything */
|
2008-11-19 16:28:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void area_move_apply(bContext *C, wmOperator *op)
|
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
sAreaMoveData *md = op->customdata;
|
2008-11-19 16:28:11 +00:00
|
|
|
int delta;
|
|
|
|
|
2012-05-08 11:48:19 +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)
|
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (op->customdata)
|
2008-11-19 16:28:11 +00:00
|
|
|
MEM_freeN(op->customdata);
|
2012-05-08 11:48:19 +00:00
|
|
|
op->customdata = NULL;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
static int area_move_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!area_move_init(C, op))
|
2008-11-19 16:28:11 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
|
|
area_move_apply(C, op);
|
|
|
|
area_move_exit(C, op);
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* interaction callback */
|
2013-03-13 09:03:46 +00:00
|
|
|
static int area_move_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
2008-11-19 16:28:11 +00:00
|
|
|
{
|
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
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!area_move_init(C, op))
|
2008-11-19 16:28:11 +00:00
|
|
|
return OPERATOR_PASS_THROUGH;
|
|
|
|
|
|
|
|
/* add temp handler */
|
2009-10-22 23:22:05 +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 */
|
2013-03-13 09:03:46 +00:00
|
|
|
static int area_move_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
2008-11-19 16:28:11 +00:00
|
|
|
{
|
2012-05-08 11:48:19 +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 */
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (event->type) {
|
2008-11-19 16:28:11 +00:00
|
|
|
case MOUSEMOVE:
|
2013-07-21 08:16:37 +00:00
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
x = RNA_int_get(op->ptr, "x");
|
|
|
|
y = RNA_int_get(op->ptr, "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
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
delta = (md->dir == 'v') ? event->x - x : event->y - y;
|
|
|
|
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;
|
2013-07-21 08:16:37 +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 EVT_MODAL_MAP:
|
2013-07-21 08:16:37 +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:
|
2012-05-08 11:48:19 +00:00
|
|
|
md->step = 10;
|
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
|
|
|
break;
|
|
|
|
case KM_MODAL_STEP10_OFF:
|
2012-05-08 11:48:19 +00:00
|
|
|
md->step = 0;
|
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
|
|
|
break;
|
|
|
|
}
|
2013-07-21 08:16:37 +00:00
|
|
|
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 */
|
2013-01-27 07:23:58 +00:00
|
|
|
ot->name = "Move Area Edges";
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->description = "Move selected area edges";
|
|
|
|
ot->idname = "SCREEN_OT_area_move";
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2012-03-22 07:26:09 +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
|
|
|
|
2012-03-22 07:26:09 +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 *********************************** */
|
|
|
|
|
|
|
|
/*
|
2012-03-03 16:31:46 +00:00
|
|
|
* operator state vars:
|
|
|
|
* fac spit point
|
|
|
|
* dir direction 'v' or 'h'
|
|
|
|
*
|
|
|
|
* operator customdata:
|
2012-05-08 11:48:19 +00:00
|
|
|
* area pointer to (active) area
|
2012-03-03 16:31:46 +00:00
|
|
|
* 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
|
2009-12-10 09:25:30 +00:00
|
|
|
*/
|
2008-11-19 16:28:11 +00:00
|
|
|
|
2011-03-02 14:09:54 +00:00
|
|
|
typedef struct sAreaSplitData {
|
2012-05-08 11:48:19 +00:00
|
|
|
int x, y; /* last used mouse position */
|
2011-03-02 14:09:54 +00:00
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
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 */
|
|
|
|
int previewmode; /* draw previewline, then split */
|
|
|
|
|
|
|
|
ScrEdge *nedge; /* new edge */
|
|
|
|
ScrArea *sarea; /* start area */
|
|
|
|
ScrArea *narea; /* new area */
|
2011-03-02 14:09:54 +00:00
|
|
|
|
|
|
|
} sAreaSplitData;
|
|
|
|
|
|
|
|
/* generic init, menu case, doesn't need active area */
|
|
|
|
static int area_split_menu_init(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
sAreaSplitData *sd;
|
|
|
|
|
|
|
|
/* custom data */
|
2012-06-17 09:58:26 +00:00
|
|
|
sd = (sAreaSplitData *)MEM_callocN(sizeof(sAreaSplitData), "op_area_split");
|
2012-05-08 11:48:19 +00:00
|
|
|
op->customdata = sd;
|
2011-03-02 14:09:54 +00:00
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
sd->sarea = CTX_wm_area(C);
|
2011-03-02 14:09:54 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sd->sarea) {
|
2012-05-08 11:48:19 +00:00
|
|
|
int dir = RNA_enum_get(op->ptr, "direction");
|
2008-11-19 16:28:11 +00:00
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
if (dir == 'h')
|
2011-03-02 14:09:54 +00:00
|
|
|
sd->sarea->flag |= AREA_FLAG_DRAWSPLIT_H;
|
|
|
|
else
|
|
|
|
sd->sarea->flag |= AREA_FLAG_DRAWSPLIT_V;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* generic init, no UI stuff here, assumes active area */
|
2008-11-19 16:28:11 +00:00
|
|
|
static int area_split_init(bContext *C, wmOperator *op)
|
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
ScrArea *sa = CTX_wm_area(C);
|
2008-11-19 16:28:11 +00:00
|
|
|
sAreaSplitData *sd;
|
2012-05-08 11:48:19 +00:00
|
|
|
int areaminy = ED_area_headersize() + 1;
|
2008-11-19 16:28:11 +00:00
|
|
|
int dir;
|
|
|
|
|
|
|
|
/* required context */
|
2012-05-08 11:48:19 +00:00
|
|
|
if (sa == NULL) return 0;
|
2008-11-19 16:28:11 +00:00
|
|
|
|
|
|
|
/* required properties */
|
2012-05-08 11:48:19 +00:00
|
|
|
dir = RNA_enum_get(op->ptr, "direction");
|
2008-11-19 16:28:11 +00:00
|
|
|
|
|
|
|
/* minimal size */
|
2012-05-08 11:48:19 +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 */
|
2012-06-17 09:58:26 +00:00
|
|
|
sd = (sAreaSplitData *)MEM_callocN(sizeof(sAreaSplitData), "op_area_split");
|
2012-05-08 11:48:19 +00:00
|
|
|
op->customdata = sd;
|
2008-11-19 16:28:11 +00:00
|
|
|
|
2012-05-08 11:48:19 +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)
|
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
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;
|
2008-11-19 16:28:11 +00:00
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
if (sav1 == sbv4 && sav2 == sbv3) { /* sa to right of sb = W */
|
2008-11-19 16:28:11 +00:00
|
|
|
return screen_findedge(screen, sav1, sav2);
|
|
|
|
}
|
2012-05-08 11:48:19 +00:00
|
|
|
else if (sav2 == sbv1 && sav3 == sbv4) { /* sa to bottom of sb = N */
|
2008-11-19 16:28:11 +00:00
|
|
|
return screen_findedge(screen, sav2, sav3);
|
|
|
|
}
|
2012-05-08 11:48:19 +00:00
|
|
|
else if (sav3 == sbv2 && sav4 == sbv1) { /* sa to left of sb = E */
|
2008-11-19 16:28:11 +00:00
|
|
|
return screen_findedge(screen, sav3, sav4);
|
|
|
|
}
|
2012-05-08 11:48:19 +00:00
|
|
|
else if (sav1 == sbv2 && sav4 == sbv3) { /* sa on top of sb = S*/
|
2008-11-19 16:28:11 +00:00
|
|
|
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
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
bScreen *sc = CTX_wm_screen(C);
|
|
|
|
sAreaSplitData *sd = (sAreaSplitData *)op->customdata;
|
2008-11-19 16:28:11 +00:00
|
|
|
float fac;
|
|
|
|
int dir;
|
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
fac = RNA_float_get(op->ptr, "factor");
|
|
|
|
dir = RNA_enum_get(op->ptr, "direction");
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
sd->narea = area_split(sc, sd->sarea, dir, fac, 0); /* 0 = no merge */
|
2008-11-19 16:28:11 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sd->narea) {
|
2008-11-19 16:28:11 +00:00
|
|
|
ScrVert *sv;
|
|
|
|
|
2012-05-08 11:48:19 +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 */
|
2012-05-08 11:48:19 +00:00
|
|
|
for (sv = sc->vertbase.first; sv; sv = sv->next)
|
2012-12-15 09:45:34 +00:00
|
|
|
sv->editflag = 0;
|
2008-11-19 16:28:11 +00:00
|
|
|
|
2012-12-15 09:45:34 +00:00
|
|
|
sd->nedge->v1->editflag = 1;
|
|
|
|
sd->nedge->v2->editflag = 1;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
if (dir == 'h') sd->origval = sd->nedge->v1->vec.y;
|
|
|
|
else sd->origval = sd->nedge->v1->vec.x;
|
2010-01-16 22:56:52 +00:00
|
|
|
|
|
|
|
ED_area_tag_redraw(sd->sarea);
|
|
|
|
ED_area_tag_redraw(sd->narea);
|
2010-07-25 01:39:47 +00:00
|
|
|
|
2012-05-08 11:48:19 +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;
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
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) {
|
2012-05-08 11:48:19 +00:00
|
|
|
sAreaSplitData *sd = (sAreaSplitData *)op->customdata;
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sd->sarea) ED_area_tag_redraw(sd->sarea);
|
|
|
|
if (sd->narea) ED_area_tag_redraw(sd->narea);
|
2010-01-16 22:56:52 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sd->sarea)
|
2012-05-08 11:48:19 +00:00
|
|
|
sd->sarea->flag &= ~(AREA_FLAG_DRAWSPLIT_H | AREA_FLAG_DRAWSPLIT_V);
|
2011-03-02 14:09:54 +00:00
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
MEM_freeN(op->customdata);
|
|
|
|
op->customdata = NULL;
|
|
|
|
}
|
|
|
|
|
2011-12-20 00:46:55 +00:00
|
|
|
WM_cursor_restore(CTX_wm_window(C));
|
2012-05-08 11:48:19 +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 */
|
2013-03-13 09:03:46 +00:00
|
|
|
static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
2008-11-19 16:28:11 +00:00
|
|
|
{
|
|
|
|
sAreaSplitData *sd;
|
2011-03-02 14:09:54 +00:00
|
|
|
int dir;
|
2008-11-19 16:28:11 +00:00
|
|
|
|
2011-03-23 16:36:41 +00:00
|
|
|
/* no full window splitting allowed */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (CTX_wm_screen(C)->full != SCREENNORMAL)
|
2011-03-23 16:36:41 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
2008-11-19 16:28:11 +00:00
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
if (event->type == EVT_ACTIONZONE_AREA) {
|
|
|
|
sActionzoneData *sad = event->customdata;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2012-09-14 06:17:14 +00:00
|
|
|
if (sad == NULL || sad->modifier > 0) {
|
2009-03-05 23:19:44 +00:00
|
|
|
return OPERATOR_PASS_THROUGH;
|
|
|
|
}
|
2008-11-19 16:28:11 +00:00
|
|
|
|
|
|
|
/* verify *sad itself */
|
2012-09-14 06:17:14 +00:00
|
|
|
if (sad->sa1 == NULL || sad->az == NULL)
|
2008-11-19 16:28:11 +00:00
|
|
|
return OPERATOR_PASS_THROUGH;
|
|
|
|
|
|
|
|
/* is this our *sad? if areas not equal it should be passed on */
|
2012-05-08 11:48:19 +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 */
|
2012-05-08 11:48:19 +00:00
|
|
|
if (sad->gesture_dir == 'n' || sad->gesture_dir == 's') {
|
|
|
|
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 {
|
2012-05-08 11:48:19 +00:00
|
|
|
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 */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!area_split_init(C, op))
|
2008-11-19 16:28:11 +00:00
|
|
|
return OPERATOR_PASS_THROUGH;
|
|
|
|
|
2011-03-02 14:09:54 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
ScrEdge *actedge;
|
|
|
|
int x, y;
|
2008-11-19 16:28:11 +00:00
|
|
|
|
2011-03-02 14:09:54 +00:00
|
|
|
/* retrieve initial mouse coord, so we can find the active edge */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (RNA_struct_property_is_set(op->ptr, "mouse_x"))
|
2012-05-08 11:48:19 +00:00
|
|
|
x = RNA_int_get(op->ptr, "mouse_x");
|
2011-03-02 14:09:54 +00:00
|
|
|
else
|
2012-05-08 11:48:19 +00:00
|
|
|
x = event->x;
|
2011-03-02 14:09:54 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (RNA_struct_property_is_set(op->ptr, "mouse_y"))
|
2012-05-08 11:48:19 +00:00
|
|
|
y = RNA_int_get(op->ptr, "mouse_y");
|
2011-03-02 14:09:54 +00:00
|
|
|
else
|
2012-05-08 11:48:19 +00:00
|
|
|
y = event->x;
|
2011-03-02 14:09:54 +00:00
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
actedge = screen_find_active_scredge(CTX_wm_screen(C), x, y);
|
|
|
|
if (actedge == NULL)
|
2011-03-02 14:09:54 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
2008-11-19 16:28:11 +00:00
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
dir = scredge_is_horizontal(actedge) ? 'v' : 'h';
|
2011-03-02 14:09:54 +00:00
|
|
|
|
|
|
|
RNA_enum_set(op->ptr, "direction", dir);
|
|
|
|
|
|
|
|
/* special case, adds customdata, sets defaults */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!area_split_menu_init(C, op))
|
2011-03-02 14:09:54 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
sd = (sAreaSplitData *)op->customdata;
|
2011-03-02 14:09:54 +00:00
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
sd->x = event->x;
|
|
|
|
sd->y = event->y;
|
2011-03-02 14:09:54 +00:00
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
if (event->type == EVT_ACTIONZONE_AREA) {
|
2008-11-19 16:28:11 +00:00
|
|
|
|
|
|
|
/* do the split */
|
2012-03-24 06:38:07 +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-10-22 23:22:05 +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 {
|
2012-05-08 11:48:19 +00:00
|
|
|
sd->previewmode = 1;
|
2011-03-02 14:09:54 +00:00
|
|
|
/* add temp handler for edge move or cancel */
|
|
|
|
WM_event_add_modal_handler(C, op);
|
|
|
|
|
|
|
|
return OPERATOR_RUNNING_MODAL;
|
|
|
|
|
2008-11-24 10:45:36 +00:00
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!area_split_init(C, op))
|
2008-11-19 16:28:11 +00:00
|
|
|
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)
|
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
sAreaSplitData *sd = (sAreaSplitData *)op->customdata;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sd->previewmode) {
|
2011-03-02 14:09:54 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
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);
|
|
|
|
CTX_wm_region_set(C, NULL);
|
|
|
|
}
|
|
|
|
sd->narea = NULL;
|
2008-11-19 16:28:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
area_split_exit(C, op);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
|
|
|
|
2013-03-13 09:03:46 +00:00
|
|
|
static int area_split_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
2008-11-19 16:28:11 +00:00
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
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 */
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (event->type) {
|
2008-11-19 16:28:11 +00:00
|
|
|
case MOUSEMOVE:
|
2012-05-08 11:48:19 +00:00
|
|
|
dir = RNA_enum_get(op->ptr, "direction");
|
2008-11-19 16:28:11 +00:00
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
sd->delta = (dir == 'v') ? event->x - sd->origval : event->y - sd->origval;
|
|
|
|
if (sd->previewmode == 0)
|
2011-03-02 14:09:54 +00:00
|
|
|
area_move_apply_do(C, sd->origval, sd->delta, dir, sd->bigger, sd->smaller);
|
|
|
|
else {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sd->sarea) {
|
2012-05-08 11:48:19 +00:00
|
|
|
sd->sarea->flag &= ~(AREA_FLAG_DRAWSPLIT_H | AREA_FLAG_DRAWSPLIT_V);
|
2011-03-02 14:09:54 +00:00
|
|
|
ED_area_tag_redraw(sd->sarea);
|
|
|
|
}
|
2012-05-08 11:48:19 +00:00
|
|
|
sd->sarea = screen_areahascursor(CTX_wm_screen(C), event->x, event->y); /* area context not set */
|
2011-03-02 14:09:54 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sd->sarea) {
|
2011-03-02 14:09:54 +00:00
|
|
|
ED_area_tag_redraw(sd->sarea);
|
2012-05-08 11:48:19 +00:00
|
|
|
if (dir == 'v') {
|
|
|
|
sd->origsize = sd->sarea->winx;
|
|
|
|
sd->origmin = sd->sarea->totrct.xmin;
|
2011-03-02 14:09:54 +00:00
|
|
|
sd->sarea->flag |= AREA_FLAG_DRAWSPLIT_V;
|
|
|
|
}
|
|
|
|
else {
|
2012-05-08 11:48:19 +00:00
|
|
|
sd->origsize = sd->sarea->winy;
|
|
|
|
sd->origmin = sd->sarea->totrct.ymin;
|
2011-03-02 14:09:54 +00:00
|
|
|
sd->sarea->flag |= AREA_FLAG_DRAWSPLIT_H;
|
|
|
|
}
|
2011-03-10 11:47:36 +00:00
|
|
|
}
|
|
|
|
|
2012-05-19 13:28:19 +00:00
|
|
|
CTX_wm_window(C)->screen->do_draw = TRUE;
|
2011-03-10 11:47:36 +00:00
|
|
|
|
2011-03-02 14:09:54 +00:00
|
|
|
}
|
2008-11-19 16:28:11 +00:00
|
|
|
|
2012-05-08 11:48:19 +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);
|
2011-03-02 14:09:54 +00:00
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LEFTMOUSE:
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sd->previewmode) {
|
2011-03-02 14:09:54 +00:00
|
|
|
area_split_apply(C, op);
|
2008-11-19 16:28:11 +00:00
|
|
|
area_split_exit(C, op);
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
2011-03-02 14:09:54 +00:00
|
|
|
else {
|
2012-05-08 11:48:19 +00:00
|
|
|
if (event->val == KM_RELEASE) { /* mouse up */
|
2011-03-02 14:09:54 +00:00
|
|
|
area_split_exit(C, op);
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
}
|
2008-11-19 16:28:11 +00:00
|
|
|
break;
|
2011-12-20 00:46:55 +00:00
|
|
|
|
|
|
|
case MIDDLEMOUSE:
|
|
|
|
case TABKEY:
|
2012-05-08 11:48:19 +00:00
|
|
|
if (sd->previewmode == 0) {
|
2011-12-20 00:46:55 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else {
|
2011-12-20 00:46:55 +00:00
|
|
|
dir = RNA_enum_get(op->ptr, "direction");
|
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
if (event->val == KM_PRESS) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sd->sarea) {
|
2012-05-08 11:48:19 +00:00
|
|
|
sd->sarea->flag &= ~(AREA_FLAG_DRAWSPLIT_H | AREA_FLAG_DRAWSPLIT_V);
|
2011-12-20 00:46:55 +00:00
|
|
|
ED_area_tag_redraw(sd->sarea);
|
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
if (dir == 'v') {
|
2011-12-20 00:46:55 +00:00
|
|
|
RNA_enum_set(op->ptr, "direction", 'h');
|
|
|
|
sd->sarea->flag |= AREA_FLAG_DRAWSPLIT_H;
|
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
WM_cursor_set(CTX_wm_window(C), CURSOR_X_MOVE);
|
2011-12-20 00:46:55 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else {
|
2011-12-20 00:46:55 +00:00
|
|
|
RNA_enum_set(op->ptr, "direction", 'v');
|
|
|
|
sd->sarea->flag |= AREA_FLAG_DRAWSPLIT_V;
|
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
WM_cursor_set(CTX_wm_window(C), CURSOR_Y_MOVE);
|
2011-12-20 00:46:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
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[] = {
|
2012-05-08 11:48:19 +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
|
|
|
{
|
2012-05-19 09:46:41 +00:00
|
|
|
ot->name = "Split Area";
|
2012-03-22 07:26:09 +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
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = area_split_exec;
|
|
|
|
ot->invoke = area_split_invoke;
|
|
|
|
ot->modal = area_split_modal;
|
|
|
|
ot->cancel = area_split_cancel;
|
2008-11-19 16:28:11 +00:00
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->poll = screen_active_editable;
|
|
|
|
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);
|
2011-03-02 14:09:54 +00:00
|
|
|
RNA_def_int(ot->srna, "mouse_x", -100, INT_MIN, INT_MAX, "Mouse X", "", INT_MIN, INT_MAX);
|
|
|
|
RNA_def_int(ot->srna, "mouse_y", -100, INT_MIN, INT_MAX, "Mouse Y", "", INT_MIN, INT_MAX);
|
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-16 17:43:09 +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-16 17:43:09 +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;
|
2010-09-20 13:13:40 +00:00
|
|
|
AZEdge edge;
|
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
|
|
|
|
|
|
|
} RegionMoveData;
|
|
|
|
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2010-09-20 13:13:40 +00:00
|
|
|
static int area_max_regionsize(ScrArea *sa, ARegion *scalear, AZEdge edge)
|
2009-12-10 09:25:30 +00:00
|
|
|
{
|
|
|
|
ARegion *ar;
|
|
|
|
int dist;
|
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
if (edge == AE_RIGHT_TO_TOPLEFT || edge == AE_LEFT_TO_TOPRIGHT) {
|
2012-09-15 11:48:20 +00:00
|
|
|
dist = BLI_rcti_size_x(&sa->totrct);
|
2012-03-24 06:38:07 +00:00
|
|
|
}
|
2012-05-08 11:48:19 +00:00
|
|
|
else { /* AE_BOTTOM_TO_TOPLEFT, AE_TOP_TO_BOTTOMRIGHT */
|
2012-09-15 11:48:20 +00:00
|
|
|
dist = BLI_rcti_size_y(&sa->totrct);
|
2009-12-10 09:25:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* subtractwidth of regions on opposite side
|
|
|
|
* prevents dragging regions into other opposite regions */
|
2012-05-08 11:48:19 +00:00
|
|
|
for (ar = sa->regionbase.first; ar; ar = ar->next) {
|
2010-06-07 06:50:56 +00:00
|
|
|
if (ar == scalear)
|
|
|
|
continue;
|
|
|
|
|
2009-12-10 09:25:30 +00:00
|
|
|
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;
|
2010-06-07 06:50:56 +00:00
|
|
|
|
|
|
|
/* case of regions in regions, like operator properties panel */
|
|
|
|
/* these can sit on top of other regions such as headers, so account for this */
|
2012-05-27 11:10:27 +00:00
|
|
|
else if (edge == AE_BOTTOM_TO_TOPLEFT && scalear->alignment & RGN_ALIGN_TOP &&
|
|
|
|
ar->alignment == RGN_ALIGN_TOP && ar->regiontype == RGN_TYPE_HEADER)
|
|
|
|
{
|
2010-06-07 06:50:56 +00:00
|
|
|
dist -= ar->winy;
|
2012-05-27 11:10:27 +00:00
|
|
|
}
|
|
|
|
else if (edge == AE_TOP_TO_BOTTOMRIGHT && scalear->alignment & RGN_ALIGN_BOTTOM &&
|
|
|
|
ar->alignment == RGN_ALIGN_BOTTOM && ar->regiontype == RGN_TYPE_HEADER)
|
|
|
|
{
|
2010-06-07 06:50:56 +00:00
|
|
|
dist -= ar->winy;
|
2012-05-27 11:10:27 +00:00
|
|
|
}
|
2009-12-10 09:25:30 +00:00
|
|
|
}
|
2010-06-07 06:50:56 +00:00
|
|
|
|
2009-12-10 09:25:30 +00:00
|
|
|
return dist;
|
|
|
|
}
|
|
|
|
|
2013-03-13 09:03:46 +00:00
|
|
|
static int region_scale_invoke(bContext *C, wmOperator *op, const wmEvent *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
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
sActionzoneData *sad = event->customdata;
|
2009-12-10 03:07:04 +00:00
|
|
|
AZone *az;
|
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
if (event->type != EVT_ACTIONZONE_REGION) {
|
2012-10-21 05:46:41 +00:00
|
|
|
BKE_report(op->reports, RPT_ERROR, "Can only scale region size from an action zone");
|
2009-12-10 03:07:04 +00:00
|
|
|
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
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (az->ar) {
|
2012-05-08 11:48:19 +00:00
|
|
|
RegionMoveData *rmd = MEM_callocN(sizeof(RegionMoveData), "RegionMoveData");
|
2010-01-29 01:57:15 +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
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
op->customdata = rmd;
|
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-16 17:43:09 +00:00
|
|
|
rmd->az = az;
|
2012-05-08 11:48:19 +00:00
|
|
|
rmd->ar = az->ar;
|
2009-09-16 17:43:09 +00:00
|
|
|
rmd->sa = sad->sa1;
|
2012-05-08 11:48:19 +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);
|
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 18:18:21 +00:00
|
|
|
|
|
|
|
/* if not set we do now, otherwise it uses type */
|
2012-05-08 11:48:19 +00:00
|
|
|
if (rmd->ar->sizex == 0)
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
rmd->ar->sizex = rmd->ar->winx;
|
2012-05-08 11:48:19 +00:00
|
|
|
if (rmd->ar->sizey == 0)
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
rmd->ar->sizey = rmd->ar->winy;
|
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 18:18:21 +00:00
|
|
|
|
|
|
|
/* now copy to regionmovedata */
|
2012-05-08 11:48:19 +00:00
|
|
|
if (rmd->edge == AE_LEFT_TO_TOPRIGHT || rmd->edge == AE_RIGHT_TO_TOPLEFT) {
|
|
|
|
rmd->origval = rmd->ar->sizex;
|
2012-03-24 06:38:07 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-05-08 11:48:19 +00:00
|
|
|
rmd->origval = rmd->ar->sizey;
|
2009-12-10 09:25:30 +00:00
|
|
|
}
|
2010-01-29 01:57:15 +00:00
|
|
|
|
|
|
|
/* limit headers to standard height for now */
|
|
|
|
if (rmd->ar->regiontype == RGN_TYPE_HEADER)
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
maxsize = ED_area_headersize();
|
2010-01-29 01:57:15 +00:00
|
|
|
else
|
|
|
|
maxsize = 1000;
|
|
|
|
|
|
|
|
CLAMP(rmd->maxsize, 0, 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
|
|
|
|
|
|
|
/* add temp handler */
|
2009-10-22 23:22:05 +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;
|
|
|
|
}
|
|
|
|
|
2011-12-23 12:56:48 +00:00
|
|
|
static int region_scale_get_maxsize(RegionMoveData *rmd)
|
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
int maxsize = 0;
|
2011-12-23 12:56:48 +00:00
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
if (rmd->edge == AE_LEFT_TO_TOPRIGHT || rmd->edge == AE_RIGHT_TO_TOPLEFT) {
|
2012-12-19 15:44:47 +00:00
|
|
|
return (int) ( (rmd->sa->winx / UI_DPI_FAC) - UI_UNIT_X);
|
2011-12-23 12:56:48 +00:00
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (rmd->ar->regiontype == RGN_TYPE_TOOL_PROPS) {
|
2011-12-23 12:56:48 +00:00
|
|
|
/* this calculation seems overly verbose
|
|
|
|
* can someone explain why this method is necessary? - campbell */
|
2012-05-08 11:48:19 +00:00
|
|
|
maxsize = rmd->maxsize - ((rmd->sa->headertype == HEADERTOP) ? UI_UNIT_Y * 2 : UI_UNIT_Y) - (UI_UNIT_Y / 4);
|
2011-12-23 12:56:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return maxsize;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void region_scale_validate_size(RegionMoveData *rmd)
|
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
if ((rmd->ar->flag & RGN_FLAG_HIDDEN) == 0) {
|
|
|
|
short *size, maxsize = -1;
|
2011-12-23 12:56:48 +00:00
|
|
|
|
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
if (rmd->edge == AE_LEFT_TO_TOPRIGHT || rmd->edge == AE_RIGHT_TO_TOPLEFT)
|
|
|
|
size = &rmd->ar->sizex;
|
2011-12-23 12:56:48 +00:00
|
|
|
else
|
2012-05-08 11:48:19 +00:00
|
|
|
size = &rmd->ar->sizey;
|
2011-12-23 12:56:48 +00:00
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
maxsize = region_scale_get_maxsize(rmd);
|
2011-12-23 12:56:48 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (*size > maxsize && maxsize > 0)
|
2012-05-08 11:48:19 +00:00
|
|
|
*size = maxsize;
|
2011-12-23 12:56:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void region_scale_toggle_hidden(bContext *C, RegionMoveData *rmd)
|
|
|
|
{
|
2012-12-13 12:17:57 +00:00
|
|
|
region_toggle_hidden(C, rmd->ar, 0);
|
2011-12-23 12:56:48 +00:00
|
|
|
region_scale_validate_size(rmd);
|
|
|
|
}
|
|
|
|
|
2013-03-13 09:03:46 +00:00
|
|
|
static int region_scale_modal(bContext *C, wmOperator *op, const wmEvent *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
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
RegionMoveData *rmd = 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
|
|
|
int delta;
|
|
|
|
|
|
|
|
/* execute the events */
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (event->type) {
|
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 MOUSEMOVE:
|
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
if (rmd->edge == AE_LEFT_TO_TOPRIGHT || rmd->edge == AE_RIGHT_TO_TOPLEFT) {
|
|
|
|
delta = event->x - rmd->origx;
|
|
|
|
if (rmd->edge == AE_LEFT_TO_TOPRIGHT) delta = -delta;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2012-12-19 15:44:47 +00:00
|
|
|
/* region sizes now get multiplied */
|
|
|
|
delta /= UI_DPI_FAC;
|
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
rmd->ar->sizex = rmd->origval + delta;
|
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 18:18:21 +00:00
|
|
|
CLAMP(rmd->ar->sizex, 0, rmd->maxsize);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (rmd->ar->sizex < UI_UNIT_X) {
|
2012-05-08 11:48:19 +00:00
|
|
|
rmd->ar->sizex = rmd->origval;
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!(rmd->ar->flag & RGN_FLAG_HIDDEN))
|
2011-12-23 12:56:48 +00:00
|
|
|
region_scale_toggle_hidden(C, rmd);
|
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
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (rmd->ar->flag & RGN_FLAG_HIDDEN)
|
2011-12-23 12:56:48 +00:00
|
|
|
region_scale_toggle_hidden(C, rmd);
|
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 {
|
2012-05-08 11:48:19 +00:00
|
|
|
int maxsize = region_scale_get_maxsize(rmd);
|
|
|
|
delta = event->y - rmd->origy;
|
|
|
|
if (rmd->edge == AE_BOTTOM_TO_TOPLEFT) delta = -delta;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2012-12-19 15:44:47 +00:00
|
|
|
/* region sizes now get multiplied */
|
|
|
|
delta /= UI_DPI_FAC;
|
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
rmd->ar->sizey = rmd->origval + delta;
|
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 18:18:21 +00:00
|
|
|
CLAMP(rmd->ar->sizey, 0, rmd->maxsize);
|
2010-09-17 23:50:10 +00:00
|
|
|
|
2011-06-05 09:00:36 +00:00
|
|
|
/* note, 'UI_UNIT_Y/4' means you need to drag the header almost
|
|
|
|
* all the way down for it to become hidden, this is done
|
|
|
|
* otherwise its too easy to do this by accident */
|
2012-05-08 11:48:19 +00:00
|
|
|
if (rmd->ar->sizey < UI_UNIT_Y / 4) {
|
|
|
|
rmd->ar->sizey = rmd->origval;
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!(rmd->ar->flag & RGN_FLAG_HIDDEN))
|
2011-12-23 12:56:48 +00:00
|
|
|
region_scale_toggle_hidden(C, rmd);
|
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
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (maxsize > 0 && (rmd->ar->sizey > maxsize))
|
2012-05-08 11:48:19 +00:00
|
|
|
rmd->ar->sizey = maxsize;
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (rmd->ar->flag & RGN_FLAG_HIDDEN)
|
2011-12-23 12:56:48 +00:00
|
|
|
region_scale_toggle_hidden(C, rmd);
|
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
|
|
|
}
|
2010-01-16 22:56:52 +00:00
|
|
|
ED_area_tag_redraw(rmd->sa);
|
2012-05-08 11:48:19 +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:
|
2012-05-08 11:48:19 +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
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ABS(event->x - rmd->origx) < 2 && ABS(event->y - rmd->origy) < 2) {
|
|
|
|
if (rmd->ar->flag & RGN_FLAG_HIDDEN) {
|
2011-12-23 12:56:48 +00:00
|
|
|
region_scale_toggle_hidden(C, rmd);
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (rmd->ar->flag & RGN_FLAG_TOO_SMALL) {
|
2011-12-23 12:56:48 +00:00
|
|
|
region_scale_validate_size(rmd);
|
2009-10-22 23:22:05 +00:00
|
|
|
}
|
2011-12-23 12:56:48 +00:00
|
|
|
|
|
|
|
ED_area_tag_redraw(rmd->sa);
|
2012-05-08 11:48:19 +00:00
|
|
|
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL);
|
2009-10-22 23:22:05 +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
|
|
|
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:
|
2012-10-21 07:58:38 +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
|
|
|
}
|
|
|
|
|
|
|
|
return OPERATOR_RUNNING_MODAL;
|
|
|
|
}
|
|
|
|
|
2011-08-28 05:06:30 +00:00
|
|
|
static int region_scale_cancel(bContext *UNUSED(C), wmOperator *op)
|
2011-06-06 11:04:54 +00:00
|
|
|
{
|
|
|
|
MEM_freeN(op->customdata);
|
|
|
|
op->customdata = NULL;
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
static void SCREEN_OT_region_scale(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Scale Region Size";
|
|
|
|
ot->description = "Scale selected area";
|
|
|
|
ot->idname = "SCREEN_OT_region_scale";
|
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
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->invoke = region_scale_invoke;
|
|
|
|
ot->modal = region_scale_modal;
|
|
|
|
ot->cancel = region_scale_cancel;
|
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
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->poll = ED_operator_areaactive;
|
2009-07-11 14:51:13 +00:00
|
|
|
|
2012-03-22 07:26:09 +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)
|
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
Main *bmain = CTX_data_main(C);
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
2008-12-17 16:21:14 +00:00
|
|
|
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");
|
2010-02-07 23:41:17 +00:00
|
|
|
|
2012-02-12 11:42:17 +00:00
|
|
|
CFRA += delta;
|
|
|
|
FRAMENUMBER_MIN_CLAMP(CFRA);
|
|
|
|
SUBFRA = 0.f;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2011-09-05 19:34:27 +00:00
|
|
|
sound_seek_scene(bmain, scene);
|
2010-02-07 23:41:17 +00:00
|
|
|
|
2012-05-08 11:48:19 +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";
|
2012-05-06 15:03:31 +00:00
|
|
|
ot->description = "Move current frame forward/backward by a given number";
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = frame_offset_exec;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->poll = ED_operator_screenactive_norender;
|
|
|
|
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)
|
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
Main *bmain = CTX_data_main(C);
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
wmTimer *animtimer = CTX_wm_screen(C)->animtimer;
|
2010-10-11 10:40:34 +00:00
|
|
|
|
|
|
|
/* Don't change CFRA directly if animtimer is running as this can cause
|
|
|
|
* first/last frame not to be actually shown (bad since for example physics
|
|
|
|
* simulations aren't reset properly).
|
|
|
|
*/
|
2012-03-24 06:38:07 +00:00
|
|
|
if (animtimer) {
|
2010-10-11 10:40:34 +00:00
|
|
|
ScreenAnimData *sad = animtimer->customdata;
|
|
|
|
|
|
|
|
sad->flag |= ANIMPLAY_FLAG_USE_NEXT_FRAME;
|
|
|
|
|
|
|
|
if (RNA_boolean_get(op->ptr, "end"))
|
2012-05-08 11:48:19 +00:00
|
|
|
sad->nextfra = PEFRA;
|
2010-10-11 10:40:34 +00:00
|
|
|
else
|
2012-05-08 11:48:19 +00:00
|
|
|
sad->nextfra = PSFRA;
|
2010-10-11 10:40:34 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (RNA_boolean_get(op->ptr, "end"))
|
2012-05-08 11:48:19 +00:00
|
|
|
CFRA = PEFRA;
|
2010-10-11 10:40:34 +00:00
|
|
|
else
|
2012-05-08 11:48:19 +00:00
|
|
|
CFRA = PSFRA;
|
2010-10-11 10:40:34 +00:00
|
|
|
|
2011-09-05 19:34:27 +00:00
|
|
|
sound_seek_scene(bmain, scene);
|
2010-02-10 23:15:12 +00:00
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
|
2010-10-11 10:40:34 +00:00
|
|
|
}
|
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";
|
2012-03-22 07:26:09 +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
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = frame_jump_exec;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->poll = ED_operator_screenactive_norender;
|
|
|
|
ot->flag = OPTYPE_UNDO;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-08-02 07:08:51 +00:00
|
|
|
/* rna */
|
2011-09-19 12:26:20 +00:00
|
|
|
RNA_def_boolean(ot->srna, "end", 0, "Last Frame", "Jump to the last frame of the frame range");
|
2009-08-02 07:08:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
Main *bmain = CTX_data_main(C);
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
Object *ob = CTX_data_active_object(C);
|
|
|
|
bDopeSheet ads = {NULL};
|
2009-07-24 13:34:45 +00:00
|
|
|
DLRBT_Tree keys;
|
|
|
|
ActKeyColumn *ak;
|
2011-05-01 10:14:09 +00:00
|
|
|
float cfra;
|
2012-05-08 11:48:19 +00:00
|
|
|
short next = RNA_boolean_get(op->ptr, "next");
|
2012-05-19 13:28:19 +00:00
|
|
|
short done = FALSE;
|
2009-07-24 13:34:45 +00:00
|
|
|
|
|
|
|
/* sanity checks */
|
|
|
|
if (scene == NULL)
|
|
|
|
return OPERATOR_CANCELLED;
|
2011-05-01 10:14:09 +00:00
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
cfra = (float)(CFRA);
|
2011-05-01 10:14:09 +00:00
|
|
|
|
2009-07-24 13:34:45 +00:00
|
|
|
/* init binarytree-list for getting keyframes */
|
|
|
|
BLI_dlrbTree_init(&keys);
|
|
|
|
|
|
|
|
/* populate tree with keyframe nodes */
|
2011-05-01 10:14:09 +00:00
|
|
|
scene_to_keylist(&ads, scene, &keys, NULL);
|
|
|
|
|
2010-12-19 01:27:32 +00:00
|
|
|
if (ob)
|
|
|
|
ob_to_keylist(&ads, ob, &keys, NULL);
|
2012-06-04 16:42:58 +00:00
|
|
|
|
|
|
|
{
|
2012-07-27 10:55:24 +00:00
|
|
|
Mask *mask = CTX_data_edit_mask(C);
|
|
|
|
if (mask) {
|
|
|
|
MaskLayer *masklay = BKE_mask_layer_active(mask);
|
|
|
|
mask_to_keylist(&ads, masklay, &keys);
|
2012-06-04 16:42:58 +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 */
|
2010-06-08 00:08:45 +00:00
|
|
|
do {
|
|
|
|
if (next)
|
2012-05-08 11:48:19 +00:00
|
|
|
ak = (ActKeyColumn *)BLI_dlrbTree_search_next(&keys, compare_ak_cfraPtr, &cfra);
|
2010-06-08 00:08:45 +00:00
|
|
|
else
|
2012-05-08 11:48:19 +00:00
|
|
|
ak = (ActKeyColumn *)BLI_dlrbTree_search_prev(&keys, compare_ak_cfraPtr, &cfra);
|
2010-06-08 00:08:45 +00:00
|
|
|
|
|
|
|
if (ak) {
|
|
|
|
if (CFRA != (int)ak->cfra) {
|
|
|
|
/* this changes the frame, so set the frame and we're done */
|
2012-05-08 11:48:19 +00:00
|
|
|
CFRA = (int)ak->cfra;
|
2012-05-19 13:28:19 +00:00
|
|
|
done = TRUE;
|
2010-06-08 00:08:45 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* make this the new starting point for the search */
|
|
|
|
cfra = ak->cfra;
|
|
|
|
}
|
|
|
|
}
|
2012-05-27 11:22:06 +00:00
|
|
|
} while ((ak != NULL) && (done == FALSE));
|
|
|
|
|
2009-07-24 13:34:45 +00:00
|
|
|
/* free temp stuff */
|
|
|
|
BLI_dlrbTree_free(&keys);
|
2010-02-10 23:15:12 +00:00
|
|
|
|
2012-05-27 11:22:06 +00:00
|
|
|
/* any success? */
|
|
|
|
if (done == FALSE) {
|
|
|
|
BKE_report(op->reports, RPT_INFO, "No more keyframes to jump to in this direction");
|
|
|
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
sound_seek_scene(bmain, scene);
|
|
|
|
|
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
2009-07-24 13:34:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void SCREEN_OT_keyframe_jump(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
ot->name = "Jump to Keyframe";
|
2012-03-22 07:26:09 +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
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = keyframe_jump_exec;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->poll = ED_operator_screenactive_norender;
|
|
|
|
ot->flag = OPTYPE_UNDO;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2012-08-23 07:39:51 +00:00
|
|
|
/* properties */
|
|
|
|
RNA_def_boolean(ot->srna, "next", TRUE, "Next Keyframe", "");
|
2009-07-24 13:34:45 +00:00
|
|
|
}
|
|
|
|
|
2008-12-17 17:33:45 +00:00
|
|
|
/* ************** switch screen operator ***************************** */
|
|
|
|
|
2012-10-23 15:30:41 +00:00
|
|
|
static int screen_set_is_ok(bScreen *screen, bScreen *screen_prev)
|
|
|
|
{
|
|
|
|
return ((screen->winid == 0) &&
|
|
|
|
(screen->full == 0) &&
|
|
|
|
(screen != screen_prev) &&
|
|
|
|
(screen->id.name[2] != '.' || !(U.uiflag & USER_HIDE_DOT)));
|
|
|
|
}
|
2008-12-17 17:33:45 +00:00
|
|
|
|
|
|
|
/* function to be called outside UI context, or for redo */
|
|
|
|
static int screen_set_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
2012-10-23 15:30:41 +00:00
|
|
|
Main *bmain = CTX_data_main(C);
|
2012-05-08 11:48:19 +00:00
|
|
|
bScreen *screen = CTX_wm_screen(C);
|
|
|
|
bScreen *screen_prev = screen;
|
2011-04-30 11:28:09 +00:00
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
ScrArea *sa = CTX_wm_area(C);
|
2012-10-23 15:30:41 +00:00
|
|
|
int tot = BLI_countlist(&bmain->screen);
|
2012-05-08 11:48:19 +00:00
|
|
|
int delta = RNA_int_get(op->ptr, "delta");
|
2008-12-17 17:33:45 +00:00
|
|
|
|
2010-11-09 14:54:59 +00:00
|
|
|
/* temp screens are for userpref or render display */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (screen->temp)
|
2010-11-09 14:54:59 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
if (delta == 1) {
|
2012-03-24 06:38:07 +00:00
|
|
|
while (tot--) {
|
2012-05-08 11:48:19 +00:00
|
|
|
screen = screen->id.next;
|
2012-10-23 15:30:41 +00:00
|
|
|
if (screen == NULL) screen = bmain->screen.first;
|
|
|
|
if (screen_set_is_ok(screen, screen_prev)) {
|
2009-02-07 19:37:29 +00:00
|
|
|
break;
|
2012-10-23 15:30:41 +00:00
|
|
|
}
|
2009-02-07 19:37:29 +00:00
|
|
|
}
|
2008-12-17 17:33:45 +00:00
|
|
|
}
|
2012-05-08 11:48:19 +00:00
|
|
|
else if (delta == -1) {
|
2012-03-24 06:38:07 +00:00
|
|
|
while (tot--) {
|
2012-05-08 11:48:19 +00:00
|
|
|
screen = screen->id.prev;
|
2012-10-23 15:30:41 +00:00
|
|
|
if (screen == NULL) screen = bmain->screen.last;
|
|
|
|
if (screen_set_is_ok(screen, screen_prev)) {
|
2009-02-07 19:37:29 +00:00
|
|
|
break;
|
2012-10-23 15:30:41 +00:00
|
|
|
}
|
2009-02-07 19:37:29 +00:00
|
|
|
}
|
2008-12-17 17:33:45 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-05-08 11:48:19 +00:00
|
|
|
screen = NULL;
|
2008-12-17 17:33:45 +00:00
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (screen && screen_prev != screen) {
|
2011-04-30 11:28:09 +00:00
|
|
|
/* return to previous state before switching screens */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sa && sa->full) {
|
2011-04-30 11:28:09 +00:00
|
|
|
ED_screen_full_restore(C, sa); /* may free 'screen_prev' */
|
|
|
|
}
|
|
|
|
|
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";
|
2012-03-22 07:26:09 +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
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = screen_set_exec;
|
|
|
|
ot->poll = ED_operator_screenactive;
|
2008-12-17 17:33:45 +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 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 */
|
2010-10-14 12:24:08 +00:00
|
|
|
static int screen_full_area_exec(bContext *C, wmOperator *UNUSED(op))
|
2008-12-17 19:40:19 +00:00
|
|
|
{
|
2011-04-02 14:11:13 +00:00
|
|
|
bScreen *screen = CTX_wm_screen(C);
|
2012-05-08 11:48:19 +00:00
|
|
|
ScrArea *sa = NULL;
|
2011-04-02 14:11:13 +00:00
|
|
|
|
|
|
|
/* search current screen for 'fullscreen' areas */
|
|
|
|
/* prevents restoring info header, when mouse is over it */
|
2012-05-08 11:48:19 +00:00
|
|
|
for (sa = screen->areabase.first; sa; sa = sa->next) {
|
2011-04-02 14:11:13 +00:00
|
|
|
if (sa->full) break;
|
|
|
|
}
|
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
if (sa == NULL) sa = CTX_wm_area(C);
|
2011-04-02 14:11:13 +00:00
|
|
|
|
|
|
|
ED_screen_full_toggle(C, CTX_wm_window(C), sa);
|
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-10-22 23:22:05 +00:00
|
|
|
ot->name = "Toggle Full Screen";
|
2012-03-22 07:26:09 +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
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = screen_full_area_exec;
|
|
|
|
ot->poll = ED_operator_areaactive;
|
|
|
|
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:
|
2012-03-03 16:31:46 +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
|
2009-12-10 09:25:30 +00:00
|
|
|
*/
|
2008-11-19 16:28:11 +00:00
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
typedef struct sAreaJoinData {
|
|
|
|
ScrArea *sa1; /* first area to be considered */
|
|
|
|
ScrArea *sa2; /* second area to be considered */
|
|
|
|
ScrArea *scr; /* designed for removal */
|
2011-08-25 15:49:52 +00:00
|
|
|
|
|
|
|
} 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;
|
2012-05-08 11:48:19 +00:00
|
|
|
sAreaJoinData *jd = NULL;
|
2008-11-19 16:28:11 +00:00
|
|
|
int x1, y1;
|
|
|
|
int x2, y2;
|
2012-05-08 11:48:19 +00:00
|
|
|
int shared = 0;
|
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 */
|
2012-05-08 11:48:19 +00:00
|
|
|
x1 = RNA_int_get(op->ptr, "min_x");
|
|
|
|
y1 = RNA_int_get(op->ptr, "min_y");
|
|
|
|
x2 = RNA_int_get(op->ptr, "max_x");
|
|
|
|
y2 = RNA_int_get(op->ptr, "max_y");
|
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);
|
2012-05-08 11:48:19 +00:00
|
|
|
if (sa1 == NULL || sa2 == NULL || sa1 == sa2)
|
2008-11-19 16:28:11 +00:00
|
|
|
return 0;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2011-03-02 14:09:54 +00:00
|
|
|
/* do areas share an edge? */
|
2012-05-08 11:48:19 +00:00
|
|
|
if (sa1->v1 == sa2->v1 || sa1->v1 == sa2->v2 || sa1->v1 == sa2->v3 || sa1->v1 == sa2->v4) shared++;
|
|
|
|
if (sa1->v2 == sa2->v1 || sa1->v2 == sa2->v2 || sa1->v2 == sa2->v3 || sa1->v2 == sa2->v4) shared++;
|
|
|
|
if (sa1->v3 == sa2->v1 || sa1->v3 == sa2->v2 || sa1->v3 == sa2->v3 || sa1->v3 == sa2->v4) shared++;
|
|
|
|
if (sa1->v4 == sa2->v1 || sa1->v4 == sa2->v2 || sa1->v4 == sa2->v3 || sa1->v4 == sa2->v4) shared++;
|
|
|
|
if (shared != 2) {
|
2011-03-02 14:09:54 +00:00
|
|
|
printf("areas don't share edge\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-06-17 09:58:26 +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;
|
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
op->customdata = jd;
|
2008-11-19 16:28:11 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
2012-03-24 06:38:07 +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)
|
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!area_join_init(C, op))
|
2008-11-19 16:28:11 +00:00
|
|
|
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 */
|
2013-03-13 09:03:46 +00:00
|
|
|
static int area_join_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
2008-11-19 16:28:11 +00:00
|
|
|
{
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
if (event->type == EVT_ACTIONZONE_AREA) {
|
|
|
|
sActionzoneData *sad = event->customdata;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2012-09-14 06:17:14 +00:00
|
|
|
if (sad == NULL || sad->modifier > 0) {
|
2009-03-05 23:19:44 +00:00
|
|
|
return OPERATOR_PASS_THROUGH;
|
|
|
|
}
|
2008-11-19 16:28:11 +00:00
|
|
|
|
|
|
|
/* verify *sad itself */
|
2012-09-14 06:17:14 +00:00
|
|
|
if (sad->sa1 == NULL || sad->sa2 == NULL)
|
2008-11-19 16:28:11 +00:00
|
|
|
return OPERATOR_PASS_THROUGH;
|
|
|
|
|
|
|
|
/* is this our *sad? if areas equal it should be passed on */
|
2012-05-08 11:48:19 +00:00
|
|
|
if (sad->sa1 == sad->sa2)
|
2008-11-19 16:28:11 +00:00
|
|
|
return OPERATOR_PASS_THROUGH;
|
|
|
|
|
|
|
|
/* prepare operator state vars */
|
2010-08-20 06:09:58 +00:00
|
|
|
RNA_int_set(op->ptr, "min_x", sad->x);
|
|
|
|
RNA_int_set(op->ptr, "min_y", sad->y);
|
|
|
|
RNA_int_set(op->ptr, "max_x", event->x);
|
|
|
|
RNA_int_set(op->ptr, "max_y", event->y);
|
2008-11-19 16:28:11 +00:00
|
|
|
}
|
|
|
|
|
2011-03-02 14:09:54 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!area_join_init(C, op))
|
2011-03-02 14:09:54 +00:00
|
|
|
return OPERATOR_PASS_THROUGH;
|
|
|
|
|
|
|
|
/* add temp handler */
|
|
|
|
WM_event_add_modal_handler(C, op);
|
|
|
|
|
|
|
|
return OPERATOR_RUNNING_MODAL;
|
2008-11-19 16:28:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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 */
|
2013-03-13 09:03:46 +00:00
|
|
|
static int area_join_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
2008-11-19 16:28:11 +00:00
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
bScreen *sc = CTX_wm_screen(C);
|
2008-11-19 16:28:11 +00:00
|
|
|
sAreaJoinData *jd = (sAreaJoinData *)op->customdata;
|
|
|
|
|
|
|
|
/* execute the events */
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (event->type) {
|
2008-11-19 16:28:11 +00:00
|
|
|
|
|
|
|
case MOUSEMOVE:
|
2009-12-10 09:25:30 +00:00
|
|
|
{
|
|
|
|
ScrArea *sa = screen_areahascursor(sc, event->x, event->y);
|
|
|
|
int dir;
|
|
|
|
|
2012-10-21 05:46:41 +00:00
|
|
|
if (sa) {
|
2009-12-10 09:25:30 +00:00
|
|
|
if (jd->sa1 != sa) {
|
2010-10-14 12:24:08 +00:00
|
|
|
dir = area_getorientation(jd->sa1, sa);
|
2009-12-10 09:25:30 +00:00
|
|
|
if (dir >= 0) {
|
|
|
|
if (jd->sa2) jd->sa2->flag &= ~AREA_FLAG_DRAWJOINTO;
|
|
|
|
jd->sa2 = sa;
|
|
|
|
jd->sa2->flag |= AREA_FLAG_DRAWJOINTO;
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
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
|
2012-03-03 16:31:46 +00:00
|
|
|
* we check if area has common border with the one marked for removal
|
|
|
|
* in this case we can swap areas.
|
2009-12-10 09:25:30 +00:00
|
|
|
*/
|
2010-10-14 12:24:08 +00:00
|
|
|
dir = area_getorientation(sa, jd->sa2);
|
2009-12-10 09:25:30 +00:00
|
|
|
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;
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2008-11-19 16:28:11 +00:00
|
|
|
else {
|
2009-12-10 09:25:30 +00:00
|
|
|
if (jd->sa2) jd->sa2->flag &= ~AREA_FLAG_DRAWJOINTO;
|
|
|
|
jd->sa2 = NULL;
|
2008-11-19 16:28:11 +00:00
|
|
|
}
|
|
|
|
}
|
2009-12-10 09:25:30 +00:00
|
|
|
WM_event_add_notifier(C, NC_WINDOW, NULL);
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2009-12-10 09:25:30 +00:00
|
|
|
else {
|
|
|
|
/* we are back in the area previously selected for keeping
|
2012-05-16 23:37:23 +00:00
|
|
|
* we swap the areas if possible to allow user to choose */
|
2009-12-10 09:25:30 +00:00
|
|
|
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;
|
2010-10-14 12:24:08 +00:00
|
|
|
dir = area_getorientation(jd->sa1, jd->sa2);
|
2009-12-10 09:25:30 +00:00
|
|
|
if (dir < 0) {
|
|
|
|
printf("oops, didn't expect that!\n");
|
|
|
|
}
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2009-12-10 09:25:30 +00:00
|
|
|
else {
|
2010-10-14 12:24:08 +00:00
|
|
|
dir = area_getorientation(jd->sa1, sa);
|
2009-12-10 09:25:30 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|
2013-07-19 15:23:42 +00:00
|
|
|
break;
|
2009-12-10 09:25:30 +00:00
|
|
|
}
|
2008-11-19 16:28:11 +00:00
|
|
|
case LEFTMOUSE:
|
2012-05-08 11:48:19 +00:00
|
|
|
if (event->val == KM_RELEASE) {
|
2010-01-16 22:56:52 +00:00
|
|
|
ED_area_tag_redraw(jd->sa1);
|
|
|
|
ED_area_tag_redraw(jd->sa2);
|
2010-07-25 01:39:47 +00:00
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
area_join_apply(C, op);
|
2012-05-08 11:48:19 +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-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 */
|
2012-05-19 09:46:41 +00:00
|
|
|
ot->name = "Join Area";
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->description = "Join selected areas into new window";
|
|
|
|
ot->idname = "SCREEN_OT_area_join";
|
2008-11-19 16:28:11 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = area_join_exec;
|
|
|
|
ot->invoke = area_join_invoke;
|
|
|
|
ot->modal = area_join_modal;
|
|
|
|
ot->poll = screen_active_editable;
|
|
|
|
ot->cancel = area_join_cancel;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
ot->flag = OPTYPE_BLOCKING | OPTYPE_INTERNAL;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2008-11-21 19:14:38 +00:00
|
|
|
/* rna */
|
2010-08-20 06:09:58 +00:00
|
|
|
RNA_def_int(ot->srna, "min_x", -100, INT_MIN, INT_MAX, "X 1", "", INT_MIN, INT_MAX);
|
|
|
|
RNA_def_int(ot->srna, "min_y", -100, INT_MIN, INT_MAX, "Y 1", "", INT_MIN, INT_MAX);
|
|
|
|
RNA_def_int(ot->srna, "max_x", -100, INT_MIN, INT_MAX, "X 2", "", INT_MIN, INT_MAX);
|
|
|
|
RNA_def_int(ot->srna, "max_y", -100, INT_MIN, INT_MAX, "Y 2", "", INT_MIN, INT_MAX);
|
2008-11-19 16:28:11 +00:00
|
|
|
}
|
|
|
|
|
2011-03-02 14:09:54 +00:00
|
|
|
/* ******************************* */
|
|
|
|
|
2013-03-13 09:03:46 +00:00
|
|
|
static int screen_area_options_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
2011-03-02 14:09:54 +00:00
|
|
|
{
|
|
|
|
uiPopupMenu *pup;
|
|
|
|
uiLayout *layout;
|
|
|
|
PointerRNA ptr1, ptr2;
|
2012-05-08 11:48:19 +00:00
|
|
|
ScrEdge *actedge = screen_find_active_scredge(CTX_wm_screen(C), event->x, event->y);
|
2011-03-02 14:09:54 +00:00
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
if (actedge == NULL) return OPERATOR_CANCELLED;
|
2011-03-02 14:09:54 +00:00
|
|
|
|
2012-05-19 09:46:41 +00:00
|
|
|
pup = uiPupMenuBegin(C, RNA_struct_ui_name(op->type->srna), ICON_NONE);
|
2012-05-08 11:48:19 +00:00
|
|
|
layout = uiPupMenuLayout(pup);
|
2011-03-02 14:09:54 +00:00
|
|
|
|
|
|
|
WM_operator_properties_create(&ptr1, "SCREEN_OT_area_join");
|
|
|
|
|
|
|
|
/* mouse cursor on edge, '4' can fail on wide edges... */
|
2012-05-08 11:48:19 +00:00
|
|
|
RNA_int_set(&ptr1, "min_x", event->x + 4);
|
|
|
|
RNA_int_set(&ptr1, "min_y", event->y + 4);
|
|
|
|
RNA_int_set(&ptr1, "max_x", event->x - 4);
|
|
|
|
RNA_int_set(&ptr1, "max_y", event->y - 4);
|
2011-03-02 14:09:54 +00:00
|
|
|
|
|
|
|
WM_operator_properties_create(&ptr2, "SCREEN_OT_area_split");
|
|
|
|
|
|
|
|
/* store initial mouse cursor position */
|
|
|
|
RNA_int_set(&ptr2, "mouse_x", event->x);
|
|
|
|
RNA_int_set(&ptr2, "mouse_y", event->y);
|
|
|
|
|
2012-05-19 09:46:41 +00:00
|
|
|
uiItemFullO(layout, "SCREEN_OT_area_split", NULL, ICON_NONE, ptr2.data, WM_OP_INVOKE_DEFAULT, 0);
|
|
|
|
uiItemFullO(layout, "SCREEN_OT_area_join", NULL, ICON_NONE, ptr1.data, WM_OP_INVOKE_DEFAULT, 0);
|
2011-03-02 14:09:54 +00:00
|
|
|
|
|
|
|
uiPupMenuEnd(C, pup);
|
|
|
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void SCREEN_OT_area_options(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Area Options";
|
|
|
|
ot->description = "Operations for splitting and merging";
|
|
|
|
ot->idname = "SCREEN_OT_area_options";
|
2011-03-02 14:09:54 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->invoke = screen_area_options_invoke;
|
2011-03-02 14:09:54 +00:00
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->poll = ED_operator_screen_mainwinactive;
|
2011-03-02 14:09:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ******************************* */
|
|
|
|
|
2011-01-06 17:54:17 +00:00
|
|
|
|
2013-07-28 17:06:31 +00:00
|
|
|
static int spacedata_cleanup_exec(bContext *C, wmOperator *op)
|
2011-01-06 17:54:17 +00:00
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
Main *bmain = CTX_data_main(C);
|
2011-01-06 17:54:17 +00:00
|
|
|
bScreen *screen;
|
|
|
|
ScrArea *sa;
|
2012-05-08 11:48:19 +00:00
|
|
|
int tot = 0;
|
2011-01-06 17:54:17 +00:00
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
for (screen = bmain->screen.first; screen; screen = screen->id.next) {
|
|
|
|
for (sa = screen->areabase.first; sa; sa = sa->next) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sa->spacedata.first != sa->spacedata.last) {
|
2012-05-08 11:48:19 +00:00
|
|
|
SpaceLink *sl = sa->spacedata.first;
|
2011-01-06 17:54:17 +00:00
|
|
|
|
|
|
|
BLI_remlink(&sa->spacedata, sl);
|
2012-05-08 11:48:19 +00:00
|
|
|
tot += BLI_countlist(&sa->spacedata);
|
2011-01-06 17:54:17 +00:00
|
|
|
BKE_spacedata_freelist(&sa->spacedata);
|
|
|
|
BLI_addtail(&sa->spacedata, sl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
BKE_reportf(op->reports, RPT_INFO, "Removed amount of editors: %d", tot);
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void SCREEN_OT_spacedata_cleanup(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2013-01-27 07:23:58 +00:00
|
|
|
ot->name = "Clean-up Space-data";
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->description = "Remove unused settings for invisible editors";
|
|
|
|
ot->idname = "SCREEN_OT_spacedata_cleanup";
|
2011-01-06 17:54:17 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2013-07-28 17:06:31 +00:00
|
|
|
ot->exec = spacedata_cleanup_exec;
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->poll = WM_operator_winactive;
|
2011-01-06 17:54:17 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2008-12-03 19:33:42 +00:00
|
|
|
/* ************** repeat last operator ***************************** */
|
|
|
|
|
2010-10-14 12:24:08 +00:00
|
|
|
static int repeat_last_exec(bContext *C, wmOperator *UNUSED(op))
|
2008-12-03 19:33:42 +00:00
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
wmOperator *lastop = CTX_wm_manager(C)->operators.last;
|
2008-12-03 19:33:42 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (lastop)
|
2009-02-01 12:00:00 +00:00
|
|
|
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 */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Repeat Last";
|
|
|
|
ot->description = "Repeat last action";
|
|
|
|
ot->idname = "SCREEN_OT_repeat_last";
|
2008-12-03 19:33:42 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = repeat_last_exec;
|
2008-12-03 19:33:42 +00:00
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->poll = ED_operator_screenactive;
|
2008-12-03 19:33:42 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-03-13 09:03:46 +00:00
|
|
|
static int repeat_history_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
|
2009-01-15 18:28:40 +00:00
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
wmWindowManager *wm = CTX_wm_manager(C);
|
2009-01-15 18:28:40 +00:00
|
|
|
wmOperator *lastop;
|
2009-05-23 03:24:15 +00:00
|
|
|
uiPopupMenu *pup;
|
|
|
|
uiLayout *layout;
|
2009-01-15 18:28:40 +00:00
|
|
|
int items, i;
|
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
items = BLI_countlist(&wm->operators);
|
|
|
|
if (items == 0)
|
2009-01-15 18:28:40 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
2012-05-20 13:56:42 +00:00
|
|
|
pup = uiPupMenuBegin(C, RNA_struct_ui_name(op->type->srna), ICON_NONE);
|
2012-05-08 11:48:19 +00:00
|
|
|
layout = uiPupMenuLayout(pup);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
for (i = items - 1, lastop = wm->operators.last; lastop; lastop = lastop->prev, i--)
|
2012-05-20 13:56:42 +00:00
|
|
|
uiItemIntO(layout, RNA_struct_ui_name(lastop->type->srna), ICON_NONE, op->type->idname, "index", i);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-05-23 03:24:15 +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)
|
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
wmWindowManager *wm = CTX_wm_manager(C);
|
2009-01-15 18:28:40 +00:00
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
op = BLI_findlink(&wm->operators, RNA_int_get(op->ptr, "index"));
|
2012-03-24 06:38:07 +00:00
|
|
|
if (op) {
|
2009-01-15 18:28:40 +00:00
|
|
|
/* 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 */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Repeat History";
|
|
|
|
ot->description = "Display menu for previous actions performed";
|
|
|
|
ot->idname = "SCREEN_OT_repeat_history";
|
2009-01-15 18:28:40 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->invoke = repeat_history_invoke;
|
|
|
|
ot->exec = repeat_history_exec;
|
2009-01-15 18:28:40 +00:00
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->poll = ED_operator_screenactive;
|
2009-01-15 18:28:40 +00:00
|
|
|
|
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 ***************************** */
|
|
|
|
|
2013-03-13 09:03:46 +00:00
|
|
|
static int redo_last_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event))
|
2009-02-04 11:52:16 +00:00
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
wmOperator *lastop = WM_operator_last_redo(C);
|
2009-02-19 16:22:07 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (lastop)
|
2009-05-23 03:24:15 +00:00
|
|
|
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 */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Redo Last";
|
|
|
|
ot->description = "Display menu for last action performed";
|
|
|
|
ot->idname = "SCREEN_OT_redo_last";
|
2009-02-04 11:52:16 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->invoke = redo_last_invoke;
|
2009-02-04 11:52:16 +00:00
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->poll = ED_operator_screenactive;
|
2009-02-04 11:52:16 +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
|
|
|
/* ************** region four-split operator ***************************** */
|
|
|
|
|
2012-05-27 11:10:27 +00:00
|
|
|
static void view3d_localview_update_rv3d(struct RegionView3D *rv3d)
|
|
|
|
{
|
|
|
|
if (rv3d->localvd) {
|
|
|
|
rv3d->localvd->view = rv3d->view;
|
|
|
|
rv3d->localvd->persp = rv3d->persp;
|
|
|
|
copy_qt_qt(rv3d->localvd->viewquat, rv3d->viewquat);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-08 13:01:05 +00:00
|
|
|
static void region_quadview_init_rv3d(ScrArea *sa, ARegion *ar,
|
|
|
|
const char viewlock, const char view, const char persp)
|
|
|
|
{
|
|
|
|
RegionView3D *rv3d = ar->regiondata;
|
|
|
|
|
|
|
|
rv3d->viewlock = viewlock;
|
|
|
|
rv3d->view = view;
|
|
|
|
rv3d->persp = persp;
|
|
|
|
|
|
|
|
ED_view3d_lock(rv3d);
|
|
|
|
view3d_localview_update_rv3d(rv3d);
|
|
|
|
if ((viewlock & RV3D_BOXCLIP) && (persp == RV3D_ORTHO)) {
|
|
|
|
ED_view3d_quadview_update(sa, ar, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
/* 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
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
ARegion *ar = CTX_wm_region(C);
|
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
|
|
|
|
|
|
|
/* some rules... */
|
2012-05-08 11:48:19 +00:00
|
|
|
if (ar->regiontype != RGN_TYPE_WINDOW)
|
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
|
|
|
BKE_report(op->reports, RPT_ERROR, "Only window region can be 4-splitted");
|
2012-05-08 11:48:19 +00:00
|
|
|
else if (ar->alignment == RGN_ALIGN_QSPLIT) {
|
|
|
|
ScrArea *sa = CTX_wm_area(C);
|
2009-01-20 18:31:11 +00:00
|
|
|
ARegion *arn;
|
|
|
|
|
|
|
|
/* keep current region */
|
2012-05-08 11:48:19 +00:00
|
|
|
ar->alignment = 0;
|
2009-01-20 18:31:11 +00:00
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
if (sa->spacetype == SPACE_VIEW3D) {
|
|
|
|
RegionView3D *rv3d = ar->regiondata;
|
2013-05-08 13:01:05 +00:00
|
|
|
rv3d->viewlock_quad = rv3d->viewlock | RV3D_VIEWLOCK_INIT;
|
2012-05-08 11:48:19 +00:00
|
|
|
rv3d->viewlock = 0;
|
2009-02-16 15:08:06 +00:00
|
|
|
rv3d->rflag &= ~RV3D_CLIPPING;
|
2009-01-20 18:31:11 +00:00
|
|
|
}
|
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
for (ar = sa->regionbase.first; ar; ar = arn) {
|
|
|
|
arn = ar->next;
|
|
|
|
if (ar->alignment == RGN_ALIGN_QSPLIT) {
|
2009-01-20 18:31:11 +00:00
|
|
|
ED_region_exit(C, ar);
|
|
|
|
BKE_area_region_free(sa->type, ar);
|
|
|
|
BLI_remlink(&sa->regionbase, ar);
|
|
|
|
MEM_freeN(ar);
|
|
|
|
}
|
|
|
|
}
|
2010-01-16 22:56:52 +00:00
|
|
|
ED_area_tag_redraw(sa);
|
2012-05-08 11:48:19 +00:00
|
|
|
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL);
|
2009-01-20 18:31:11 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (ar->next)
|
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
|
|
|
BKE_report(op->reports, RPT_ERROR, "Only last region can be 4-splitted");
|
|
|
|
else {
|
2012-05-08 11:48:19 +00:00
|
|
|
ScrArea *sa = CTX_wm_area(C);
|
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 *newar;
|
|
|
|
int count;
|
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
ar->alignment = RGN_ALIGN_QSPLIT;
|
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
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
for (count = 0; count < 3; count++) {
|
|
|
|
newar = BKE_area_region_copy(sa->type, ar);
|
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
|
|
|
BLI_addtail(&sa->regionbase, newar);
|
|
|
|
}
|
|
|
|
|
2009-01-20 14:23:32 +00:00
|
|
|
/* lock views and set them */
|
2012-05-08 11:48:19 +00:00
|
|
|
if (sa->spacetype == SPACE_VIEW3D) {
|
2012-10-10 08:47:53 +00:00
|
|
|
View3D *v3d = sa->spacedata.first;
|
|
|
|
|
2011-03-08 07:44:30 +00:00
|
|
|
/* run ED_view3d_lock() so the correct 'rv3d->viewquat' is set,
|
|
|
|
* otherwise when restoring rv3d->localvd the 'viewquat' won't
|
|
|
|
* match the 'view', set on entering localview See: [#26315],
|
|
|
|
*
|
|
|
|
* We could avoid manipulating rv3d->localvd here if exiting
|
|
|
|
* localview with a 4-split would assign these view locks */
|
2013-05-08 13:01:05 +00:00
|
|
|
RegionView3D *rv3d = ar->regiondata;
|
|
|
|
const char viewlock = (rv3d->viewlock_quad & RV3D_VIEWLOCK_INIT) ?
|
|
|
|
(rv3d->viewlock_quad & ~RV3D_VIEWLOCK_INIT) : RV3D_LOCKED;
|
2012-10-10 08:47:53 +00:00
|
|
|
|
2013-05-08 13:01:05 +00:00
|
|
|
region_quadview_init_rv3d(sa, ar, viewlock, RV3D_VIEW_FRONT, RV3D_ORTHO);
|
|
|
|
region_quadview_init_rv3d(sa, (ar = ar->next), viewlock, RV3D_VIEW_TOP, RV3D_ORTHO);
|
|
|
|
region_quadview_init_rv3d(sa, (ar = ar->next), viewlock, RV3D_VIEW_RIGHT, RV3D_ORTHO);
|
|
|
|
if (v3d->camera) region_quadview_init_rv3d(sa, (ar = ar->next), 0, RV3D_VIEW_CAMERA, RV3D_CAMOB);
|
|
|
|
else region_quadview_init_rv3d(sa, (ar = ar->next), 0, RV3D_VIEW_PERSPORTHO, RV3D_PERSP);
|
2012-10-10 08:47:53 +00:00
|
|
|
|
2009-01-20 14:23:32 +00:00
|
|
|
}
|
2010-01-16 22:56:52 +00:00
|
|
|
ED_area_tag_redraw(sa);
|
2012-05-08 11:48:19 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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 */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Toggle Quad View";
|
|
|
|
ot->description = "Split selected area into camera, front, right & top views";
|
|
|
|
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 */
|
2012-03-22 07:26:09 +00:00
|
|
|
// ot->invoke = WM_operator_confirm;
|
|
|
|
ot->exec = region_quadview_exec;
|
|
|
|
ot->poll = ED_operator_region_view3d_active;
|
|
|
|
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 */
|
2010-10-14 12:24:08 +00:00
|
|
|
static int region_flip_exec(bContext *C, wmOperator *UNUSED(op))
|
2008-12-15 11:59:42 +00:00
|
|
|
{
|
2012-05-08 11:48:19 +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;
|
|
|
|
|
2012-05-08 11:48:19 +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;
|
2010-07-25 01:39:47 +00:00
|
|
|
|
|
|
|
ED_area_tag_redraw(CTX_wm_area(C));
|
2012-05-08 11:48:19 +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 */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Flip Region";
|
|
|
|
ot->idname = "SCREEN_OT_region_flip";
|
2012-05-06 15:03:31 +00:00
|
|
|
ot->description = "Toggle the region's alignment (left/right or top/bottom)";
|
2008-12-15 11:59:42 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = region_flip_exec;
|
|
|
|
ot->poll = ED_operator_areaactive;
|
|
|
|
ot->flag = 0;
|
2009-11-27 06:24:09 +00:00
|
|
|
}
|
|
|
|
|
2009-11-27 11:51:34 +00:00
|
|
|
/* ************** header flip operator ***************************** */
|
2008-12-18 02:56:48 +00:00
|
|
|
|
2009-11-27 11:51:34 +00:00
|
|
|
/* flip a header region alignment */
|
2010-10-14 12:24:08 +00:00
|
|
|
static int header_flip_exec(bContext *C, wmOperator *UNUSED(op))
|
2009-11-27 11:51:34 +00:00
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
ARegion *ar = CTX_wm_region(C);
|
2009-11-27 11:51:34 +00:00
|
|
|
|
|
|
|
/* find the header region
|
|
|
|
* - try context first, but upon failing, search all regions in area...
|
|
|
|
*/
|
2012-03-24 06:38:07 +00:00
|
|
|
if ((ar == NULL) || (ar->regiontype != RGN_TYPE_HEADER)) {
|
2012-05-08 11:48:19 +00:00
|
|
|
ScrArea *sa = CTX_wm_area(C);
|
|
|
|
ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
|
2011-05-20 05:27:31 +00:00
|
|
|
|
2009-11-27 11:51:34 +00:00
|
|
|
/* don't do anything if no region */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ar == NULL)
|
2009-11-27 11:51:34 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2009-11-27 11:51:34 +00:00
|
|
|
|
|
|
|
/* copied from SCREEN_OT_region_flip */
|
2012-05-08 11:48:19 +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;
|
2010-07-25 01:39:47 +00:00
|
|
|
|
2010-01-16 22:56:52 +00:00
|
|
|
ED_area_tag_redraw(CTX_wm_area(C));
|
|
|
|
|
2012-05-08 11:48:19 +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-11-27 11:51:34 +00:00
|
|
|
static void SCREEN_OT_header_flip(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Flip Header Region";
|
|
|
|
ot->idname = "SCREEN_OT_header_flip";
|
2012-05-06 15:03:31 +00:00
|
|
|
ot->description = "Toggle the header over/below the main window area";
|
2009-11-27 11:51:34 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = header_flip_exec;
|
2009-11-27 11:51:34 +00:00
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->poll = ED_operator_areaactive;
|
|
|
|
ot->flag = 0;
|
2009-11-27 11:51:34 +00:00
|
|
|
}
|
|
|
|
|
2012-10-25 13:08:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* ************** show menus operator ***************************** */
|
|
|
|
|
|
|
|
/* show/hide header text menus */
|
|
|
|
static int header_toggle_menus_exec(bContext *C, wmOperator *UNUSED(op))
|
|
|
|
{
|
|
|
|
ScrArea *sa = CTX_wm_area(C);
|
|
|
|
|
|
|
|
sa->flag = sa->flag ^ HEADER_NO_PULLDOWN;
|
|
|
|
|
|
|
|
ED_area_tag_redraw(CTX_wm_area(C));
|
|
|
|
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL);
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void SCREEN_OT_header_toggle_menus(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
|
|
|
ot->name = "Show/Hide Header Menus";
|
|
|
|
ot->idname = "SCREEN_OT_header_toggle_menus";
|
2012-10-26 17:32:50 +00:00
|
|
|
ot->description = "Show or hide the header pulldown menus";
|
2012-10-25 13:08:47 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-10-26 17:32:50 +00:00
|
|
|
ot->exec = header_toggle_menus_exec;
|
2012-10-25 13:08:47 +00:00
|
|
|
ot->poll = ED_operator_areaactive;
|
|
|
|
ot->flag = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-27 06:24:09 +00:00
|
|
|
/* ************** header tools operator ***************************** */
|
2012-09-19 18:47:41 +00:00
|
|
|
void ED_screens_header_tools_menu_create(bContext *C, uiLayout *layout, void *UNUSED(arg))
|
2009-11-27 06:24:09 +00:00
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
ScrArea *sa = CTX_wm_area(C);
|
|
|
|
ARegion *ar = CTX_wm_region(C);
|
2012-09-19 18:47:41 +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)
|
2012-09-19 18:47:41 +00:00
|
|
|
uiItemO(layout, IFACE_("Flip to Bottom"), ICON_NONE, "SCREEN_OT_header_flip");
|
2009-11-27 06:24:09 +00:00
|
|
|
else
|
2012-09-19 18:47:41 +00:00
|
|
|
uiItemO(layout, IFACE_("Flip to Top"), ICON_NONE, "SCREEN_OT_header_flip");
|
|
|
|
|
2012-10-25 13:08:47 +00:00
|
|
|
if (sa->flag & HEADER_NO_PULLDOWN)
|
|
|
|
uiItemO(layout, IFACE_("Show Menus"), ICON_NONE, "SCREEN_OT_header_toggle_menus");
|
|
|
|
else
|
|
|
|
uiItemO(layout, IFACE_("Hide Menus"), ICON_NONE, "SCREEN_OT_header_toggle_menus");
|
|
|
|
|
2009-11-27 06:24:09 +00:00
|
|
|
uiItemS(layout);
|
2012-09-19 18:47:41 +00:00
|
|
|
|
2012-07-04 15:04:38 +00:00
|
|
|
/* file browser should be fullscreen all the time, but other regions can be maximized/restored... */
|
2009-11-27 06:24:09 +00:00
|
|
|
if (sa->spacetype != SPACE_FILE) {
|
|
|
|
if (sa->full)
|
2012-09-19 18:47:41 +00:00
|
|
|
uiItemO(layout, IFACE_("Tile Area"), ICON_NONE, "SCREEN_OT_screen_full_area");
|
2009-11-27 06:24:09 +00:00
|
|
|
else
|
2012-09-19 18:47:41 +00:00
|
|
|
uiItemO(layout, IFACE_("Maximize Area"), ICON_NONE, "SCREEN_OT_screen_full_area");
|
2009-11-27 06:24:09 +00:00
|
|
|
}
|
2012-09-19 18:47:41 +00:00
|
|
|
}
|
|
|
|
|
2013-03-13 09:03:46 +00:00
|
|
|
static int header_toolbox_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event))
|
2012-09-19 18:47:41 +00:00
|
|
|
{
|
|
|
|
uiPopupMenu *pup;
|
|
|
|
uiLayout *layout;
|
|
|
|
|
2013-02-15 14:30:36 +00:00
|
|
|
pup = uiPupMenuBegin(C, IFACE_("Header"), ICON_NONE);
|
2012-09-19 18:47:41 +00:00
|
|
|
layout = uiPupMenuLayout(pup);
|
|
|
|
|
|
|
|
ED_screens_header_tools_menu_create(C, layout, NULL);
|
|
|
|
|
2009-11-27 06:24:09 +00:00
|
|
|
uiPupMenuEnd(C, pup);
|
2012-09-19 18:47:41 +00:00
|
|
|
|
2009-11-27 06:24:09 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
2009-01-25 20:22:05 +00:00
|
|
|
|
2011-02-14 17:55:27 +00:00
|
|
|
static void SCREEN_OT_header_toolbox(wmOperatorType *ot)
|
2008-12-15 11:59:42 +00:00
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Header Toolbox";
|
|
|
|
ot->description = "Display header region toolbox";
|
|
|
|
ot->idname = "SCREEN_OT_header_toolbox";
|
2008-12-15 11:59:42 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
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
|
|
|
|
Timeline addition: Display cached frames
This started off doing pointcache debugging but it's also very useful for users too.
Previously it was very hard to see the state of the system when you're working caches
such as physics point cache - is it baked? which frames are cached? is it out of date?
Now, for better feedback, cached frames are drawn for the active object at the bottom
of the timeline - a semitransparent area shows the entire cache extents, and more
solid blocks on top show the frames that are cached. Darker versions indicate it's
using a disk cache.
It can be disabled in general in the timeline View -> Caches menu, or by each individual
system that can be shown.
There's still a bit to do on this, behaviour needs to be clarified still eg. deciding what
shows when it's out of date, or when it's been played back but not cached, etc. etc.
Part of this is due to a lack of definition in the point cache system itself, so we should
try and clean up/clarify this behaviour and what it means to users, at the same time.
Also would be interested in extending this to other caches such as fluid cache,
sequencer memory cache etc. in the future, too.
2010-06-22 02:29:52 +00:00
|
|
|
static int match_area_with_refresh(int spacetype, int refresh)
|
|
|
|
{
|
|
|
|
switch (spacetype) {
|
|
|
|
case SPACE_TIME:
|
|
|
|
if (refresh & SPACE_TIME)
|
|
|
|
return 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
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:
|
2012-03-24 06:38:07 +00:00
|
|
|
if (redraws & TIME_ALL_3D_WIN)
|
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 1;
|
|
|
|
break;
|
|
|
|
case SPACE_IPO:
|
|
|
|
case SPACE_ACTION:
|
|
|
|
case SPACE_NLA:
|
2012-03-24 06:38:07 +00:00
|
|
|
if (redraws & TIME_ALL_ANIM_WIN)
|
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 1;
|
|
|
|
break;
|
|
|
|
case SPACE_TIME:
|
|
|
|
/* if only 1 window or 3d windows, we do timeline too */
|
2012-05-08 11:48:19 +00:00
|
|
|
if (redraws & (TIME_ALL_ANIM_WIN | TIME_REGION | TIME_ALL_3D_WIN))
|
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 1;
|
|
|
|
break;
|
|
|
|
case SPACE_BUTS:
|
2012-03-24 06:38:07 +00:00
|
|
|
if (redraws & TIME_ALL_BUTS_WIN)
|
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 1;
|
|
|
|
break;
|
|
|
|
case SPACE_SEQ:
|
2012-05-08 11:48:19 +00:00
|
|
|
if (redraws & (TIME_SEQ | TIME_ALL_ANIM_WIN))
|
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 1;
|
|
|
|
break;
|
2009-10-22 23:22:05 +00:00
|
|
|
case SPACE_NODE:
|
2012-03-24 06:38:07 +00:00
|
|
|
if (redraws & (TIME_NODES))
|
2009-10-22 23:22:05 +00:00
|
|
|
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:
|
2012-03-24 06:38:07 +00:00
|
|
|
if (redraws & TIME_ALL_IMAGE_WIN)
|
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 1;
|
|
|
|
break;
|
2011-11-07 12:55:18 +00:00
|
|
|
case SPACE_CLIP:
|
2012-03-24 06:38:07 +00:00
|
|
|
if (redraws & TIME_CLIPS)
|
2011-11-07 12:55:18 +00:00
|
|
|
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
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2012-05-08 11:48:19 +00:00
|
|
|
else if (regiontype == RGN_TYPE_UI) {
|
|
|
|
if (spacetype == SPACE_CLIP) {
|
2011-11-07 12:55:18 +00:00
|
|
|
/* Track Preview button is on Properties Editor in SpaceClip,
|
2012-03-03 16:31:46 +00:00
|
|
|
* and it's very common case when users want it be refreshing
|
|
|
|
* during playback, so asking people to enable special option
|
2012-03-04 04:35:12 +00:00
|
|
|
* for this is a bit tricky, so add exception here for refreshing
|
2012-03-03 16:31:46 +00:00
|
|
|
* Properties Editor for SpaceClip always */
|
2011-11-07 12:55:18 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (redraws & TIME_ALL_BUTS_WIN)
|
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 1;
|
|
|
|
}
|
2012-05-08 11:48:19 +00:00
|
|
|
else if (regiontype == RGN_TYPE_HEADER) {
|
|
|
|
if (spacetype == SPACE_TIME)
|
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 1;
|
|
|
|
}
|
2012-05-08 11:48:19 +00:00
|
|
|
else if (regiontype == RGN_TYPE_PREVIEW) {
|
2009-12-18 13:28:03 +00:00
|
|
|
switch (spacetype) {
|
|
|
|
case SPACE_SEQ:
|
2012-05-08 11:48:19 +00:00
|
|
|
if (redraws & (TIME_SEQ | TIME_ALL_ANIM_WIN))
|
2009-12-18 13:28:03 +00:00
|
|
|
return 1;
|
|
|
|
break;
|
2011-11-07 12:55:18 +00:00
|
|
|
case SPACE_CLIP:
|
|
|
|
return 1;
|
2009-12-18 13:28:03 +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
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-03-13 09:03:46 +00:00
|
|
|
static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
|
2008-12-21 19:58:25 +00:00
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
bScreen *screen = CTX_wm_screen(C);
|
2010-06-01 15:35:38 +00:00
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
if (screen->animtimer && screen->animtimer == event->customdata) {
|
|
|
|
Main *bmain = CTX_data_main(C);
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
wmTimer *wt = screen->animtimer;
|
|
|
|
ScreenAnimData *sad = wt->customdata;
|
2012-05-25 12:37:11 +00:00
|
|
|
wmWindowManager *wm = CTX_wm_manager(C);
|
|
|
|
wmWindow *window;
|
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
|
|
|
ScrArea *sa;
|
2009-08-16 20:37:22 +00:00
|
|
|
int sync;
|
2010-03-21 00:04:50 +00:00
|
|
|
float time;
|
2010-07-18 14:46:52 +00:00
|
|
|
|
2009-08-16 20:37:22 +00:00
|
|
|
/* sync, don't sync, or follow scene setting */
|
2012-05-08 11:48:19 +00:00
|
|
|
if (sad->flag & ANIMPLAY_FLAG_SYNC) sync = 1;
|
|
|
|
else if (sad->flag & ANIMPLAY_FLAG_NO_SYNC) sync = 0;
|
|
|
|
else sync = (scene->flag & SCE_FRAME_DROP);
|
2008-12-21 19:58:25 +00:00
|
|
|
|
2012-03-06 18:40:15 +00:00
|
|
|
if ((scene->audio.flag & AUDIO_SYNC) &&
|
|
|
|
(sad->flag & ANIMPLAY_FLAG_REVERSE) == FALSE &&
|
|
|
|
finite(time = sound_sync_scene(scene)))
|
2010-02-19 12:20:29 +00:00
|
|
|
{
|
2012-03-06 18:40:15 +00:00
|
|
|
scene->r.cfra = (double)time * FPS + 0.5;
|
|
|
|
}
|
|
|
|
else {
|
2010-07-19 11:25:23 +00:00
|
|
|
if (sync) {
|
2012-10-26 06:22:54 +00:00
|
|
|
/* note: this is very simplistic,
|
|
|
|
* its has problem that it may skip too many frames.
|
|
|
|
* however at least this gives a less jittery playback */
|
2012-10-25 11:48:56 +00:00
|
|
|
const int step = max_ii(1, floor((wt->duration - sad->last_duration) * FPS));
|
|
|
|
|
2010-02-19 12:20:29 +00:00
|
|
|
/* skip frames */
|
2010-07-19 11:25:23 +00:00
|
|
|
if (sad->flag & ANIMPLAY_FLAG_REVERSE)
|
2010-02-19 12:20:29 +00:00
|
|
|
scene->r.cfra -= step;
|
|
|
|
else
|
|
|
|
scene->r.cfra += step;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* one frame +/- */
|
2010-07-19 11:25:23 +00:00
|
|
|
if (sad->flag & ANIMPLAY_FLAG_REVERSE)
|
2010-02-19 12:20:29 +00:00
|
|
|
scene->r.cfra--;
|
|
|
|
else
|
|
|
|
scene->r.cfra++;
|
|
|
|
}
|
2009-07-07 07:29:21 +00:00
|
|
|
}
|
2008-12-21 23:39:52 +00:00
|
|
|
|
2012-03-18 22:21:29 +00:00
|
|
|
sad->last_duration = wt->duration;
|
|
|
|
|
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? */
|
2010-01-19 20:30:04 +00:00
|
|
|
if (PRVRANGEON) {
|
2009-07-31 07:43:47 +00:00
|
|
|
if (scene->r.cfra < scene->r.psfra) {
|
2012-05-08 11:48:19 +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) {
|
2012-05-08 11:48:19 +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? */
|
2010-01-19 20:30:04 +00:00
|
|
|
if (PRVRANGEON) {
|
2009-07-31 07:43:47 +00:00
|
|
|
if (scene->r.cfra > scene->r.pefra) {
|
2012-05-08 11:48:19 +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) {
|
2012-05-08 11:48:19 +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
|
|
|
}
|
2010-10-11 10:40:34 +00:00
|
|
|
|
2012-07-16 23:23:33 +00:00
|
|
|
/* next frame overridden by user action (pressed jump to first/last frame) */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sad->flag & ANIMPLAY_FLAG_USE_NEXT_FRAME) {
|
2010-10-11 10:40:34 +00:00
|
|
|
scene->r.cfra = sad->nextfra;
|
|
|
|
sad->flag &= ~ANIMPLAY_FLAG_USE_NEXT_FRAME;
|
|
|
|
sad->flag |= ANIMPLAY_FLAG_JUMPED;
|
|
|
|
}
|
2009-11-10 09:50:39 +00:00
|
|
|
|
2010-07-19 11:25:23 +00:00
|
|
|
if (sad->flag & ANIMPLAY_FLAG_JUMPED)
|
2011-09-05 19:34:27 +00:00
|
|
|
sound_seek_scene(bmain, scene);
|
2010-02-12 00:44:26 +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 */
|
2013-07-23 18:30:06 +00:00
|
|
|
ED_update_for_newframe(bmain, scene, 1);
|
2012-05-25 12:37:11 +00:00
|
|
|
|
|
|
|
for (window = wm->windows.first; window; window = window->next) {
|
|
|
|
for (sa = window->screen->areabase.first; sa; sa = sa->next) {
|
|
|
|
ARegion *ar;
|
|
|
|
for (ar = sa->regionbase.first; ar; ar = ar->next) {
|
2012-10-31 10:09:06 +00:00
|
|
|
if (ar == sad->ar) {
|
2012-05-25 12:37:11 +00:00
|
|
|
ED_region_tag_redraw(ar);
|
2012-10-31 10:09:06 +00:00
|
|
|
}
|
|
|
|
else if (match_region_with_redraws(sa->spacetype, ar->regiontype, sad->redraws)) {
|
2012-05-25 12:37:11 +00:00
|
|
|
ED_region_tag_redraw(ar);
|
2012-10-31 10:09:06 +00:00
|
|
|
}
|
2012-05-25 12:37:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (match_area_with_refresh(sa->spacetype, sad->refresh))
|
|
|
|
ED_area_tag_refresh(sa);
|
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
|
|
|
}
|
|
|
|
}
|
2012-05-25 12:37:11 +00:00
|
|
|
|
2010-02-12 00:44:26 +00:00
|
|
|
/* update frame rate info too
|
|
|
|
* NOTE: this may not be accurate enough, since we might need this after modifiers/etc.
|
|
|
|
* have been calculated instead of just before updates have been done?
|
|
|
|
*/
|
|
|
|
ED_refresh_viewport_fps(C);
|
|
|
|
|
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
|
|
|
|
*/
|
2012-10-20 20:20:02 +00:00
|
|
|
/* TODO: this may make evaluation a bit slower if the value doesn't change... any way to avoid this? */
|
2012-05-08 11:48:19 +00:00
|
|
|
wt->timestep = (1.0 / FPS);
|
2009-11-10 09:50:39 +00:00
|
|
|
|
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 */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Animation Step";
|
|
|
|
ot->description = "Step through animation by position";
|
|
|
|
ot->idname = "SCREEN_OT_animation_step";
|
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
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->invoke = screen_animation_step;
|
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
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->poll = ED_operator_screenactive_norender;
|
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, starts or ends timer ***************** */
|
|
|
|
|
2012-05-25 12:37:11 +00:00
|
|
|
/* find window that owns the animation timer */
|
2012-05-25 12:56:29 +00:00
|
|
|
bScreen *ED_screen_animation_playing(const wmWindowManager *wm)
|
2012-05-25 12:37:11 +00:00
|
|
|
{
|
|
|
|
wmWindow *window;
|
|
|
|
|
|
|
|
for (window = wm->windows.first; window; window = window->next)
|
|
|
|
if (window->screen->animtimer)
|
|
|
|
return window->screen;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
/* toggle operator */
|
2010-02-21 18:01:41 +00:00
|
|
|
int ED_screen_animation_play(bContext *C, int sync, int mode)
|
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
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
bScreen *screen = CTX_wm_screen(C);
|
2010-07-19 11:25:23 +00:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
2010-02-21 18:01:41 +00:00
|
|
|
|
2012-05-25 12:56:29 +00:00
|
|
|
if (ED_screen_animation_playing(CTX_wm_manager(C))) {
|
2009-11-27 04:14:56 +00:00
|
|
|
/* stop playback now */
|
Timeline addition: Display cached frames
This started off doing pointcache debugging but it's also very useful for users too.
Previously it was very hard to see the state of the system when you're working caches
such as physics point cache - is it baked? which frames are cached? is it out of date?
Now, for better feedback, cached frames are drawn for the active object at the bottom
of the timeline - a semitransparent area shows the entire cache extents, and more
solid blocks on top show the frames that are cached. Darker versions indicate it's
using a disk cache.
It can be disabled in general in the timeline View -> Caches menu, or by each individual
system that can be shown.
There's still a bit to do on this, behaviour needs to be clarified still eg. deciding what
shows when it's out of date, or when it's been played back but not cached, etc. etc.
Part of this is due to a lack of definition in the point cache system itself, so we should
try and clean up/clarify this behaviour and what it means to users, at the same time.
Also would be interested in extending this to other caches such as fluid cache,
sequencer memory cache etc. in the future, too.
2010-06-22 02:29:52 +00:00
|
|
|
ED_screen_animation_timer(C, 0, 0, 0, 0);
|
2010-02-07 23:41:17 +00:00
|
|
|
sound_stop_scene(scene);
|
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 {
|
2012-05-08 11:48:19 +00:00
|
|
|
int refresh = SPACE_TIME; /* these settings are currently only available from a menu in the TimeLine */
|
2010-07-19 11:25:23 +00:00
|
|
|
|
2012-10-20 20:20:02 +00:00
|
|
|
if (mode == 1) /* XXX only play audio forwards!? */
|
2010-02-07 23:41:17 +00:00
|
|
|
sound_play_scene(scene);
|
2010-07-19 11:25:23 +00:00
|
|
|
|
2011-02-01 23:41:01 +00:00
|
|
|
ED_screen_animation_timer(C, screen->redraws_flag, refresh, sync, mode);
|
|
|
|
|
|
|
|
if (screen->animtimer) {
|
2012-05-08 11:48:19 +00:00
|
|
|
wmTimer *wt = screen->animtimer;
|
|
|
|
ScreenAnimData *sad = wt->customdata;
|
2010-07-19 11:25:23 +00:00
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
sad->ar = CTX_wm_region(C);
|
2011-12-04 23:13:28 +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
|
|
|
}
|
2010-02-21 18:01:41 +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
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
2010-04-20 02:39:07 +00:00
|
|
|
static int screen_animation_play_exec(bContext *C, wmOperator *op)
|
2010-02-21 18:01:41 +00:00
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
int mode = (RNA_boolean_get(op->ptr, "reverse")) ? -1 : 1;
|
|
|
|
int sync = -1;
|
2010-07-19 11:25:23 +00:00
|
|
|
|
2012-01-11 16:32:12 +00:00
|
|
|
if (RNA_struct_property_is_set(op->ptr, "sync"))
|
2012-05-08 11:48:19 +00:00
|
|
|
sync = (RNA_boolean_get(op->ptr, "sync"));
|
2010-07-19 11:25:23 +00:00
|
|
|
|
2010-02-21 18:01:41 +00:00
|
|
|
return ED_screen_animation_play(C, sync, mode);
|
|
|
|
}
|
|
|
|
|
2009-07-24 12:43:59 +00:00
|
|
|
static void SCREEN_OT_animation_play(wmOperatorType *ot)
|
2008-12-21 19:58:25 +00:00
|
|
|
{
|
2012-03-28 22:43:26 +00:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2008-12-21 19:58:25 +00:00
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Play Animation";
|
|
|
|
ot->description = "Play animation";
|
|
|
|
ot->idname = "SCREEN_OT_animation_play";
|
2008-12-21 19:58:25 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = screen_animation_play_exec;
|
2008-12-21 19:58:25 +00:00
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->poll = ED_operator_screenactive_norender;
|
2008-12-21 19:58:25 +00:00
|
|
|
|
2012-03-28 22:43:26 +00:00
|
|
|
prop = RNA_def_boolean(ot->srna, "reverse", 0, "Play in Reverse", "Animation is played backwards");
|
|
|
|
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
|
|
|
prop = RNA_def_boolean(ot->srna, "sync", 0, "Sync", "Drop frames to maintain framerate");
|
|
|
|
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
2008-12-21 19:58:25 +00:00
|
|
|
}
|
2008-12-09 15:59:43 +00:00
|
|
|
|
2011-03-27 08:31:10 +00:00
|
|
|
static int screen_animation_cancel_exec(bContext *C, wmOperator *op)
|
2009-10-22 23:22:05 +00:00
|
|
|
{
|
2012-05-25 12:56:29 +00:00
|
|
|
bScreen *screen = ED_screen_animation_playing(CTX_wm_manager(C));
|
2011-03-27 08:31:10 +00:00
|
|
|
|
2012-05-25 12:37:11 +00:00
|
|
|
if (screen) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (RNA_boolean_get(op->ptr, "restore_frame")) {
|
2012-05-08 11:48:19 +00:00
|
|
|
ScreenAnimData *sad = screen->animtimer->customdata;
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
2011-03-27 08:31:10 +00:00
|
|
|
|
|
|
|
/* reset current frame before stopping, and just send a notifier to deal with the rest
|
|
|
|
* (since playback still needs to be stopped)
|
|
|
|
*/
|
2012-05-08 11:48:19 +00:00
|
|
|
scene->r.cfra = sad->sfra;
|
2011-03-27 08:31:10 +00:00
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
|
2011-03-27 08:31:10 +00:00
|
|
|
}
|
|
|
|
|
2009-11-27 04:14:56 +00:00
|
|
|
/* call the other "toggling" operator to clean up now */
|
2010-04-02 08:51:48 +00:00
|
|
|
ED_screen_animation_play(C, 0, 0);
|
2009-11-27 04:14:56 +00:00
|
|
|
}
|
2010-04-02 08:51:48 +00:00
|
|
|
|
2009-10-22 23:22:05 +00:00
|
|
|
return OPERATOR_PASS_THROUGH;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void SCREEN_OT_animation_cancel(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Cancel Animation";
|
|
|
|
ot->description = "Cancel animation, returning to the original frame";
|
|
|
|
ot->idname = "SCREEN_OT_animation_cancel";
|
2009-10-22 23:22:05 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = screen_animation_cancel_exec;
|
2009-10-22 23:22:05 +00:00
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->poll = ED_operator_screenactive;
|
2011-03-27 08:31:10 +00:00
|
|
|
|
2011-09-19 12:26:20 +00:00
|
|
|
RNA_def_boolean(ot->srna, "restore_frame", TRUE, "Restore Frame", "Restore the frame when animation was initialized");
|
2009-10-22 23:22:05 +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
|
|
|
/* ************** border select operator (template) ***************************** */
|
2008-11-19 16:28:11 +00:00
|
|
|
|
|
|
|
/* operator state vars used: (added by default WM callbacks)
|
2012-03-03 16:31:46 +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
|
2009-12-10 09:25:30 +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
|
|
|
#if 0
|
2013-07-28 17:06:31 +00:00
|
|
|
static int border_select_exec(bContext *C, wmOperator *op)
|
2008-11-19 16:28:11 +00:00
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
int event_type = RNA_int_get(op->ptr, "event_type");
|
2008-11-24 10:45:36 +00:00
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
if (event_type == LEFTMOUSE)
|
2008-11-24 10:45:36 +00:00
|
|
|
printf("border select do select\n");
|
2012-05-08 11:48:19 +00:00
|
|
|
else if (event_type == RIGHTMOUSE)
|
2008-11-24 10:45:36 +00:00
|
|
|
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 */
|
2013-01-27 07:23:58 +00:00
|
|
|
ot->name = "Border Select";
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->idname = "SCREEN_OT_border_select";
|
2008-11-19 16:28:11 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2013-07-28 17:06:31 +00:00
|
|
|
ot->exec = border_select_exec;
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->invoke = WM_border_select_invoke;
|
|
|
|
ot->modal = WM_border_select_modal;
|
|
|
|
ot->cancel = WM_border_select_cancel;
|
2008-11-19 16:28:11 +00:00
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
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);
|
2012-08-08 20:38:55 +00:00
|
|
|
WM_operator_properties_border(ot);
|
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-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);
|
2012-05-08 11:48:19 +00:00
|
|
|
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 */
|
2012-05-08 11:48:19 +00:00
|
|
|
for (sa = screen->areabase.first; sa; sa = sa->next) {
|
2009-12-08 07:12:06 +00:00
|
|
|
if (sa->full) break;
|
|
|
|
}
|
|
|
|
if (!sa) {
|
2011-09-19 12:26:20 +00:00
|
|
|
BKE_report(op->reports, RPT_ERROR, "No fullscreen areas were found");
|
2009-12-08 07:12:06 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
ED_screen_full_restore(C, sa);
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void SCREEN_OT_back_to_previous(struct wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
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";
|
2009-12-08 07:12:06 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = fullscreen_back_exec;
|
|
|
|
ot->poll = ED_operator_screenactive;
|
2009-12-08 07:12:06 +00:00
|
|
|
}
|
|
|
|
|
2009-07-24 12:43:59 +00:00
|
|
|
/* *********** show user pref window ****** */
|
|
|
|
|
2013-03-13 09:03:46 +00:00
|
|
|
static int userpref_show_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
|
2009-07-24 12:43:59 +00:00
|
|
|
{
|
2012-12-14 16:10:46 +00:00
|
|
|
wmWindow *win = CTX_wm_window(C);
|
2009-07-24 12:43:59 +00:00
|
|
|
rcti rect;
|
|
|
|
int sizex, sizey;
|
|
|
|
|
2013-02-28 16:37:19 +00:00
|
|
|
sizex = 800 * UI_DPI_WINDOW_FAC;
|
|
|
|
sizey = 480 * UI_DPI_WINDOW_FAC;
|
2009-07-24 12:43:59 +00:00
|
|
|
|
|
|
|
/* some magic to calculate postition */
|
2012-12-14 15:09:59 +00:00
|
|
|
/* pixelsize: mouse coords are in U.pixelsize units :/ */
|
2012-12-14 16:10:46 +00:00
|
|
|
rect.xmin = (event->x / U.pixelsize) + win->posx - sizex / 2;
|
|
|
|
rect.ymin = (event->y / U.pixelsize) + win->posy - sizey / 2;
|
2012-03-24 02:51:46 +00:00
|
|
|
rect.xmax = rect.xmin + sizex;
|
|
|
|
rect.ymax = rect.ymin + sizey;
|
2009-07-24 12:43:59 +00:00
|
|
|
|
|
|
|
/* changes context! */
|
|
|
|
WM_window_open_temp(C, &rect, WM_WINDOW_USERPREFS);
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void SCREEN_OT_userpref_show(struct wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2013-02-28 16:37:19 +00:00
|
|
|
ot->name = "Show User Preferences";
|
|
|
|
ot->description = "Show user preferences";
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->idname = "SCREEN_OT_userpref_show";
|
2009-07-24 12:43:59 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->invoke = userpref_show_invoke;
|
|
|
|
ot->poll = ED_operator_screenactive;
|
2009-07-10 16:55:49 +00:00
|
|
|
}
|
|
|
|
|
2009-08-15 16:43:03 +00:00
|
|
|
/********************* new screen operator *********************/
|
2009-07-10 16:55:49 +00:00
|
|
|
|
2010-10-14 12:24:08 +00:00
|
|
|
static int screen_new_exec(bContext *C, wmOperator *UNUSED(op))
|
2009-08-15 16:43:03 +00:00
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
wmWindow *win = CTX_wm_window(C);
|
|
|
|
bScreen *sc = CTX_wm_screen(C);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2012-05-08 11:48:19 +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;
|
|
|
|
}
|
|
|
|
|
2011-02-14 17:55:27 +00:00
|
|
|
static void SCREEN_OT_new(wmOperatorType *ot)
|
2009-08-15 16:43:03 +00:00
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "New Screen";
|
|
|
|
ot->description = "Add a new screen";
|
|
|
|
ot->idname = "SCREEN_OT_new";
|
2009-08-15 16:43:03 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = screen_new_exec;
|
|
|
|
ot->poll = WM_operator_winactive;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-08-15 16:43:03 +00:00
|
|
|
/* flags */
|
2012-05-08 11:48:19 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2009-08-15 16:43:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/********************* delete screen operator *********************/
|
|
|
|
|
2010-10-14 12:24:08 +00:00
|
|
|
static int screen_delete_exec(bContext *C, wmOperator *UNUSED(op))
|
2009-08-15 16:43:03 +00:00
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
bScreen *sc = CTX_wm_screen(C);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2012-05-08 11:48:19 +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;
|
|
|
|
}
|
|
|
|
|
2011-02-14 17:55:27 +00:00
|
|
|
static void SCREEN_OT_delete(wmOperatorType *ot)
|
2009-08-15 16:43:03 +00:00
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-10-20 20:20:02 +00:00
|
|
|
ot->name = "Delete Screen"; /* was scene */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->description = "Delete active screen";
|
|
|
|
ot->idname = "SCREEN_OT_delete";
|
2009-08-15 16:43:03 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = screen_delete_exec;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-08-15 16:43:03 +00:00
|
|
|
/* flags */
|
2012-05-08 11:48:19 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2009-08-15 16:43:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/********************* new scene operator *********************/
|
|
|
|
|
|
|
|
static int scene_new_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
Scene *newscene, *scene = CTX_data_scene(C);
|
|
|
|
Main *bmain = CTX_data_main(C);
|
|
|
|
int type = RNA_enum_get(op->ptr, "type");
|
2011-03-31 14:33:59 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (type == SCE_COPY_NEW) {
|
2013-03-25 08:29:06 +00:00
|
|
|
newscene = BKE_scene_add(bmain, DATA_("Scene"));
|
2011-03-31 14:33:59 +00:00
|
|
|
}
|
|
|
|
else { /* different kinds of copying */
|
2012-05-08 11:48:19 +00:00
|
|
|
newscene = BKE_scene_copy(scene, type);
|
2011-03-31 14:33:59 +00:00
|
|
|
|
|
|
|
/* these can't be handled in blenkernel curently, so do them here */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (type == SCE_COPY_LINK_DATA) {
|
2013-04-24 23:09:25 +00:00
|
|
|
ED_object_single_users(bmain, newscene, false, true);
|
2011-03-31 14:33:59 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (type == SCE_COPY_FULL) {
|
2013-04-24 23:09:25 +00:00
|
|
|
ED_object_single_users(bmain, newscene, true, true);
|
2011-03-31 14:33:59 +00:00
|
|
|
}
|
|
|
|
}
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2012-03-07 16:43:42 +00:00
|
|
|
ED_screen_set_scene(C, CTX_wm_screen(C), newscene);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_SCENEBROWSE, newscene);
|
2011-03-31 17:14:31 +00:00
|
|
|
|
2009-08-15 16:43:03 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
2011-02-14 17:55:27 +00:00
|
|
|
static void SCENE_OT_new(wmOperatorType *ot)
|
2009-08-15 16:43:03 +00:00
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
static EnumPropertyItem type_items[] = {
|
2011-03-31 14:33:59 +00:00
|
|
|
{SCE_COPY_NEW, "NEW", 0, "New", "Add new scene"},
|
|
|
|
{SCE_COPY_EMPTY, "EMPTY", 0, "Copy Settings", "Make a copy without any objects"},
|
2010-02-11 02:03:18 +00:00
|
|
|
{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"},
|
2009-08-15 16:43:03 +00:00
|
|
|
{0, NULL, 0, NULL, NULL}};
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-08-15 16:43:03 +00:00
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "New Scene";
|
|
|
|
ot->description = "Add new scene by type";
|
|
|
|
ot->idname = "SCENE_OT_new";
|
2009-08-15 16:43:03 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
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 */
|
2012-05-08 11:48:19 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-08-15 16:43:03 +00:00
|
|
|
/* properties */
|
2012-03-22 07:26:09 +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 *********************/
|
|
|
|
|
2010-10-14 12:24:08 +00:00
|
|
|
static int scene_delete_exec(bContext *C, wmOperator *UNUSED(op))
|
2009-08-15 16:43:03 +00:00
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
2012-01-06 17:32:20 +00:00
|
|
|
|
|
|
|
ED_screen_delete_scene(C, scene);
|
|
|
|
|
2012-03-31 00:59:17 +00:00
|
|
|
if (G.debug & G_DEBUG)
|
2012-01-06 17:32:20 +00:00
|
|
|
printf("scene delete %p\n", scene);
|
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
WM_event_add_notifier(C, NC_SCENE | NA_REMOVED, scene);
|
2012-01-06 17:32:20 +00:00
|
|
|
|
2009-08-15 16:43:03 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
2011-02-14 17:55:27 +00:00
|
|
|
static void SCENE_OT_delete(wmOperatorType *ot)
|
2009-08-15 16:43:03 +00:00
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Delete Scene";
|
|
|
|
ot->description = "Delete active scene";
|
|
|
|
ot->idname = "SCENE_OT_delete";
|
2009-08-15 16:43:03 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = scene_delete_exec;
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-08-15 16:43:03 +00:00
|
|
|
/* flags */
|
2012-05-08 11:48:19 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2009-08-15 16:43:03 +00:00
|
|
|
}
|
2009-02-04 17:40:50 +00:00
|
|
|
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
/* ***************** region alpha blending ***************** */
|
|
|
|
|
2013-02-11 00:49:00 +00:00
|
|
|
/* implementation note: a disappearing region needs at least 1 last draw with 100% backbuffer
|
2013-02-02 04:58:03 +00:00
|
|
|
* texture over it- then triple buffer will clear it entirely.
|
|
|
|
* This because flag RGN_HIDDEN is set in end - region doesnt draw at all then */
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
|
|
|
|
typedef struct RegionAlphaInfo {
|
|
|
|
ScrArea *sa;
|
|
|
|
ARegion *ar, *child_ar; /* other region */
|
|
|
|
int hidden;
|
|
|
|
} RegionAlphaInfo;
|
|
|
|
|
2012-12-13 12:17:57 +00:00
|
|
|
#define TIMEOUT 0.2f
|
2012-12-13 00:47:47 +00:00
|
|
|
#define TIMESTEP 0.04f
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
|
|
|
|
float ED_region_blend_factor(ARegion *ar)
|
|
|
|
{
|
|
|
|
/* check parent too */
|
2012-12-13 01:00:21 +00:00
|
|
|
if (ar->regiontimer == NULL && (ar->alignment & RGN_SPLIT_PREV) && ar->prev) {
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
ar = ar->prev;
|
2012-12-13 01:00:21 +00:00
|
|
|
}
|
|
|
|
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
if (ar->regiontimer) {
|
|
|
|
RegionAlphaInfo *rgi = ar->regiontimer->customdata;
|
|
|
|
float alpha;
|
2012-12-13 01:00:21 +00:00
|
|
|
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
alpha = (float)ar->regiontimer->duration / TIMEOUT;
|
|
|
|
/* makes sure the blend out works 100% - without area redraws */
|
2012-12-13 00:47:47 +00:00
|
|
|
if (rgi->hidden) alpha = 0.9f - TIMESTEP - alpha;
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
|
|
|
|
CLAMP(alpha, 0.0f, 1.0f);
|
|
|
|
return alpha;
|
|
|
|
}
|
|
|
|
return 1.0f;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* assumes region has running region-blend timer */
|
|
|
|
static void region_blend_end(bContext *C, ARegion *ar, int is_running)
|
|
|
|
{
|
|
|
|
RegionAlphaInfo *rgi = ar->regiontimer->customdata;
|
|
|
|
|
|
|
|
/* always send redraw */
|
|
|
|
ED_region_tag_redraw(ar);
|
|
|
|
if (rgi->child_ar)
|
|
|
|
ED_region_tag_redraw(rgi->child_ar);
|
|
|
|
|
|
|
|
/* if running timer was hiding, the flag toggle went wrong */
|
|
|
|
if (is_running) {
|
|
|
|
if (rgi->hidden)
|
|
|
|
rgi->ar->flag &= ~RGN_FLAG_HIDDEN;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (rgi->hidden) {
|
|
|
|
rgi->ar->flag |= rgi->hidden;
|
|
|
|
ED_area_initialize(CTX_wm_manager(C), CTX_wm_window(C), rgi->sa);
|
|
|
|
}
|
|
|
|
/* area decoration needs redraw in end */
|
|
|
|
ED_area_tag_redraw(rgi->sa);
|
|
|
|
}
|
|
|
|
WM_event_remove_timer(CTX_wm_manager(C), NULL, ar->regiontimer); /* frees rgi */
|
|
|
|
ar->regiontimer = NULL;
|
|
|
|
|
|
|
|
}
|
|
|
|
/* assumes that *ar itself is not a splitted version from previous region */
|
|
|
|
void region_blend_start(bContext *C, ScrArea *sa, ARegion *ar)
|
|
|
|
{
|
|
|
|
wmWindowManager *wm = CTX_wm_manager(C);
|
|
|
|
wmWindow *win = CTX_wm_window(C);
|
|
|
|
RegionAlphaInfo *rgi;
|
|
|
|
|
|
|
|
/* end running timer */
|
|
|
|
if (ar->regiontimer) {
|
|
|
|
|
|
|
|
region_blend_end(C, ar, 1);
|
|
|
|
}
|
|
|
|
rgi = MEM_callocN(sizeof(RegionAlphaInfo), "RegionAlphaInfo");
|
|
|
|
|
|
|
|
rgi->hidden = ar->flag & RGN_FLAG_HIDDEN;
|
|
|
|
rgi->sa = sa;
|
|
|
|
rgi->ar = ar;
|
|
|
|
ar->flag &= ~RGN_FLAG_HIDDEN;
|
|
|
|
|
|
|
|
/* blend in, reinitialize regions because it got unhidden */
|
|
|
|
if (rgi->hidden == 0)
|
|
|
|
ED_area_initialize(wm, win, sa);
|
|
|
|
else
|
|
|
|
WM_event_remove_handlers(C, &ar->handlers);
|
|
|
|
|
2012-12-13 01:00:21 +00:00
|
|
|
if (ar->next) {
|
|
|
|
if (ar->next->alignment & RGN_SPLIT_PREV) {
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
rgi->child_ar = ar->next;
|
2012-12-13 01:00:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
/* new timer */
|
|
|
|
ar->regiontimer = WM_event_add_timer(wm, win, TIMERREGION, TIMESTEP);
|
|
|
|
ar->regiontimer->customdata = rgi;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* timer runs in win->handlers, so it cannot use context to find area/region */
|
2013-03-13 09:03:46 +00:00
|
|
|
static int region_blend_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
{
|
|
|
|
RegionAlphaInfo *rgi;
|
|
|
|
wmTimer *timer = event->customdata;
|
|
|
|
|
|
|
|
/* event type is TIMERREGION, but we better check */
|
|
|
|
if (event->type != TIMERREGION || timer == NULL)
|
|
|
|
return OPERATOR_PASS_THROUGH;
|
|
|
|
|
|
|
|
rgi = timer->customdata;
|
|
|
|
|
|
|
|
/* always send redraws */
|
|
|
|
ED_region_tag_redraw(rgi->ar);
|
|
|
|
if (rgi->child_ar)
|
|
|
|
ED_region_tag_redraw(rgi->child_ar);
|
|
|
|
|
|
|
|
/* end timer? */
|
2012-12-13 00:47:47 +00:00
|
|
|
if (rgi->ar->regiontimer->duration > (double)TIMEOUT) {
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
region_blend_end(C, rgi->ar, 0);
|
|
|
|
return (OPERATOR_FINISHED | OPERATOR_PASS_THROUGH);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (OPERATOR_FINISHED | OPERATOR_PASS_THROUGH);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void SCREEN_OT_region_blend(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
|
|
|
ot->name = "Region Alpha";
|
|
|
|
ot->idname = "SCREEN_OT_region_blend";
|
|
|
|
ot->description = "Blend in and out overlapping region";
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
ot->invoke = region_blend_invoke;
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
ot->flag = 0;
|
|
|
|
|
|
|
|
/* properties */
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-19 16:28:11 +00:00
|
|
|
/* **************** Assigning operatortypes to global list, adding handlers **************** */
|
|
|
|
|
2010-12-17 19:05:34 +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 */
|
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);
|
2011-03-02 14:09:54 +00:00
|
|
|
WM_operatortype_append(SCREEN_OT_area_options);
|
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);
|
2012-10-25 13:08:47 +00:00
|
|
|
WM_operatortype_append(SCREEN_OT_header_toggle_menus);
|
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);
|
2011-01-06 17:54:17 +00:00
|
|
|
WM_operatortype_append(SCREEN_OT_spacedata_cleanup);
|
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);
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
WM_operatortype_append(SCREEN_OT_region_blend);
|
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-22 23:22:05 +00:00
|
|
|
WM_operatortype_append(SCREEN_OT_animation_cancel);
|
2008-12-21 19:58:25 +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);
|
2011-02-22 02:42:19 +00:00
|
|
|
WM_operatortype_append(ED_OT_undo_push);
|
2012-10-21 05:46:41 +00:00
|
|
|
WM_operatortype_append(ED_OT_redo);
|
Code holiday commit:
- fix: user pref, window title was reset to 'Blender' on tab usage
- Undo history menu back:
- name "Undo History"
- hotkey alt+ctrl+z (alt+apple+z for mac)
- works like 2.4x, only for global undo, editmode and particle edit.
- Menu scroll
- for small windows or screens, popup menus now allow to display
all items, using internal scrolling
- works with a timer, scrolling 10 items per second when mouse
is over the top or bottom arrow
- if menu is too big to display, it now draws to top or bottom,
based on largest available space.
- also works for hotkey driven pop up menus.
- User pref "DPI" follows widget/layout size
- widgets & headers now become bigger and smaller, to match
'dpi' font sizes. Works well to match UI to monitor size.
- note that icons can get fuzzy, we need better mipmaps for it
2011-06-04 17:03:46 +00:00
|
|
|
WM_operatortype_append(ED_OT_undo_history);
|
2008-11-24 18:59:59 +00:00
|
|
|
|
2008-01-07 18:03:41 +00:00
|
|
|
}
|
|
|
|
|
2009-10-22 23:22:05 +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 ------------------------------------------------ */
|
2012-05-08 11:48:19 +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
|
|
|
}
|
|
|
|
|
2013-03-13 09:03:46 +00:00
|
|
|
static int open_file_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event))
|
2010-12-17 19:05:34 +00:00
|
|
|
{
|
2012-05-08 11:48:19 +00:00
|
|
|
if (drag->type == WM_DRAG_PATH) {
|
|
|
|
if (drag->icon == ICON_FILE_BLEND)
|
2011-04-21 15:53:30 +00:00
|
|
|
return 1;
|
2010-12-17 19:05:34 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void open_file_drop_copy(wmDrag *drag, wmDropBox *drop)
|
|
|
|
{
|
|
|
|
/* copy drag path to properties */
|
|
|
|
RNA_string_set(drop->ptr, "filepath", drag->path);
|
2012-05-08 11:48:19 +00:00
|
|
|
drop->opcontext = WM_OP_EXEC_DEFAULT;
|
2010-12-17 19:05:34 +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 */
|
2009-10-22 23:22:05 +00:00
|
|
|
void ED_keymap_screen(wmKeyConfig *keyconf)
|
2008-01-07 18:03:41 +00:00
|
|
|
{
|
2010-12-17 19:05:34 +00:00
|
|
|
ListBase *lb;
|
2009-10-22 23:22:05 +00:00
|
|
|
wmKeyMap *keymap;
|
2012-01-16 16:12:03 +00:00
|
|
|
wmKeyMapItem *kmi;
|
2009-08-22 00:19:24 +00:00
|
|
|
|
2009-10-22 23:22:05 +00:00
|
|
|
/* Screen Editing ------------------------------------------------ */
|
2012-03-24 02:51:46 +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);
|
2010-04-06 08:11:37 +00:00
|
|
|
RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_actionzone", LEFTMOUSE, KM_PRESS, KM_CTRL, 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);
|
2010-01-26 03:16:14 +00:00
|
|
|
WM_keymap_verify_item(keymap, "SCREEN_OT_area_swap", EVT_ACTIONZONE_AREA, 0, KM_CTRL, 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
|
|
|
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
|
|
|
|
2011-03-02 14:09:54 +00:00
|
|
|
WM_keymap_verify_item(keymap, "SCREEN_OT_area_options", RIGHTMOUSE, KM_PRESS, 0, 0);
|
|
|
|
|
|
|
|
|
2009-11-27 06:24:09 +00:00
|
|
|
/* Header Editing ------------------------------------------------ */
|
2012-03-24 02:51:46 +00:00
|
|
|
keymap = WM_keymap_find(keyconf, "Header", 0, 0);
|
2009-11-27 06:24:09 +00:00
|
|
|
|
|
|
|
WM_keymap_add_item(keymap, "SCREEN_OT_header_toolbox", RIGHTMOUSE, KM_PRESS, 0, 0);
|
|
|
|
|
2009-10-22 23:22:05 +00:00
|
|
|
/* Screen General ------------------------------------------------ */
|
2012-03-24 02:51:46 +00:00
|
|
|
keymap = WM_keymap_find(keyconf, "Screen", 0, 0);
|
2009-10-22 23:22:05 +00:00
|
|
|
|
|
|
|
/* standard timers */
|
|
|
|
WM_keymap_add_item(keymap, "SCREEN_OT_animation_step", TIMER0, KM_ANY, KM_ANY, 0);
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
WM_keymap_add_item(keymap, "SCREEN_OT_region_blend", TIMERREGION, KM_ANY, KM_ANY, 0);
|
2009-10-22 23:22:05 +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
|
|
|
|
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);
|
2008-12-27 11:44:00 +00:00
|
|
|
|
2009-12-10 09:25:30 +00:00
|
|
|
/* tests */
|
2012-05-08 11:48:19 +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-16 17:43:09 +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);
|
2010-06-01 08:15:43 +00:00
|
|
|
WM_keymap_verify_item(keymap, "SCRIPT_OT_reload", F8KEY, KM_PRESS, 0, 0);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-01-28 18:26:47 +00:00
|
|
|
/* files */
|
2009-09-16 17:43:09 +00:00
|
|
|
WM_keymap_add_item(keymap, "FILE_OT_execute", RETKEY, KM_PRESS, 0, 0);
|
2009-10-22 23:22:05 +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);
|
2012-05-08 11:48:19 +00:00
|
|
|
WM_keymap_add_item(keymap, "ED_OT_redo", ZKEY, KM_PRESS, KM_SHIFT | KM_OSKEY, 0);
|
|
|
|
WM_keymap_add_item(keymap, "ED_OT_undo_history", ZKEY, KM_PRESS, KM_ALT | KM_OSKEY, 0);
|
2009-12-10 09:25:30 +00:00
|
|
|
#endif
|
2009-09-16 17:43:09 +00:00
|
|
|
WM_keymap_add_item(keymap, "ED_OT_undo", ZKEY, KM_PRESS, KM_CTRL, 0);
|
2012-05-08 11:48:19 +00:00
|
|
|
WM_keymap_add_item(keymap, "ED_OT_redo", ZKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
|
|
|
|
WM_keymap_add_item(keymap, "ED_OT_undo_history", ZKEY, KM_PRESS, KM_ALT | KM_CTRL, 0);
|
2009-09-16 17:43:09 +00:00
|
|
|
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2009-02-04 17:40:50 +00:00
|
|
|
/* render */
|
2010-03-08 16:36:53 +00:00
|
|
|
WM_keymap_add_item(keymap, "RENDER_OT_render", F12KEY, KM_PRESS, 0, 0);
|
2012-01-16 16:12:03 +00:00
|
|
|
kmi = WM_keymap_add_item(keymap, "RENDER_OT_render", F12KEY, KM_PRESS, KM_CTRL, 0);
|
|
|
|
RNA_boolean_set(kmi->ptr, "animation", TRUE);
|
2010-03-08 16:36:53 +00:00
|
|
|
WM_keymap_add_item(keymap, "RENDER_OT_view_cancel", ESCKEY, KM_PRESS, 0, 0);
|
|
|
|
WM_keymap_add_item(keymap, "RENDER_OT_view_show", F11KEY, KM_PRESS, 0, 0);
|
2010-03-16 05:04:56 +00:00
|
|
|
WM_keymap_add_item(keymap, "RENDER_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-08-22 00:19:24 +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
|
2012-05-08 11:48:19 +00:00
|
|
|
WM_keymap_add_item(keymap, "SCREEN_OT_userpref_show", UKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
|
2009-09-16 17:43:09 +00:00
|
|
|
|
2009-07-24 12:43:59 +00:00
|
|
|
|
2009-07-19 05:20:30 +00:00
|
|
|
/* Anim Playback ------------------------------------------------ */
|
2012-03-24 02:51:46 +00:00
|
|
|
keymap = WM_keymap_find(keyconf, "Frames", 0, 0);
|
2009-07-19 05:20:30 +00:00
|
|
|
|
|
|
|
/* frame offsets */
|
2011-08-22 01:22:14 +00:00
|
|
|
RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_offset", UPARROWKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "delta", 10);
|
|
|
|
RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_offset", DOWNARROWKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "delta", -10);
|
2009-01-23 14:43:25 +00:00
|
|
|
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);
|
|
|
|
|
2012-05-08 11:48:19 +00:00
|
|
|
RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_jump", UPARROWKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0)->ptr, "end", TRUE);
|
|
|
|
RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_jump", DOWNARROWKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0)->ptr, "end", FALSE);
|
2012-01-16 16:12:03 +00:00
|
|
|
RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_jump", RIGHTARROWKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "end", TRUE);
|
|
|
|
RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_jump", LEFTARROWKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "end", FALSE);
|
2009-08-02 07:08:51 +00:00
|
|
|
|
2012-03-23 10:18:45 +00:00
|
|
|
kmi = WM_keymap_add_item(keymap, "SCREEN_OT_keyframe_jump", UPARROWKEY, KM_PRESS, 0, 0);
|
|
|
|
RNA_boolean_set(kmi->ptr, "next", TRUE);
|
|
|
|
|
|
|
|
kmi = WM_keymap_add_item(keymap, "SCREEN_OT_keyframe_jump", DOWNARROWKEY, KM_PRESS, 0, 0);
|
|
|
|
RNA_boolean_set(kmi->ptr, "next", FALSE);
|
2009-07-24 13:34:45 +00:00
|
|
|
|
2012-03-23 10:18:45 +00:00
|
|
|
kmi = WM_keymap_add_item(keymap, "SCREEN_OT_keyframe_jump", MEDIALAST, KM_PRESS, 0, 0);
|
|
|
|
RNA_boolean_set(kmi->ptr, "next", TRUE);
|
|
|
|
|
2012-01-16 16:12:03 +00:00
|
|
|
kmi = WM_keymap_add_item(keymap, "SCREEN_OT_keyframe_jump", MEDIAFIRST, KM_PRESS, 0, 0);
|
|
|
|
RNA_boolean_set(kmi->ptr, "next", FALSE);
|
2011-02-27 01:53:05 +00:00
|
|
|
|
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);
|
2012-05-08 11:48:19 +00:00
|
|
|
RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", AKEY, KM_PRESS, KM_ALT | KM_SHIFT, 0)->ptr, "reverse", TRUE);
|
2009-10-22 23:22:05 +00:00
|
|
|
WM_keymap_add_item(keymap, "SCREEN_OT_animation_cancel", ESCKEY, KM_PRESS, 0, 0);
|
2009-12-10 09:25:30 +00:00
|
|
|
|
2011-02-27 01:53:05 +00:00
|
|
|
WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", MEDIAPLAY, KM_PRESS, 0, 0);
|
|
|
|
WM_keymap_add_item(keymap, "SCREEN_OT_animation_cancel", MEDIASTOP, KM_PRESS, 0, 0);
|
|
|
|
|
2010-07-18 14:46:52 +00:00
|
|
|
/* Alternative keys for animation and sequencer playing */
|
2012-10-20 20:20:02 +00:00
|
|
|
#if 0 /* XXX: disabled for restoring later... bad implementation */
|
2012-03-24 02:51:46 +00:00
|
|
|
keymap = WM_keymap_find(keyconf, "Frames", 0, 0);
|
2010-07-18 14:46:52 +00:00
|
|
|
kmi = WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", RIGHTARROWKEY, KM_PRESS, KM_ALT, 0);
|
2012-05-08 11:48:19 +00:00
|
|
|
RNA_boolean_set(kmi->ptr, "cycle_speed", TRUE);
|
2010-07-18 14:46:52 +00:00
|
|
|
|
|
|
|
kmi = WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", LEFTARROWKEY, KM_PRESS, KM_ALT, 0);
|
2012-05-08 11:48:19 +00:00
|
|
|
RNA_boolean_set(kmi->ptr, "reverse", TRUE);
|
|
|
|
RNA_boolean_set(kmi->ptr, "cycle_speed", TRUE);
|
2010-07-18 14:46:52 +00:00
|
|
|
|
|
|
|
WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", DOWNARROWKEY, KM_PRESS, KM_ALT, 0);
|
2010-07-19 11:25:23 +00:00
|
|
|
#endif
|
2010-07-18 14:46:52 +00:00
|
|
|
|
2010-12-17 19:05:34 +00:00
|
|
|
/* dropbox for entire window */
|
2012-05-08 11:48:19 +00:00
|
|
|
lb = WM_dropboxmap_find("Window", 0, 0);
|
2010-12-17 19:05:34 +00:00
|
|
|
WM_dropbox_add(lb, "WM_OT_open_mainfile", open_file_drop_poll, open_file_drop_copy);
|
|
|
|
|
2009-10-22 23:22:05 +00:00
|
|
|
keymap_modal_set(keyconf);
|
2008-01-07 18:03:41 +00:00
|
|
|
}
|
|
|
|
|