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/screen | |
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/screen')
-rw-r--r-- | source/blender/editors/screen/area.c | 8 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_edit.c | 1 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_ops.c | 28 |
3 files changed, 23 insertions, 14 deletions
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index a7a3754d16f..93f6542f9cb 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -624,8 +624,8 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int if(ar->next==NULL && alignment!=RGN_ALIGN_QSPLIT) alignment= RGN_ALIGN_NONE; - prefsizex= ar->type->minsizex; - prefsizey= ar->type->minsizey; + prefsizex= ar->sizex?ar->sizex:ar->type->prefsizex; + prefsizey= ar->sizey?ar->sizey:ar->type->prefsizey; /* hidden is user flag */ if(ar->flag & RGN_FLAG_HIDDEN); @@ -1230,11 +1230,11 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, char *contex if(vertical) { w= v2d->cur.xmax - v2d->cur.xmin; - em= (ar->type->minsizex)? 10: 20; + em= (ar->type->prefsizex)? 10: 20; } else { w= UI_PANEL_WIDTH; - em= (ar->type->minsizex)? 10: 20; + em= (ar->type->prefsizex)? 10: 20; } x= 0; diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 786f9ee9e3f..048ade764d5 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -468,6 +468,7 @@ static void screen_copy(bScreen *to, bScreen *from) sa->spacedata.first= sa->spacedata.last= NULL; sa->regionbase.first= sa->regionbase.last= NULL; sa->actionzones.first= sa->actionzones.last= NULL; + sa->handlers.first= sa->handlers.last= NULL; area_copy_data(sa, saf, 0); } diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index bc9e7239f01..7f6f1c34760 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -1384,10 +1384,18 @@ static int region_scale_invoke(bContext *C, wmOperator *op, wmEvent *event) rmd->origx= event->x; rmd->origy= event->y; rmd->maxsize = area_max_regionsize(rmd->sa, rmd->ar, rmd->edge); + + /* if not set we do now, otherwise it uses type */ + if(rmd->ar->sizex==0) + rmd->ar->sizex= rmd->ar->type->prefsizex; + if(rmd->ar->sizey==0) + rmd->ar->sizey= rmd->ar->type->prefsizey; + + /* now copy to regionmovedata */ if(rmd->edge=='l' || rmd->edge=='r') { - rmd->origval= rmd->ar->type->minsizex; + rmd->origval= rmd->ar->sizex; } else { - rmd->origval= rmd->ar->type->minsizey; + rmd->origval= rmd->ar->sizey; } CLAMP(rmd->maxsize, 0, 1000); @@ -1413,11 +1421,11 @@ static int region_scale_modal(bContext *C, wmOperator *op, wmEvent *event) delta= event->x - rmd->origx; if(rmd->edge=='l') delta= -delta; - rmd->ar->type->minsizex= rmd->origval + delta; - CLAMP(rmd->ar->type->minsizex, 0, rmd->maxsize); + rmd->ar->sizex= rmd->origval + delta; + CLAMP(rmd->ar->sizex, 0, rmd->maxsize); - if(rmd->ar->type->minsizex < 24) { - rmd->ar->type->minsizex= rmd->origval; + if(rmd->ar->sizex < 24) { + rmd->ar->sizex= rmd->origval; if(!(rmd->ar->flag & RGN_FLAG_HIDDEN)) ED_region_toggle_hidden(C, rmd->ar); } @@ -1428,11 +1436,11 @@ static int region_scale_modal(bContext *C, wmOperator *op, wmEvent *event) delta= event->y - rmd->origy; if(rmd->edge=='b') delta= -delta; - rmd->ar->type->minsizey= rmd->origval + delta; - CLAMP(rmd->ar->type->minsizey, 0, rmd->maxsize); + rmd->ar->sizey= rmd->origval + delta; + CLAMP(rmd->ar->sizey, 0, rmd->maxsize); - if(rmd->ar->type->minsizey < 24) { - rmd->ar->type->minsizey= rmd->origval; + if(rmd->ar->sizey < 24) { + rmd->ar->sizey= rmd->origval; if(!(rmd->ar->flag & RGN_FLAG_HIDDEN)) ED_region_toggle_hidden(C, rmd->ar); } |