2013-08-23 22:35:00 +02:00
|
|
|
/*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
2015-04-07 03:01:47 +02:00
|
|
|
#ifndef __BKE_OUTLINER_TREEHASH_H__
|
|
|
|
#define __BKE_OUTLINER_TREEHASH_H__
|
2013-08-23 22:35:00 +02:00
|
|
|
|
2015-04-07 03:01:47 +02:00
|
|
|
/** \file BKE_outliner_treehash.h
|
2013-08-23 22:35:00 +02:00
|
|
|
* \ingroup bke
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct BLI_mempool;
|
2019-01-28 11:08:24 +01:00
|
|
|
struct ID;
|
2013-08-23 22:35:00 +02:00
|
|
|
struct TreeStoreElem;
|
|
|
|
|
|
|
|
/* create and fill hashtable with treestore elements */
|
2015-04-07 03:01:47 +02:00
|
|
|
void *BKE_outliner_treehash_create_from_treestore(struct BLI_mempool *treestore);
|
2013-08-23 22:35:00 +02:00
|
|
|
|
|
|
|
/* full rebuild for already allocated hashtable */
|
2015-04-07 03:01:47 +02:00
|
|
|
void *BKE_outliner_treehash_rebuild_from_treestore(void *treehash, struct BLI_mempool *treestore);
|
2013-08-23 22:35:00 +02:00
|
|
|
|
2018-05-28 17:07:52 +02:00
|
|
|
/* clear element usage flags */
|
|
|
|
void BKE_outliner_treehash_clear_used(void *treehash);
|
|
|
|
|
Outliner: Delete all selected collections, not just active one
There were some issues with how we store outliner tree elements:
Apparently the only removable elements have been data-blocks so far.
When recreating the TreeElements, their TreeStoreElem instances were
mainly identified by their ID pointer. However non-data-blocks mostly
depend on an index. For collections, such an index isn't a reliable
measure though if we want to allow removing items. Depending on it for
identifying the TreeStoreElem instance would cause some quite noticeable
glitches (wrong highlights, two elements sharing highlight, etc).
For now I've solved that by actually removing the TreeStoreElem that
represents the removed element. A little limitation of this is that
after undoing the removal, some information might get lost, like
flags to store selection, or opened/closed state.
A better solution that would also fix this issue would be having a real
unique identifier for each non-data-block element, like an idname or even
its data-pointer. Not sure if we can get those to work reliable with
file read/write though, would have to investigate...
Also added a general Outliner tree traversal utility.
2017-02-28 20:37:14 +01:00
|
|
|
/* Add/remove hashtable elements */
|
2015-04-07 03:01:47 +02:00
|
|
|
void BKE_outliner_treehash_add_element(void *treehash, struct TreeStoreElem *elem);
|
Outliner: Delete all selected collections, not just active one
There were some issues with how we store outliner tree elements:
Apparently the only removable elements have been data-blocks so far.
When recreating the TreeElements, their TreeStoreElem instances were
mainly identified by their ID pointer. However non-data-blocks mostly
depend on an index. For collections, such an index isn't a reliable
measure though if we want to allow removing items. Depending on it for
identifying the TreeStoreElem instance would cause some quite noticeable
glitches (wrong highlights, two elements sharing highlight, etc).
For now I've solved that by actually removing the TreeStoreElem that
represents the removed element. A little limitation of this is that
after undoing the removal, some information might get lost, like
flags to store selection, or opened/closed state.
A better solution that would also fix this issue would be having a real
unique identifier for each non-data-block element, like an idname or even
its data-pointer. Not sure if we can get those to work reliable with
file read/write though, would have to investigate...
Also added a general Outliner tree traversal utility.
2017-02-28 20:37:14 +01:00
|
|
|
void BKE_outliner_treehash_remove_element(void *treehash, struct TreeStoreElem *elem);
|
2013-08-23 22:35:00 +02:00
|
|
|
|
|
|
|
/* find first unused element with specific type, nr and id */
|
2015-04-07 03:01:47 +02:00
|
|
|
struct TreeStoreElem *BKE_outliner_treehash_lookup_unused(void *treehash, short type, short nr, struct ID *id);
|
2013-08-23 22:35:00 +02:00
|
|
|
|
|
|
|
/* find user or unused element with specific type, nr and id */
|
2015-04-07 03:01:47 +02:00
|
|
|
struct TreeStoreElem *BKE_outliner_treehash_lookup_any(void *treehash, short type, short nr, struct ID *id);
|
2013-08-23 22:35:00 +02:00
|
|
|
|
|
|
|
/* free treehash structure */
|
2015-04-07 03:01:47 +02:00
|
|
|
void BKE_outliner_treehash_free(void *treehash);
|
2013-08-23 22:35:00 +02:00
|
|
|
|
|
|
|
#endif
|