Blender  V2.93
outliner_context.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2017 Blender Foundation.
17  * All rights reserved.
18  */
19 
24 #include "BLI_listbase.h"
25 
26 #include "BKE_context.h"
27 
28 #include "DNA_space_types.h"
29 
30 #include "outliner_intern.h"
31 
34 {
35  LISTBASE_FOREACH (const TreeElement *, te, subtree) {
36  const TreeStoreElem *tse = TREESTORE(te);
37  if ((tse->flag & TSE_SELECTED) && (ELEM(tse->type, TSE_SOME_ID, TSE_LAYER_COLLECTION))) {
39  }
41  }
42 }
43 
44 static void outliner_context_selected_ids(const SpaceOutliner *space_outliner,
46 {
49 }
50 
51 static const char *outliner_context_dir[] = {"selected_ids", NULL};
52 
53 int /*eContextResult*/ outliner_context(const bContext *C,
54  const char *member,
56 {
57  SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
58 
59  if (CTX_data_dir(member)) {
61  return CTX_RESULT_OK;
62  }
63  if (CTX_data_equals(member, "selected_ids")) {
64  outliner_context_selected_ids(space_outliner, result);
65  return CTX_RESULT_OK;
66  }
67  /* Note: Querying non-ID selection could also work if tree elements stored their matching RNA
68  * struct type. */
69 
71 }
void CTX_data_dir_set(bContextDataResult *result, const char **dir)
Definition: context.c:672
bool CTX_data_equals(const char *member, const char *str)
Definition: context.c:623
bool CTX_data_dir(const char *member)
Definition: context.c:628
void CTX_data_id_list_add(bContextDataResult *result, struct ID *id)
Definition: context.c:643
struct SpaceOutliner * CTX_wm_space_outliner(const bContext *C)
Definition: context.c:836
@ CTX_DATA_TYPE_COLLECTION
Definition: BKE_context.h:221
@ CTX_RESULT_MEMBER_NOT_FOUND
Definition: BKE_context.h:86
@ CTX_RESULT_OK
Definition: BKE_context.h:83
void CTX_data_type_set(struct bContextDataResult *result, short type)
Definition: context.c:677
#define LISTBASE_FOREACH(type, var, list)
Definition: BLI_listbase.h:172
#define ELEM(...)
@ TSE_LAYER_COLLECTION
@ TSE_SOME_ID
@ TSE_SELECTED
#define C
Definition: RandGen.cpp:39
int outliner_context(const bContext *C, const char *member, bContextDataResult *result)
static const char * outliner_context_dir[]
static void outliner_context_selected_ids_recursive(const ListBase *subtree, bContextDataResult *result)
static void outliner_context_selected_ids(const SpaceOutliner *space_outliner, bContextDataResult *result)
#define TREESTORE(a)