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.
243 lines
7.0 KiB
C
243 lines
7.0 KiB
C
/**
|
|
* blenlib/BKE_screen.h (mar-2001 nzc)
|
|
*
|
|
* $Id$
|
|
*
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation; either version 2
|
|
* of the License, or (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
*
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
* All rights reserved.
|
|
*
|
|
* The Original Code is: all of this file.
|
|
*
|
|
* Contributor(s): none yet.
|
|
*
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
*/
|
|
#ifndef BKE_SCREEN_H
|
|
#define BKE_SCREEN_H
|
|
|
|
struct ARegion;
|
|
struct bContext;
|
|
struct bContextDataResult;
|
|
struct bScreen;
|
|
struct ListBase;
|
|
struct Panel;
|
|
struct Header;
|
|
struct Menu;
|
|
struct ScrArea;
|
|
struct SpaceType;
|
|
struct Scene;
|
|
struct wmNotifier;
|
|
struct wmWindow;
|
|
struct wmWindowManager;
|
|
struct wmKeyConfig;
|
|
struct uiLayout;
|
|
struct uiMenuItem;
|
|
|
|
#include "RNA_types.h"
|
|
|
|
/* spacetype has everything stored to get an editor working, it gets initialized via
|
|
ED_spacetypes_init() in editors/area/spacetypes.c */
|
|
/* an editor in Blender is a combined ScrArea + SpaceType + SpaceData */
|
|
|
|
#define BKE_ST_MAXNAME 64
|
|
|
|
typedef struct SpaceType {
|
|
struct SpaceType *next, *prev;
|
|
|
|
char name[BKE_ST_MAXNAME]; /* for menus */
|
|
int spaceid; /* unique space identifier */
|
|
int iconid; /* icon lookup for menus */
|
|
|
|
/* initial allocation, after this WM will call init() too */
|
|
struct SpaceLink *(*new)(const struct bContext *C);
|
|
/* not free spacelink itself */
|
|
void (*free)(struct SpaceLink *);
|
|
|
|
/* init is to cope with file load, screen (size) changes, check handlers */
|
|
void (*init)(struct wmWindowManager *, struct ScrArea *);
|
|
/* Listeners can react to bContext changes */
|
|
void (*listener)(struct ScrArea *, struct wmNotifier *);
|
|
|
|
/* refresh context, called after filereads, ED_area_tag_refresh() */
|
|
void (*refresh)(const struct bContext *, struct ScrArea *);
|
|
|
|
/* after a spacedata copy, an init should result in exact same situation */
|
|
struct SpaceLink *(*duplicate)(struct SpaceLink *);
|
|
|
|
/* register operator types on startup */
|
|
void (*operatortypes)(void);
|
|
/* add default items to WM keymap */
|
|
void (*keymap)(struct wmKeyConfig *);
|
|
/* on startup, define dropboxes for spacetype+regions */
|
|
void (*dropboxes)(void);
|
|
|
|
/* return context data */
|
|
int (*context)(const struct bContext *, const char*, struct bContextDataResult *);
|
|
|
|
/* region type definitions */
|
|
ListBase regiontypes;
|
|
|
|
/* tool shelf definitions */
|
|
ListBase toolshelf;
|
|
|
|
/* read and write... */
|
|
|
|
/* default keymaps to add */
|
|
int keymapflag;
|
|
|
|
} SpaceType;
|
|
|
|
/* region types are also defined using spacetypes_init, via a callback */
|
|
|
|
typedef struct ARegionType {
|
|
struct ARegionType *next, *prev;
|
|
|
|
int regionid; /* unique identifier within this space */
|
|
|
|
/* add handlers, stuff you only do once or on area/region type/size changes */
|
|
void (*init)(struct wmWindowManager *, struct ARegion *);
|
|
/* draw entirely, view changes should be handled here */
|
|
void (*draw)(const struct bContext *, struct ARegion *);
|
|
/* contextual changes should be handled here */
|
|
void (*listener)(struct ARegion *, struct wmNotifier *);
|
|
|
|
void (*free)(struct ARegion *);
|
|
|
|
/* split region, copy data optionally */
|
|
void *(*duplicate)(void *);
|
|
|
|
|
|
/* register operator types on startup */
|
|
void (*operatortypes)(void);
|
|
/* add own items to keymap */
|
|
void (*keymap)(struct wmKeyConfig *);
|
|
/* allows default cursor per region */
|
|
void (*cursor)(struct wmWindow *, struct ScrArea *, struct ARegion *ar);
|
|
|
|
/* return context data */
|
|
int (*context)(const struct bContext *, const char *, struct bContextDataResult *);
|
|
|
|
/* custom drawing callbacks */
|
|
ListBase drawcalls;
|
|
|
|
/* panels type definitions */
|
|
ListBase paneltypes;
|
|
|
|
/* header type definitions */
|
|
ListBase headertypes;
|
|
|
|
/* hardcoded constraints, smaller than these values region is not visible */
|
|
int minsizex, minsizey;
|
|
/* when new region opens (region prefsizex/y are zero then */
|
|
int prefsizex, prefsizey;
|
|
/* default keymaps to add */
|
|
int keymapflag;
|
|
} ARegionType;
|
|
|
|
/* panel types */
|
|
|
|
typedef struct PanelType {
|
|
struct PanelType *next, *prev;
|
|
|
|
char idname[BKE_ST_MAXNAME]; /* unique name */
|
|
char label[BKE_ST_MAXNAME]; /* for panel header */
|
|
char context[BKE_ST_MAXNAME]; /* for buttons window */
|
|
int space_type;
|
|
int region_type;
|
|
|
|
int flag;
|
|
|
|
/* verify if the panel should draw or not */
|
|
int (*poll)(const struct bContext *, struct PanelType *);
|
|
/* draw header (optional) */
|
|
void (*draw_header)(const struct bContext *, struct Panel *);
|
|
/* draw entirely, view changes should be handled here */
|
|
void (*draw)(const struct bContext *, struct Panel *);
|
|
|
|
/* RNA integration */
|
|
ExtensionRNA ext;
|
|
} PanelType;
|
|
|
|
/* header types */
|
|
|
|
typedef struct HeaderType {
|
|
struct HeaderType *next, *prev;
|
|
|
|
char idname[BKE_ST_MAXNAME]; /* unique name */
|
|
int space_type;
|
|
|
|
/* draw entirely, view changes should be handled here */
|
|
void (*draw)(const struct bContext *, struct Header *);
|
|
|
|
/* RNA integration */
|
|
ExtensionRNA ext;
|
|
} HeaderType;
|
|
|
|
typedef struct Header {
|
|
struct HeaderType *type; /* runtime */
|
|
struct uiLayout *layout; /* runtime for drawing */
|
|
} Header;
|
|
|
|
|
|
/* menu types */
|
|
|
|
typedef struct MenuType {
|
|
struct MenuType *next, *prev;
|
|
|
|
char idname[BKE_ST_MAXNAME]; /* unique name */
|
|
char label[BKE_ST_MAXNAME]; /* for button text */
|
|
|
|
/* verify if the menu should draw or not */
|
|
int (*poll)(const struct bContext *, struct MenuType *);
|
|
/* draw entirely, view changes should be handled here */
|
|
void (*draw)(const struct bContext *, struct Menu *);
|
|
|
|
/* RNA integration */
|
|
ExtensionRNA ext;
|
|
} MenuType;
|
|
|
|
typedef struct Menu {
|
|
struct MenuType *type; /* runtime */
|
|
struct uiLayout *layout; /* runtime for drawing */
|
|
} Menu;
|
|
|
|
/* spacetypes */
|
|
struct SpaceType *BKE_spacetype_from_id(int spaceid);
|
|
struct ARegionType *BKE_regiontype_from_id(struct SpaceType *st, int regionid);
|
|
const struct ListBase *BKE_spacetypes_list(void);
|
|
void BKE_spacetype_register(struct SpaceType *st);
|
|
void BKE_spacetypes_free(void); /* only for quitting blender */
|
|
|
|
/* spacedata */
|
|
void BKE_spacedata_freelist(ListBase *lb);
|
|
void BKE_spacedata_copylist(ListBase *lb1, ListBase *lb2);
|
|
void BKE_spacedata_copyfirst(ListBase *lb1, ListBase *lb2);
|
|
|
|
/* area/regions */
|
|
struct ARegion *BKE_area_region_copy(struct SpaceType *st, struct ARegion *ar);
|
|
void BKE_area_region_free(struct SpaceType *st, struct ARegion *ar);
|
|
void BKE_screen_area_free(struct ScrArea *sa);
|
|
|
|
/* screen */
|
|
void free_screen(struct bScreen *sc);
|
|
unsigned int BKE_screen_visible_layers(struct bScreen *screen, struct Scene *scene);
|
|
|
|
#endif
|
|
|