2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2008-12-14 11:25:00 +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-12-14 11:25:00 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2008 Blender Foundation.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Contributor(s): Blender Foundation
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
2011-02-27 20:29:51 +00:00
|
|
|
/** \file blender/editors/space_file/space_file.c
|
|
|
|
* \ingroup spfile
|
|
|
|
*/
|
|
|
|
|
2008-12-14 11:25:00 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
2009-03-03 10:24:06 +00:00
|
|
|
#include "BIF_gl.h"
|
|
|
|
|
2008-12-14 11:25:00 +00:00
|
|
|
#include "BLI_blenlib.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2013-03-05 03:44:47 +00:00
|
|
|
#include "BLI_fileops_types.h"
|
2008-12-14 11:25:00 +00:00
|
|
|
|
2013-04-05 17:56:54 +00:00
|
|
|
|
2014-11-23 14:37:13 +01:00
|
|
|
#include "BKE_appdir.h"
|
2008-12-18 02:56:48 +00:00
|
|
|
#include "BKE_context.h"
|
2008-12-14 11:25:00 +00:00
|
|
|
#include "BKE_screen.h"
|
2012-08-08 08:25:20 +00:00
|
|
|
#include "BKE_global.h"
|
2008-12-14 11:25:00 +00:00
|
|
|
|
2013-03-07 02:44:55 +00:00
|
|
|
#include "RNA_access.h"
|
|
|
|
|
|
|
|
#include "WM_api.h"
|
|
|
|
#include "WM_types.h"
|
|
|
|
|
2011-02-14 17:55:27 +00:00
|
|
|
#include "ED_space_api.h"
|
2008-12-14 11:25:00 +00:00
|
|
|
#include "ED_screen.h"
|
2009-01-06 14:42:54 +00:00
|
|
|
#include "ED_fileselect.h"
|
2008-12-14 11:25:00 +00:00
|
|
|
|
2009-03-03 10:24:06 +00:00
|
|
|
#include "IMB_imbuf_types.h"
|
|
|
|
#include "IMB_thumbs.h"
|
2008-12-14 11:25:00 +00:00
|
|
|
|
|
|
|
#include "UI_resources.h"
|
|
|
|
#include "UI_view2d.h"
|
|
|
|
|
2009-03-08 13:14:12 +00:00
|
|
|
|
2012-06-18 13:01:24 +00:00
|
|
|
#include "file_intern.h" // own include
|
2009-01-06 14:42:54 +00:00
|
|
|
#include "fsmenu.h"
|
|
|
|
#include "filelist.h"
|
2008-12-14 11:25:00 +00:00
|
|
|
|
2008-12-14 12:16:55 +00:00
|
|
|
/* ******************** default callbacks for file space ***************** */
|
2008-12-14 11:25:00 +00:00
|
|
|
|
2010-10-16 08:03:28 +00:00
|
|
|
static SpaceLink *file_new(const bContext *UNUSED(C))
|
2008-12-14 11:25:00 +00:00
|
|
|
{
|
|
|
|
ARegion *ar;
|
|
|
|
SpaceFile *sfile;
|
2015-02-11 00:09:45 +01:00
|
|
|
|
2012-06-18 13:01:24 +00:00
|
|
|
sfile = MEM_callocN(sizeof(SpaceFile), "initfile");
|
|
|
|
sfile->spacetype = SPACE_FILE;
|
2009-01-06 14:42:54 +00:00
|
|
|
|
2008-12-14 11:25:00 +00:00
|
|
|
/* header */
|
2012-06-18 13:01:24 +00:00
|
|
|
ar = MEM_callocN(sizeof(ARegion), "header for file");
|
2008-12-14 11:25:00 +00:00
|
|
|
BLI_addtail(&sfile->regionbase, ar);
|
2012-06-18 13:01:24 +00:00
|
|
|
ar->regiontype = RGN_TYPE_HEADER;
|
|
|
|
ar->alignment = RGN_ALIGN_TOP;
|
2009-01-06 14:42:54 +00:00
|
|
|
|
2015-02-11 00:09:45 +01:00
|
|
|
/* Tools region */
|
2015-11-28 17:14:45 +01:00
|
|
|
ar = MEM_callocN(sizeof(ARegion), "tools region for file");
|
2009-01-06 14:42:54 +00:00
|
|
|
BLI_addtail(&sfile->regionbase, ar);
|
2015-02-11 00:09:45 +01:00
|
|
|
ar->regiontype = RGN_TYPE_TOOLS;
|
2012-06-18 13:01:24 +00:00
|
|
|
ar->alignment = RGN_ALIGN_LEFT;
|
2009-01-06 14:42:54 +00:00
|
|
|
|
2015-02-11 00:09:45 +01:00
|
|
|
/* Tool props (aka operator) region */
|
2015-11-28 17:14:45 +01:00
|
|
|
ar = MEM_callocN(sizeof(ARegion), "tool props region for file");
|
2015-02-11 00:09:45 +01:00
|
|
|
BLI_addtail(&sfile->regionbase, ar);
|
|
|
|
ar->regiontype = RGN_TYPE_TOOL_PROPS;
|
|
|
|
ar->alignment = RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV;
|
|
|
|
|
2009-01-06 14:42:54 +00:00
|
|
|
/* ui list region */
|
2015-11-28 17:14:45 +01:00
|
|
|
ar = MEM_callocN(sizeof(ARegion), "ui region for file");
|
2009-01-06 14:42:54 +00:00
|
|
|
BLI_addtail(&sfile->regionbase, ar);
|
2012-06-18 13:01:24 +00:00
|
|
|
ar->regiontype = RGN_TYPE_UI;
|
|
|
|
ar->alignment = RGN_ALIGN_TOP;
|
2009-01-06 14:42:54 +00:00
|
|
|
|
2015-11-28 17:14:45 +01:00
|
|
|
/* main region */
|
|
|
|
ar = MEM_callocN(sizeof(ARegion), "main region for file");
|
2008-12-14 11:25:00 +00:00
|
|
|
BLI_addtail(&sfile->regionbase, ar);
|
2012-06-18 13:01:24 +00:00
|
|
|
ar->regiontype = RGN_TYPE_WINDOW;
|
2009-01-06 14:42:54 +00:00
|
|
|
ar->v2d.scroll = (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM);
|
2012-06-18 13:01:24 +00:00
|
|
|
ar->v2d.align = (V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_POS_Y);
|
|
|
|
ar->v2d.keepzoom = (V2D_LOCKZOOM_X | V2D_LOCKZOOM_Y | V2D_LIMITZOOM | V2D_KEEPASPECT);
|
|
|
|
ar->v2d.keeptot = V2D_KEEPTOT_STRICT;
|
|
|
|
ar->v2d.minzoom = ar->v2d.maxzoom = 1.0f;
|
2008-12-14 11:25:00 +00:00
|
|
|
|
|
|
|
return (SpaceLink *)sfile;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* not spacelink itself */
|
|
|
|
static void file_free(SpaceLink *sl)
|
|
|
|
{
|
2012-06-18 13:01:24 +00:00
|
|
|
SpaceFile *sfile = (SpaceFile *) sl;
|
2009-01-06 14:42:54 +00:00
|
|
|
|
Final 'FileBrowser First Stage' merge.
It basically rewrites most of filelist.c, with some more limited changes in other areas of filebrowser.
From user perspective, it:
* Removes some info in 'long' drawing mode (owner, permissions) - OS-specific data that do not really matter in Blender!
* Makes short/long display 'fixed' size (among four choices, like thumbnails mode).
* Allows to list several layers of dirtree at once, in a flat way (inside .blend files and/or real directories).
* Consequently, adds datablocks types filtering.
* Uses way less RAM when listing big directories, especially in thumbnail mode (we are talking of several hundred of MiB spared).
* Generates thumbnails way faster.
From code perspective, it:
* Is ready for asset engine needs (on data structure level in filebrowser's listing).
* Simplifies and makes 'generic' file listing much lighter.
* Separates file listing in three different aspects:
** 'generic' filelisting (in BLI), which becomes a shallow wrapper around stat struct.
** 'filebrowser drawing' filelisting, which only contains current visible subset of the whole list (sliding window), with extra drawing data (strings for size, date/time, preview, etc.).
** 'asset-ready' filelisting, which is used for operations common to 'basic' filehandling and future asset-related one.
* Uses uuid's to handle file selection/state in the browser, instead of using flags in filelisting items.
* Uses much lighter BLI_task handling for previews, instead of heavy 'job' system (using the new 'notifier' timer to handle UI refresh, in similar way to jobs).
* Moves .blend datablocks preview handling to IMB_thumbnail (necessary to avoid storing all datablock previews at once, and gives better consistency and performances too).
Revision: https://developer.blender.org/D1316
Thanks to Campbell & Sergey for the reviews. :)
2015-08-19 22:41:39 +02:00
|
|
|
BLI_assert(sfile->previews_timer == NULL);
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sfile->files) {
|
2010-03-10 19:30:20 +00:00
|
|
|
// XXXXX would need to do thumbnails_stop here, but no context available
|
2009-09-12 19:54:39 +00:00
|
|
|
filelist_freelib(sfile->files);
|
2009-01-06 19:22:29 +00:00
|
|
|
filelist_free(sfile->files);
|
|
|
|
MEM_freeN(sfile->files);
|
2012-06-18 13:01:24 +00:00
|
|
|
sfile->files = NULL;
|
2009-01-06 19:22:29 +00:00
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sfile->folders_prev) {
|
2009-07-07 07:25:44 +00:00
|
|
|
folderlist_free(sfile->folders_prev);
|
|
|
|
MEM_freeN(sfile->folders_prev);
|
2012-06-18 13:01:24 +00:00
|
|
|
sfile->folders_prev = NULL;
|
2009-07-07 07:25:44 +00:00
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sfile->folders_next) {
|
2009-07-07 07:25:44 +00:00
|
|
|
folderlist_free(sfile->folders_next);
|
|
|
|
MEM_freeN(sfile->folders_next);
|
2012-06-18 13:01:24 +00:00
|
|
|
sfile->folders_next = NULL;
|
2009-07-07 07:25:44 +00:00
|
|
|
}
|
|
|
|
|
2009-01-06 14:42:54 +00:00
|
|
|
if (sfile->params) {
|
|
|
|
MEM_freeN(sfile->params);
|
2012-06-18 13:01:24 +00:00
|
|
|
sfile->params = NULL;
|
2009-01-06 14:42:54 +00:00
|
|
|
}
|
2009-03-08 13:14:12 +00:00
|
|
|
|
|
|
|
if (sfile->layout) {
|
|
|
|
MEM_freeN(sfile->layout);
|
|
|
|
sfile->layout = NULL;
|
|
|
|
}
|
2008-12-14 11:25:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-02-17 13:11:09 +00:00
|
|
|
/* spacetype; init callback, area size changes, screen set, etc */
|
2013-03-15 19:56:29 +00:00
|
|
|
static void file_init(wmWindowManager *UNUSED(wm), ScrArea *sa)
|
2009-01-06 19:22:29 +00:00
|
|
|
{
|
2012-06-18 13:01:24 +00:00
|
|
|
SpaceFile *sfile = (SpaceFile *)sa->spacedata.first;
|
2009-09-28 12:10:23 +00:00
|
|
|
|
2012-05-18 12:49:25 +00:00
|
|
|
/* refresh system directory list */
|
2015-02-11 00:09:45 +01:00
|
|
|
fsmenu_refresh_system_category(ED_fsmenu_get());
|
2012-05-18 12:49:25 +00:00
|
|
|
|
2015-02-16 15:48:37 +01:00
|
|
|
/* Update bookmarks 'valid' state.
|
|
|
|
* Done here, because it seems BLI_is_dir() can have huge impact on performances
|
|
|
|
* in some cases, on win systems... See T43684.
|
|
|
|
*/
|
|
|
|
fsmenu_refresh_bookmarks_status(ED_fsmenu_get());
|
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
if (sfile->layout) sfile->layout->dirty = true;
|
2008-12-14 11:25:00 +00:00
|
|
|
}
|
|
|
|
|
2013-03-15 19:56:29 +00:00
|
|
|
static void file_exit(wmWindowManager *wm, ScrArea *sa)
|
|
|
|
{
|
|
|
|
SpaceFile *sfile = (SpaceFile *)sa->spacedata.first;
|
|
|
|
|
Final 'FileBrowser First Stage' merge.
It basically rewrites most of filelist.c, with some more limited changes in other areas of filebrowser.
From user perspective, it:
* Removes some info in 'long' drawing mode (owner, permissions) - OS-specific data that do not really matter in Blender!
* Makes short/long display 'fixed' size (among four choices, like thumbnails mode).
* Allows to list several layers of dirtree at once, in a flat way (inside .blend files and/or real directories).
* Consequently, adds datablocks types filtering.
* Uses way less RAM when listing big directories, especially in thumbnail mode (we are talking of several hundred of MiB spared).
* Generates thumbnails way faster.
From code perspective, it:
* Is ready for asset engine needs (on data structure level in filebrowser's listing).
* Simplifies and makes 'generic' file listing much lighter.
* Separates file listing in three different aspects:
** 'generic' filelisting (in BLI), which becomes a shallow wrapper around stat struct.
** 'filebrowser drawing' filelisting, which only contains current visible subset of the whole list (sliding window), with extra drawing data (strings for size, date/time, preview, etc.).
** 'asset-ready' filelisting, which is used for operations common to 'basic' filehandling and future asset-related one.
* Uses uuid's to handle file selection/state in the browser, instead of using flags in filelisting items.
* Uses much lighter BLI_task handling for previews, instead of heavy 'job' system (using the new 'notifier' timer to handle UI refresh, in similar way to jobs).
* Moves .blend datablocks preview handling to IMB_thumbnail (necessary to avoid storing all datablock previews at once, and gives better consistency and performances too).
Revision: https://developer.blender.org/D1316
Thanks to Campbell & Sergey for the reviews. :)
2015-08-19 22:41:39 +02:00
|
|
|
if (sfile->previews_timer) {
|
|
|
|
WM_event_remove_timer_notifier(wm, NULL, sfile->previews_timer);
|
|
|
|
sfile->previews_timer = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ED_fileselect_exit(wm, sa, sfile);
|
2013-03-15 19:56:29 +00:00
|
|
|
}
|
2009-02-17 13:11:09 +00:00
|
|
|
|
2008-12-14 11:25:00 +00:00
|
|
|
static SpaceLink *file_duplicate(SpaceLink *sl)
|
|
|
|
{
|
2012-06-18 13:01:24 +00:00
|
|
|
SpaceFile *sfileo = (SpaceFile *)sl;
|
|
|
|
SpaceFile *sfilen = MEM_dupallocN(sl);
|
2008-12-14 11:25:00 +00:00
|
|
|
|
|
|
|
/* clear or remove stuff from old */
|
2009-02-17 13:11:09 +00:00
|
|
|
sfilen->op = NULL; /* file window doesn't own operators */
|
2009-01-06 19:22:29 +00:00
|
|
|
|
2010-03-10 19:30:20 +00:00
|
|
|
if (sfileo->params) {
|
2009-09-13 08:08:50 +00:00
|
|
|
sfilen->files = filelist_new(sfileo->params->type);
|
2012-06-18 13:01:24 +00:00
|
|
|
sfilen->params = MEM_dupallocN(sfileo->params);
|
2010-03-10 19:30:20 +00:00
|
|
|
filelist_setdir(sfilen->files, sfilen->params->dir);
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sfileo->folders_prev)
|
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
|
|
|
sfilen->folders_prev = folderlist_duplicate(sfileo->folders_prev);
|
2009-07-07 07:25:44 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sfileo->folders_next)
|
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
|
|
|
sfilen->folders_next = folderlist_duplicate(sfileo->folders_next);
|
2010-03-10 19:30:20 +00:00
|
|
|
|
2009-03-08 13:14:12 +00:00
|
|
|
if (sfileo->layout) {
|
2012-06-18 13:01:24 +00:00
|
|
|
sfilen->layout = MEM_dupallocN(sfileo->layout);
|
2009-03-08 13:14:12 +00:00
|
|
|
}
|
2008-12-14 12:16:55 +00:00
|
|
|
return (SpaceLink *)sfilen;
|
2008-12-14 11:25:00 +00:00
|
|
|
}
|
|
|
|
|
2015-02-11 00:09:45 +01:00
|
|
|
static void file_refresh(const bContext *C, ScrArea *sa)
|
2009-06-29 20:23:40 +00:00
|
|
|
{
|
2013-03-15 19:56:29 +00:00
|
|
|
wmWindowManager *wm = CTX_wm_manager(C);
|
2012-06-18 13:01:24 +00:00
|
|
|
SpaceFile *sfile = CTX_wm_space_file(C);
|
2009-06-29 20:23:40 +00:00
|
|
|
FileSelectParams *params = ED_fileselect_get_params(sfile);
|
2015-02-11 00:09:45 +01:00
|
|
|
struct FSMenu *fsmenu = ED_fsmenu_get();
|
2009-06-29 20:23:40 +00:00
|
|
|
|
2014-12-31 20:13:21 +01:00
|
|
|
if (!sfile->folders_prev) {
|
2009-07-07 07:25:44 +00:00
|
|
|
sfile->folders_prev = folderlist_new();
|
2014-12-31 20:13:21 +01:00
|
|
|
}
|
2009-06-29 20:23:40 +00:00
|
|
|
if (!sfile->files) {
|
2009-09-12 19:54:39 +00:00
|
|
|
sfile->files = filelist_new(params->type);
|
File Browser Arrow Keys Navigation
Adds support for selecting/deselecting files in File Browser using the
arrow keys. All directions (up, down, left, right) are possible.
When to Select, When to Deselect?
Standard behaviour is selecting, however if we move into a block of
already selected files (meaning 2+ files are selected) we start
deselecting
Possible Selection Methods
Simple selection (arrow-key): All other files are deselected
Expand selection (Shift+arrow key): Add to/remove from existing
selection
ill-Expand selection (Ctrl+Shift+arrow key): Add to/remove from existing
selection and fill everything in-between
From which file do we start navigating?
From each available selection method (Mouse-, Walk-, All-, Border
Select), we use the last selected file. If there's no selection at all
we use the first (down/right arrow) or last (up/left arrow) file.
(Ideally, the view would automatically be set to the new selection, but
this behaviour overlaps with an other patch I've been working on, so
prefer to do that separately)
(Also tweaks color for highlighted file for better feedback)
D1297, Review done by @campbellbarton, thx a lot :)
2015-06-11 17:20:29 +02:00
|
|
|
params->highlight_file = -1; /* added this so it opens nicer (ton) */
|
2009-06-29 20:23:40 +00:00
|
|
|
}
|
Final 'FileBrowser First Stage' merge.
It basically rewrites most of filelist.c, with some more limited changes in other areas of filebrowser.
From user perspective, it:
* Removes some info in 'long' drawing mode (owner, permissions) - OS-specific data that do not really matter in Blender!
* Makes short/long display 'fixed' size (among four choices, like thumbnails mode).
* Allows to list several layers of dirtree at once, in a flat way (inside .blend files and/or real directories).
* Consequently, adds datablocks types filtering.
* Uses way less RAM when listing big directories, especially in thumbnail mode (we are talking of several hundred of MiB spared).
* Generates thumbnails way faster.
From code perspective, it:
* Is ready for asset engine needs (on data structure level in filebrowser's listing).
* Simplifies and makes 'generic' file listing much lighter.
* Separates file listing in three different aspects:
** 'generic' filelisting (in BLI), which becomes a shallow wrapper around stat struct.
** 'filebrowser drawing' filelisting, which only contains current visible subset of the whole list (sliding window), with extra drawing data (strings for size, date/time, preview, etc.).
** 'asset-ready' filelisting, which is used for operations common to 'basic' filehandling and future asset-related one.
* Uses uuid's to handle file selection/state in the browser, instead of using flags in filelisting items.
* Uses much lighter BLI_task handling for previews, instead of heavy 'job' system (using the new 'notifier' timer to handle UI refresh, in similar way to jobs).
* Moves .blend datablocks preview handling to IMB_thumbnail (necessary to avoid storing all datablock previews at once, and gives better consistency and performances too).
Revision: https://developer.blender.org/D1316
Thanks to Campbell & Sergey for the reviews. :)
2015-08-19 22:41:39 +02:00
|
|
|
filelist_setdir(sfile->files, params->dir);
|
|
|
|
filelist_setrecursion(sfile->files, params->recursion_level);
|
2014-12-31 20:13:21 +01:00
|
|
|
filelist_setsorting(sfile->files, params->sort);
|
Final 'FileBrowser First Stage' merge.
It basically rewrites most of filelist.c, with some more limited changes in other areas of filebrowser.
From user perspective, it:
* Removes some info in 'long' drawing mode (owner, permissions) - OS-specific data that do not really matter in Blender!
* Makes short/long display 'fixed' size (among four choices, like thumbnails mode).
* Allows to list several layers of dirtree at once, in a flat way (inside .blend files and/or real directories).
* Consequently, adds datablocks types filtering.
* Uses way less RAM when listing big directories, especially in thumbnail mode (we are talking of several hundred of MiB spared).
* Generates thumbnails way faster.
From code perspective, it:
* Is ready for asset engine needs (on data structure level in filebrowser's listing).
* Simplifies and makes 'generic' file listing much lighter.
* Separates file listing in three different aspects:
** 'generic' filelisting (in BLI), which becomes a shallow wrapper around stat struct.
** 'filebrowser drawing' filelisting, which only contains current visible subset of the whole list (sliding window), with extra drawing data (strings for size, date/time, preview, etc.).
** 'asset-ready' filelisting, which is used for operations common to 'basic' filehandling and future asset-related one.
* Uses uuid's to handle file selection/state in the browser, instead of using flags in filelisting items.
* Uses much lighter BLI_task handling for previews, instead of heavy 'job' system (using the new 'notifier' timer to handle UI refresh, in similar way to jobs).
* Moves .blend datablocks preview handling to IMB_thumbnail (necessary to avoid storing all datablock previews at once, and gives better consistency and performances too).
Revision: https://developer.blender.org/D1316
Thanks to Campbell & Sergey for the reviews. :)
2015-08-19 22:41:39 +02:00
|
|
|
filelist_setfilter_options(sfile->files, (params->flag & FILE_HIDE_DOT) != 0,
|
2014-12-31 20:13:21 +01:00
|
|
|
false, /* TODO hide_parent, should be controllable? */
|
2016-04-30 04:04:18 +10:00
|
|
|
(params->flag & FILE_FILTER) ? params->filter : 0,
|
Final 'FileBrowser First Stage' merge.
It basically rewrites most of filelist.c, with some more limited changes in other areas of filebrowser.
From user perspective, it:
* Removes some info in 'long' drawing mode (owner, permissions) - OS-specific data that do not really matter in Blender!
* Makes short/long display 'fixed' size (among four choices, like thumbnails mode).
* Allows to list several layers of dirtree at once, in a flat way (inside .blend files and/or real directories).
* Consequently, adds datablocks types filtering.
* Uses way less RAM when listing big directories, especially in thumbnail mode (we are talking of several hundred of MiB spared).
* Generates thumbnails way faster.
From code perspective, it:
* Is ready for asset engine needs (on data structure level in filebrowser's listing).
* Simplifies and makes 'generic' file listing much lighter.
* Separates file listing in three different aspects:
** 'generic' filelisting (in BLI), which becomes a shallow wrapper around stat struct.
** 'filebrowser drawing' filelisting, which only contains current visible subset of the whole list (sliding window), with extra drawing data (strings for size, date/time, preview, etc.).
** 'asset-ready' filelisting, which is used for operations common to 'basic' filehandling and future asset-related one.
* Uses uuid's to handle file selection/state in the browser, instead of using flags in filelisting items.
* Uses much lighter BLI_task handling for previews, instead of heavy 'job' system (using the new 'notifier' timer to handle UI refresh, in similar way to jobs).
* Moves .blend datablocks preview handling to IMB_thumbnail (necessary to avoid storing all datablock previews at once, and gives better consistency and performances too).
Revision: https://developer.blender.org/D1316
Thanks to Campbell & Sergey for the reviews. :)
2015-08-19 22:41:39 +02:00
|
|
|
params->filter_id,
|
2015-01-03 21:55:16 +01:00
|
|
|
params->filter_glob,
|
|
|
|
params->filter_search);
|
2012-03-06 18:40:15 +00:00
|
|
|
|
2015-02-11 00:09:45 +01:00
|
|
|
/* Update the active indices of bookmarks & co. */
|
|
|
|
sfile->systemnr = fsmenu_get_active_indices(fsmenu, FS_CATEGORY_SYSTEM, params->dir);
|
|
|
|
sfile->system_bookmarknr = fsmenu_get_active_indices(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, params->dir);
|
|
|
|
sfile->bookmarknr = fsmenu_get_active_indices(fsmenu, FS_CATEGORY_BOOKMARKS, params->dir);
|
|
|
|
sfile->recentnr = fsmenu_get_active_indices(fsmenu, FS_CATEGORY_RECENT, params->dir);
|
|
|
|
|
Final 'FileBrowser First Stage' merge.
It basically rewrites most of filelist.c, with some more limited changes in other areas of filebrowser.
From user perspective, it:
* Removes some info in 'long' drawing mode (owner, permissions) - OS-specific data that do not really matter in Blender!
* Makes short/long display 'fixed' size (among four choices, like thumbnails mode).
* Allows to list several layers of dirtree at once, in a flat way (inside .blend files and/or real directories).
* Consequently, adds datablocks types filtering.
* Uses way less RAM when listing big directories, especially in thumbnail mode (we are talking of several hundred of MiB spared).
* Generates thumbnails way faster.
From code perspective, it:
* Is ready for asset engine needs (on data structure level in filebrowser's listing).
* Simplifies and makes 'generic' file listing much lighter.
* Separates file listing in three different aspects:
** 'generic' filelisting (in BLI), which becomes a shallow wrapper around stat struct.
** 'filebrowser drawing' filelisting, which only contains current visible subset of the whole list (sliding window), with extra drawing data (strings for size, date/time, preview, etc.).
** 'asset-ready' filelisting, which is used for operations common to 'basic' filehandling and future asset-related one.
* Uses uuid's to handle file selection/state in the browser, instead of using flags in filelisting items.
* Uses much lighter BLI_task handling for previews, instead of heavy 'job' system (using the new 'notifier' timer to handle UI refresh, in similar way to jobs).
* Moves .blend datablocks preview handling to IMB_thumbnail (necessary to avoid storing all datablock previews at once, and gives better consistency and performances too).
Revision: https://developer.blender.org/D1316
Thanks to Campbell & Sergey for the reviews. :)
2015-08-19 22:41:39 +02:00
|
|
|
if (filelist_force_reset(sfile->files)) {
|
|
|
|
filelist_readjob_stop(wm, sa);
|
|
|
|
filelist_clear(sfile->files);
|
2014-12-31 20:13:21 +01:00
|
|
|
}
|
|
|
|
|
Final 'FileBrowser First Stage' merge.
It basically rewrites most of filelist.c, with some more limited changes in other areas of filebrowser.
From user perspective, it:
* Removes some info in 'long' drawing mode (owner, permissions) - OS-specific data that do not really matter in Blender!
* Makes short/long display 'fixed' size (among four choices, like thumbnails mode).
* Allows to list several layers of dirtree at once, in a flat way (inside .blend files and/or real directories).
* Consequently, adds datablocks types filtering.
* Uses way less RAM when listing big directories, especially in thumbnail mode (we are talking of several hundred of MiB spared).
* Generates thumbnails way faster.
From code perspective, it:
* Is ready for asset engine needs (on data structure level in filebrowser's listing).
* Simplifies and makes 'generic' file listing much lighter.
* Separates file listing in three different aspects:
** 'generic' filelisting (in BLI), which becomes a shallow wrapper around stat struct.
** 'filebrowser drawing' filelisting, which only contains current visible subset of the whole list (sliding window), with extra drawing data (strings for size, date/time, preview, etc.).
** 'asset-ready' filelisting, which is used for operations common to 'basic' filehandling and future asset-related one.
* Uses uuid's to handle file selection/state in the browser, instead of using flags in filelisting items.
* Uses much lighter BLI_task handling for previews, instead of heavy 'job' system (using the new 'notifier' timer to handle UI refresh, in similar way to jobs).
* Moves .blend datablocks preview handling to IMB_thumbnail (necessary to avoid storing all datablock previews at once, and gives better consistency and performances too).
Revision: https://developer.blender.org/D1316
Thanks to Campbell & Sergey for the reviews. :)
2015-08-19 22:41:39 +02:00
|
|
|
if (filelist_empty(sfile->files)) {
|
|
|
|
if (!filelist_pending(sfile->files)) {
|
|
|
|
filelist_readjob_start(sfile->files, C);
|
2010-05-14 10:50:43 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
}
|
2014-12-31 20:13:21 +01:00
|
|
|
|
Final 'FileBrowser First Stage' merge.
It basically rewrites most of filelist.c, with some more limited changes in other areas of filebrowser.
From user perspective, it:
* Removes some info in 'long' drawing mode (owner, permissions) - OS-specific data that do not really matter in Blender!
* Makes short/long display 'fixed' size (among four choices, like thumbnails mode).
* Allows to list several layers of dirtree at once, in a flat way (inside .blend files and/or real directories).
* Consequently, adds datablocks types filtering.
* Uses way less RAM when listing big directories, especially in thumbnail mode (we are talking of several hundred of MiB spared).
* Generates thumbnails way faster.
From code perspective, it:
* Is ready for asset engine needs (on data structure level in filebrowser's listing).
* Simplifies and makes 'generic' file listing much lighter.
* Separates file listing in three different aspects:
** 'generic' filelisting (in BLI), which becomes a shallow wrapper around stat struct.
** 'filebrowser drawing' filelisting, which only contains current visible subset of the whole list (sliding window), with extra drawing data (strings for size, date/time, preview, etc.).
** 'asset-ready' filelisting, which is used for operations common to 'basic' filehandling and future asset-related one.
* Uses uuid's to handle file selection/state in the browser, instead of using flags in filelisting items.
* Uses much lighter BLI_task handling for previews, instead of heavy 'job' system (using the new 'notifier' timer to handle UI refresh, in similar way to jobs).
* Moves .blend datablocks preview handling to IMB_thumbnail (necessary to avoid storing all datablock previews at once, and gives better consistency and performances too).
Revision: https://developer.blender.org/D1316
Thanks to Campbell & Sergey for the reviews. :)
2015-08-19 22:41:39 +02:00
|
|
|
filelist_sort(sfile->files);
|
2014-12-31 20:13:21 +01:00
|
|
|
filelist_filter(sfile->files);
|
|
|
|
|
Final 'FileBrowser First Stage' merge.
It basically rewrites most of filelist.c, with some more limited changes in other areas of filebrowser.
From user perspective, it:
* Removes some info in 'long' drawing mode (owner, permissions) - OS-specific data that do not really matter in Blender!
* Makes short/long display 'fixed' size (among four choices, like thumbnails mode).
* Allows to list several layers of dirtree at once, in a flat way (inside .blend files and/or real directories).
* Consequently, adds datablocks types filtering.
* Uses way less RAM when listing big directories, especially in thumbnail mode (we are talking of several hundred of MiB spared).
* Generates thumbnails way faster.
From code perspective, it:
* Is ready for asset engine needs (on data structure level in filebrowser's listing).
* Simplifies and makes 'generic' file listing much lighter.
* Separates file listing in three different aspects:
** 'generic' filelisting (in BLI), which becomes a shallow wrapper around stat struct.
** 'filebrowser drawing' filelisting, which only contains current visible subset of the whole list (sliding window), with extra drawing data (strings for size, date/time, preview, etc.).
** 'asset-ready' filelisting, which is used for operations common to 'basic' filehandling and future asset-related one.
* Uses uuid's to handle file selection/state in the browser, instead of using flags in filelisting items.
* Uses much lighter BLI_task handling for previews, instead of heavy 'job' system (using the new 'notifier' timer to handle UI refresh, in similar way to jobs).
* Moves .blend datablocks preview handling to IMB_thumbnail (necessary to avoid storing all datablock previews at once, and gives better consistency and performances too).
Revision: https://developer.blender.org/D1316
Thanks to Campbell & Sergey for the reviews. :)
2015-08-19 22:41:39 +02:00
|
|
|
if (params->display == FILE_IMGDISPLAY) {
|
|
|
|
filelist_cache_previews_set(sfile->files, true);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
filelist_cache_previews_set(sfile->files, false);
|
|
|
|
if (sfile->previews_timer) {
|
|
|
|
WM_event_remove_timer_notifier(wm, CTX_wm_window(C), sfile->previews_timer);
|
|
|
|
sfile->previews_timer = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-13 09:41:00 +00:00
|
|
|
if (params->renamefile[0] != '\0') {
|
Final 'FileBrowser First Stage' merge.
It basically rewrites most of filelist.c, with some more limited changes in other areas of filebrowser.
From user perspective, it:
* Removes some info in 'long' drawing mode (owner, permissions) - OS-specific data that do not really matter in Blender!
* Makes short/long display 'fixed' size (among four choices, like thumbnails mode).
* Allows to list several layers of dirtree at once, in a flat way (inside .blend files and/or real directories).
* Consequently, adds datablocks types filtering.
* Uses way less RAM when listing big directories, especially in thumbnail mode (we are talking of several hundred of MiB spared).
* Generates thumbnails way faster.
From code perspective, it:
* Is ready for asset engine needs (on data structure level in filebrowser's listing).
* Simplifies and makes 'generic' file listing much lighter.
* Separates file listing in three different aspects:
** 'generic' filelisting (in BLI), which becomes a shallow wrapper around stat struct.
** 'filebrowser drawing' filelisting, which only contains current visible subset of the whole list (sliding window), with extra drawing data (strings for size, date/time, preview, etc.).
** 'asset-ready' filelisting, which is used for operations common to 'basic' filehandling and future asset-related one.
* Uses uuid's to handle file selection/state in the browser, instead of using flags in filelisting items.
* Uses much lighter BLI_task handling for previews, instead of heavy 'job' system (using the new 'notifier' timer to handle UI refresh, in similar way to jobs).
* Moves .blend datablocks preview handling to IMB_thumbnail (necessary to avoid storing all datablock previews at once, and gives better consistency and performances too).
Revision: https://developer.blender.org/D1316
Thanks to Campbell & Sergey for the reviews. :)
2015-08-19 22:41:39 +02:00
|
|
|
int idx = filelist_file_findpath(sfile->files, params->renamefile);
|
2009-09-13 09:41:00 +00:00
|
|
|
if (idx >= 0) {
|
Final 'FileBrowser First Stage' merge.
It basically rewrites most of filelist.c, with some more limited changes in other areas of filebrowser.
From user perspective, it:
* Removes some info in 'long' drawing mode (owner, permissions) - OS-specific data that do not really matter in Blender!
* Makes short/long display 'fixed' size (among four choices, like thumbnails mode).
* Allows to list several layers of dirtree at once, in a flat way (inside .blend files and/or real directories).
* Consequently, adds datablocks types filtering.
* Uses way less RAM when listing big directories, especially in thumbnail mode (we are talking of several hundred of MiB spared).
* Generates thumbnails way faster.
From code perspective, it:
* Is ready for asset engine needs (on data structure level in filebrowser's listing).
* Simplifies and makes 'generic' file listing much lighter.
* Separates file listing in three different aspects:
** 'generic' filelisting (in BLI), which becomes a shallow wrapper around stat struct.
** 'filebrowser drawing' filelisting, which only contains current visible subset of the whole list (sliding window), with extra drawing data (strings for size, date/time, preview, etc.).
** 'asset-ready' filelisting, which is used for operations common to 'basic' filehandling and future asset-related one.
* Uses uuid's to handle file selection/state in the browser, instead of using flags in filelisting items.
* Uses much lighter BLI_task handling for previews, instead of heavy 'job' system (using the new 'notifier' timer to handle UI refresh, in similar way to jobs).
* Moves .blend datablocks preview handling to IMB_thumbnail (necessary to avoid storing all datablock previews at once, and gives better consistency and performances too).
Revision: https://developer.blender.org/D1316
Thanks to Campbell & Sergey for the reviews. :)
2015-08-19 22:41:39 +02:00
|
|
|
FileDirEntry *file = filelist_file(sfile->files, idx);
|
2009-09-13 09:41:00 +00:00
|
|
|
if (file) {
|
Final 'FileBrowser First Stage' merge.
It basically rewrites most of filelist.c, with some more limited changes in other areas of filebrowser.
From user perspective, it:
* Removes some info in 'long' drawing mode (owner, permissions) - OS-specific data that do not really matter in Blender!
* Makes short/long display 'fixed' size (among four choices, like thumbnails mode).
* Allows to list several layers of dirtree at once, in a flat way (inside .blend files and/or real directories).
* Consequently, adds datablocks types filtering.
* Uses way less RAM when listing big directories, especially in thumbnail mode (we are talking of several hundred of MiB spared).
* Generates thumbnails way faster.
From code perspective, it:
* Is ready for asset engine needs (on data structure level in filebrowser's listing).
* Simplifies and makes 'generic' file listing much lighter.
* Separates file listing in three different aspects:
** 'generic' filelisting (in BLI), which becomes a shallow wrapper around stat struct.
** 'filebrowser drawing' filelisting, which only contains current visible subset of the whole list (sliding window), with extra drawing data (strings for size, date/time, preview, etc.).
** 'asset-ready' filelisting, which is used for operations common to 'basic' filehandling and future asset-related one.
* Uses uuid's to handle file selection/state in the browser, instead of using flags in filelisting items.
* Uses much lighter BLI_task handling for previews, instead of heavy 'job' system (using the new 'notifier' timer to handle UI refresh, in similar way to jobs).
* Moves .blend datablocks preview handling to IMB_thumbnail (necessary to avoid storing all datablock previews at once, and gives better consistency and performances too).
Revision: https://developer.blender.org/D1316
Thanks to Campbell & Sergey for the reviews. :)
2015-08-19 22:41:39 +02:00
|
|
|
filelist_entry_select_set(sfile->files, file, FILE_SEL_ADD, FILE_SEL_EDITING, CHECK_ALL);
|
2009-09-13 09:41:00 +00:00
|
|
|
}
|
|
|
|
}
|
2010-08-12 00:14:32 +00:00
|
|
|
BLI_strncpy(sfile->params->renameedit, sfile->params->renamefile, sizeof(sfile->params->renameedit));
|
Final 'FileBrowser First Stage' merge.
It basically rewrites most of filelist.c, with some more limited changes in other areas of filebrowser.
From user perspective, it:
* Removes some info in 'long' drawing mode (owner, permissions) - OS-specific data that do not really matter in Blender!
* Makes short/long display 'fixed' size (among four choices, like thumbnails mode).
* Allows to list several layers of dirtree at once, in a flat way (inside .blend files and/or real directories).
* Consequently, adds datablocks types filtering.
* Uses way less RAM when listing big directories, especially in thumbnail mode (we are talking of several hundred of MiB spared).
* Generates thumbnails way faster.
From code perspective, it:
* Is ready for asset engine needs (on data structure level in filebrowser's listing).
* Simplifies and makes 'generic' file listing much lighter.
* Separates file listing in three different aspects:
** 'generic' filelisting (in BLI), which becomes a shallow wrapper around stat struct.
** 'filebrowser drawing' filelisting, which only contains current visible subset of the whole list (sliding window), with extra drawing data (strings for size, date/time, preview, etc.).
** 'asset-ready' filelisting, which is used for operations common to 'basic' filehandling and future asset-related one.
* Uses uuid's to handle file selection/state in the browser, instead of using flags in filelisting items.
* Uses much lighter BLI_task handling for previews, instead of heavy 'job' system (using the new 'notifier' timer to handle UI refresh, in similar way to jobs).
* Moves .blend datablocks preview handling to IMB_thumbnail (necessary to avoid storing all datablock previews at once, and gives better consistency and performances too).
Revision: https://developer.blender.org/D1316
Thanks to Campbell & Sergey for the reviews. :)
2015-08-19 22:41:39 +02:00
|
|
|
/* File listing is now async, do not clear renamefile if matching entry not found
|
|
|
|
* and dirlist is not finished! */
|
|
|
|
if (idx >= 0 || filelist_is_ready(sfile->files)) {
|
|
|
|
params->renamefile[0] = '\0';
|
|
|
|
}
|
2009-09-13 09:41:00 +00:00
|
|
|
}
|
2009-07-26 12:40:44 +00:00
|
|
|
|
2014-12-31 20:13:21 +01:00
|
|
|
if (sfile->layout) {
|
|
|
|
sfile->layout->dirty = true;
|
|
|
|
}
|
2015-02-11 00:09:45 +01:00
|
|
|
|
2015-11-28 17:14:45 +01:00
|
|
|
/* Might be called with NULL sa, see file_main_region_draw() below. */
|
2015-02-11 11:16:32 +01:00
|
|
|
if (sa && BKE_area_find_region_type(sa, RGN_TYPE_TOOLS) == NULL) {
|
2015-02-11 00:09:45 +01:00
|
|
|
/* Create TOOLS/TOOL_PROPS regions. */
|
|
|
|
file_tools_region(sa);
|
|
|
|
|
|
|
|
ED_area_initialize(wm, CTX_wm_window(C), sa);
|
|
|
|
ED_area_tag_redraw(sa);
|
|
|
|
}
|
2009-06-29 20:23:40 +00:00
|
|
|
}
|
|
|
|
|
2013-06-24 22:41:33 +00:00
|
|
|
static void file_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn)
|
2009-06-29 20:23:40 +00:00
|
|
|
{
|
Final 'FileBrowser First Stage' merge.
It basically rewrites most of filelist.c, with some more limited changes in other areas of filebrowser.
From user perspective, it:
* Removes some info in 'long' drawing mode (owner, permissions) - OS-specific data that do not really matter in Blender!
* Makes short/long display 'fixed' size (among four choices, like thumbnails mode).
* Allows to list several layers of dirtree at once, in a flat way (inside .blend files and/or real directories).
* Consequently, adds datablocks types filtering.
* Uses way less RAM when listing big directories, especially in thumbnail mode (we are talking of several hundred of MiB spared).
* Generates thumbnails way faster.
From code perspective, it:
* Is ready for asset engine needs (on data structure level in filebrowser's listing).
* Simplifies and makes 'generic' file listing much lighter.
* Separates file listing in three different aspects:
** 'generic' filelisting (in BLI), which becomes a shallow wrapper around stat struct.
** 'filebrowser drawing' filelisting, which only contains current visible subset of the whole list (sliding window), with extra drawing data (strings for size, date/time, preview, etc.).
** 'asset-ready' filelisting, which is used for operations common to 'basic' filehandling and future asset-related one.
* Uses uuid's to handle file selection/state in the browser, instead of using flags in filelisting items.
* Uses much lighter BLI_task handling for previews, instead of heavy 'job' system (using the new 'notifier' timer to handle UI refresh, in similar way to jobs).
* Moves .blend datablocks preview handling to IMB_thumbnail (necessary to avoid storing all datablock previews at once, and gives better consistency and performances too).
Revision: https://developer.blender.org/D1316
Thanks to Campbell & Sergey for the reviews. :)
2015-08-19 22:41:39 +02:00
|
|
|
SpaceFile *sfile = (SpaceFile *)sa->spacedata.first;
|
2009-06-29 20:23:40 +00:00
|
|
|
|
|
|
|
/* context changes */
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (wmn->category) {
|
2.5
Notifiers
---------
Various fixes for wrong use of notifiers, and some new notifiers
to make things a bit more clear and consistent, with two notable
changes:
* Geometry changes are now done with NC_GEOM, rather than
NC_OBJECT|ND_GEOM_, so an object does need to be available.
* Space data now use NC_SPACE|ND_SPACE_*, instead of data
notifiers or even NC_WINDOW in some cases. Note that NC_SPACE
should only be used for notifying about changes in space data,
we don't want to go back to allqueue(REDRAW..).
Depsgraph
---------
The dependency graph now has a different flush call:
DAG_object_flush_update(scene, ob, flag)
is replaced by:
DAG_id_flush_update(id, flag)
It still works basically the same, one difference is that it now
also accepts object data (e.g. Mesh), again to avoid requiring an
Object to be available. Other ID types will simply do nothing at
the moment.
Docs
----
I made some guidelines for how/when to do which kinds of updates
and notifiers. I can't specify totally exact how to make these
decisions, but these are basically the guidelines I use. So, new
and updated docs are here:
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/NotifiersUpdates
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/DataNotifiers
2009-09-04 20:51:09 +00:00
|
|
|
case NC_SPACE:
|
2009-06-29 20:23:40 +00:00
|
|
|
switch (wmn->data) {
|
2.5
Notifiers
---------
Various fixes for wrong use of notifiers, and some new notifiers
to make things a bit more clear and consistent, with two notable
changes:
* Geometry changes are now done with NC_GEOM, rather than
NC_OBJECT|ND_GEOM_, so an object does need to be available.
* Space data now use NC_SPACE|ND_SPACE_*, instead of data
notifiers or even NC_WINDOW in some cases. Note that NC_SPACE
should only be used for notifying about changes in space data,
we don't want to go back to allqueue(REDRAW..).
Depsgraph
---------
The dependency graph now has a different flush call:
DAG_object_flush_update(scene, ob, flag)
is replaced by:
DAG_id_flush_update(id, flag)
It still works basically the same, one difference is that it now
also accepts object data (e.g. Mesh), again to avoid requiring an
Object to be available. Other ID types will simply do nothing at
the moment.
Docs
----
I made some guidelines for how/when to do which kinds of updates
and notifiers. I can't specify totally exact how to make these
decisions, but these are basically the guidelines I use. So, new
and updated docs are here:
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/NotifiersUpdates
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/DataNotifiers
2009-09-04 20:51:09 +00:00
|
|
|
case ND_SPACE_FILE_LIST:
|
2009-06-29 20:23:40 +00:00
|
|
|
ED_area_tag_refresh(sa);
|
2009-07-28 16:46:14 +00:00
|
|
|
ED_area_tag_redraw(sa);
|
2009-06-29 20:23:40 +00:00
|
|
|
break;
|
2.5
Notifiers
---------
Various fixes for wrong use of notifiers, and some new notifiers
to make things a bit more clear and consistent, with two notable
changes:
* Geometry changes are now done with NC_GEOM, rather than
NC_OBJECT|ND_GEOM_, so an object does need to be available.
* Space data now use NC_SPACE|ND_SPACE_*, instead of data
notifiers or even NC_WINDOW in some cases. Note that NC_SPACE
should only be used for notifying about changes in space data,
we don't want to go back to allqueue(REDRAW..).
Depsgraph
---------
The dependency graph now has a different flush call:
DAG_object_flush_update(scene, ob, flag)
is replaced by:
DAG_id_flush_update(id, flag)
It still works basically the same, one difference is that it now
also accepts object data (e.g. Mesh), again to avoid requiring an
Object to be available. Other ID types will simply do nothing at
the moment.
Docs
----
I made some guidelines for how/when to do which kinds of updates
and notifiers. I can't specify totally exact how to make these
decisions, but these are basically the guidelines I use. So, new
and updated docs are here:
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/NotifiersUpdates
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/DataNotifiers
2009-09-04 20:51:09 +00:00
|
|
|
case ND_SPACE_FILE_PARAMS:
|
2009-06-29 20:23:40 +00:00
|
|
|
ED_area_tag_refresh(sa);
|
2009-07-28 16:46:14 +00:00
|
|
|
ED_area_tag_redraw(sa);
|
2009-06-29 20:23:40 +00:00
|
|
|
break;
|
Final 'FileBrowser First Stage' merge.
It basically rewrites most of filelist.c, with some more limited changes in other areas of filebrowser.
From user perspective, it:
* Removes some info in 'long' drawing mode (owner, permissions) - OS-specific data that do not really matter in Blender!
* Makes short/long display 'fixed' size (among four choices, like thumbnails mode).
* Allows to list several layers of dirtree at once, in a flat way (inside .blend files and/or real directories).
* Consequently, adds datablocks types filtering.
* Uses way less RAM when listing big directories, especially in thumbnail mode (we are talking of several hundred of MiB spared).
* Generates thumbnails way faster.
From code perspective, it:
* Is ready for asset engine needs (on data structure level in filebrowser's listing).
* Simplifies and makes 'generic' file listing much lighter.
* Separates file listing in three different aspects:
** 'generic' filelisting (in BLI), which becomes a shallow wrapper around stat struct.
** 'filebrowser drawing' filelisting, which only contains current visible subset of the whole list (sliding window), with extra drawing data (strings for size, date/time, preview, etc.).
** 'asset-ready' filelisting, which is used for operations common to 'basic' filehandling and future asset-related one.
* Uses uuid's to handle file selection/state in the browser, instead of using flags in filelisting items.
* Uses much lighter BLI_task handling for previews, instead of heavy 'job' system (using the new 'notifier' timer to handle UI refresh, in similar way to jobs).
* Moves .blend datablocks preview handling to IMB_thumbnail (necessary to avoid storing all datablock previews at once, and gives better consistency and performances too).
Revision: https://developer.blender.org/D1316
Thanks to Campbell & Sergey for the reviews. :)
2015-08-19 22:41:39 +02:00
|
|
|
case ND_SPACE_FILE_PREVIEW:
|
2015-08-23 20:27:59 +02:00
|
|
|
if (sfile->files && filelist_cache_previews_update(sfile->files)) {
|
Final 'FileBrowser First Stage' merge.
It basically rewrites most of filelist.c, with some more limited changes in other areas of filebrowser.
From user perspective, it:
* Removes some info in 'long' drawing mode (owner, permissions) - OS-specific data that do not really matter in Blender!
* Makes short/long display 'fixed' size (among four choices, like thumbnails mode).
* Allows to list several layers of dirtree at once, in a flat way (inside .blend files and/or real directories).
* Consequently, adds datablocks types filtering.
* Uses way less RAM when listing big directories, especially in thumbnail mode (we are talking of several hundred of MiB spared).
* Generates thumbnails way faster.
From code perspective, it:
* Is ready for asset engine needs (on data structure level in filebrowser's listing).
* Simplifies and makes 'generic' file listing much lighter.
* Separates file listing in three different aspects:
** 'generic' filelisting (in BLI), which becomes a shallow wrapper around stat struct.
** 'filebrowser drawing' filelisting, which only contains current visible subset of the whole list (sliding window), with extra drawing data (strings for size, date/time, preview, etc.).
** 'asset-ready' filelisting, which is used for operations common to 'basic' filehandling and future asset-related one.
* Uses uuid's to handle file selection/state in the browser, instead of using flags in filelisting items.
* Uses much lighter BLI_task handling for previews, instead of heavy 'job' system (using the new 'notifier' timer to handle UI refresh, in similar way to jobs).
* Moves .blend datablocks preview handling to IMB_thumbnail (necessary to avoid storing all datablock previews at once, and gives better consistency and performances too).
Revision: https://developer.blender.org/D1316
Thanks to Campbell & Sergey for the reviews. :)
2015-08-19 22:41:39 +02:00
|
|
|
ED_area_tag_refresh(sa);
|
|
|
|
ED_area_tag_redraw(sa);
|
|
|
|
}
|
|
|
|
break;
|
2009-06-29 20:23:40 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-12-14 11:25:00 +00:00
|
|
|
|
|
|
|
/* add handlers, stuff you only do once or on area/region changes */
|
2015-11-28 17:14:45 +01:00
|
|
|
static void file_main_region_init(wmWindowManager *wm, ARegion *ar)
|
2008-12-14 11:25:00 +00:00
|
|
|
{
|
2009-09-17 21:36:02 +00:00
|
|
|
wmKeyMap *keymap;
|
2008-12-14 11:25:00 +00:00
|
|
|
|
2008-12-16 11:24:24 +00:00
|
|
|
UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy);
|
2008-12-14 11:25:00 +00:00
|
|
|
|
2009-07-05 22:26:43 +00:00
|
|
|
/* own keymaps */
|
2012-03-24 02:51:46 +00:00
|
|
|
keymap = WM_keymap_find(wm->defaultconf, "File Browser", SPACE_FILE, 0);
|
2009-07-05 22:26:43 +00:00
|
|
|
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
|
|
|
|
|
2012-03-24 02:51:46 +00:00
|
|
|
keymap = WM_keymap_find(wm->defaultconf, "File Browser Main", SPACE_FILE, 0);
|
2008-12-14 11:25:00 +00:00
|
|
|
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
|
|
|
|
}
|
|
|
|
|
2015-11-28 17:14:45 +01:00
|
|
|
static void file_main_region_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn)
|
2009-07-26 12:40:44 +00:00
|
|
|
{
|
|
|
|
/* context changes */
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (wmn->category) {
|
2.5
Notifiers
---------
Various fixes for wrong use of notifiers, and some new notifiers
to make things a bit more clear and consistent, with two notable
changes:
* Geometry changes are now done with NC_GEOM, rather than
NC_OBJECT|ND_GEOM_, so an object does need to be available.
* Space data now use NC_SPACE|ND_SPACE_*, instead of data
notifiers or even NC_WINDOW in some cases. Note that NC_SPACE
should only be used for notifying about changes in space data,
we don't want to go back to allqueue(REDRAW..).
Depsgraph
---------
The dependency graph now has a different flush call:
DAG_object_flush_update(scene, ob, flag)
is replaced by:
DAG_id_flush_update(id, flag)
It still works basically the same, one difference is that it now
also accepts object data (e.g. Mesh), again to avoid requiring an
Object to be available. Other ID types will simply do nothing at
the moment.
Docs
----
I made some guidelines for how/when to do which kinds of updates
and notifiers. I can't specify totally exact how to make these
decisions, but these are basically the guidelines I use. So, new
and updated docs are here:
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/NotifiersUpdates
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/DataNotifiers
2009-09-04 20:51:09 +00:00
|
|
|
case NC_SPACE:
|
2009-07-26 12:40:44 +00:00
|
|
|
switch (wmn->data) {
|
2.5
Notifiers
---------
Various fixes for wrong use of notifiers, and some new notifiers
to make things a bit more clear and consistent, with two notable
changes:
* Geometry changes are now done with NC_GEOM, rather than
NC_OBJECT|ND_GEOM_, so an object does need to be available.
* Space data now use NC_SPACE|ND_SPACE_*, instead of data
notifiers or even NC_WINDOW in some cases. Note that NC_SPACE
should only be used for notifying about changes in space data,
we don't want to go back to allqueue(REDRAW..).
Depsgraph
---------
The dependency graph now has a different flush call:
DAG_object_flush_update(scene, ob, flag)
is replaced by:
DAG_id_flush_update(id, flag)
It still works basically the same, one difference is that it now
also accepts object data (e.g. Mesh), again to avoid requiring an
Object to be available. Other ID types will simply do nothing at
the moment.
Docs
----
I made some guidelines for how/when to do which kinds of updates
and notifiers. I can't specify totally exact how to make these
decisions, but these are basically the guidelines I use. So, new
and updated docs are here:
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/NotifiersUpdates
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/DataNotifiers
2009-09-04 20:51:09 +00:00
|
|
|
case ND_SPACE_FILE_LIST:
|
2009-07-26 12:40:44 +00:00
|
|
|
ED_region_tag_redraw(ar);
|
|
|
|
break;
|
2.5
Notifiers
---------
Various fixes for wrong use of notifiers, and some new notifiers
to make things a bit more clear and consistent, with two notable
changes:
* Geometry changes are now done with NC_GEOM, rather than
NC_OBJECT|ND_GEOM_, so an object does need to be available.
* Space data now use NC_SPACE|ND_SPACE_*, instead of data
notifiers or even NC_WINDOW in some cases. Note that NC_SPACE
should only be used for notifying about changes in space data,
we don't want to go back to allqueue(REDRAW..).
Depsgraph
---------
The dependency graph now has a different flush call:
DAG_object_flush_update(scene, ob, flag)
is replaced by:
DAG_id_flush_update(id, flag)
It still works basically the same, one difference is that it now
also accepts object data (e.g. Mesh), again to avoid requiring an
Object to be available. Other ID types will simply do nothing at
the moment.
Docs
----
I made some guidelines for how/when to do which kinds of updates
and notifiers. I can't specify totally exact how to make these
decisions, but these are basically the guidelines I use. So, new
and updated docs are here:
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/NotifiersUpdates
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/DataNotifiers
2009-09-04 20:51:09 +00:00
|
|
|
case ND_SPACE_FILE_PARAMS:
|
2009-07-26 12:40:44 +00:00
|
|
|
ED_region_tag_redraw(ar);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-28 17:14:45 +01:00
|
|
|
static void file_main_region_draw(const bContext *C, ARegion *ar)
|
2008-12-14 11:25:00 +00:00
|
|
|
{
|
|
|
|
/* draw entirely, view changes should be handled here */
|
2012-06-18 13:01:24 +00:00
|
|
|
SpaceFile *sfile = CTX_wm_space_file(C);
|
2009-03-14 18:15:28 +00:00
|
|
|
FileSelectParams *params = ED_fileselect_get_params(sfile);
|
|
|
|
|
2012-06-18 13:01:24 +00:00
|
|
|
View2D *v2d = &ar->v2d;
|
2009-01-06 14:42:54 +00:00
|
|
|
View2DScrollers *scrollers;
|
2008-12-14 11:25:00 +00:00
|
|
|
float col[3];
|
2009-01-06 14:42:54 +00:00
|
|
|
|
2009-07-26 12:40:44 +00:00
|
|
|
/* Needed, because filelist is not initialized on loading */
|
2009-07-26 18:52:27 +00:00
|
|
|
if (!sfile->files || filelist_empty(sfile->files))
|
2009-07-26 12:40:44 +00:00
|
|
|
file_refresh(C, NULL);
|
|
|
|
|
2008-12-14 11:25:00 +00:00
|
|
|
/* clear and setup matrix */
|
|
|
|
UI_GetThemeColor3fv(TH_BACK, col);
|
|
|
|
glClearColor(col[0], col[1], col[2], 0.0);
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT);
|
|
|
|
|
2009-02-17 13:11:09 +00:00
|
|
|
/* Allow dynamically sliders to be set, saves notifiers etc. */
|
2013-08-24 12:53:47 +00:00
|
|
|
|
2013-08-26 06:54:05 +00:00
|
|
|
if (params->display == FILE_IMGDISPLAY) {
|
2009-02-17 13:11:09 +00:00
|
|
|
v2d->scroll = V2D_SCROLL_RIGHT;
|
2009-03-09 09:15:23 +00:00
|
|
|
v2d->keepofs &= ~V2D_LOCKOFS_Y;
|
|
|
|
v2d->keepofs |= V2D_LOCKOFS_X;
|
|
|
|
}
|
|
|
|
else {
|
2009-02-17 13:11:09 +00:00
|
|
|
v2d->scroll = V2D_SCROLL_BOTTOM;
|
2009-03-09 09:15:23 +00:00
|
|
|
v2d->keepofs &= ~V2D_LOCKOFS_X;
|
|
|
|
v2d->keepofs |= V2D_LOCKOFS_Y;
|
2010-12-20 18:29:32 +00:00
|
|
|
|
|
|
|
/* XXX this happens on scaling down Screen (like from startup.blend) */
|
|
|
|
/* view2d has no type specific for filewindow case, which doesnt scroll vertically */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (v2d->cur.ymax < 0) {
|
2010-12-20 18:29:32 +00:00
|
|
|
v2d->cur.ymin -= v2d->cur.ymax;
|
2012-03-24 02:51:46 +00:00
|
|
|
v2d->cur.ymax = 0;
|
2010-12-20 18:29:32 +00:00
|
|
|
}
|
2009-03-09 09:15:23 +00:00
|
|
|
}
|
|
|
|
/* v2d has initialized flag, so this call will only set the mask correct */
|
2009-02-17 13:11:09 +00:00
|
|
|
UI_view2d_region_reinit(v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy);
|
|
|
|
|
2009-01-28 11:27:25 +00:00
|
|
|
/* sets tile/border settings in sfile */
|
|
|
|
file_calc_previews(C, ar);
|
2009-01-06 14:42:54 +00:00
|
|
|
|
2009-02-17 13:11:09 +00:00
|
|
|
/* set view */
|
2010-10-14 01:22:14 +00:00
|
|
|
UI_view2d_view_ortho(v2d);
|
2009-02-17 13:11:09 +00:00
|
|
|
|
2009-01-28 11:27:25 +00:00
|
|
|
/* on first read, find active file */
|
File Browser Arrow Keys Navigation
Adds support for selecting/deselecting files in File Browser using the
arrow keys. All directions (up, down, left, right) are possible.
When to Select, When to Deselect?
Standard behaviour is selecting, however if we move into a block of
already selected files (meaning 2+ files are selected) we start
deselecting
Possible Selection Methods
Simple selection (arrow-key): All other files are deselected
Expand selection (Shift+arrow key): Add to/remove from existing
selection
ill-Expand selection (Ctrl+Shift+arrow key): Add to/remove from existing
selection and fill everything in-between
From which file do we start navigating?
From each available selection method (Mouse-, Walk-, All-, Border
Select), we use the last selected file. If there's no selection at all
we use the first (down/right arrow) or last (up/left arrow) file.
(Ideally, the view would automatically be set to the new selection, but
this behaviour overlaps with an other patch I've been working on, so
prefer to do that separately)
(Also tweaks color for highlighted file for better feedback)
D1297, Review done by @campbellbarton, thx a lot :)
2015-06-11 17:20:29 +02:00
|
|
|
if (params->highlight_file == -1) {
|
2012-06-18 13:01:24 +00:00
|
|
|
wmEvent *event = CTX_wm_window(C)->eventstate;
|
2012-07-04 15:04:38 +00:00
|
|
|
file_highlight_set(sfile, ar, event->x, event->y);
|
2009-01-28 11:27:25 +00:00
|
|
|
}
|
|
|
|
|
2009-08-20 18:39:25 +00:00
|
|
|
file_draw_list(C, ar);
|
2008-12-14 11:25:00 +00:00
|
|
|
|
|
|
|
/* reset view matrix */
|
|
|
|
UI_view2d_view_restore(C);
|
|
|
|
|
2009-01-06 14:42:54 +00:00
|
|
|
/* scrollers */
|
2012-06-18 13:01:24 +00:00
|
|
|
scrollers = UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
|
2009-01-06 14:42:54 +00:00
|
|
|
UI_view2d_scrollers_draw(C, v2d, scrollers);
|
|
|
|
UI_view2d_scrollers_free(scrollers);
|
|
|
|
|
2008-12-14 11:25:00 +00:00
|
|
|
}
|
|
|
|
|
2011-02-14 17:55:27 +00:00
|
|
|
static void file_operatortypes(void)
|
2008-12-14 11:25:00 +00:00
|
|
|
{
|
2009-02-14 14:25:48 +00:00
|
|
|
WM_operatortype_append(FILE_OT_select);
|
File Browser Arrow Keys Navigation
Adds support for selecting/deselecting files in File Browser using the
arrow keys. All directions (up, down, left, right) are possible.
When to Select, When to Deselect?
Standard behaviour is selecting, however if we move into a block of
already selected files (meaning 2+ files are selected) we start
deselecting
Possible Selection Methods
Simple selection (arrow-key): All other files are deselected
Expand selection (Shift+arrow key): Add to/remove from existing
selection
ill-Expand selection (Ctrl+Shift+arrow key): Add to/remove from existing
selection and fill everything in-between
From which file do we start navigating?
From each available selection method (Mouse-, Walk-, All-, Border
Select), we use the last selected file. If there's no selection at all
we use the first (down/right arrow) or last (up/left arrow) file.
(Ideally, the view would automatically be set to the new selection, but
this behaviour overlaps with an other patch I've been working on, so
prefer to do that separately)
(Also tweaks color for highlighted file for better feedback)
D1297, Review done by @campbellbarton, thx a lot :)
2015-06-11 17:20:29 +02:00
|
|
|
WM_operatortype_append(FILE_OT_select_walk);
|
2009-03-29 02:15:13 +00:00
|
|
|
WM_operatortype_append(FILE_OT_select_all_toggle);
|
|
|
|
WM_operatortype_append(FILE_OT_select_border);
|
2009-02-14 14:25:48 +00:00
|
|
|
WM_operatortype_append(FILE_OT_select_bookmark);
|
|
|
|
WM_operatortype_append(FILE_OT_highlight);
|
2009-09-04 04:29:54 +00:00
|
|
|
WM_operatortype_append(FILE_OT_execute);
|
2009-02-14 14:25:48 +00:00
|
|
|
WM_operatortype_append(FILE_OT_cancel);
|
|
|
|
WM_operatortype_append(FILE_OT_parent);
|
2009-07-07 07:25:44 +00:00
|
|
|
WM_operatortype_append(FILE_OT_previous);
|
|
|
|
WM_operatortype_append(FILE_OT_next);
|
2009-03-12 06:40:03 +00:00
|
|
|
WM_operatortype_append(FILE_OT_refresh);
|
2009-03-08 13:14:12 +00:00
|
|
|
WM_operatortype_append(FILE_OT_bookmark_toggle);
|
2009-11-28 14:37:21 +00:00
|
|
|
WM_operatortype_append(FILE_OT_bookmark_add);
|
2013-10-08 13:16:14 +00:00
|
|
|
WM_operatortype_append(FILE_OT_bookmark_delete);
|
2015-02-11 17:07:52 +01:00
|
|
|
WM_operatortype_append(FILE_OT_bookmark_cleanup);
|
2015-02-11 00:09:45 +01:00
|
|
|
WM_operatortype_append(FILE_OT_bookmark_move);
|
2012-09-17 21:38:04 +00:00
|
|
|
WM_operatortype_append(FILE_OT_reset_recent);
|
2009-07-05 22:26:43 +00:00
|
|
|
WM_operatortype_append(FILE_OT_filenum);
|
2009-07-10 17:05:04 +00:00
|
|
|
WM_operatortype_append(FILE_OT_directory_new);
|
|
|
|
WM_operatortype_append(FILE_OT_delete);
|
2009-07-26 18:52:27 +00:00
|
|
|
WM_operatortype_append(FILE_OT_rename);
|
2010-05-08 21:02:22 +00:00
|
|
|
WM_operatortype_append(FILE_OT_smoothscroll);
|
2015-11-04 14:24:46 +01:00
|
|
|
WM_operatortype_append(FILE_OT_filepath_drop);
|
2008-12-14 11:25:00 +00:00
|
|
|
}
|
|
|
|
|
2009-01-28 12:28:50 +00:00
|
|
|
/* NOTE: do not add .blend file reading on this level */
|
2011-02-14 17:55:27 +00:00
|
|
|
static void file_keymap(struct wmKeyConfig *keyconf)
|
2008-12-14 11:25:00 +00:00
|
|
|
{
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
wmKeyMapItem *kmi;
|
2015-11-28 17:14:45 +01:00
|
|
|
/* keys for all regions */
|
2012-03-24 02:51:46 +00:00
|
|
|
wmKeyMap *keymap = WM_keymap_find(keyconf, "File Browser", SPACE_FILE, 0);
|
2015-12-03 12:21:57 +01:00
|
|
|
|
|
|
|
/* More common 'fliebrowser-like navigation' shortcuts. */
|
|
|
|
WM_keymap_add_item(keymap, "FILE_OT_parent", UPARROWKEY, KM_PRESS, KM_ALT, 0);
|
|
|
|
WM_keymap_add_item(keymap, "FILE_OT_previous", LEFTARROWKEY, KM_PRESS, KM_ALT, 0);
|
|
|
|
WM_keymap_add_item(keymap, "FILE_OT_next", RIGHTARROWKEY, KM_PRESS, KM_ALT, 0);
|
|
|
|
WM_keymap_add_item(keymap, "FILE_OT_refresh", RKEY, KM_PRESS, 0, 0);
|
|
|
|
|
2009-07-05 22:26:43 +00:00
|
|
|
WM_keymap_add_item(keymap, "FILE_OT_parent", PKEY, KM_PRESS, 0, 0);
|
2009-07-07 07:25:44 +00:00
|
|
|
WM_keymap_add_item(keymap, "FILE_OT_previous", BACKSPACEKEY, KM_PRESS, 0, 0);
|
|
|
|
WM_keymap_add_item(keymap, "FILE_OT_next", BACKSPACEKEY, KM_PRESS, KM_SHIFT, 0);
|
2015-12-03 12:21:57 +01:00
|
|
|
kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", HKEY, KM_PRESS, 0, 0);
|
|
|
|
RNA_string_set(kmi->ptr, "data_path", "space_data.params.show_hidden");
|
2013-06-08 05:24:08 +00:00
|
|
|
WM_keymap_add_item(keymap, "FILE_OT_directory_new", IKEY, KM_PRESS, 0, 0);
|
2009-07-10 17:05:04 +00:00
|
|
|
WM_keymap_add_item(keymap, "FILE_OT_delete", XKEY, KM_PRESS, 0, 0);
|
2009-09-28 12:33:52 +00:00
|
|
|
WM_keymap_add_item(keymap, "FILE_OT_delete", DELKEY, KM_PRESS, 0, 0);
|
2015-12-03 12:21:57 +01:00
|
|
|
|
2010-05-10 08:57:58 +00:00
|
|
|
WM_keymap_verify_item(keymap, "FILE_OT_smoothscroll", TIMER1, KM_ANY, KM_ANY, 0);
|
2009-07-05 22:26:43 +00:00
|
|
|
|
2015-12-03 12:21:57 +01:00
|
|
|
WM_keymap_add_item(keymap, "FILE_OT_bookmark_toggle", TKEY, KM_PRESS, 0, 0);
|
|
|
|
WM_keymap_add_item(keymap, "FILE_OT_bookmark_add", BKEY, KM_PRESS, KM_CTRL, 0);
|
|
|
|
|
2015-11-28 17:14:45 +01:00
|
|
|
/* keys for main region */
|
2012-03-24 02:51:46 +00:00
|
|
|
keymap = WM_keymap_find(keyconf, "File Browser Main", SPACE_FILE, 0);
|
|
|
|
kmi = WM_keymap_add_item(keymap, "FILE_OT_execute", LEFTMOUSE, KM_DBL_CLICK, 0, 0);
|
2014-04-01 11:34:00 +11:00
|
|
|
RNA_boolean_set(kmi->ptr, "need_active", true);
|
2012-09-12 10:04:09 +00:00
|
|
|
|
2015-12-03 12:21:57 +01:00
|
|
|
WM_keymap_add_item(keymap, "FILE_OT_refresh", PADPERIOD, KM_PRESS, 0, 0);
|
|
|
|
|
2012-09-12 10:04:09 +00:00
|
|
|
/* left mouse selects and opens */
|
2015-04-07 14:08:30 +02:00
|
|
|
WM_keymap_add_item(keymap, "FILE_OT_select", LEFTMOUSE, KM_CLICK, 0, 0);
|
|
|
|
kmi = WM_keymap_add_item(keymap, "FILE_OT_select", LEFTMOUSE, KM_CLICK, KM_SHIFT, 0);
|
2014-04-01 11:34:00 +11:00
|
|
|
RNA_boolean_set(kmi->ptr, "extend", true);
|
2015-04-07 14:08:30 +02:00
|
|
|
kmi = WM_keymap_add_item(keymap, "FILE_OT_select", LEFTMOUSE, KM_CLICK, KM_CTRL | KM_SHIFT, 0);
|
2014-04-01 11:34:00 +11:00
|
|
|
RNA_boolean_set(kmi->ptr, "extend", true);
|
|
|
|
RNA_boolean_set(kmi->ptr, "fill", true);
|
2012-09-12 10:04:09 +00:00
|
|
|
|
|
|
|
/* right mouse selects without opening */
|
2015-04-07 14:08:30 +02:00
|
|
|
kmi = WM_keymap_add_item(keymap, "FILE_OT_select", RIGHTMOUSE, KM_CLICK, 0, 0);
|
2014-04-01 11:34:00 +11:00
|
|
|
RNA_boolean_set(kmi->ptr, "open", false);
|
2015-04-07 14:08:30 +02:00
|
|
|
kmi = WM_keymap_add_item(keymap, "FILE_OT_select", RIGHTMOUSE, KM_CLICK, KM_SHIFT, 0);
|
2014-04-01 11:34:00 +11:00
|
|
|
RNA_boolean_set(kmi->ptr, "extend", true);
|
|
|
|
RNA_boolean_set(kmi->ptr, "open", false);
|
2015-04-07 14:08:30 +02:00
|
|
|
kmi = WM_keymap_add_item(keymap, "FILE_OT_select", RIGHTMOUSE, KM_CLICK, KM_ALT, 0);
|
2014-04-01 11:34:00 +11:00
|
|
|
RNA_boolean_set(kmi->ptr, "extend", true);
|
|
|
|
RNA_boolean_set(kmi->ptr, "fill", true);
|
|
|
|
RNA_boolean_set(kmi->ptr, "open", false);
|
2012-09-12 10:04:09 +00:00
|
|
|
|
File Browser Arrow Keys Navigation
Adds support for selecting/deselecting files in File Browser using the
arrow keys. All directions (up, down, left, right) are possible.
When to Select, When to Deselect?
Standard behaviour is selecting, however if we move into a block of
already selected files (meaning 2+ files are selected) we start
deselecting
Possible Selection Methods
Simple selection (arrow-key): All other files are deselected
Expand selection (Shift+arrow key): Add to/remove from existing
selection
ill-Expand selection (Ctrl+Shift+arrow key): Add to/remove from existing
selection and fill everything in-between
From which file do we start navigating?
From each available selection method (Mouse-, Walk-, All-, Border
Select), we use the last selected file. If there's no selection at all
we use the first (down/right arrow) or last (up/left arrow) file.
(Ideally, the view would automatically be set to the new selection, but
this behaviour overlaps with an other patch I've been working on, so
prefer to do that separately)
(Also tweaks color for highlighted file for better feedback)
D1297, Review done by @campbellbarton, thx a lot :)
2015-06-11 17:20:29 +02:00
|
|
|
|
|
|
|
/* arrow keys navigation (walk selecting) */
|
|
|
|
kmi = WM_keymap_add_item(keymap, "FILE_OT_select_walk", UPARROWKEY, KM_PRESS, 0, 0);
|
|
|
|
RNA_enum_set(kmi->ptr, "direction", FILE_SELECT_WALK_UP);
|
|
|
|
kmi = WM_keymap_add_item(keymap, "FILE_OT_select_walk", UPARROWKEY, KM_PRESS, KM_SHIFT, 0);
|
|
|
|
RNA_enum_set(kmi->ptr, "direction", FILE_SELECT_WALK_UP);
|
|
|
|
RNA_boolean_set(kmi->ptr, "extend", true);
|
|
|
|
kmi = WM_keymap_add_item(keymap, "FILE_OT_select_walk", UPARROWKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
|
|
|
|
RNA_enum_set(kmi->ptr, "direction", FILE_SELECT_WALK_UP);
|
|
|
|
RNA_boolean_set(kmi->ptr, "extend", true);
|
|
|
|
RNA_boolean_set(kmi->ptr, "fill", true);
|
|
|
|
|
|
|
|
kmi = WM_keymap_add_item(keymap, "FILE_OT_select_walk", DOWNARROWKEY, KM_PRESS, 0, 0);
|
|
|
|
RNA_enum_set(kmi->ptr, "direction", FILE_SELECT_WALK_DOWN);
|
|
|
|
kmi = WM_keymap_add_item(keymap, "FILE_OT_select_walk", DOWNARROWKEY, KM_PRESS, KM_SHIFT, 0);
|
|
|
|
RNA_enum_set(kmi->ptr, "direction", FILE_SELECT_WALK_DOWN);
|
|
|
|
RNA_boolean_set(kmi->ptr, "extend", true);
|
|
|
|
kmi = WM_keymap_add_item(keymap, "FILE_OT_select_walk", DOWNARROWKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
|
|
|
|
RNA_enum_set(kmi->ptr, "direction", FILE_SELECT_WALK_DOWN);
|
|
|
|
RNA_boolean_set(kmi->ptr, "extend", true);
|
|
|
|
RNA_boolean_set(kmi->ptr, "fill", true);
|
|
|
|
|
|
|
|
kmi = WM_keymap_add_item(keymap, "FILE_OT_select_walk", LEFTARROWKEY, KM_PRESS, 0, 0);
|
|
|
|
RNA_enum_set(kmi->ptr, "direction", FILE_SELECT_WALK_LEFT);
|
|
|
|
kmi = WM_keymap_add_item(keymap, "FILE_OT_select_walk", LEFTARROWKEY, KM_PRESS, KM_SHIFT, 0);
|
|
|
|
RNA_enum_set(kmi->ptr, "direction", FILE_SELECT_WALK_LEFT);
|
|
|
|
RNA_boolean_set(kmi->ptr, "extend", true);
|
|
|
|
kmi = WM_keymap_add_item(keymap, "FILE_OT_select_walk", LEFTARROWKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
|
|
|
|
RNA_enum_set(kmi->ptr, "direction", FILE_SELECT_WALK_LEFT);
|
|
|
|
RNA_boolean_set(kmi->ptr, "extend", true);
|
|
|
|
RNA_boolean_set(kmi->ptr, "fill", true);
|
|
|
|
|
|
|
|
kmi = WM_keymap_add_item(keymap, "FILE_OT_select_walk", RIGHTARROWKEY, KM_PRESS, 0, 0);
|
|
|
|
RNA_enum_set(kmi->ptr, "direction", FILE_SELECT_WALK_RIGHT);
|
|
|
|
kmi = WM_keymap_add_item(keymap, "FILE_OT_select_walk", RIGHTARROWKEY, KM_PRESS, KM_SHIFT, 0);
|
|
|
|
RNA_enum_set(kmi->ptr, "direction", FILE_SELECT_WALK_RIGHT);
|
|
|
|
RNA_boolean_set(kmi->ptr, "extend", true);
|
|
|
|
kmi = WM_keymap_add_item(keymap, "FILE_OT_select_walk", RIGHTARROWKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
|
|
|
|
RNA_enum_set(kmi->ptr, "direction", FILE_SELECT_WALK_RIGHT);
|
|
|
|
RNA_boolean_set(kmi->ptr, "extend", true);
|
|
|
|
RNA_boolean_set(kmi->ptr, "fill", true);
|
|
|
|
|
|
|
|
|
2013-06-08 05:23:47 +00:00
|
|
|
/* front and back mouse folder navigation */
|
2015-04-07 14:08:30 +02:00
|
|
|
WM_keymap_add_item(keymap, "FILE_OT_previous", BUTTON4MOUSE, KM_CLICK, 0, 0);
|
|
|
|
WM_keymap_add_item(keymap, "FILE_OT_next", BUTTON5MOUSE, KM_CLICK, 0, 0);
|
2013-06-08 05:23:47 +00:00
|
|
|
|
2009-03-29 02:15:13 +00:00
|
|
|
WM_keymap_add_item(keymap, "FILE_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0);
|
|
|
|
WM_keymap_add_item(keymap, "FILE_OT_select_border", BKEY, KM_PRESS, 0, 0);
|
2009-11-22 22:23:58 +00:00
|
|
|
WM_keymap_add_item(keymap, "FILE_OT_select_border", EVT_TWEAK_L, KM_ANY, 0, 0);
|
2009-07-26 18:52:27 +00:00
|
|
|
WM_keymap_add_item(keymap, "FILE_OT_rename", LEFTMOUSE, KM_PRESS, KM_CTRL, 0);
|
2009-11-22 22:23:58 +00:00
|
|
|
WM_keymap_add_item(keymap, "FILE_OT_highlight", MOUSEMOVE, KM_ANY, KM_ANY, 0);
|
2009-07-05 22:26:43 +00:00
|
|
|
kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADPLUSKEY, KM_PRESS, 0, 0);
|
|
|
|
RNA_int_set(kmi->ptr, "increment", 1);
|
|
|
|
kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADPLUSKEY, KM_PRESS, KM_SHIFT, 0);
|
|
|
|
RNA_int_set(kmi->ptr, "increment", 10);
|
|
|
|
kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADPLUSKEY, KM_PRESS, KM_CTRL, 0);
|
|
|
|
RNA_int_set(kmi->ptr, "increment", 100);
|
2012-04-29 15:47:02 +00:00
|
|
|
kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADMINUS, KM_PRESS, 0, 0);
|
2009-07-05 22:26:43 +00:00
|
|
|
RNA_int_set(kmi->ptr, "increment", -1);
|
|
|
|
kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADMINUS, KM_PRESS, KM_SHIFT, 0);
|
|
|
|
RNA_int_set(kmi->ptr, "increment", -10);
|
|
|
|
kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADMINUS, KM_PRESS, KM_CTRL, 0);
|
2012-04-29 15:47:02 +00:00
|
|
|
RNA_int_set(kmi->ptr, "increment", -100);
|
2010-05-10 08:57:58 +00:00
|
|
|
|
2009-06-30 18:29:30 +00:00
|
|
|
|
2015-11-28 17:14:45 +01:00
|
|
|
/* keys for button region (top) */
|
2012-03-24 02:51:46 +00:00
|
|
|
keymap = WM_keymap_find(keyconf, "File Browser Buttons", SPACE_FILE, 0);
|
2009-07-05 22:26:43 +00:00
|
|
|
kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADPLUSKEY, KM_PRESS, 0, 0);
|
|
|
|
RNA_int_set(kmi->ptr, "increment", 1);
|
|
|
|
kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADPLUSKEY, KM_PRESS, KM_SHIFT, 0);
|
|
|
|
RNA_int_set(kmi->ptr, "increment", 10);
|
|
|
|
kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADPLUSKEY, KM_PRESS, KM_CTRL, 0);
|
|
|
|
RNA_int_set(kmi->ptr, "increment", 100);
|
|
|
|
kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADMINUS, KM_PRESS, 0, 0);
|
|
|
|
RNA_int_set(kmi->ptr, "increment", -1);
|
2012-04-29 15:47:02 +00:00
|
|
|
kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADMINUS, KM_PRESS, KM_SHIFT, 0);
|
2009-07-05 22:26:43 +00:00
|
|
|
RNA_int_set(kmi->ptr, "increment", -10);
|
2012-04-29 15:47:02 +00:00
|
|
|
kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADMINUS, KM_PRESS, KM_CTRL, 0);
|
|
|
|
RNA_int_set(kmi->ptr, "increment", -100);
|
2009-01-06 14:42:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-11-28 17:14:45 +01:00
|
|
|
static void file_tools_region_init(wmWindowManager *wm, ARegion *ar)
|
2009-01-06 14:42:54 +00:00
|
|
|
{
|
2009-09-17 21:36:02 +00:00
|
|
|
wmKeyMap *keymap;
|
2009-07-05 22:26:43 +00:00
|
|
|
|
2013-02-10 14:52:08 +00:00
|
|
|
ar->v2d.scroll = V2D_SCROLL_RIGHT | V2D_SCROLL_VERTICAL_HIDE;
|
2009-06-29 20:23:40 +00:00
|
|
|
ED_region_panels_init(wm, ar);
|
2009-07-05 22:26:43 +00:00
|
|
|
|
|
|
|
/* own keymaps */
|
2012-10-21 05:46:41 +00:00
|
|
|
keymap = WM_keymap_find(wm->defaultconf, "File Browser", SPACE_FILE, 0);
|
2009-07-05 22:26:43 +00:00
|
|
|
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
|
2009-01-06 14:42:54 +00:00
|
|
|
}
|
|
|
|
|
2015-11-28 17:14:45 +01:00
|
|
|
static void file_tools_region_draw(const bContext *C, ARegion *ar)
|
2009-01-06 14:42:54 +00:00
|
|
|
{
|
2015-07-01 21:48:42 +02:00
|
|
|
ED_region_panels(C, ar, NULL, -1, true);
|
2009-06-29 20:23:40 +00:00
|
|
|
}
|
2009-01-06 14:42:54 +00:00
|
|
|
|
2015-11-28 17:14:45 +01:00
|
|
|
static void file_tools_region_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *UNUSED(ar), wmNotifier *UNUSED(wmn))
|
2009-06-29 20:23:40 +00:00
|
|
|
{
|
2013-08-07 03:44:05 +00:00
|
|
|
#if 0
|
2009-06-29 20:23:40 +00:00
|
|
|
/* context changes */
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (wmn->category) {
|
2009-06-29 20:23:40 +00:00
|
|
|
|
|
|
|
}
|
2013-08-07 03:44:05 +00:00
|
|
|
#endif
|
2008-12-14 11:25:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* add handlers, stuff you only do once or on area/region changes */
|
2015-11-28 17:14:45 +01:00
|
|
|
static void file_header_region_init(wmWindowManager *wm, ARegion *ar)
|
2008-12-14 11:25:00 +00:00
|
|
|
{
|
2010-05-10 08:57:58 +00:00
|
|
|
wmKeyMap *keymap;
|
|
|
|
|
2009-06-29 20:23:40 +00:00
|
|
|
ED_region_header_init(ar);
|
2010-05-10 08:57:58 +00:00
|
|
|
|
2012-10-21 05:46:41 +00:00
|
|
|
keymap = WM_keymap_find(wm->defaultconf, "File Browser", SPACE_FILE, 0);
|
2010-05-10 08:57:58 +00:00
|
|
|
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
|
2008-12-14 11:25:00 +00:00
|
|
|
}
|
|
|
|
|
2015-11-28 17:14:45 +01:00
|
|
|
static void file_header_region_draw(const bContext *C, ARegion *ar)
|
2008-12-14 11:25:00 +00:00
|
|
|
{
|
2009-06-29 20:23:40 +00:00
|
|
|
ED_region_header(C, ar);
|
2008-12-14 11:25:00 +00:00
|
|
|
}
|
|
|
|
|
2009-01-06 14:42:54 +00:00
|
|
|
/* add handlers, stuff you only do once or on area/region changes */
|
2015-11-28 17:14:45 +01:00
|
|
|
static void file_ui_region_init(wmWindowManager *wm, ARegion *ar)
|
2009-01-06 14:42:54 +00:00
|
|
|
{
|
2009-09-17 21:36:02 +00:00
|
|
|
wmKeyMap *keymap;
|
2009-07-05 22:26:43 +00:00
|
|
|
|
2009-01-06 14:42:54 +00:00
|
|
|
UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy);
|
2009-07-05 22:26:43 +00:00
|
|
|
|
|
|
|
/* own keymap */
|
2012-03-24 02:51:46 +00:00
|
|
|
keymap = WM_keymap_find(wm->defaultconf, "File Browser", SPACE_FILE, 0);
|
2009-07-05 22:26:43 +00:00
|
|
|
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
|
|
|
|
|
2012-03-24 02:51:46 +00:00
|
|
|
keymap = WM_keymap_find(wm->defaultconf, "File Browser Buttons", SPACE_FILE, 0);
|
2009-07-05 22:26:43 +00:00
|
|
|
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
|
2009-01-06 14:42:54 +00:00
|
|
|
}
|
|
|
|
|
2015-11-28 17:14:45 +01:00
|
|
|
static void file_ui_region_draw(const bContext *C, ARegion *ar)
|
2009-01-06 14:42:54 +00:00
|
|
|
{
|
|
|
|
float col[3];
|
|
|
|
/* clear */
|
2012-12-15 16:22:18 +00:00
|
|
|
UI_GetThemeColor3fv(TH_BACK, col);
|
2009-01-06 14:42:54 +00:00
|
|
|
glClearColor(col[0], col[1], col[2], 0.0);
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT);
|
|
|
|
|
2011-10-03 04:48:14 +00:00
|
|
|
/* scrolling here is just annoying, disable it */
|
2012-09-15 11:48:20 +00:00
|
|
|
ar->v2d.cur.ymax = BLI_rctf_size_y(&ar->v2d.cur);
|
2012-03-24 02:51:46 +00:00
|
|
|
ar->v2d.cur.ymin = 0;
|
2011-10-03 04:48:14 +00:00
|
|
|
|
2009-01-06 14:42:54 +00:00
|
|
|
/* set view2d view matrix for scrolling (without scrollers) */
|
2010-10-14 01:22:14 +00:00
|
|
|
UI_view2d_view_ortho(&ar->v2d);
|
2009-01-06 14:42:54 +00:00
|
|
|
|
2011-10-03 04:48:14 +00:00
|
|
|
|
2009-01-06 14:42:54 +00:00
|
|
|
file_draw_buttons(C, ar);
|
|
|
|
|
|
|
|
UI_view2d_view_restore(C);
|
|
|
|
}
|
|
|
|
|
2015-11-28 17:14:45 +01:00
|
|
|
static void file_ui_region_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn)
|
2009-07-26 19:23:07 +00:00
|
|
|
{
|
2008-12-14 11:25:00 +00:00
|
|
|
/* context changes */
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (wmn->category) {
|
2.5
Notifiers
---------
Various fixes for wrong use of notifiers, and some new notifiers
to make things a bit more clear and consistent, with two notable
changes:
* Geometry changes are now done with NC_GEOM, rather than
NC_OBJECT|ND_GEOM_, so an object does need to be available.
* Space data now use NC_SPACE|ND_SPACE_*, instead of data
notifiers or even NC_WINDOW in some cases. Note that NC_SPACE
should only be used for notifying about changes in space data,
we don't want to go back to allqueue(REDRAW..).
Depsgraph
---------
The dependency graph now has a different flush call:
DAG_object_flush_update(scene, ob, flag)
is replaced by:
DAG_id_flush_update(id, flag)
It still works basically the same, one difference is that it now
also accepts object data (e.g. Mesh), again to avoid requiring an
Object to be available. Other ID types will simply do nothing at
the moment.
Docs
----
I made some guidelines for how/when to do which kinds of updates
and notifiers. I can't specify totally exact how to make these
decisions, but these are basically the guidelines I use. So, new
and updated docs are here:
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/NotifiersUpdates
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/DataNotifiers
2009-09-04 20:51:09 +00:00
|
|
|
case NC_SPACE:
|
2009-07-26 19:23:07 +00:00
|
|
|
switch (wmn->data) {
|
2.5
Notifiers
---------
Various fixes for wrong use of notifiers, and some new notifiers
to make things a bit more clear and consistent, with two notable
changes:
* Geometry changes are now done with NC_GEOM, rather than
NC_OBJECT|ND_GEOM_, so an object does need to be available.
* Space data now use NC_SPACE|ND_SPACE_*, instead of data
notifiers or even NC_WINDOW in some cases. Note that NC_SPACE
should only be used for notifying about changes in space data,
we don't want to go back to allqueue(REDRAW..).
Depsgraph
---------
The dependency graph now has a different flush call:
DAG_object_flush_update(scene, ob, flag)
is replaced by:
DAG_id_flush_update(id, flag)
It still works basically the same, one difference is that it now
also accepts object data (e.g. Mesh), again to avoid requiring an
Object to be available. Other ID types will simply do nothing at
the moment.
Docs
----
I made some guidelines for how/when to do which kinds of updates
and notifiers. I can't specify totally exact how to make these
decisions, but these are basically the guidelines I use. So, new
and updated docs are here:
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/NotifiersUpdates
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/DataNotifiers
2009-09-04 20:51:09 +00:00
|
|
|
case ND_SPACE_FILE_LIST:
|
2009-07-26 19:23:07 +00:00
|
|
|
ED_region_tag_redraw(ar);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-12-14 11:25:00 +00:00
|
|
|
|
2015-11-04 14:24:46 +01:00
|
|
|
static int filepath_drop_poll(bContext *C, wmDrag *drag, const wmEvent *UNUSED(event))
|
|
|
|
{
|
|
|
|
if (drag->type == WM_DRAG_PATH) {
|
|
|
|
SpaceFile *sfile = CTX_wm_space_file(C);
|
|
|
|
if (sfile) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void filepath_drop_copy(wmDrag *drag, wmDropBox *drop)
|
|
|
|
{
|
|
|
|
RNA_string_set(drop->ptr, "filepath", drag->path);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* region dropbox definition */
|
|
|
|
static void file_dropboxes(void)
|
|
|
|
{
|
|
|
|
ListBase *lb = WM_dropboxmap_find("Window", SPACE_EMPTY, RGN_TYPE_WINDOW);
|
|
|
|
|
|
|
|
WM_dropbox_add(lb, "FILE_OT_filepath_drop", filepath_drop_poll, filepath_drop_copy);
|
|
|
|
}
|
|
|
|
|
2008-12-14 11:25:00 +00:00
|
|
|
/* only called once, from space/spacetypes.c */
|
|
|
|
void ED_spacetype_file(void)
|
|
|
|
{
|
2012-06-18 13:01:24 +00:00
|
|
|
SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype file");
|
2008-12-14 11:25:00 +00:00
|
|
|
ARegionType *art;
|
|
|
|
|
2012-06-18 13:01:24 +00:00
|
|
|
st->spaceid = SPACE_FILE;
|
2009-12-19 22:37:51 +00:00
|
|
|
strncpy(st->name, "File", BKE_ST_MAXNAME);
|
2008-12-14 11:25:00 +00:00
|
|
|
|
2012-06-18 13:01:24 +00:00
|
|
|
st->new = file_new;
|
|
|
|
st->free = file_free;
|
|
|
|
st->init = file_init;
|
2013-03-15 19:56:29 +00:00
|
|
|
st->exit = file_exit;
|
2012-06-18 13:01:24 +00:00
|
|
|
st->duplicate = file_duplicate;
|
|
|
|
st->refresh = file_refresh;
|
|
|
|
st->listener = file_listener;
|
|
|
|
st->operatortypes = file_operatortypes;
|
|
|
|
st->keymap = file_keymap;
|
2015-11-04 14:24:46 +01:00
|
|
|
st->dropboxes = file_dropboxes;
|
|
|
|
|
2008-12-14 11:25:00 +00:00
|
|
|
/* regions: main window */
|
2012-06-18 13:01:24 +00:00
|
|
|
art = MEM_callocN(sizeof(ARegionType), "spacetype file region");
|
2008-12-14 11:25:00 +00:00
|
|
|
art->regionid = RGN_TYPE_WINDOW;
|
2015-11-28 17:14:45 +01:00
|
|
|
art->init = file_main_region_init;
|
|
|
|
art->draw = file_main_region_draw;
|
|
|
|
art->listener = file_main_region_listener;
|
2012-06-18 13:01:24 +00:00
|
|
|
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D;
|
2008-12-14 11:25:00 +00:00
|
|
|
BLI_addhead(&st->regiontypes, art);
|
|
|
|
|
|
|
|
/* regions: header */
|
2012-06-18 13:01:24 +00:00
|
|
|
art = MEM_callocN(sizeof(ARegionType), "spacetype file region");
|
2008-12-14 11:25:00 +00:00
|
|
|
art->regionid = RGN_TYPE_HEADER;
|
2012-06-18 13:01:24 +00:00
|
|
|
art->prefsizey = HEADERY;
|
|
|
|
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_HEADER;
|
2015-11-28 17:14:45 +01:00
|
|
|
art->init = file_header_region_init;
|
|
|
|
art->draw = file_header_region_draw;
|
|
|
|
// art->listener = file_header_region_listener;
|
2008-12-14 11:25:00 +00:00
|
|
|
BLI_addhead(&st->regiontypes, art);
|
2008-12-14 12:16:55 +00:00
|
|
|
|
2009-01-06 14:42:54 +00:00
|
|
|
/* regions: ui */
|
2012-06-18 13:01:24 +00:00
|
|
|
art = MEM_callocN(sizeof(ARegionType), "spacetype file region");
|
2009-01-06 14:42:54 +00:00
|
|
|
art->regionid = RGN_TYPE_UI;
|
2012-06-18 13:01:24 +00:00
|
|
|
art->prefsizey = 60;
|
|
|
|
art->keymapflag = ED_KEYMAP_UI;
|
2015-11-28 17:14:45 +01:00
|
|
|
art->listener = file_ui_region_listener;
|
|
|
|
art->init = file_ui_region_init;
|
|
|
|
art->draw = file_ui_region_draw;
|
2009-01-06 14:42:54 +00:00
|
|
|
BLI_addhead(&st->regiontypes, art);
|
|
|
|
|
|
|
|
/* regions: channels (directories) */
|
2012-06-18 13:01:24 +00:00
|
|
|
art = MEM_callocN(sizeof(ARegionType), "spacetype file region");
|
2015-02-11 00:09:45 +01:00
|
|
|
art->regionid = RGN_TYPE_TOOLS;
|
2012-06-18 13:01:24 +00:00
|
|
|
art->prefsizex = 240;
|
2015-02-11 00:09:45 +01:00
|
|
|
art->prefsizey = 60;
|
|
|
|
art->keymapflag = ED_KEYMAP_UI;
|
2015-11-28 17:14:45 +01:00
|
|
|
art->listener = file_tools_region_listener;
|
|
|
|
art->init = file_tools_region_init;
|
|
|
|
art->draw = file_tools_region_draw;
|
2015-02-11 00:09:45 +01:00
|
|
|
BLI_addhead(&st->regiontypes, art);
|
|
|
|
|
|
|
|
/* regions: tool properties */
|
|
|
|
art = MEM_callocN(sizeof(ARegionType), "spacetype file operator region");
|
|
|
|
art->regionid = RGN_TYPE_TOOL_PROPS;
|
|
|
|
art->prefsizex = 0;
|
2015-02-17 15:15:55 +01:00
|
|
|
art->prefsizey = 360;
|
2012-06-18 13:01:24 +00:00
|
|
|
art->keymapflag = ED_KEYMAP_UI;
|
2015-11-28 17:14:45 +01:00
|
|
|
art->listener = file_tools_region_listener;
|
|
|
|
art->init = file_tools_region_init;
|
|
|
|
art->draw = file_tools_region_draw;
|
2008-12-14 12:16:55 +00:00
|
|
|
BLI_addhead(&st->regiontypes, art);
|
2009-06-29 20:23:40 +00:00
|
|
|
file_panels_register(art);
|
|
|
|
|
2008-12-14 11:25:00 +00:00
|
|
|
BKE_spacetype_register(st);
|
2009-01-06 14:42:54 +00:00
|
|
|
|
2008-12-14 11:25:00 +00:00
|
|
|
}
|
|
|
|
|
2009-01-06 14:42:54 +00:00
|
|
|
void ED_file_init(void)
|
|
|
|
{
|
2013-12-20 17:39:22 +01:00
|
|
|
ED_file_read_bookmarks();
|
2010-07-04 15:35:23 +00:00
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
if (G.background == false) {
|
2012-08-08 08:25:20 +00:00
|
|
|
filelist_init_icons();
|
|
|
|
}
|
|
|
|
|
2009-03-03 10:24:06 +00:00
|
|
|
IMB_thumb_makedirs();
|
2009-01-06 14:42:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ED_file_exit(void)
|
|
|
|
{
|
2013-12-20 17:39:22 +01:00
|
|
|
fsmenu_free();
|
2012-08-08 08:25:20 +00:00
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
if (G.background == false) {
|
2012-08-08 08:25:20 +00:00
|
|
|
filelist_free_icons();
|
|
|
|
}
|
2009-01-18 18:24:11 +00:00
|
|
|
}
|
2013-12-20 17:39:22 +01:00
|
|
|
|
|
|
|
void ED_file_read_bookmarks(void)
|
|
|
|
{
|
2014-11-23 15:54:29 +01:00
|
|
|
const char * const cfgdir = BKE_appdir_folder_id(BLENDER_USER_CONFIG, NULL);
|
2013-12-20 17:39:22 +01:00
|
|
|
|
|
|
|
fsmenu_free();
|
|
|
|
|
2015-02-11 00:09:45 +01:00
|
|
|
fsmenu_read_system(ED_fsmenu_get(), true);
|
2013-12-20 17:39:22 +01:00
|
|
|
|
|
|
|
if (cfgdir) {
|
|
|
|
char name[FILE_MAX];
|
|
|
|
BLI_make_file_string("/", name, cfgdir, BLENDER_BOOKMARK_FILE);
|
2015-02-11 00:09:45 +01:00
|
|
|
fsmenu_read_bookmarks(ED_fsmenu_get(), name);
|
2013-12-20 17:39:22 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|