Blender
V2.93
source
blender
editors
asset
asset_edit.cc
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
21
#include "
BKE_asset.h
"
22
#include "
BKE_context.h
"
23
#include "
BKE_lib_id.h
"
24
25
#include "
DNA_ID.h
"
26
27
#include "
UI_interface_icons.h
"
28
29
#include "
RNA_access.h
"
30
31
#include "
ED_asset.h
"
32
33
bool
ED_asset_mark_id
(
const
bContext
*
C
,
ID
*
id
)
34
{
35
if
(
id
->
asset_data
) {
36
return
false
;
37
}
38
if
(!
BKE_id_can_be_asset
(
id
)) {
39
return
false
;
40
}
41
42
id_fake_user_set
(
id
);
43
44
id
->asset_data =
BKE_asset_metadata_create
();
45
46
UI_icon_render_id
(
C
,
nullptr
,
id
,
ICON_SIZE_PREVIEW
,
true
);
47
48
return
true
;
49
}
50
51
bool
ED_asset_clear_id
(
ID
*
id
)
52
{
53
if
(!
id
->
asset_data
) {
54
return
false
;
55
}
56
BKE_asset_metadata_free
(&
id
->
asset_data
);
57
/* Don't clear fake user here, there's no guarantee that it was actually set by
58
* #ED_asset_mark_id(), it might have been something/someone else. */
59
60
return
true
;
61
}
62
63
bool
ED_asset_can_make_single_from_context
(
const
bContext
*
C
)
64
{
65
/* Context needs a "id" pointer to be set for #ASSET_OT_mark()/#ASSET_OT_clear() to use. */
66
return
CTX_data_pointer_get_type_silent
(
C
,
"id"
, &
RNA_ID
).
data
!=
nullptr
;
67
}
BKE_asset.h
BKE_asset_metadata_create
struct AssetMetaData * BKE_asset_metadata_create(void)
Definition:
asset.cc:40
BKE_asset_metadata_free
void BKE_asset_metadata_free(struct AssetMetaData **asset_data)
Definition:
asset.cc:47
BKE_context.h
CTX_data_pointer_get_type_silent
PointerRNA CTX_data_pointer_get_type_silent(const bContext *C, const char *member, StructRNA *type)
Definition:
context.c:475
BKE_lib_id.h
id_fake_user_set
void id_fake_user_set(struct ID *id)
Definition:
lib_id.c:328
BKE_id_can_be_asset
bool BKE_id_can_be_asset(const struct ID *id)
DNA_ID.h
ID and Library types, which are fundamental for sdna.
ICON_SIZE_PREVIEW
@ ICON_SIZE_PREVIEW
Definition:
DNA_ID_enums.h:30
ED_asset.h
RNA_access.h
RNA_ID
StructRNA RNA_ID
C
#define C
Definition:
RandGen.cpp:39
UI_interface_icons.h
UI_icon_render_id
void UI_icon_render_id(const struct bContext *C, struct Scene *scene, struct ID *id, const enum eIconSizes size, const bool use_job)
ED_asset_clear_id
bool ED_asset_clear_id(ID *id)
Definition:
asset_edit.cc:51
ED_asset_mark_id
bool ED_asset_mark_id(const bContext *C, ID *id)
Definition:
asset_edit.cc:33
ED_asset_can_make_single_from_context
bool ED_asset_can_make_single_from_context(const bContext *C)
Definition:
asset_edit.cc:63
id
ID * id
Definition:
deg_eval_runtime_backup_animation.cc:44
ID
Definition:
DNA_ID.h:273
ID::asset_data
struct AssetMetaData * asset_data
Definition:
DNA_ID.h:280
PointerRNA::data
void * data
Definition:
RNA_types.h:52
bContext
Definition:
context.c:69
Generated on Tue Jan 31 2023 14:37:24 for Blender by
doxygen
1.9.1