diff options
author | Ton Roosendaal <ton@blender.org> | 2010-01-26 21:18:21 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2010-01-26 21:18:21 +0300 |
commit | b119ce5fcc91466c6aeb1232e8bf4dca401adaed (patch) | |
tree | 1e3e7d0fde9aaaf1d4f622c518795c3aa9a366b0 /source/blender/editors/space_outliner | |
parent | 722f57ca75a7c4fb77e07d9ee43d5ea79c02c04b (diff) |
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.
Diffstat (limited to 'source/blender/editors/space_outliner')
-rw-r--r-- | source/blender/editors/space_outliner/outliner.c | 149 | ||||
-rw-r--r-- | source/blender/editors/space_outliner/space_outliner.c | 2 |
2 files changed, 97 insertions, 54 deletions
diff --git a/source/blender/editors/space_outliner/outliner.c b/source/blender/editors/space_outliner/outliner.c index 84573d44a1d..5048c12c095 100644 --- a/source/blender/editors/space_outliner/outliner.c +++ b/source/blender/editors/space_outliner/outliner.c @@ -140,7 +140,7 @@ static void error() {} /* ******************** PROTOTYPES ***************** */ -static void outliner_draw_tree_element(bContext *C, Scene *scene, ARegion *ar, SpaceOops *soops, TreeElement *te, int startx, int *starty); +static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene, ARegion *ar, SpaceOops *soops, TreeElement *te, int startx, int *starty); static void outliner_do_object_operation(bContext *C, Scene *scene, SpaceOops *soops, ListBase *lb, void (*operation_cb)(bContext *C, Scene *scene, TreeElement *, TreeStoreElem *, TreeStoreElem *)); @@ -4087,8 +4087,39 @@ void OUTLINER_OT_keyingset_remove_selected(wmOperatorType *ot) /* ***************** DRAW *************** */ -static void tselem_draw_icon(float x, float y, TreeStoreElem *tselem, TreeElement *te) +/* make function calls a bit compacter */ +struct DrawIconArg { + uiBlock *block; + ID *id; + int xmax, x, y; + float alpha; +}; + +static void tselem_draw_icon_uibut(struct DrawIconArg *arg, int icon) +{ + /* restrict collumn clip... it has been coded by simply overdrawing, doesnt work for buttons */ + if(arg->x >= arg->xmax) + UI_icon_draw(arg->x, arg->y, icon); + else { + uiBut *but= uiDefIconBut(arg->block, LABEL, 0, icon, arg->x-4, arg->y, ICON_DEFAULT_WIDTH, ICON_DEFAULT_WIDTH, NULL, 0.0, 0.0, 1.0, arg->alpha, ""); + if(arg->id) + uiButSetDragID(but, arg->id); + } + +} + +static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeStoreElem *tselem, TreeElement *te, float alpha) { + struct DrawIconArg arg; + + /* make function calls a bit compacter */ + arg.block= block; + arg.id= tselem->id; + arg.xmax= xmax; + arg.x= x; + arg.y= y; + arg.alpha= alpha; + if(tselem->type) { switch( tselem->type) { case TSE_ANIM_DATA: @@ -4219,7 +4250,12 @@ static void tselem_draw_icon(float x, float y, TreeStoreElem *tselem, TreeElemen UI_icon_draw(x, y, ICON_OBJECT_DATA); break; case TSE_RNA_STRUCT: - UI_icon_draw(x, y, RNA_struct_ui_icon(te->rnaptr.type)); + if(RNA_struct_is_ID(te->rnaptr.type)) { + arg.id= (ID *)te->rnaptr.data; + tselem_draw_icon_uibut(&arg, RNA_struct_ui_icon(te->rnaptr.type)); + } + else + UI_icon_draw(x, y, RNA_struct_ui_icon(te->rnaptr.type)); break; default: UI_icon_draw(x, y, ICON_DOT); break; @@ -4228,92 +4264,92 @@ static void tselem_draw_icon(float x, float y, TreeStoreElem *tselem, TreeElemen else if (GS(tselem->id->name) == ID_OB) { Object *ob= (Object *)tselem->id; switch (ob->type) { - case OB_LAMP: - UI_icon_draw(x, y, ICON_OUTLINER_OB_LAMP); break; + case OB_LAMP: + tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_LAMP); break; case OB_MESH: - UI_icon_draw(x, y, ICON_OUTLINER_OB_MESH); break; + tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_MESH); break; case OB_CAMERA: - UI_icon_draw(x, y, ICON_OUTLINER_OB_CAMERA); break; + tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_CAMERA); break; case OB_CURVE: - UI_icon_draw(x, y, ICON_OUTLINER_OB_CURVE); break; + tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_CURVE); break; case OB_MBALL: - UI_icon_draw(x, y, ICON_OUTLINER_OB_META); break; + tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_META); break; case OB_LATTICE: - UI_icon_draw(x, y, ICON_OUTLINER_OB_LATTICE); break; + tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_LATTICE); break; case OB_ARMATURE: - UI_icon_draw(x, y, ICON_OUTLINER_OB_ARMATURE); break; + tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_ARMATURE); break; case OB_FONT: - UI_icon_draw(x, y, ICON_OUTLINER_OB_FONT); break; + tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_FONT); break; case OB_SURF: - UI_icon_draw(x, y, ICON_OUTLINER_OB_SURFACE); break; + tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_SURFACE); break; case OB_EMPTY: - UI_icon_draw(x, y, ICON_OUTLINER_OB_EMPTY); break; + tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_EMPTY); break; } } else { switch( GS(tselem->id->name)) { case ID_SCE: - UI_icon_draw(x, y, ICON_SCENE_DATA); break; + tselem_draw_icon_uibut(&arg, ICON_SCENE_DATA); break; case ID_ME: - UI_icon_draw(x, y, ICON_OUTLINER_DATA_MESH); break; + tselem_draw_icon_uibut(&arg, ICON_OUTLINER_DATA_MESH); break; case ID_CU: - UI_icon_draw(x, y, ICON_OUTLINER_DATA_CURVE); break; + tselem_draw_icon_uibut(&arg, ICON_OUTLINER_DATA_CURVE); break; case ID_MB: - UI_icon_draw(x, y, ICON_OUTLINER_DATA_META); break; + tselem_draw_icon_uibut(&arg, ICON_OUTLINER_DATA_META); break; case ID_LT: - UI_icon_draw(x, y, ICON_OUTLINER_DATA_LATTICE); break; + tselem_draw_icon_uibut(&arg, ICON_OUTLINER_DATA_LATTICE); break; case ID_LA: { Lamp *la= (Lamp *)tselem->id; switch(la->type) { case LA_LOCAL: - UI_icon_draw(x, y, ICON_LAMP_POINT); break; + tselem_draw_icon_uibut(&arg, ICON_LAMP_POINT); break; case LA_SUN: - UI_icon_draw(x, y, ICON_LAMP_SUN); break; + tselem_draw_icon_uibut(&arg, ICON_LAMP_SUN); break; case LA_SPOT: - UI_icon_draw(x, y, ICON_LAMP_SPOT); break; + tselem_draw_icon_uibut(&arg, ICON_LAMP_SPOT); break; case LA_HEMI: - UI_icon_draw(x, y, ICON_LAMP_HEMI); break; + tselem_draw_icon_uibut(&arg, ICON_LAMP_HEMI); break; case LA_AREA: - UI_icon_draw(x, y, ICON_LAMP_AREA); break; + tselem_draw_icon_uibut(&arg, ICON_LAMP_AREA); break; default: - UI_icon_draw(x, y, ICON_OUTLINER_DATA_LAMP); break; + tselem_draw_icon_uibut(&arg, ICON_OUTLINER_DATA_LAMP); break; } break; } case ID_MA: - UI_icon_draw(x, y, ICON_MATERIAL_DATA); break; + tselem_draw_icon_uibut(&arg, ICON_MATERIAL_DATA); break; case ID_TE: - UI_icon_draw(x, y, ICON_TEXTURE_DATA); break; + tselem_draw_icon_uibut(&arg, ICON_TEXTURE_DATA); break; case ID_IM: - UI_icon_draw(x, y, ICON_IMAGE_DATA); break; + tselem_draw_icon_uibut(&arg, ICON_IMAGE_DATA); break; case ID_SO: - UI_icon_draw(x, y, ICON_SPEAKER); break; + tselem_draw_icon_uibut(&arg, ICON_SPEAKER); break; case ID_AR: - UI_icon_draw(x, y, ICON_OUTLINER_DATA_ARMATURE); break; + tselem_draw_icon_uibut(&arg, ICON_OUTLINER_DATA_ARMATURE); break; case ID_CA: - UI_icon_draw(x, y, ICON_OUTLINER_DATA_CAMERA); break; + tselem_draw_icon_uibut(&arg, ICON_OUTLINER_DATA_CAMERA); break; case ID_KE: - UI_icon_draw(x, y, ICON_SHAPEKEY_DATA); break; + tselem_draw_icon_uibut(&arg, ICON_SHAPEKEY_DATA); break; case ID_WO: - UI_icon_draw(x, y, ICON_WORLD_DATA); break; + tselem_draw_icon_uibut(&arg, ICON_WORLD_DATA); break; case ID_AC: - UI_icon_draw(x, y, ICON_ACTION); break; + tselem_draw_icon_uibut(&arg, ICON_ACTION); break; case ID_NLA: - UI_icon_draw(x, y, ICON_NLA); break; + tselem_draw_icon_uibut(&arg, ICON_NLA); break; case ID_TXT: - UI_icon_draw(x, y, ICON_SCRIPT); break; + tselem_draw_icon_uibut(&arg, ICON_SCRIPT); break; case ID_GR: - UI_icon_draw(x, y, ICON_GROUP); break; + tselem_draw_icon_uibut(&arg, ICON_GROUP); break; case ID_LI: - UI_icon_draw(x, y, ICON_LIBRARY_DATA_DIRECT); break; + tselem_draw_icon_uibut(&arg, ICON_LIBRARY_DATA_DIRECT); break; } } } -static void outliner_draw_iconrow(bContext *C, Scene *scene, SpaceOops *soops, ListBase *lb, int level, int *offsx, int ys) +static void outliner_draw_iconrow(bContext *C, uiBlock *block, Scene *scene, SpaceOops *soops, ListBase *lb, int level, int xmax, int *offsx, int ys) { TreeElement *te; TreeStoreElem *tselem; @@ -4338,10 +4374,10 @@ static void outliner_draw_iconrow(bContext *C, Scene *scene, SpaceOops *soops, L uiSetRoundBox(15); glColor4ub(255, 255, 255, 100); uiRoundBox( (float)*offsx-0.5f, (float)ys-1.0f, (float)*offsx+OL_H-3.0f, (float)ys+OL_H-3.0f, OL_H/2.0f-2.0f); - glEnable(GL_BLEND); + glEnable(GL_BLEND); /* roundbox disables */ } - tselem_draw_icon((float)*offsx, (float)ys, tselem, te); + tselem_draw_icon(block, xmax, (float)*offsx, (float)ys, tselem, te, 0.5f); te->xs= (float)*offsx; te->ys= (float)ys; te->xend= (short)*offsx+OL_X; @@ -4352,12 +4388,12 @@ static void outliner_draw_iconrow(bContext *C, Scene *scene, SpaceOops *soops, L /* this tree element always has same amount of branches, so dont draw */ if(tselem->type!=TSE_R_LAYER) - outliner_draw_iconrow(C, scene, soops, &te->subtree, level+1, offsx, ys); + outliner_draw_iconrow(C, block, scene, soops, &te->subtree, level+1, xmax, offsx, ys); } } -static void outliner_draw_tree_element(bContext *C, Scene *scene, ARegion *ar, SpaceOops *soops, TreeElement *te, int startx, int *starty) +static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene, ARegion *ar, SpaceOops *soops, TreeElement *te, int startx, int *starty) { TreeElement *ten; TreeStoreElem *tselem; @@ -4366,7 +4402,12 @@ static void outliner_draw_tree_element(bContext *C, Scene *scene, ARegion *ar, S tselem= TREESTORE(te); if(*starty+2*OL_H >= ar->v2d.cur.ymin && *starty<= ar->v2d.cur.ymax) { - + int xmax= ar->v2d.cur.xmax; + + /* icons can be ui buts, we dont want it to overlap with restrict */ + if((soops->flag & SO_HIDE_RESTRICTCOLS)==0) + xmax-= OL_TOGW+ICON_DEFAULT_WIDTH; + glEnable(GL_BLEND); /* colors for active/selected data */ @@ -4439,8 +4480,9 @@ static void outliner_draw_tree_element(bContext *C, Scene *scene, ARegion *ar, S /* datatype icon */ if(!(ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM))) { - // icons a bit higher - tselem_draw_icon((float)startx+offsx, (float)*starty+2, tselem, te); + // icons a bit higher + tselem_draw_icon(block, xmax, (float)startx+offsx, (float)*starty+2, tselem, te, 1.0f); + offsx+= OL_X; } else @@ -4472,6 +4514,7 @@ static void outliner_draw_tree_element(bContext *C, Scene *scene, ARegion *ar, S if(tselem->type==0 && te->idcode==ID_SCE); else if(tselem->type!=TSE_R_LAYER) { /* this tree element always has same amount of branches, so dont draw */ int tempx= startx+offsx; + // divider UI_ThemeColorShade(TH_BACK, -40); glRecti(tempx -10, *starty+4, tempx -8, *starty+OL_H-4); @@ -4479,8 +4522,8 @@ static void outliner_draw_tree_element(bContext *C, Scene *scene, ARegion *ar, S glEnable(GL_BLEND); glPixelTransferf(GL_ALPHA_SCALE, 0.5); - outliner_draw_iconrow(C, scene, soops, &te->subtree, 0, &tempx, *starty+2); - + outliner_draw_iconrow(C, block, scene, soops, &te->subtree, 0, xmax, &tempx, *starty+2); + glPixelTransferf(GL_ALPHA_SCALE, 1.0); glDisable(GL_BLEND); } @@ -4496,7 +4539,7 @@ static void outliner_draw_tree_element(bContext *C, Scene *scene, ARegion *ar, S if((tselem->flag & TSE_CLOSED)==0) { for(ten= te->subtree.first; ten; ten= ten->next) { - outliner_draw_tree_element(C, scene, ar, soops, ten, startx+OL_X, starty); + outliner_draw_tree_element(C, block, scene, ar, soops, ten, startx+OL_X, starty); } } } @@ -4575,7 +4618,7 @@ static void outliner_draw_selection(ARegion *ar, SpaceOops *soops, ListBase *lb, } -static void outliner_draw_tree(bContext *C, Scene *scene, ARegion *ar, SpaceOops *soops) +static void outliner_draw_tree(bContext *C, uiBlock *block, Scene *scene, ARegion *ar, SpaceOops *soops) { TreeElement *te; int starty, startx; @@ -4607,7 +4650,7 @@ static void outliner_draw_tree(bContext *C, Scene *scene, ARegion *ar, SpaceOops starty= (int)ar->v2d.tot.ymax-OL_H; startx= 0; for(te= soops->tree.first; te; te= te->next) { - outliner_draw_tree_element(C, scene, ar, soops, te, startx, &starty); + outliner_draw_tree_element(C, block, scene, ar, soops, te, startx, &starty); } } @@ -5355,10 +5398,10 @@ void draw_outliner(const bContext *C) /* draw outliner stuff (background and hierachy lines) */ outliner_back(ar, soops); - outliner_draw_tree((bContext *)C, scene, ar, soops); + block= uiBeginBlock(C, ar, "outliner buttons", UI_EMBOSS); + outliner_draw_tree((bContext *)C, block, scene, ar, soops); /* draw icons and names */ - block= uiBeginBlock(C, ar, "outliner buttons", UI_EMBOSS); outliner_buttons(C, block, ar, soops, &soops->tree); if(ELEM(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF)) { diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c index 568c0b353e3..c62f2fee66a 100644 --- a/source/blender/editors/space_outliner/space_outliner.c +++ b/source/blender/editors/space_outliner/space_outliner.c @@ -286,7 +286,7 @@ void ED_spacetype_outliner(void) /* regions: header */ art= MEM_callocN(sizeof(ARegionType), "spacetype time region"); art->regionid = RGN_TYPE_HEADER; - art->minsizey= HEADERY; + art->prefsizey= HEADERY; art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES|ED_KEYMAP_HEADER; art->init= outliner_header_area_init; |