Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_templates.cc
- This file was moved from source/blender/editors/interface/interface_templates.c.
| Context not available. | |||||
| * \ingroup edinterface | * \ingroup edinterface | ||||
| */ | */ | ||||
| #include <ctype.h> | #include <cctype> | ||||
| #include <stddef.h> | #include <cstddef> | ||||
| #include <stdlib.h> | #include <cstdlib> | ||||
| #include <string.h> | #include <cstring> | ||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| Context not available. | |||||
| const bool live_icon) | const bool live_icon) | ||||
| { | { | ||||
| const PointerRNA active_ptr = RNA_property_pointer_get(ptr, prop); | const PointerRNA active_ptr = RNA_property_pointer_get(ptr, prop); | ||||
| ID *id = (active_ptr.data && RNA_struct_is_ID(active_ptr.type)) ? active_ptr.data : NULL; | ID *id = (active_ptr.data && RNA_struct_is_ID(active_ptr.type)) ? | ||||
| static_cast<ID *>(active_ptr.data) : | |||||
| nullptr; | |||||
| const ID *idfrom = ptr->owner_id; | const ID *idfrom = ptr->owner_id; | ||||
| const StructRNA *type = active_ptr.type ? active_ptr.type : RNA_property_pointer_type(ptr, prop); | const StructRNA *type = active_ptr.type ? active_ptr.type : RNA_property_pointer_type(ptr, prop); | ||||
| uiBut *but; | uiBut *but; | ||||
| Context not available. | |||||
| const bool use_preview_icon = use_big_size || (id && (GS(id->name) != ID_SCR)); | const bool use_preview_icon = use_big_size || (id && (GS(id->name) != ID_SCR)); | ||||
| const short width = UI_UNIT_X * (use_big_size ? 6 : 1.6f); | const short width = UI_UNIT_X * (use_big_size ? 6 : 1.6f); | ||||
| const short height = UI_UNIT_Y * (use_big_size ? 6 : 1); | const short height = UI_UNIT_Y * (use_big_size ? 6 : 1); | ||||
| uiLayout *col = NULL; | uiLayout *col = nullptr; | ||||
| if (use_big_size) { | if (use_big_size) { | ||||
| /* Assume column layout here. To be more correct, we should check if the layout passed to | /* Assume column layout here. To be more correct, we should check if the layout passed to | ||||
| Context not available. | |||||
| const int h = 5 * U.widget_unit * preview_rows * scale; | const int h = 5 * U.widget_unit * preview_rows * scale; | ||||
| /* fake button, it holds space for search items */ | /* fake button, it holds space for search items */ | ||||
| uiDefBut(block, UI_BTYPE_LABEL, 0, "", 10, 26, w, h, NULL, 0, 0, 0, 0, NULL); | uiDefBut(block, UI_BTYPE_LABEL, 0, "", 10, 26, w, h, nullptr, 0, 0, 0, 0, nullptr); | ||||
| but = uiDefSearchBut(block, | but = uiDefSearchBut(block, | ||||
| search, | search, | ||||
| Context not available. | |||||
| 15, | 15, | ||||
| searchbox_width, | searchbox_width, | ||||
| searchbox_height, | searchbox_height, | ||||
| NULL, | nullptr, | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| NULL); | nullptr); | ||||
| but = uiDefSearchBut(block, | but = uiDefSearchBut(block, | ||||
| search, | search, | ||||
| 0, | 0, | ||||
| Context not available. | |||||
| search_update_fn, | search_update_fn, | ||||
| search_arg, | search_arg, | ||||
| false, | false, | ||||
| NULL, | nullptr, | ||||
| search_exec_fn, | search_exec_fn, | ||||
| active_item); | active_item); | ||||
| UI_but_func_search_set_tooltip(but, item_tooltip_fn); | UI_but_func_search_set_tooltip(but, item_tooltip_fn); | ||||
| Context not available. | |||||
| /** \name Search Callbacks | /** \name Search Callbacks | ||||
| * \{ */ | * \{ */ | ||||
| typedef struct TemplateID { | struct TemplateID { | ||||
| PointerRNA ptr; | PointerRNA ptr; | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| Context not available. | |||||
| int prv_rows, prv_cols; | int prv_rows, prv_cols; | ||||
| bool preview; | bool preview; | ||||
| float scale; | float scale; | ||||
| } TemplateID; | }; | ||||
| /* Search browse menu, assign. */ | /* Search browse menu, assign. */ | ||||
| static void template_ID_set_property_exec_fn(bContext *C, void *arg_template, void *item) | static void template_ID_set_property_exec_fn(bContext *C, void *arg_template, void *item) | ||||
| Context not available. | |||||
| if (item) { | if (item) { | ||||
| PointerRNA idptr; | PointerRNA idptr; | ||||
| RNA_id_pointer_create(item, &idptr); | RNA_id_pointer_create(static_cast<ID *>(item), &idptr); | ||||
| RNA_property_pointer_set(&template_ui->ptr, template_ui->prop, idptr, NULL); | RNA_property_pointer_set(&template_ui->ptr, template_ui->prop, idptr, nullptr); | ||||
| RNA_property_update(C, &template_ui->ptr, template_ui->prop); | RNA_property_update(C, &template_ui->ptr, template_ui->prop); | ||||
| } | } | ||||
| } | } | ||||
| Context not available. | |||||
| void *arg_template, | void *arg_template, | ||||
| const char *str, | const char *str, | ||||
| uiSearchItems *items, | uiSearchItems *items, | ||||
| const bool UNUSED(is_first)) | const bool /*is_first*/) | ||||
| { | { | ||||
| TemplateID *template_ui = (TemplateID *)arg_template; | TemplateID *template_ui = (TemplateID *)arg_template; | ||||
| ListBase *lb = template_ui->idlb; | ListBase *lb = template_ui->idlb; | ||||
| Context not available. | |||||
| void *arg_template, | void *arg_template, | ||||
| const char *str, | const char *str, | ||||
| uiSearchItems *items, | uiSearchItems *items, | ||||
| const bool UNUSED(is_first)) | const bool /*is_first*/) | ||||
| { | { | ||||
| TemplateID *template_ui = (TemplateID *)arg_template; | TemplateID *template_ui = (TemplateID *)arg_template; | ||||
| ListBase *lb = template_ui->idlb; | ListBase *lb = template_ui->idlb; | ||||
| Scene *scene = NULL; | Scene *scene = nullptr; | ||||
| ID *id_from = template_ui->ptr.owner_id; | ID *id_from = template_ui->ptr.owner_id; | ||||
| if (id_from && GS(id_from->name) == ID_SCE) { | if (id_from && GS(id_from->name) == ID_SCE) { | ||||
| Context not available. | |||||
| static ARegion *template_ID_search_menu_item_tooltip( | static ARegion *template_ID_search_menu_item_tooltip( | ||||
| bContext *C, ARegion *region, const rcti *item_rect, void *arg, void *active) | bContext *C, ARegion *region, const rcti *item_rect, void *arg, void *active) | ||||
| { | { | ||||
| TemplateID *template_ui = arg; | TemplateID *template_ui = static_cast<TemplateID *>(arg); | ||||
| ID *active_id = active; | ID *active_id = static_cast<ID *>(active); | ||||
| StructRNA *type = RNA_property_pointer_type(&template_ui->ptr, template_ui->prop); | StructRNA *type = RNA_property_pointer_type(&template_ui->ptr, template_ui->prop); | ||||
| uiSearchItemTooltipData tooltip_data = {0}; | uiSearchItemTooltipData tooltip_data = {0}; | ||||
| Context not available. | |||||
| uiBut *but = UI_context_active_but_get(C); | uiBut *but = UI_context_active_but_get(C); | ||||
| memset(r_ptr, 0, sizeof(*r_ptr)); | memset(r_ptr, 0, sizeof(*r_ptr)); | ||||
| *r_prop = NULL; | *r_prop = nullptr; | ||||
| if (but && (but->funcN == template_id_cb) && but->func_argN) { | if (but && (but->funcN == template_id_cb) && but->func_argN) { | ||||
| TemplateID *template_ui = but->func_argN; | TemplateID *template_ui = static_cast<TemplateID *>(but->func_argN); | ||||
| *r_ptr = template_ui->ptr; | *r_ptr = template_ui->ptr; | ||||
| *r_prop = template_ui->prop; | *r_prop = template_ui->prop; | ||||
| } | } | ||||
| Context not available. | |||||
| *r_collection_parent_best = collection; | *r_collection_parent_best = collection; | ||||
| } | } | ||||
| } | } | ||||
| for (CollectionParent *iter = collection->parents.first; iter != NULL; iter = iter->next) { | for (CollectionParent *iter = static_cast<CollectionParent *>(collection->parents.first); | ||||
| iter != nullptr; | |||||
| iter = iter->next) { | |||||
| if (iter->collection->id.lib != collection->id.lib && ID_IS_LINKED(iter->collection)) { | if (iter->collection->id.lib != collection->id.lib && ID_IS_LINKED(iter->collection)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| Context not available. | |||||
| /* Tag all local parents of the root collection, so that usages of the root collection and other | /* Tag all local parents of the root collection, so that usages of the root collection and other | ||||
| * linked ones can be replaced by the local overrides in those parents too. */ | * linked ones can be replaced by the local overrides in those parents too. */ | ||||
| if (do_parents) { | if (do_parents) { | ||||
| for (CollectionParent *iter = root_collection->parents.first; iter != NULL; | for (CollectionParent *iter = static_cast<CollectionParent *>(root_collection->parents.first); | ||||
| iter != nullptr; | |||||
| iter = iter->next) { | iter = iter->next) { | ||||
| if (ID_IS_LINKED(iter->collection)) { | if (ID_IS_LINKED(iter->collection)) { | ||||
| continue; | continue; | ||||
| Context not available. | |||||
| } | } | ||||
| } | } | ||||
| for (CollectionChild *iter = root_collection->children.first; iter != NULL; iter = iter->next) { | for (CollectionChild *iter = static_cast<CollectionChild *>(root_collection->children.first); | ||||
| iter != nullptr; | |||||
| iter = iter->next) { | |||||
| if (iter->collection->id.lib != root_collection->id.lib && ID_IS_LINKED(root_collection)) { | if (iter->collection->id.lib != root_collection->id.lib && ID_IS_LINKED(root_collection)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| Context not available. | |||||
| bContext *C, Main *bmain, ID *owner_id, ID *id, const char **r_undo_push_label) | bContext *C, Main *bmain, ID *owner_id, ID *id, const char **r_undo_push_label) | ||||
| { | { | ||||
| const char *undo_push_label; | const char *undo_push_label; | ||||
| if (r_undo_push_label == NULL) { | if (r_undo_push_label == nullptr) { | ||||
| r_undo_push_label = &undo_push_label; | r_undo_push_label = &undo_push_label; | ||||
| } | } | ||||
| Context not available. | |||||
| * system override with reset. */ | * system override with reset. */ | ||||
| if (!ID_IS_LINKED(id) && ID_IS_OVERRIDE_LIBRARY(id)) { | if (!ID_IS_LINKED(id) && ID_IS_OVERRIDE_LIBRARY(id)) { | ||||
| if (!ID_IS_OVERRIDE_LIBRARY_REAL(id)) { | if (!ID_IS_OVERRIDE_LIBRARY_REAL(id)) { | ||||
| BKE_lib_override_library_get(bmain, id, NULL, &id); | BKE_lib_override_library_get(bmain, id, nullptr, &id); | ||||
| } | } | ||||
| if (id->override_library->flag & IDOVERRIDE_LIBRARY_FLAG_SYSTEM_DEFINED) { | if (id->override_library->flag & IDOVERRIDE_LIBRARY_FLAG_SYSTEM_DEFINED) { | ||||
| id->override_library->flag &= ~IDOVERRIDE_LIBRARY_FLAG_SYSTEM_DEFINED; | id->override_library->flag &= ~IDOVERRIDE_LIBRARY_FLAG_SYSTEM_DEFINED; | ||||
| Context not available. | |||||
| *r_undo_push_label = "Clear Library Override Hierarchy"; | *r_undo_push_label = "Clear Library Override Hierarchy"; | ||||
| } | } | ||||
| WM_event_add_notifier(C, NC_WM | ND_DATACHANGED, NULL); | WM_event_add_notifier(C, NC_WM | ND_DATACHANGED, nullptr); | ||||
| WM_event_add_notifier(C, NC_WM | ND_LIB_OVERRIDE_CHANGED, NULL); | WM_event_add_notifier(C, NC_WM | ND_LIB_OVERRIDE_CHANGED, nullptr); | ||||
| WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, NULL); | WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, nullptr); | ||||
| return id; | return id; | ||||
| } | } | ||||
| Context not available. | |||||
| * context, better to abort than create random overrides all over the place. */ | * context, better to abort than create random overrides all over the place. */ | ||||
| if (!ID_IS_OVERRIDABLE_LIBRARY_HIERARCHY(id)) { | if (!ID_IS_OVERRIDABLE_LIBRARY_HIERARCHY(id)) { | ||||
| WM_reportf(RPT_ERROR, "The data-block %s is not overridable", id->name); | WM_reportf(RPT_ERROR, "The data-block %s is not overridable", id->name); | ||||
| return NULL; | return nullptr; | ||||
| } | } | ||||
| Object *object_active = CTX_data_active_object(C); | Object *object_active = CTX_data_active_object(C); | ||||
| if (object_active == NULL && GS(owner_id->name) == ID_OB) { | if (object_active == nullptr && GS(owner_id->name) == ID_OB) { | ||||
| object_active = (Object *)owner_id; | object_active = (Object *)owner_id; | ||||
| } | } | ||||
| if (object_active != NULL) { | if (object_active != nullptr) { | ||||
| if (ID_IS_LINKED(object_active)) { | if (ID_IS_LINKED(object_active)) { | ||||
| if (object_active->id.lib != id->lib || | if (object_active->id.lib != id->lib || | ||||
| !ID_IS_OVERRIDABLE_LIBRARY_HIERARCHY(object_active)) { | !ID_IS_OVERRIDABLE_LIBRARY_HIERARCHY(object_active)) { | ||||
| /* The active object is from a different library than the overridden ID, or otherwise | /* The active object is from a different library than the overridden ID, or otherwise | ||||
| * cannot be used in hierarchy. */ | * cannot be used in hierarchy. */ | ||||
| object_active = NULL; | object_active = nullptr; | ||||
| } | } | ||||
| } | } | ||||
| else if (!ID_IS_OVERRIDE_LIBRARY_REAL(object_active)) { | else if (!ID_IS_OVERRIDE_LIBRARY_REAL(object_active)) { | ||||
| /* Fully local object cannot be used in override hierarchy either. */ | /* Fully local object cannot be used in override hierarchy either. */ | ||||
| object_active = NULL; | object_active = nullptr; | ||||
| } | } | ||||
| } | } | ||||
| Collection *collection_active = CTX_data_collection(C); | Collection *collection_active = CTX_data_collection(C); | ||||
| if (collection_active == NULL && GS(owner_id->name) == ID_GR) { | if (collection_active == nullptr && GS(owner_id->name) == ID_GR) { | ||||
| collection_active = (Collection *)owner_id; | collection_active = (Collection *)owner_id; | ||||
| } | } | ||||
| if (collection_active != NULL) { | if (collection_active != nullptr) { | ||||
| if (ID_IS_LINKED(collection_active)) { | if (ID_IS_LINKED(collection_active)) { | ||||
| if (collection_active->id.lib != id->lib || | if (collection_active->id.lib != id->lib || | ||||
| !ID_IS_OVERRIDABLE_LIBRARY_HIERARCHY(collection_active)) { | !ID_IS_OVERRIDABLE_LIBRARY_HIERARCHY(collection_active)) { | ||||
| /* The active collection is from a different library than the overridden ID, or otherwise | /* The active collection is from a different library than the overridden ID, or otherwise | ||||
| * cannot be used in hierarchy. */ | * cannot be used in hierarchy. */ | ||||
| collection_active = NULL; | collection_active = nullptr; | ||||
| } | } | ||||
| else { | else { | ||||
| int parent_level_best = -1; | int parent_level_best = -1; | ||||
| Collection *collection_parent_best = NULL; | Collection *collection_parent_best = nullptr; | ||||
| template_id_liboverride_hierarchy_collection_root_find_recursive( | template_id_liboverride_hierarchy_collection_root_find_recursive( | ||||
| collection_active, 0, &collection_parent_best, &parent_level_best); | collection_active, 0, &collection_parent_best, &parent_level_best); | ||||
| collection_active = collection_parent_best; | collection_active = collection_parent_best; | ||||
| Context not available. | |||||
| } | } | ||||
| else if (!ID_IS_OVERRIDE_LIBRARY_REAL(collection_active)) { | else if (!ID_IS_OVERRIDE_LIBRARY_REAL(collection_active)) { | ||||
| /* Fully local collection cannot be used in override hierarchy either. */ | /* Fully local collection cannot be used in override hierarchy either. */ | ||||
| collection_active = NULL; | collection_active = nullptr; | ||||
| } | } | ||||
| } | } | ||||
| if (collection_active == NULL && object_active != NULL && | if (collection_active == nullptr && object_active != nullptr && | ||||
| (ID_IS_LINKED(object_active) || ID_IS_OVERRIDE_LIBRARY_REAL(object_active))) { | (ID_IS_LINKED(object_active) || ID_IS_OVERRIDE_LIBRARY_REAL(object_active))) { | ||||
| /* If we failed to find a valid 'active' collection so far for our override hierarchy, but do | /* If we failed to find a valid 'active' collection so far for our override hierarchy, but do | ||||
| * have a valid 'active' object, try to find a collection from that object. */ | * have a valid 'active' object, try to find a collection from that object. */ | ||||
| Context not available. | |||||
| continue; | continue; | ||||
| } | } | ||||
| int parent_level_best = -1; | int parent_level_best = -1; | ||||
| Collection *collection_parent_best = NULL; | Collection *collection_parent_best = nullptr; | ||||
| template_id_liboverride_hierarchy_collection_root_find_recursive( | template_id_liboverride_hierarchy_collection_root_find_recursive( | ||||
| collection_iter, 0, &collection_parent_best, &parent_level_best); | collection_iter, 0, &collection_parent_best, &parent_level_best); | ||||
| collection_active = collection_parent_best; | collection_active = collection_parent_best; | ||||
| Context not available. | |||||
| } | } | ||||
| } | } | ||||
| ID *id_override = NULL; | ID *id_override = nullptr; | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| ViewLayer *view_layer = CTX_data_view_layer(C); | ViewLayer *view_layer = CTX_data_view_layer(C); | ||||
| switch (GS(id->name)) { | switch (GS(id->name)) { | ||||
| case ID_GR: | case ID_GR: | ||||
| if (collection_active != NULL && | if (collection_active != nullptr && | ||||
| BKE_collection_has_collection(collection_active, (Collection *)id)) { | BKE_collection_has_collection(collection_active, (Collection *)id)) { | ||||
| template_id_liboverride_hierarchy_collections_tag_recursive(collection_active, id, true); | template_id_liboverride_hierarchy_collections_tag_recursive(collection_active, id, true); | ||||
| if (object_active != NULL) { | if (object_active != nullptr) { | ||||
| object_active->id.tag |= LIB_TAG_DOIT; | object_active->id.tag |= LIB_TAG_DOIT; | ||||
| } | } | ||||
| BKE_lib_override_library_create( | BKE_lib_override_library_create(bmain, | ||||
| bmain, scene, view_layer, NULL, id, &collection_active->id, NULL, &id_override, false); | scene, | ||||
| view_layer, | |||||
| nullptr, | |||||
| id, | |||||
| &collection_active->id, | |||||
| nullptr, | |||||
| &id_override, | |||||
| false); | |||||
| } | } | ||||
| else if (object_active != NULL && !ID_IS_LINKED(object_active) && | else if (object_active != nullptr && !ID_IS_LINKED(object_active) && | ||||
| &object_active->instance_collection->id == id) { | &object_active->instance_collection->id == id) { | ||||
| object_active->id.tag |= LIB_TAG_DOIT; | object_active->id.tag |= LIB_TAG_DOIT; | ||||
| BKE_lib_override_library_create(bmain, | BKE_lib_override_library_create(bmain, | ||||
| Context not available. | |||||
| } | } | ||||
| break; | break; | ||||
| case ID_OB: | case ID_OB: | ||||
| if (collection_active != NULL && | if (collection_active != nullptr && | ||||
| BKE_collection_has_object_recursive(collection_active, (Object *)id)) { | BKE_collection_has_object_recursive(collection_active, (Object *)id)) { | ||||
| template_id_liboverride_hierarchy_collections_tag_recursive(collection_active, id, true); | template_id_liboverride_hierarchy_collections_tag_recursive(collection_active, id, true); | ||||
| if (object_active != NULL) { | if (object_active != nullptr) { | ||||
| object_active->id.tag |= LIB_TAG_DOIT; | object_active->id.tag |= LIB_TAG_DOIT; | ||||
| } | } | ||||
| BKE_lib_override_library_create( | BKE_lib_override_library_create(bmain, | ||||
| bmain, scene, view_layer, NULL, id, &collection_active->id, NULL, &id_override, false); | scene, | ||||
| view_layer, | |||||
| nullptr, | |||||
| id, | |||||
| &collection_active->id, | |||||
| nullptr, | |||||
| &id_override, | |||||
| false); | |||||
| } | } | ||||
| else { | else { | ||||
| if (object_active != NULL) { | if (object_active != nullptr) { | ||||
| object_active->id.tag |= LIB_TAG_DOIT; | object_active->id.tag |= LIB_TAG_DOIT; | ||||
| } | } | ||||
| BKE_lib_override_library_create( | BKE_lib_override_library_create( | ||||
| bmain, scene, view_layer, NULL, id, NULL, NULL, &id_override, false); | bmain, scene, view_layer, nullptr, id, nullptr, nullptr, &id_override, false); | ||||
| BKE_scene_collections_object_remove(bmain, scene, (Object *)id, true); | BKE_scene_collections_object_remove(bmain, scene, (Object *)id, true); | ||||
| WM_event_add_notifier(C, NC_ID | NA_REMOVED, NULL); | WM_event_add_notifier(C, NC_ID | NA_REMOVED, nullptr); | ||||
| } | } | ||||
| break; | break; | ||||
| case ID_ME: | case ID_ME: | ||||
| Context not available. | |||||
| case ID_PT: | case ID_PT: | ||||
| case ID_VO: | case ID_VO: | ||||
| case ID_NT: /* Essentially geometry nodes from modifier currently. */ | case ID_NT: /* Essentially geometry nodes from modifier currently. */ | ||||
| if (object_active != NULL) { | if (object_active != nullptr) { | ||||
| if (collection_active != NULL && | if (collection_active != nullptr && | ||||
| BKE_collection_has_object_recursive(collection_active, object_active)) { | BKE_collection_has_object_recursive(collection_active, object_active)) { | ||||
| template_id_liboverride_hierarchy_collections_tag_recursive(collection_active, id, true); | template_id_liboverride_hierarchy_collections_tag_recursive(collection_active, id, true); | ||||
| if (object_active != NULL) { | if (object_active != nullptr) { | ||||
| object_active->id.tag |= LIB_TAG_DOIT; | object_active->id.tag |= LIB_TAG_DOIT; | ||||
| } | } | ||||
| BKE_lib_override_library_create(bmain, | BKE_lib_override_library_create(bmain, | ||||
| scene, | scene, | ||||
| view_layer, | view_layer, | ||||
| NULL, | nullptr, | ||||
| id, | id, | ||||
| &collection_active->id, | &collection_active->id, | ||||
| NULL, | nullptr, | ||||
| &id_override, | &id_override, | ||||
| false); | false); | ||||
| } | } | ||||
| else { | else { | ||||
| object_active->id.tag |= LIB_TAG_DOIT; | object_active->id.tag |= LIB_TAG_DOIT; | ||||
| BKE_lib_override_library_create( | BKE_lib_override_library_create(bmain, | ||||
| bmain, scene, view_layer, NULL, id, &object_active->id, NULL, &id_override, false); | scene, | ||||
| view_layer, | |||||
| nullptr, | |||||
| id, | |||||
| &object_active->id, | |||||
| nullptr, | |||||
| &id_override, | |||||
| false); | |||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| BKE_lib_override_library_create( | BKE_lib_override_library_create( | ||||
| bmain, scene, view_layer, NULL, id, id, NULL, &id_override, false); | bmain, scene, view_layer, nullptr, id, id, nullptr, &id_override, false); | ||||
| } | } | ||||
| break; | break; | ||||
| case ID_MA: | case ID_MA: | ||||
| Context not available. | |||||
| break; | break; | ||||
| } | } | ||||
| if (id_override != NULL) { | if (id_override != nullptr) { | ||||
| id_override->override_library->flag &= ~IDOVERRIDE_LIBRARY_FLAG_SYSTEM_DEFINED; | id_override->override_library->flag &= ~IDOVERRIDE_LIBRARY_FLAG_SYSTEM_DEFINED; | ||||
| *r_undo_push_label = "Make Library Override Hierarchy"; | *r_undo_push_label = "Make Library Override Hierarchy"; | ||||
| Context not available. | |||||
| * rebuild of outliner trees, leading to crashes. | * rebuild of outliner trees, leading to crashes. | ||||
| * | * | ||||
| * So for now, add some extra notifiers here. */ | * So for now, add some extra notifiers here. */ | ||||
| WM_event_add_notifier(C, NC_ID | NA_ADDED, NULL); | WM_event_add_notifier(C, NC_ID | NA_ADDED, nullptr); | ||||
| WM_event_add_notifier(C, NC_SPACE | ND_SPACE_OUTLINER, NULL); | WM_event_add_notifier(C, NC_SPACE | ND_SPACE_OUTLINER, nullptr); | ||||
| } | } | ||||
| return id_override; | return id_override; | ||||
| } | } | ||||
| Context not available. | |||||
| PointerRNA *idptr, | PointerRNA *idptr, | ||||
| const char **r_undo_push_label) | const char **r_undo_push_label) | ||||
| { | { | ||||
| ID *id = idptr->data; | ID *id = static_cast<ID *>(idptr->data); | ||||
| ID *owner_id = template_ui->ptr.owner_id; | ID *owner_id = template_ui->ptr.owner_id; | ||||
| ID *id_override = ui_template_id_liboverride_hierarchy_make( | ID *id_override = ui_template_id_liboverride_hierarchy_make( | ||||
| C, bmain, owner_id, id, r_undo_push_label); | C, bmain, owner_id, id, r_undo_push_label); | ||||
| if (id_override != NULL) { | if (id_override != nullptr) { | ||||
| /* `idptr` is re-assigned to owner property to ensure proper updates etc. Here we also use it | /* `idptr` is re-assigned to owner property to ensure proper updates etc. Here we also use it | ||||
| * to ensure remapping of the owner property from the linked data to the newly created | * to ensure remapping of the owner property from the linked data to the newly created | ||||
| * liboverride (note that in theory this remapping has already been done by code above), but | * liboverride (note that in theory this remapping has already been done by code above), but | ||||
| Context not available. | |||||
| { | { | ||||
| TemplateID *template_ui = (TemplateID *)arg_litem; | TemplateID *template_ui = (TemplateID *)arg_litem; | ||||
| PointerRNA idptr = RNA_property_pointer_get(&template_ui->ptr, template_ui->prop); | PointerRNA idptr = RNA_property_pointer_get(&template_ui->ptr, template_ui->prop); | ||||
| ID *id = idptr.data; | ID *id = static_cast<ID *>(idptr.data); | ||||
| const int event = POINTER_AS_INT(arg_event); | const int event = POINTER_AS_INT(arg_event); | ||||
| const char *undo_push_label = NULL; | const char *undo_push_label = nullptr; | ||||
| switch (event) { | switch (event) { | ||||
| case UI_ID_NOP: | case UI_ID_NOP: | ||||
| Context not available. | |||||
| break; | break; | ||||
| case UI_ID_DELETE: | case UI_ID_DELETE: | ||||
| memset(&idptr, 0, sizeof(idptr)); | memset(&idptr, 0, sizeof(idptr)); | ||||
| RNA_property_pointer_set(&template_ui->ptr, template_ui->prop, idptr, NULL); | RNA_property_pointer_set(&template_ui->ptr, template_ui->prop, idptr, nullptr); | ||||
| RNA_property_update(C, &template_ui->ptr, template_ui->prop); | RNA_property_update(C, &template_ui->ptr, template_ui->prop); | ||||
| if (id && CTX_wm_window(C)->eventstate->modifier & KM_SHIFT) { | if (id && CTX_wm_window(C)->eventstate->modifier & KM_SHIFT) { | ||||
| Context not available. | |||||
| undo_push_label = "Make Local"; | undo_push_label = "Make Local"; | ||||
| } | } | ||||
| } | } | ||||
| if (undo_push_label != NULL) { | if (undo_push_label != nullptr) { | ||||
| RNA_property_pointer_set(&template_ui->ptr, template_ui->prop, idptr, NULL); | RNA_property_pointer_set(&template_ui->ptr, template_ui->prop, idptr, nullptr); | ||||
| RNA_property_update(C, &template_ui->ptr, template_ui->prop); | RNA_property_update(C, &template_ui->ptr, template_ui->prop); | ||||
| } | } | ||||
| } | } | ||||
| Context not available. | |||||
| BKE_lib_override_library_make_local(id); | BKE_lib_override_library_make_local(id); | ||||
| /* Reassign to get proper updates/notifiers. */ | /* Reassign to get proper updates/notifiers. */ | ||||
| idptr = RNA_property_pointer_get(&template_ui->ptr, template_ui->prop); | idptr = RNA_property_pointer_get(&template_ui->ptr, template_ui->prop); | ||||
| RNA_property_pointer_set(&template_ui->ptr, template_ui->prop, idptr, NULL); | RNA_property_pointer_set(&template_ui->ptr, template_ui->prop, idptr, nullptr); | ||||
| RNA_property_update(C, &template_ui->ptr, template_ui->prop); | RNA_property_update(C, &template_ui->ptr, template_ui->prop); | ||||
| undo_push_label = "Make Local"; | undo_push_label = "Make Local"; | ||||
| } | } | ||||
| Context not available. | |||||
| if (do_scene_obj) { | if (do_scene_obj) { | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| ED_object_single_user(bmain, scene, (struct Object *)id); | ED_object_single_user(bmain, scene, (Object *)id); | ||||
| WM_event_add_notifier(C, NC_WINDOW, NULL); | WM_event_add_notifier(C, NC_WINDOW, nullptr); | ||||
| DEG_relations_tag_update(bmain); | DEG_relations_tag_update(bmain); | ||||
| } | } | ||||
| else { | else { | ||||
| Context not available. | |||||
| #endif | #endif | ||||
| } | } | ||||
| if (undo_push_label != NULL) { | if (undo_push_label != nullptr) { | ||||
| ED_undo_push(C, undo_push_label); | ED_undo_push(C, undo_push_label); | ||||
| } | } | ||||
| } | } | ||||
| Context not available. | |||||
| return; | return; | ||||
| } | } | ||||
| const wmWindow *win = template_ui->ptr.data; | const wmWindow *win = static_cast<const wmWindow *>(template_ui->ptr.data); | ||||
| const WorkSpace *workspace = WM_window_get_active_workspace(win); | const WorkSpace *workspace = WM_window_get_active_workspace(win); | ||||
| UI_but_extra_operator_icon_add(but, | UI_but_extra_operator_icon_add(but, | ||||
| "WORKSPACE_OT_scene_pin_toggle", | "WORKSPACE_OT_scene_pin_toggle", | ||||
| Context not available. | |||||
| 0, | 0, | ||||
| w, | w, | ||||
| but_height, | but_height, | ||||
| NULL); | nullptr); | ||||
| UI_but_funcN_set( | UI_but_funcN_set( | ||||
| but, template_id_cb, MEM_dupallocN(template_ui), POINTER_FROM_INT(UI_ID_ADD_NEW)); | but, template_id_cb, MEM_dupallocN(template_ui), POINTER_FROM_INT(UI_ID_ADD_NEW)); | ||||
| } | } | ||||
| Context not available. | |||||
| 0, | 0, | ||||
| w, | w, | ||||
| but_height, | but_height, | ||||
| NULL, | nullptr, | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| NULL); | nullptr); | ||||
| UI_but_funcN_set( | UI_but_funcN_set( | ||||
| but, template_id_cb, MEM_dupallocN(template_ui), POINTER_FROM_INT(UI_ID_ADD_NEW)); | but, template_id_cb, MEM_dupallocN(template_ui), POINTER_FROM_INT(UI_ID_ADD_NEW)); | ||||
| } | } | ||||
| Context not available. | |||||
| const bool use_previews = template_ui->preview = (flag & UI_ID_PREVIEWS) != 0; | const bool use_previews = template_ui->preview = (flag & UI_ID_PREVIEWS) != 0; | ||||
| PointerRNA idptr = RNA_property_pointer_get(&template_ui->ptr, template_ui->prop); | PointerRNA idptr = RNA_property_pointer_get(&template_ui->ptr, template_ui->prop); | ||||
| ID *id = idptr.data; | ID *id = static_cast<ID *>(idptr.data); | ||||
| ID *idfrom = template_ui->ptr.owner_id; | ID *idfrom = template_ui->ptr.owner_id; | ||||
| // lb = template_ui->idlb; | // lb = template_ui->idlb; | ||||
| Context not available. | |||||
| 0, | 0, | ||||
| UI_UNIT_X, | UI_UNIT_X, | ||||
| UI_UNIT_Y, | UI_UNIT_Y, | ||||
| NULL, | nullptr, | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| Context not available. | |||||
| 0, | 0, | ||||
| UI_UNIT_X, | UI_UNIT_X, | ||||
| UI_UNIT_Y, | UI_UNIT_Y, | ||||
| NULL, | nullptr, | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| Context not available. | |||||
| 0, | 0, | ||||
| UI_UNIT_X, | UI_UNIT_X, | ||||
| UI_UNIT_Y, | UI_UNIT_Y, | ||||
| NULL, | nullptr, | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| Context not available. | |||||
| 0, | 0, | ||||
| numstr_len * 0.2f * UI_UNIT_X + UI_UNIT_X, | numstr_len * 0.2f * UI_UNIT_X + UI_UNIT_X, | ||||
| UI_UNIT_Y, | UI_UNIT_Y, | ||||
| NULL, | nullptr, | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| Context not available. | |||||
| 0, | 0, | ||||
| UI_UNIT_X, | UI_UNIT_X, | ||||
| UI_UNIT_Y, | UI_UNIT_Y, | ||||
| NULL); | nullptr); | ||||
| } | } | ||||
| else if (!ELEM(GS(id->name), ID_GR, ID_SCE, ID_SCR, ID_OB, ID_WS) && | else if (!ELEM(GS(id->name), ID_GR, ID_SCE, ID_SCR, ID_OB, ID_WS) && | ||||
| (hide_buttons == false)) { | (hide_buttons == false)) { | ||||
| Context not available. | |||||
| 0, | 0, | ||||
| -1, | -1, | ||||
| -1, | -1, | ||||
| NULL); | nullptr); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| Context not available. | |||||
| 0, | 0, | ||||
| w, | w, | ||||
| UI_UNIT_Y, | UI_UNIT_Y, | ||||
| NULL); | nullptr); | ||||
| UI_but_funcN_set( | UI_but_funcN_set( | ||||
| but, template_id_cb, MEM_dupallocN(template_ui), POINTER_FROM_INT(UI_ID_OPEN)); | but, template_id_cb, MEM_dupallocN(template_ui), POINTER_FROM_INT(UI_ID_OPEN)); | ||||
| } | } | ||||
| Context not available. | |||||
| 0, | 0, | ||||
| w, | w, | ||||
| UI_UNIT_Y, | UI_UNIT_Y, | ||||
| NULL, | nullptr, | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| NULL); | nullptr); | ||||
| UI_but_funcN_set( | UI_but_funcN_set( | ||||
| but, template_id_cb, MEM_dupallocN(template_ui), POINTER_FROM_INT(UI_ID_OPEN)); | but, template_id_cb, MEM_dupallocN(template_ui), POINTER_FROM_INT(UI_ID_OPEN)); | ||||
| } | } | ||||
| Context not available. | |||||
| /* don't use RNA_property_is_unlink here */ | /* don't use RNA_property_is_unlink here */ | ||||
| if (id && (flag & UI_ID_DELETE) && (hide_buttons == false)) { | if (id && (flag & UI_ID_DELETE) && (hide_buttons == false)) { | ||||
| /* allow unlink if 'unlinkop' is passed, even when 'PROP_NEVER_UNLINK' is set */ | /* allow unlink if 'unlinkop' is passed, even when 'PROP_NEVER_UNLINK' is set */ | ||||
| but = NULL; | but = nullptr; | ||||
| if (unlinkop) { | if (unlinkop) { | ||||
| but = uiDefIconButO(block, | but = uiDefIconButO(block, | ||||
| Context not available. | |||||
| 0, | 0, | ||||
| UI_UNIT_X, | UI_UNIT_X, | ||||
| UI_UNIT_Y, | UI_UNIT_Y, | ||||
| NULL); | nullptr); | ||||
| /* so we can access the template from operators, font unlinking needs this */ | /* so we can access the template from operators, font unlinking needs this */ | ||||
| UI_but_funcN_set( | UI_but_funcN_set( | ||||
| but, template_id_cb, MEM_dupallocN(template_ui), POINTER_FROM_INT(UI_ID_NOP)); | but, template_id_cb, MEM_dupallocN(template_ui), POINTER_FROM_INT(UI_ID_NOP)); | ||||
| Context not available. | |||||
| 0, | 0, | ||||
| UI_UNIT_X, | UI_UNIT_X, | ||||
| UI_UNIT_Y, | UI_UNIT_Y, | ||||
| NULL, | nullptr, | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| Context not available. | |||||
| uiBut *but = UI_context_active_but_get(C); | uiBut *but = UI_context_active_but_get(C); | ||||
| if (but && but->type == UI_BTYPE_TAB) { | if (but && but->type == UI_BTYPE_TAB) { | ||||
| return but->custom_data; | return static_cast<ID *>(but->custom_data); | ||||
| } | } | ||||
| return NULL; | return nullptr; | ||||
| } | } | ||||
| static void template_ID_tabs(const bContext *C, | static void template_ID_tabs(const bContext *C, | ||||
| uiLayout *layout, | uiLayout *layout, | ||||
| TemplateID *template, | TemplateID *template_id, | ||||
| StructRNA *type, | StructRNA *type, | ||||
| int flag, | int flag, | ||||
| const char *newop, | const char *newop, | ||||
| const char *menu) | const char *menu) | ||||
| { | { | ||||
| const ARegion *region = CTX_wm_region(C); | const ARegion *region = CTX_wm_region(C); | ||||
| const PointerRNA active_ptr = RNA_property_pointer_get(&template->ptr, template->prop); | const PointerRNA active_ptr = RNA_property_pointer_get(&template_id->ptr, template_id->prop); | ||||
| MenuType *mt = menu ? WM_menutype_find(menu, false) : NULL; | MenuType *mt = menu ? WM_menutype_find(menu, false) : nullptr; | ||||
| const int but_align = ui_but_align_opposite_to_area_align_get(region); | const int but_align = ui_but_align_opposite_to_area_align_get(region); | ||||
| const int but_height = UI_UNIT_Y * 1.1; | const int but_height = UI_UNIT_Y * 1.1; | ||||
| Context not available. | |||||
| const uiStyle *style = UI_style_get_dpi(); | const uiStyle *style = UI_style_get_dpi(); | ||||
| ListBase ordered; | ListBase ordered; | ||||
| BKE_id_ordered_list(&ordered, template->idlb); | BKE_id_ordered_list(&ordered, template_id->idlb); | ||||
| LISTBASE_FOREACH (LinkData *, link, &ordered) { | LISTBASE_FOREACH (LinkData *, link, &ordered) { | ||||
| ID *id = link->data; | ID *id = static_cast<ID *>(link->data); | ||||
| const int name_width = UI_fontstyle_string_width(&style->widget, id->name + 2); | const int name_width = UI_fontstyle_string_width(&style->widget, id->name + 2); | ||||
| const int but_width = name_width + UI_UNIT_X; | const int but_width = name_width + UI_UNIT_X; | ||||
| Context not available. | |||||
| 0, | 0, | ||||
| but_width, | but_width, | ||||
| but_height, | but_height, | ||||
| &template->ptr, | &template_id->ptr, | ||||
| template->prop, | template_id->prop, | ||||
| 0, | 0, | ||||
| 0.0f, | 0.0f, | ||||
| sizeof(id->name) - 2, | sizeof(id->name) - 2, | ||||
| 0.0f, | 0.0f, | ||||
| 0.0f, | 0.0f, | ||||
| ""); | ""); | ||||
| UI_but_funcN_set(&tab->but, template_ID_set_property_exec_fn, MEM_dupallocN(template), id); | UI_but_funcN_set(&tab->but, template_ID_set_property_exec_fn, MEM_dupallocN(template_id), id); | ||||
| UI_but_drag_set_id(&tab->but, id); | UI_but_drag_set_id(&tab->but, id); | ||||
| tab->but.custom_data = (void *)id; | tab->but.custom_data = (void *)id; | ||||
| tab->menu = mt; | tab->menu = mt; | ||||
| Context not available. | |||||
| BLI_freelistN(&ordered); | BLI_freelistN(&ordered); | ||||
| if (flag & UI_ID_ADD_NEW) { | if (flag & UI_ID_ADD_NEW) { | ||||
| const bool editable = RNA_property_editable(&template->ptr, template->prop); | const bool editable = RNA_property_editable(&template_id->ptr, template_id->prop); | ||||
| uiBut *but; | uiBut *but; | ||||
| if (active_ptr.type) { | if (active_ptr.type) { | ||||
| Context not available. | |||||
| } | } | ||||
| but = template_id_def_new_but(block, | but = template_id_def_new_but(block, | ||||
| active_ptr.data, | static_cast<const ID *>(active_ptr.data), | ||||
| template, | template_id, | ||||
| type, | type, | ||||
| newop, | newop, | ||||
| editable, | editable, | ||||
| Context not available. | |||||
| return; | return; | ||||
| } | } | ||||
| TemplateID *template_ui = MEM_callocN(sizeof(TemplateID), "TemplateID"); | TemplateID *template_ui = MEM_cnew<TemplateID>(__func__); | ||||
| template_ui->ptr = *ptr; | template_ui->ptr = *ptr; | ||||
| template_ui->prop = prop; | template_ui->prop = prop; | ||||
| template_ui->prv_rows = prv_rows; | template_ui->prv_rows = prv_rows; | ||||
| Context not available. | |||||
| newop, | newop, | ||||
| openop, | openop, | ||||
| unlinkop, | unlinkop, | ||||
| NULL, | nullptr, | ||||
| text, | text, | ||||
| UI_ID_BROWSE | UI_ID_RENAME | UI_ID_DELETE, | UI_ID_BROWSE | UI_ID_RENAME | UI_ID_DELETE, | ||||
| 0, | 0, | ||||
| Context not available. | |||||
| newop, | newop, | ||||
| openop, | openop, | ||||
| unlinkop, | unlinkop, | ||||
| NULL, | nullptr, | ||||
| text, | text, | ||||
| UI_ID_BROWSE | UI_ID_RENAME, | UI_ID_BROWSE | UI_ID_RENAME, | ||||
| 0, | 0, | ||||
| Context not available. | |||||
| newop, | newop, | ||||
| openop, | openop, | ||||
| unlinkop, | unlinkop, | ||||
| NULL, | nullptr, | ||||
| NULL, | nullptr, | ||||
| UI_ID_BROWSE | UI_ID_RENAME | UI_ID_DELETE | UI_ID_PREVIEWS, | UI_ID_BROWSE | UI_ID_RENAME | UI_ID_DELETE | UI_ID_PREVIEWS, | ||||
| rows, | rows, | ||||
| cols, | cols, | ||||
| Context not available. | |||||
| C, | C, | ||||
| ptr, | ptr, | ||||
| propname, | propname, | ||||
| NULL, | nullptr, | ||||
| NULL, | nullptr, | ||||
| NULL, | nullptr, | ||||
| NULL, | nullptr, | ||||
| NULL, | nullptr, | ||||
| UI_ID_BROWSE | UI_ID_PREVIEWS | UI_ID_DELETE, | UI_ID_BROWSE | UI_ID_PREVIEWS | UI_ID_DELETE, | ||||
| rows, | rows, | ||||
| cols, | cols, | ||||
| Context not available. | |||||
| ptr, | ptr, | ||||
| propname, | propname, | ||||
| newop, | newop, | ||||
| NULL, | nullptr, | ||||
| NULL, | nullptr, | ||||
| menu, | menu, | ||||
| NULL, | nullptr, | ||||
| UI_ID_BROWSE | UI_ID_RENAME, | UI_ID_BROWSE | UI_ID_RENAME, | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| Context not available. | |||||
| /** \name Search Template | /** \name Search Template | ||||
| * \{ */ | * \{ */ | ||||
| typedef struct TemplateSearch { | struct TemplateSearch { | ||||
| uiRNACollectionSearch search_data; | uiRNACollectionSearch search_data; | ||||
| bool use_previews; | bool use_previews; | ||||
| int preview_rows, preview_cols; | int preview_rows, preview_cols; | ||||
| } TemplateSearch; | }; | ||||
| static void template_search_exec_fn(bContext *C, void *arg_template, void *item) | static void template_search_exec_fn(bContext *C, void *arg_template, void *item) | ||||
| { | { | ||||
| TemplateSearch *template_search = arg_template; | TemplateSearch *template_search = static_cast<TemplateSearch *>(arg_template); | ||||
| uiRNACollectionSearch *coll_search = &template_search->search_data; | uiRNACollectionSearch *coll_search = &template_search->search_data; | ||||
| StructRNA *type = RNA_property_pointer_type(&coll_search->target_ptr, coll_search->target_prop); | StructRNA *type = RNA_property_pointer_type(&coll_search->target_ptr, coll_search->target_prop); | ||||
| PointerRNA item_ptr; | PointerRNA item_ptr; | ||||
| RNA_pointer_create(NULL, type, item, &item_ptr); | RNA_pointer_create(nullptr, type, item, &item_ptr); | ||||
| RNA_property_pointer_set(&coll_search->target_ptr, coll_search->target_prop, item_ptr, NULL); | RNA_property_pointer_set(&coll_search->target_ptr, coll_search->target_prop, item_ptr, nullptr); | ||||
| RNA_property_update(C, &coll_search->target_ptr, coll_search->target_prop); | RNA_property_update(C, &coll_search->target_ptr, coll_search->target_prop); | ||||
| } | } | ||||
| Context not available. | |||||
| &template_search, | &template_search, | ||||
| template_search_exec_fn, | template_search_exec_fn, | ||||
| active_ptr.data, | active_ptr.data, | ||||
| NULL, | nullptr, | ||||
| template_search.preview_rows, | template_search.preview_rows, | ||||
| template_search.preview_cols, | template_search.preview_cols, | ||||
| 1.0f); | 1.0f); | ||||
| Context not available. | |||||
| } | } | ||||
| uiBut *but = uiDefIconButO( | uiBut *but = uiDefIconButO( | ||||
| block, UI_BTYPE_BUT, operator_name, opcontext, icon, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL); | block, UI_BTYPE_BUT, operator_name, opcontext, icon, 0, 0, UI_UNIT_X, UI_UNIT_Y, nullptr); | ||||
| if (!editable) { | if (!editable) { | ||||
| UI_but_drawflag_enable(but, UI_BUT_DISABLED); | UI_but_drawflag_enable(but, UI_BUT_DISABLED); | ||||
| Context not available. | |||||
| PropertyRNA *searchprop; | PropertyRNA *searchprop; | ||||
| if (searchptr && !searchptr->data) { | if (searchptr && !searchptr->data) { | ||||
| searchptr = NULL; | searchptr = nullptr; | ||||
| } | } | ||||
| if (!searchptr && !searchpropname) { | if (!searchptr && !searchpropname) { | ||||
| /* both NULL means we don't use a custom rna collection to search in */ | /* both nullptr means we don't use a custom rna collection to search in */ | ||||
| } | } | ||||
| else if (!searchptr && searchpropname) { | else if (!searchptr && searchpropname) { | ||||
| RNA_warning("searchpropname defined (%s) but searchptr is missing", searchpropname); | RNA_warning("searchpropname defined (%s) but searchptr is missing", searchpropname); | ||||
| Context not available. | |||||
| return searchprop; | return searchprop; | ||||
| } | } | ||||
| return NULL; | return nullptr; | ||||
| } | } | ||||
| static TemplateSearch *template_search_setup(PointerRNA *ptr, | static TemplateSearch *template_search_setup(PointerRNA *ptr, | ||||
| Context not available. | |||||
| if (!prop || RNA_property_type(prop) != PROP_POINTER) { | if (!prop || RNA_property_type(prop) != PROP_POINTER) { | ||||
| RNA_warning("pointer property not found: %s.%s", RNA_struct_identifier(ptr->type), propname); | RNA_warning("pointer property not found: %s.%s", RNA_struct_identifier(ptr->type), propname); | ||||
| return NULL; | return nullptr; | ||||
| } | } | ||||
| PropertyRNA *searchprop = template_search_get_searchprop(ptr, prop, searchptr, searchpropname); | PropertyRNA *searchprop = template_search_get_searchprop(ptr, prop, searchptr, searchpropname); | ||||
| TemplateSearch *template_search = MEM_callocN(sizeof(*template_search), __func__); | TemplateSearch *template_search = MEM_cnew<TemplateSearch>(__func__); | ||||
| template_search->search_data.target_ptr = *ptr; | template_search->search_data.target_ptr = *ptr; | ||||
| template_search->search_data.target_prop = prop; | template_search->search_data.target_prop = prop; | ||||
| template_search->search_data.search_ptr = *searchptr; | template_search->search_data.search_ptr = *searchptr; | ||||
| Context not available. | |||||
| { | { | ||||
| TemplateSearch *template_search = template_search_setup( | TemplateSearch *template_search = template_search_setup( | ||||
| ptr, propname, searchptr, searchpropname); | ptr, propname, searchptr, searchpropname); | ||||
| if (template_search != NULL) { | if (template_search != nullptr) { | ||||
| template_search_buttons(C, layout, template_search, newop, unlinkop); | template_search_buttons(C, layout, template_search, newop, unlinkop); | ||||
| MEM_freeN(template_search); | MEM_freeN(template_search); | ||||
| } | } | ||||
| Context not available. | |||||
| TemplateSearch *template_search = template_search_setup( | TemplateSearch *template_search = template_search_setup( | ||||
| ptr, propname, searchptr, searchpropname); | ptr, propname, searchptr, searchpropname); | ||||
| if (template_search != NULL) { | if (template_search != nullptr) { | ||||
| template_search->use_previews = true; | template_search->use_previews = true; | ||||
| template_search->preview_rows = rows; | template_search->preview_rows = rows; | ||||
| template_search->preview_cols = cols; | template_search->preview_cols = cols; | ||||
| Context not available. | |||||
| void uiTemplatePathBuilder(uiLayout *layout, | void uiTemplatePathBuilder(uiLayout *layout, | ||||
| PointerRNA *ptr, | PointerRNA *ptr, | ||||
| const char *propname, | const char *propname, | ||||
| PointerRNA *UNUSED(root_ptr), | PointerRNA * /*root_ptr*/, | ||||
| const char *text) | const char *text) | ||||
| { | { | ||||
| /* check that properties are valid */ | /* check that properties are valid */ | ||||
| Context not available. | |||||
| static void modifier_panel_id(void *md_link, char *r_name) | static void modifier_panel_id(void *md_link, char *r_name) | ||||
| { | { | ||||
| ModifierData *md = (ModifierData *)md_link; | ModifierData *md = (ModifierData *)md_link; | ||||
| BKE_modifier_type_panel_id(md->type, r_name); | BKE_modifier_type_panel_id(ModifierType(md->type), r_name); | ||||
| } | } | ||||
| void uiTemplateModifiers(uiLayout *UNUSED(layout), bContext *C) | void uiTemplateModifiers(uiLayout * /*layout*/, bContext *C) | ||||
| { | { | ||||
| ARegion *region = CTX_wm_region(C); | ARegion *region = CTX_wm_region(C); | ||||
| Context not available. | |||||
| if (!panels_match) { | if (!panels_match) { | ||||
| UI_panels_free_instanced(C, region); | UI_panels_free_instanced(C, region); | ||||
| ModifierData *md = modifiers->first; | ModifierData *md = static_cast<ModifierData *>(modifiers->first); | ||||
| for (int i = 0; md; i++, md = md->next) { | for (int i = 0; md; i++, md = md->next) { | ||||
| const ModifierTypeInfo *mti = BKE_modifier_get_info(md->type); | const ModifierTypeInfo *mti = BKE_modifier_get_info(ModifierType(md->type)); | ||||
| if (mti->panelRegister == NULL) { | if (mti->panelRegister == nullptr) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| Context not available. | |||||
| modifier_panel_id(md, panel_idname); | modifier_panel_id(md, panel_idname); | ||||
| /* Create custom data RNA pointer. */ | /* Create custom data RNA pointer. */ | ||||
| PointerRNA *md_ptr = MEM_mallocN(sizeof(PointerRNA), "panel customdata"); | PointerRNA *md_ptr = static_cast<PointerRNA *>(MEM_mallocN(sizeof(PointerRNA), __func__)); | ||||
| RNA_pointer_create(&ob->id, &RNA_Modifier, md, md_ptr); | RNA_pointer_create(&ob->id, &RNA_Modifier, md, md_ptr); | ||||
| UI_panel_add_instanced(C, region, ®ion->panels, panel_idname, md_ptr); | UI_panel_add_instanced(C, region, ®ion->panels, panel_idname, md_ptr); | ||||
| Context not available. | |||||
| } | } | ||||
| else { | else { | ||||
| /* Assuming there's only one group of instanced panels, update the custom data pointers. */ | /* Assuming there's only one group of instanced panels, update the custom data pointers. */ | ||||
| Panel *panel = region->panels.first; | Panel *panel = static_cast<Panel *>(region->panels.first); | ||||
| LISTBASE_FOREACH (ModifierData *, md, modifiers) { | LISTBASE_FOREACH (ModifierData *, md, modifiers) { | ||||
| const ModifierTypeInfo *mti = BKE_modifier_get_info(md->type); | const ModifierTypeInfo *mti = BKE_modifier_get_info(ModifierType(md->type)); | ||||
| if (mti->panelRegister == NULL) { | if (mti->panelRegister == nullptr) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| /* Move to the next instanced panel corresponding to the next modifier. */ | /* Move to the next instanced panel corresponding to the next modifier. */ | ||||
| while ((panel->type == NULL) || !(panel->type->flag & PANEL_TYPE_INSTANCED)) { | while ((panel->type == nullptr) || !(panel->type->flag & PANEL_TYPE_INSTANCED)) { | ||||
| panel = panel->next; | panel = panel->next; | ||||
| BLI_assert(panel != NULL); /* There shouldn't be fewer panels than modifiers with UIs. */ | BLI_assert(panel != | ||||
| nullptr); /* There shouldn't be fewer panels than modifiers with UIs. */ | |||||
| } | } | ||||
| PointerRNA *md_ptr = MEM_mallocN(sizeof(PointerRNA), "panel customdata"); | PointerRNA *md_ptr = static_cast<PointerRNA *>(MEM_mallocN(sizeof(PointerRNA), __func__)); | ||||
| RNA_pointer_create(&ob->id, &RNA_Modifier, md, md_ptr); | RNA_pointer_create(&ob->id, &RNA_Modifier, md, md_ptr); | ||||
| UI_panel_custom_data_set(panel, md_ptr); | UI_panel_custom_data_set(panel, md_ptr); | ||||
| Context not available. | |||||
| RNA_int_set(&props_ptr, "index", new_index); | RNA_int_set(&props_ptr, "index", new_index); | ||||
| /* Set owner to #EDIT_CONSTRAINT_OWNER_OBJECT or #EDIT_CONSTRAINT_OWNER_BONE. */ | /* Set owner to #EDIT_CONSTRAINT_OWNER_OBJECT or #EDIT_CONSTRAINT_OWNER_BONE. */ | ||||
| RNA_enum_set(&props_ptr, "owner", constraint_from_bone ? 1 : 0); | RNA_enum_set(&props_ptr, "owner", constraint_from_bone ? 1 : 0); | ||||
| WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &props_ptr, NULL); | WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &props_ptr, nullptr); | ||||
| WM_operator_properties_free(&props_ptr); | WM_operator_properties_free(&props_ptr); | ||||
| } | } | ||||
| /** | /** | ||||
| * Get the expand flag from the active constraint to use for the panel. | * Get the expand flag from the active constraint to use for the panel. | ||||
| */ | */ | ||||
| static short get_constraint_expand_flag(const bContext *UNUSED(C), Panel *panel) | static short get_constraint_expand_flag(const bContext * /*C*/, Panel *panel) | ||||
| { | { | ||||
| PointerRNA *con_ptr = UI_panel_custom_data_get(panel); | PointerRNA *con_ptr = UI_panel_custom_data_get(panel); | ||||
| bConstraint *con = (bConstraint *)con_ptr->data; | bConstraint *con = (bConstraint *)con_ptr->data; | ||||
| Context not available. | |||||
| /** | /** | ||||
| * Save the expand flag for the panel and sub-panels to the constraint. | * Save the expand flag for the panel and sub-panels to the constraint. | ||||
| */ | */ | ||||
| static void set_constraint_expand_flag(const bContext *UNUSED(C), Panel *panel, short expand_flag) | static void set_constraint_expand_flag(const bContext * /*C*/, Panel *panel, short expand_flag) | ||||
| { | { | ||||
| PointerRNA *con_ptr = UI_panel_custom_data_get(panel); | PointerRNA *con_ptr = UI_panel_custom_data_get(panel); | ||||
| bConstraint *con = (bConstraint *)con_ptr->data; | bConstraint *con = (bConstraint *)con_ptr->data; | ||||
| Context not available. | |||||
| const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_from_type(con->type); | const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_from_type(con->type); | ||||
| /* Cannot get TypeInfo for invalid/legacy constraints. */ | /* Cannot get TypeInfo for invalid/legacy constraints. */ | ||||
| if (cti == NULL) { | if (cti == nullptr) { | ||||
| return; | return; | ||||
| } | } | ||||
| Context not available. | |||||
| const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_from_type(con->type); | const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_from_type(con->type); | ||||
| /* Cannot get TypeInfo for invalid/legacy constraints. */ | /* Cannot get TypeInfo for invalid/legacy constraints. */ | ||||
| if (cti == NULL) { | if (cti == nullptr) { | ||||
| return; | return; | ||||
| } | } | ||||
| Context not available. | |||||
| strcat(r_name, cti->structName); | strcat(r_name, cti->structName); | ||||
| } | } | ||||
| void uiTemplateConstraints(uiLayout *UNUSED(layout), bContext *C, bool use_bone_constraints) | void uiTemplateConstraints(uiLayout * /*layout*/, bContext *C, bool use_bone_constraints) | ||||
| { | { | ||||
| ARegion *region = CTX_wm_region(C); | ARegion *region = CTX_wm_region(C); | ||||
| Object *ob = ED_object_active_context(C); | Object *ob = ED_object_active_context(C); | ||||
| ListBase *constraints = {NULL}; | ListBase *constraints = {nullptr}; | ||||
| if (use_bone_constraints) { | if (use_bone_constraints) { | ||||
| constraints = ED_object_pose_constraint_list(C); | constraints = ED_object_pose_constraint_list(C); | ||||
| } | } | ||||
| else if (ob != NULL) { | else if (ob != nullptr) { | ||||
| constraints = &ob->constraints; | constraints = &ob->constraints; | ||||
| } | } | ||||
| Context not available. | |||||
| if (!panels_match) { | if (!panels_match) { | ||||
| UI_panels_free_instanced(C, region); | UI_panels_free_instanced(C, region); | ||||
| bConstraint *con = (constraints == NULL) ? NULL : constraints->first; | bConstraint *con = (constraints == nullptr) ? nullptr : | ||||
| static_cast<bConstraint *>(constraints->first); | |||||
| for (int i = 0; con; i++, con = con->next) { | for (int i = 0; con; i++, con = con->next) { | ||||
| /* Don't show invalid/legacy constraints. */ | /* Don't show invalid/legacy constraints. */ | ||||
| if (con->type == CONSTRAINT_TYPE_NULL) { | if (con->type == CONSTRAINT_TYPE_NULL) { | ||||
| Context not available. | |||||
| } | } | ||||
| /* Don't show temporary constraints (AutoIK and target-less IK constraints). */ | /* Don't show temporary constraints (AutoIK and target-less IK constraints). */ | ||||
| if (con->type == CONSTRAINT_TYPE_KINEMATIC) { | if (con->type == CONSTRAINT_TYPE_KINEMATIC) { | ||||
| bKinematicConstraint *data = con->data; | bKinematicConstraint *data = static_cast<bKinematicConstraint *>(con->data); | ||||
| if (data->flag & CONSTRAINT_IK_TEMP) { | if (data->flag & CONSTRAINT_IK_TEMP) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| Context not available. | |||||
| panel_id_func(con, panel_idname); | panel_id_func(con, panel_idname); | ||||
| /* Create custom data RNA pointer. */ | /* Create custom data RNA pointer. */ | ||||
| PointerRNA *con_ptr = MEM_mallocN(sizeof(PointerRNA), "panel customdata"); | PointerRNA *con_ptr = static_cast<PointerRNA *>(MEM_mallocN(sizeof(PointerRNA), __func__)); | ||||
| RNA_pointer_create(&ob->id, &RNA_Constraint, con, con_ptr); | RNA_pointer_create(&ob->id, &RNA_Constraint, con, con_ptr); | ||||
| Panel *new_panel = UI_panel_add_instanced(C, region, ®ion->panels, panel_idname, con_ptr); | Panel *new_panel = UI_panel_add_instanced(C, region, ®ion->panels, panel_idname, con_ptr); | ||||
| Context not available. | |||||
| } | } | ||||
| else { | else { | ||||
| /* Assuming there's only one group of instanced panels, update the custom data pointers. */ | /* Assuming there's only one group of instanced panels, update the custom data pointers. */ | ||||
| Panel *panel = region->panels.first; | Panel *panel = static_cast<Panel *>(region->panels.first); | ||||
| LISTBASE_FOREACH (bConstraint *, con, constraints) { | LISTBASE_FOREACH (bConstraint *, con, constraints) { | ||||
| /* Don't show invalid/legacy constraints. */ | /* Don't show invalid/legacy constraints. */ | ||||
| if (con->type == CONSTRAINT_TYPE_NULL) { | if (con->type == CONSTRAINT_TYPE_NULL) { | ||||
| Context not available. | |||||
| } | } | ||||
| /* Don't show temporary constraints (AutoIK and target-less IK constraints). */ | /* Don't show temporary constraints (AutoIK and target-less IK constraints). */ | ||||
| if (con->type == CONSTRAINT_TYPE_KINEMATIC) { | if (con->type == CONSTRAINT_TYPE_KINEMATIC) { | ||||
| bKinematicConstraint *data = con->data; | bKinematicConstraint *data = static_cast<bKinematicConstraint *>(con->data); | ||||
| if (data->flag & CONSTRAINT_IK_TEMP) { | if (data->flag & CONSTRAINT_IK_TEMP) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| } | } | ||||
| /* Move to the next instanced panel corresponding to the next constraint. */ | /* Move to the next instanced panel corresponding to the next constraint. */ | ||||
| while ((panel->type == NULL) || !(panel->type->flag & PANEL_TYPE_INSTANCED)) { | while ((panel->type == nullptr) || !(panel->type->flag & PANEL_TYPE_INSTANCED)) { | ||||
| panel = panel->next; | panel = panel->next; | ||||
| BLI_assert(panel != NULL); /* There shouldn't be fewer panels than constraint panels. */ | BLI_assert(panel != nullptr); /* There shouldn't be fewer panels than constraint panels. */ | ||||
| } | } | ||||
| PointerRNA *con_ptr = MEM_mallocN(sizeof(PointerRNA), "constraint panel customdata"); | PointerRNA *con_ptr = static_cast<PointerRNA *>(MEM_mallocN(sizeof(PointerRNA), __func__)); | ||||
| RNA_pointer_create(&ob->id, &RNA_Constraint, con, con_ptr); | RNA_pointer_create(&ob->id, &RNA_Constraint, con, con_ptr); | ||||
| UI_panel_custom_data_set(panel, con_ptr); | UI_panel_custom_data_set(panel, con_ptr); | ||||
| Context not available. | |||||
| static void gpencil_modifier_panel_id(void *md_link, char *r_name) | static void gpencil_modifier_panel_id(void *md_link, char *r_name) | ||||
| { | { | ||||
| ModifierData *md = (ModifierData *)md_link; | ModifierData *md = (ModifierData *)md_link; | ||||
| BKE_gpencil_modifierType_panel_id(md->type, r_name); | BKE_gpencil_modifierType_panel_id(GpencilModifierType(md->type), r_name); | ||||
| } | } | ||||
| void uiTemplateGpencilModifiers(uiLayout *UNUSED(layout), bContext *C) | void uiTemplateGpencilModifiers(uiLayout * /*layout*/, bContext *C) | ||||
| { | { | ||||
| ARegion *region = CTX_wm_region(C); | ARegion *region = CTX_wm_region(C); | ||||
| Object *ob = ED_object_active_context(C); | Object *ob = ED_object_active_context(C); | ||||
| Context not available. | |||||
| if (!panels_match) { | if (!panels_match) { | ||||
| UI_panels_free_instanced(C, region); | UI_panels_free_instanced(C, region); | ||||
| GpencilModifierData *md = modifiers->first; | GpencilModifierData *md = static_cast<GpencilModifierData *>(modifiers->first); | ||||
| for (int i = 0; md; i++, md = md->next) { | for (int i = 0; md; i++, md = md->next) { | ||||
| const GpencilModifierTypeInfo *mti = BKE_gpencil_modifier_get_info(md->type); | const GpencilModifierTypeInfo *mti = BKE_gpencil_modifier_get_info( | ||||
| if (mti->panelRegister == NULL) { | GpencilModifierType(md->type)); | ||||
| if (mti->panelRegister == nullptr) { | |||||
| continue; | continue; | ||||
| } | } | ||||
| Context not available. | |||||
| gpencil_modifier_panel_id(md, panel_idname); | gpencil_modifier_panel_id(md, panel_idname); | ||||
| /* Create custom data RNA pointer. */ | /* Create custom data RNA pointer. */ | ||||
| PointerRNA *md_ptr = MEM_mallocN(sizeof(PointerRNA), "panel customdata"); | PointerRNA *md_ptr = static_cast<PointerRNA *>(MEM_mallocN(sizeof(PointerRNA), __func__)); | ||||
| RNA_pointer_create(&ob->id, &RNA_GpencilModifier, md, md_ptr); | RNA_pointer_create(&ob->id, &RNA_GpencilModifier, md, md_ptr); | ||||
| UI_panel_add_instanced(C, region, ®ion->panels, panel_idname, md_ptr); | UI_panel_add_instanced(C, region, ®ion->panels, panel_idname, md_ptr); | ||||
| Context not available. | |||||
| } | } | ||||
| else { | else { | ||||
| /* Assuming there's only one group of instanced panels, update the custom data pointers. */ | /* Assuming there's only one group of instanced panels, update the custom data pointers. */ | ||||
| Panel *panel = region->panels.first; | Panel *panel = static_cast<Panel *>(region->panels.first); | ||||
| LISTBASE_FOREACH (ModifierData *, md, modifiers) { | LISTBASE_FOREACH (ModifierData *, md, modifiers) { | ||||
| const GpencilModifierTypeInfo *mti = BKE_gpencil_modifier_get_info(md->type); | const GpencilModifierTypeInfo *mti = BKE_gpencil_modifier_get_info( | ||||
| if (mti->panelRegister == NULL) { | GpencilModifierType(md->type)); | ||||
| if (mti->panelRegister == nullptr) { | |||||
| continue; | continue; | ||||
| } | } | ||||
| /* Move to the next instanced panel corresponding to the next modifier. */ | /* Move to the next instanced panel corresponding to the next modifier. */ | ||||
| while ((panel->type == NULL) || !(panel->type->flag & PANEL_TYPE_INSTANCED)) { | while ((panel->type == nullptr) || !(panel->type->flag & PANEL_TYPE_INSTANCED)) { | ||||
| panel = panel->next; | panel = panel->next; | ||||
| BLI_assert(panel != NULL); /* There shouldn't be fewer panels than modifiers with UIs. */ | BLI_assert(panel != | ||||
| nullptr); /* There shouldn't be fewer panels than modifiers with UIs. */ | |||||
| } | } | ||||
| PointerRNA *md_ptr = MEM_mallocN(sizeof(PointerRNA), "panel customdata"); | PointerRNA *md_ptr = static_cast<PointerRNA *>(MEM_mallocN(sizeof(PointerRNA), __func__)); | ||||
| RNA_pointer_create(&ob->id, &RNA_GpencilModifier, md, md_ptr); | RNA_pointer_create(&ob->id, &RNA_GpencilModifier, md, md_ptr); | ||||
| UI_panel_custom_data_set(panel, md_ptr); | UI_panel_custom_data_set(panel, md_ptr); | ||||
| Context not available. | |||||
| static void shaderfx_panel_id(void *fx_v, char *r_idname) | static void shaderfx_panel_id(void *fx_v, char *r_idname) | ||||
| { | { | ||||
| ShaderFxData *fx = (ShaderFxData *)fx_v; | ShaderFxData *fx = (ShaderFxData *)fx_v; | ||||
| BKE_shaderfxType_panel_id(fx->type, r_idname); | BKE_shaderfxType_panel_id(ShaderFxType(fx->type), r_idname); | ||||
| } | } | ||||
| void uiTemplateShaderFx(uiLayout *UNUSED(layout), bContext *C) | void uiTemplateShaderFx(uiLayout * /*layout*/, bContext *C) | ||||
| { | { | ||||
| ARegion *region = CTX_wm_region(C); | ARegion *region = CTX_wm_region(C); | ||||
| Object *ob = ED_object_active_context(C); | Object *ob = ED_object_active_context(C); | ||||
| Context not available. | |||||
| if (!panels_match) { | if (!panels_match) { | ||||
| UI_panels_free_instanced(C, region); | UI_panels_free_instanced(C, region); | ||||
| ShaderFxData *fx = shaderfx->first; | ShaderFxData *fx = static_cast<ShaderFxData *>(shaderfx->first); | ||||
| for (int i = 0; fx; i++, fx = fx->next) { | for (int i = 0; fx; i++, fx = fx->next) { | ||||
| char panel_idname[MAX_NAME]; | char panel_idname[MAX_NAME]; | ||||
| shaderfx_panel_id(fx, panel_idname); | shaderfx_panel_id(fx, panel_idname); | ||||
| /* Create custom data RNA pointer. */ | /* Create custom data RNA pointer. */ | ||||
| PointerRNA *fx_ptr = MEM_mallocN(sizeof(PointerRNA), "panel customdata"); | PointerRNA *fx_ptr = static_cast<PointerRNA *>(MEM_mallocN(sizeof(PointerRNA), __func__)); | ||||
| RNA_pointer_create(&ob->id, &RNA_ShaderFx, fx, fx_ptr); | RNA_pointer_create(&ob->id, &RNA_ShaderFx, fx, fx_ptr); | ||||
| UI_panel_add_instanced(C, region, ®ion->panels, panel_idname, fx_ptr); | UI_panel_add_instanced(C, region, ®ion->panels, panel_idname, fx_ptr); | ||||
| Context not available. | |||||
| } | } | ||||
| else { | else { | ||||
| /* Assuming there's only one group of instanced panels, update the custom data pointers. */ | /* Assuming there's only one group of instanced panels, update the custom data pointers. */ | ||||
| Panel *panel = region->panels.first; | Panel *panel = static_cast<Panel *>(region->panels.first); | ||||
| LISTBASE_FOREACH (ShaderFxData *, fx, shaderfx) { | LISTBASE_FOREACH (ShaderFxData *, fx, shaderfx) { | ||||
| const ShaderFxTypeInfo *fxi = BKE_shaderfx_get_info(fx->type); | const ShaderFxTypeInfo *fxi = BKE_shaderfx_get_info(ShaderFxType(fx->type)); | ||||
| if (fxi->panelRegister == NULL) { | if (fxi->panelRegister == nullptr) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| /* Move to the next instanced panel corresponding to the next modifier. */ | /* Move to the next instanced panel corresponding to the next modifier. */ | ||||
| while ((panel->type == NULL) || !(panel->type->flag & PANEL_TYPE_INSTANCED)) { | while ((panel->type == nullptr) || !(panel->type->flag & PANEL_TYPE_INSTANCED)) { | ||||
| panel = panel->next; | panel = panel->next; | ||||
| BLI_assert(panel != NULL); /* There shouldn't be fewer panels than modifiers with UIs. */ | BLI_assert(panel != | ||||
| nullptr); /* There shouldn't be fewer panels than modifiers with UIs. */ | |||||
| } | } | ||||
| PointerRNA *fx_ptr = MEM_mallocN(sizeof(PointerRNA), "panel customdata"); | PointerRNA *fx_ptr = static_cast<PointerRNA *>(MEM_mallocN(sizeof(PointerRNA), __func__)); | ||||
| RNA_pointer_create(&ob->id, &RNA_ShaderFx, fx, fx_ptr); | RNA_pointer_create(&ob->id, &RNA_ShaderFx, fx, fx_ptr); | ||||
| UI_panel_custom_data_set(panel, fx_ptr); | UI_panel_custom_data_set(panel, fx_ptr); | ||||
| Context not available. | |||||
| /** \name Operator Property Buttons Template | /** \name Operator Property Buttons Template | ||||
| * \{ */ | * \{ */ | ||||
| typedef struct uiTemplateOperatorPropertyPollParam { | struct uiTemplateOperatorPropertyPollParam { | ||||
| const bContext *C; | const bContext *C; | ||||
| wmOperator *op; | wmOperator *op; | ||||
| short flag; | short flag; | ||||
| } uiTemplateOperatorPropertyPollParam; | }; | ||||
| #ifdef USE_OP_RESET_BUT | #ifdef USE_OP_RESET_BUT | ||||
| static void ui_layout_operator_buts__reset_cb(bContext *UNUSED(C), | static void ui_layout_operator_buts__reset_cb(bContext * /*C*/, void *op_pt, void * /*arg_dummy2*/) | ||||
| void *op_pt, | |||||
| void *UNUSED(arg_dummy2)) | |||||
| { | { | ||||
| WM_operator_properties_reset((wmOperator *)op_pt); | WM_operator_properties_reset((wmOperator *)op_pt); | ||||
| } | } | ||||
| #endif | #endif | ||||
| static bool ui_layout_operator_buts_poll_property(struct PointerRNA *UNUSED(ptr), | static bool ui_layout_operator_buts_poll_property(PointerRNA * /*ptr*/, | ||||
| struct PropertyRNA *prop, | PropertyRNA *prop, | ||||
| void *user_data) | void *user_data) | ||||
| { | { | ||||
| uiTemplateOperatorPropertyPollParam *params = user_data; | uiTemplateOperatorPropertyPollParam *params = static_cast<uiTemplateOperatorPropertyPollParam *>( | ||||
| user_data); | |||||
| if ((params->flag & UI_TEMPLATE_OP_PROPS_HIDE_ADVANCED) && | if ((params->flag & UI_TEMPLATE_OP_PROPS_HIDE_ADVANCED) && | ||||
| (RNA_property_tags(prop) & OP_PROP_TAG_ADVANCED)) { | (RNA_property_tags(prop) & OP_PROP_TAG_ADVANCED)) { | ||||
| Context not available. | |||||
| int layout_flags) | int layout_flags) | ||||
| { | { | ||||
| uiBlock *block = uiLayoutGetBlock(layout); | uiBlock *block = uiLayoutGetBlock(layout); | ||||
| eAutoPropButsReturn return_info = 0; | eAutoPropButsReturn return_info = eAutoPropButsReturn(0); | ||||
| if (!op->properties) { | if (!op->properties) { | ||||
| const IDPropertyTemplate val = {0}; | const IDPropertyTemplate val = {0}; | ||||
| Context not available. | |||||
| block->ui_operator = op; | block->ui_operator = op; | ||||
| row = uiLayoutRow(layout, true); | row = uiLayoutRow(layout, true); | ||||
| uiItemM(row, "WM_MT_operator_presets", NULL, ICON_NONE); | uiItemM(row, "WM_MT_operator_presets", nullptr, ICON_NONE); | ||||
| wmOperatorType *ot = WM_operatortype_find("WM_OT_operator_preset_add", false); | wmOperatorType *ot = WM_operatortype_find("WM_OT_operator_preset_add", false); | ||||
| uiItemFullO_ptr(row, ot, "", ICON_ADD, NULL, WM_OP_INVOKE_DEFAULT, 0, &op_ptr); | uiItemFullO_ptr(row, ot, "", ICON_ADD, nullptr, WM_OP_INVOKE_DEFAULT, 0, &op_ptr); | ||||
| RNA_string_set(&op_ptr, "operator", op->type->idname); | RNA_string_set(&op_ptr, "operator", op->type->idname); | ||||
| uiItemFullO_ptr(row, ot, "", ICON_REMOVE, NULL, WM_OP_INVOKE_DEFAULT, 0, &op_ptr); | uiItemFullO_ptr(row, ot, "", ICON_REMOVE, nullptr, WM_OP_INVOKE_DEFAULT, 0, &op_ptr); | ||||
| RNA_string_set(&op_ptr, "operator", op->type->idname); | RNA_string_set(&op_ptr, "operator", op->type->idname); | ||||
| RNA_boolean_set(&op_ptr, "remove_active", true); | RNA_boolean_set(&op_ptr, "remove_active", true); | ||||
| } | } | ||||
| Context not available. | |||||
| if (op->type->ui) { | if (op->type->ui) { | ||||
| op->layout = layout; | op->layout = layout; | ||||
| op->type->ui((bContext *)C, op); | op->type->ui((bContext *)C, op); | ||||
| op->layout = NULL; | op->layout = nullptr; | ||||
| /* #UI_LAYOUT_OP_SHOW_EMPTY ignored. retun_info is ignored too. | /* #UI_LAYOUT_OP_SHOW_EMPTY ignored. retun_info is ignored too. | ||||
| * We could allow #wmOperatorType.ui callback to return this, but not needed right now. */ | * We could allow #wmOperatorType.ui callback to return this, but not needed right now. */ | ||||
| } | } | ||||
| else { | else { | ||||
| wmWindowManager *wm = CTX_wm_manager(C); | wmWindowManager *wm = CTX_wm_manager(C); | ||||
| uiTemplateOperatorPropertyPollParam user_data = {.C = C, .op = op, .flag = layout_flags}; | uiTemplateOperatorPropertyPollParam user_data{}; | ||||
| user_data.C = C; | |||||
| user_data.op = op; | |||||
| user_data.flag = layout_flags; | |||||
| const bool use_prop_split = (layout_flags & UI_TEMPLATE_OP_PROPS_NO_SPLIT_LAYOUT) == 0; | const bool use_prop_split = (layout_flags & UI_TEMPLATE_OP_PROPS_NO_SPLIT_LAYOUT) == 0; | ||||
| PointerRNA ptr; | PointerRNA ptr; | ||||
| Context not available. | |||||
| return_info = uiDefAutoButsRNA( | return_info = uiDefAutoButsRNA( | ||||
| layout, | layout, | ||||
| &ptr, | &ptr, | ||||
| op->type->poll_property ? ui_layout_operator_buts_poll_property : NULL, | op->type->poll_property ? ui_layout_operator_buts_poll_property : nullptr, | ||||
| op->type->poll_property ? &user_data : NULL, | op->type->poll_property ? &user_data : nullptr, | ||||
| op->type->prop, | op->type->prop, | ||||
| label_align, | label_align, | ||||
| (layout_flags & UI_TEMPLATE_OP_PROPS_COMPACT)); | (layout_flags & UI_TEMPLATE_OP_PROPS_COMPACT)); | ||||
| Context not available. | |||||
| 0, | 0, | ||||
| UI_UNIT_X, | UI_UNIT_X, | ||||
| UI_UNIT_Y, | UI_UNIT_Y, | ||||
| NULL, | nullptr, | ||||
| 0.0, | 0.0, | ||||
| 0.0, | 0.0, | ||||
| 0.0, | 0.0, | ||||
| 0.0, | 0.0, | ||||
| TIP_("Reset operator defaults")); | TIP_("Reset operator defaults")); | ||||
| UI_but_func_set(but, ui_layout_operator_buts__reset_cb, op, NULL); | UI_but_func_set(but, ui_layout_operator_buts__reset_cb, op, nullptr); | ||||
| } | } | ||||
| #endif | #endif | ||||
| /* set various special settings for buttons */ | /* set various special settings for buttons */ | ||||
| /* Only do this if we're not refreshing an existing UI. */ | /* Only do this if we're not refreshing an existing UI. */ | ||||
| if (block->oldblock == NULL) { | if (block->oldblock == nullptr) { | ||||
| const bool is_popup = (block->flag & UI_BLOCK_KEEP_OPEN) != 0; | const bool is_popup = (block->flag & UI_BLOCK_KEEP_OPEN) != 0; | ||||
| LISTBASE_FOREACH (uiBut *, but, &block->buttons) { | LISTBASE_FOREACH (uiBut *, but, &block->buttons) { | ||||
| Context not available. | |||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| uiTemplateOperatorPropertyPollParam user_data = {.C = C, .op = op, .flag = layout_flags}; | uiTemplateOperatorPropertyPollParam user_data{}; | ||||
| user_data.C = C; | |||||
| user_data.op = op; | |||||
| user_data.flag = layout_flags; | |||||
| PointerRNA ptr; | PointerRNA ptr; | ||||
| RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr); | RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr); | ||||
| Context not available. | |||||
| flag |= UI_TEMPLATE_OP_PROPS_NO_SPLIT_LAYOUT; | flag |= UI_TEMPLATE_OP_PROPS_NO_SPLIT_LAYOUT; | ||||
| } | } | ||||
| template_operator_property_buts_draw_recursive(C, op, layout, label_align, flag, NULL); | template_operator_property_buts_draw_recursive(C, op, layout, label_align, flag, nullptr); | ||||
| } | } | ||||
| void uiTemplateOperatorRedoProperties(uiLayout *layout, const bContext *C) | void uiTemplateOperatorRedoProperties(uiLayout *layout, const bContext *C) | ||||
| Context not available. | |||||
| wmOperator *op = WM_operator_last_redo(C); | wmOperator *op = WM_operator_last_redo(C); | ||||
| uiBlock *block = uiLayoutGetBlock(layout); | uiBlock *block = uiLayoutGetBlock(layout); | ||||
| if (op == NULL) { | if (op == nullptr) { | ||||
| return; | return; | ||||
| } | } | ||||
| Context not available. | |||||
| "SCREEN_OT_repeat_last", | "SCREEN_OT_repeat_last", | ||||
| WM_operatortype_name(op->type, op->ptr), | WM_operatortype_name(op->type, op->ptr), | ||||
| ICON_NONE, | ICON_NONE, | ||||
| NULL, | nullptr, | ||||
| WM_OP_INVOKE_DEFAULT, | WM_OP_INVOKE_DEFAULT, | ||||
| 0, | 0, | ||||
| NULL); | nullptr); | ||||
| #endif | #endif | ||||
| if (WM_operator_repeat_check(C, op)) { | if (WM_operator_repeat_check(C, op)) { | ||||
| int layout_flags = 0; | int layout_flags = 0; | ||||
| if (block->panel == NULL) { | if (block->panel == nullptr) { | ||||
| layout_flags = UI_TEMPLATE_OP_PROPS_SHOW_TITLE; | layout_flags = UI_TEMPLATE_OP_PROPS_SHOW_TITLE; | ||||
| } | } | ||||
| #if 0 | #if 0 | ||||
| Context not available. | |||||
| UI_block_func_handle_set(block, ED_undo_operator_repeat_cb_evt, op); | UI_block_func_handle_set(block, ED_undo_operator_repeat_cb_evt, op); | ||||
| template_operator_property_buts_draw_recursive( | template_operator_property_buts_draw_recursive( | ||||
| C, op, layout, UI_BUT_LABEL_ALIGN_NONE, layout_flags, NULL /* &has_advanced */); | C, op, layout, UI_BUT_LABEL_ALIGN_NONE, layout_flags, nullptr /* &has_advanced */); | ||||
| /* Warning! this leaves the handle function for any other users of this block. */ | /* Warning! this leaves the handle function for any other users of this block. */ | ||||
| #if 0 | #if 0 | ||||
| Context not available. | |||||
| #define ERROR_LIBDATA_MESSAGE TIP_("Can't edit external library data") | #define ERROR_LIBDATA_MESSAGE TIP_("Can't edit external library data") | ||||
| static void constraint_active_func(bContext *UNUSED(C), void *ob_v, void *con_v) | static void constraint_active_func(bContext * /*C*/, void *ob_v, void *con_v) | ||||
| { | { | ||||
| ED_object_constraint_active_set(ob_v, con_v); | ED_object_constraint_active_set(static_cast<Object *>(ob_v), static_cast<bConstraint *>(con_v)); | ||||
| } | } | ||||
| static void constraint_ops_extra_draw(bContext *C, uiLayout *layout, void *con_v) | static void constraint_ops_extra_draw(bContext *C, uiLayout *layout, void *con_v) | ||||
| Context not available. | |||||
| "CONSTRAINT_OT_move_to_index", | "CONSTRAINT_OT_move_to_index", | ||||
| IFACE_("Move to First"), | IFACE_("Move to First"), | ||||
| ICON_TRIA_UP, | ICON_TRIA_UP, | ||||
| NULL, | nullptr, | ||||
| WM_OP_INVOKE_DEFAULT, | WM_OP_INVOKE_DEFAULT, | ||||
| 0, | 0, | ||||
| &op_ptr); | &op_ptr); | ||||
| Context not available. | |||||
| "CONSTRAINT_OT_move_to_index", | "CONSTRAINT_OT_move_to_index", | ||||
| IFACE_("Move to Last"), | IFACE_("Move to Last"), | ||||
| ICON_TRIA_DOWN, | ICON_TRIA_DOWN, | ||||
| NULL, | nullptr, | ||||
| WM_OP_INVOKE_DEFAULT, | WM_OP_INVOKE_DEFAULT, | ||||
| 0, | 0, | ||||
| &op_ptr); | &op_ptr); | ||||
| ListBase *constraint_list = ED_object_constraint_list_from_constraint(ob, con, NULL); | ListBase *constraint_list = ED_object_constraint_list_from_constraint(ob, con, nullptr); | ||||
| RNA_int_set(&op_ptr, "index", BLI_listbase_count(constraint_list) - 1); | RNA_int_set(&op_ptr, "index", BLI_listbase_count(constraint_list) - 1); | ||||
| if (!con->next) { | if (!con->next) { | ||||
| uiLayoutSetEnabled(row, false); | uiLayoutSetEnabled(row, false); | ||||
| Context not available. | |||||
| /* Constraint type icon. */ | /* Constraint type icon. */ | ||||
| uiLayout *sub = uiLayoutRow(layout, false); | uiLayout *sub = uiLayoutRow(layout, false); | ||||
| uiLayoutSetEmboss(sub, false); | uiLayoutSetEmboss(sub, UI_EMBOSS); | ||||
| uiLayoutSetRedAlert(sub, (con->flag & CONSTRAINT_DISABLE)); | uiLayoutSetRedAlert(sub, (con->flag & CONSTRAINT_DISABLE)); | ||||
| uiItemL(sub, "", RNA_struct_ui_icon(ptr.type)); | uiItemL(sub, "", RNA_struct_ui_icon(ptr.type)); | ||||
| Context not available. | |||||
| } | } | ||||
| Object *ob = (Object *)ptr->owner_id; | Object *ob = (Object *)ptr->owner_id; | ||||
| bConstraint *con = ptr->data; | bConstraint *con = static_cast<bConstraint *>(ptr->data); | ||||
| if (!ob || !(GS(ob->id.name) == ID_OB)) { | if (!ob || !(GS(ob->id.name) == ID_OB)) { | ||||
| RNA_warning("Expected constraint on object"); | RNA_warning("Expected constraint on object"); | ||||
| Context not available. | |||||
| MTex *slot, | MTex *slot, | ||||
| const char *preview_id) | const char *preview_id) | ||||
| { | { | ||||
| Material *ma = NULL; | Material *ma = nullptr; | ||||
| Tex *tex = (Tex *)id; | Tex *tex = (Tex *)id; | ||||
| short *pr_texture = NULL; | short *pr_texture = nullptr; | ||||
| PointerRNA material_ptr; | PointerRNA material_ptr; | ||||
| PointerRNA texture_ptr; | PointerRNA texture_ptr; | ||||
| Context not available. | |||||
| /* decide what to render */ | /* decide what to render */ | ||||
| ID *pid = id; | ID *pid = id; | ||||
| ID *pparent = NULL; | ID *pparent = nullptr; | ||||
| if (id && (GS(id->name) == ID_TE)) { | if (id && (GS(id->name) == ID_TE)) { | ||||
| if (parent && (GS(parent->name) == ID_MA)) { | if (parent && (GS(parent->name) == ID_MA)) { | ||||
| Context not available. | |||||
| /* Find or add the uiPreview to the current Region. */ | /* Find or add the uiPreview to the current Region. */ | ||||
| ARegion *region = CTX_wm_region(C); | ARegion *region = CTX_wm_region(C); | ||||
| uiPreview *ui_preview = BLI_findstring( | uiPreview *ui_preview = static_cast<uiPreview *>( | ||||
| ®ion->ui_previews, preview_id, offsetof(uiPreview, preview_id)); | BLI_findstring(®ion->ui_previews, preview_id, offsetof(uiPreview, preview_id))); | ||||
| if (!ui_preview) { | if (!ui_preview) { | ||||
| ui_preview = MEM_callocN(sizeof(uiPreview), "uiPreview"); | ui_preview = MEM_cnew<uiPreview>(__func__); | ||||
| BLI_strncpy(ui_preview->preview_id, preview_id, sizeof(ui_preview->preview_id)); | BLI_strncpy(ui_preview->preview_id, preview_id, sizeof(ui_preview->preview_id)); | ||||
| ui_preview->height = (short)(UI_UNIT_Y * 7.6f); | ui_preview->height = (short)(UI_UNIT_Y * 7.6f); | ||||
| BLI_addtail(®ion->ui_previews, ui_preview); | BLI_addtail(®ion->ui_previews, ui_preview); | ||||
| Context not available. | |||||
| 0, | 0, | ||||
| ""); | ""); | ||||
| UI_but_func_drawextra_set(block, ED_preview_draw, pparent, slot); | UI_but_func_drawextra_set(block, ED_preview_draw, pparent, slot); | ||||
| UI_block_func_handle_set(block, do_preview_buttons, NULL); | UI_block_func_handle_set(block, do_preview_buttons, nullptr); | ||||
| uiDefIconButS(block, | uiDefIconButS(block, | ||||
| UI_BTYPE_GRIP, | UI_BTYPE_GRIP, | ||||
| Context not available. | |||||
| /* Alpha button for texture preview */ | /* Alpha button for texture preview */ | ||||
| if (*pr_texture != TEX_PR_OTHER) { | if (*pr_texture != TEX_PR_OTHER) { | ||||
| row = uiLayoutRow(layout, false); | row = uiLayoutRow(layout, false); | ||||
| uiItemR(row, &texture_ptr, "use_preview_alpha", 0, NULL, ICON_NONE); | uiItemR(row, &texture_ptr, "use_preview_alpha", 0, nullptr, ICON_NONE); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| Context not available. | |||||
| /** \name ColorRamp Template | /** \name ColorRamp Template | ||||
| * \{ */ | * \{ */ | ||||
| typedef struct RNAUpdateCb { | struct RNAUpdateCb { | ||||
| PointerRNA ptr; | PointerRNA ptr; | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| } RNAUpdateCb; | }; | ||||
| static void rna_update_cb(bContext *C, void *arg_cb, void *UNUSED(arg)) | static void rna_update_cb(bContext *C, void *arg_cb, void * /*arg*/) | ||||
| { | { | ||||
| RNAUpdateCb *cb = (RNAUpdateCb *)arg_cb; | RNAUpdateCb *cb = (RNAUpdateCb *)arg_cb; | ||||
| Context not available. | |||||
| static void colorband_tools_dofunc(bContext *C, void *coba_v, int event) | static void colorband_tools_dofunc(bContext *C, void *coba_v, int event) | ||||
| { | { | ||||
| ColorBand *coba = coba_v; | ColorBand *coba = static_cast<ColorBand *>(coba_v); | ||||
| switch (event) { | switch (event) { | ||||
| case CB_FUNC_FLIP: | case CB_FUNC_FLIP: | ||||
| Context not available. | |||||
| static uiBlock *colorband_tools_func(bContext *C, ARegion *region, void *coba_v) | static uiBlock *colorband_tools_func(bContext *C, ARegion *region, void *coba_v) | ||||
| { | { | ||||
| const uiStyle *style = UI_style_get_dpi(); | const uiStyle *style = UI_style_get_dpi(); | ||||
| ColorBand *coba = coba_v; | ColorBand *coba = static_cast<ColorBand *>(coba_v); | ||||
| short yco = 0; | short yco = 0; | ||||
| const short menuwidth = 10 * UI_UNIT_X; | const short menuwidth = 10 * UI_UNIT_X; | ||||
| Context not available. | |||||
| UI_block_layout_set_current(block, layout); | UI_block_layout_set_current(block, layout); | ||||
| { | { | ||||
| PointerRNA coba_ptr; | PointerRNA coba_ptr; | ||||
| RNA_pointer_create(NULL, &RNA_ColorRamp, coba, &coba_ptr); | RNA_pointer_create(nullptr, &RNA_ColorRamp, coba, &coba_ptr); | ||||
| uiLayoutSetContextPointer(layout, "color_ramp", &coba_ptr); | uiLayoutSetContextPointer(layout, "color_ramp", &coba_ptr); | ||||
| } | } | ||||
| Context not available. | |||||
| yco -= UI_UNIT_Y, | yco -= UI_UNIT_Y, | ||||
| menuwidth, | menuwidth, | ||||
| UI_UNIT_Y, | UI_UNIT_Y, | ||||
| NULL, | nullptr, | ||||
| 0.0, | 0.0, | ||||
| 0.0, | 0.0, | ||||
| 0, | 0, | ||||
| Context not available. | |||||
| yco -= UI_UNIT_Y, | yco -= UI_UNIT_Y, | ||||
| menuwidth, | menuwidth, | ||||
| UI_UNIT_Y, | UI_UNIT_Y, | ||||
| NULL, | nullptr, | ||||
| 0.0, | 0.0, | ||||
| 0.0, | 0.0, | ||||
| 0, | 0, | ||||
| Context not available. | |||||
| yco -= UI_UNIT_Y, | yco -= UI_UNIT_Y, | ||||
| menuwidth, | menuwidth, | ||||
| UI_UNIT_Y, | UI_UNIT_Y, | ||||
| NULL, | nullptr, | ||||
| 0.0, | 0.0, | ||||
| 0.0, | 0.0, | ||||
| 0, | 0, | ||||
| Context not available. | |||||
| yco -= UI_UNIT_Y, | yco -= UI_UNIT_Y, | ||||
| menuwidth, | menuwidth, | ||||
| UI_UNIT_Y, | UI_UNIT_Y, | ||||
| NULL, | nullptr, | ||||
| 0.0, | 0.0, | ||||
| 0.0, | 0.0, | ||||
| 0, | 0, | ||||
| Context not available. | |||||
| static void colorband_add_cb(bContext *C, void *cb_v, void *coba_v) | static void colorband_add_cb(bContext *C, void *cb_v, void *coba_v) | ||||
| { | { | ||||
| ColorBand *coba = coba_v; | ColorBand *coba = static_cast<ColorBand *>(coba_v); | ||||
| float pos = 0.5f; | float pos = 0.5f; | ||||
| if (coba->tot > 1) { | if (coba->tot > 1) { | ||||
| Context not available. | |||||
| } | } | ||||
| if (BKE_colorband_element_add(coba, pos)) { | if (BKE_colorband_element_add(coba, pos)) { | ||||
| rna_update_cb(C, cb_v, NULL); | rna_update_cb(C, cb_v, nullptr); | ||||
| ED_undo_push(C, "Add Color Ramp Stop"); | ED_undo_push(C, "Add Color Ramp Stop"); | ||||
| } | } | ||||
| } | } | ||||
| static void colorband_del_cb(bContext *C, void *cb_v, void *coba_v) | static void colorband_del_cb(bContext *C, void *cb_v, void *coba_v) | ||||
| { | { | ||||
| ColorBand *coba = coba_v; | ColorBand *coba = static_cast<ColorBand *>(coba_v); | ||||
| if (BKE_colorband_element_remove(coba, coba->cur)) { | if (BKE_colorband_element_remove(coba, coba->cur)) { | ||||
| ED_undo_push(C, "Delete Color Ramp Stop"); | ED_undo_push(C, "Delete Color Ramp Stop"); | ||||
| rna_update_cb(C, cb_v, NULL); | rna_update_cb(C, cb_v, nullptr); | ||||
| } | } | ||||
| } | } | ||||
| static void colorband_update_cb(bContext *UNUSED(C), void *bt_v, void *coba_v) | static void colorband_update_cb(bContext * /*C*/, void *bt_v, void *coba_v) | ||||
| { | { | ||||
| uiBut *bt = bt_v; | uiBut *bt = static_cast<uiBut *>(bt_v); | ||||
| ColorBand *coba = coba_v; | ColorBand *coba = static_cast<ColorBand *>(coba_v); | ||||
| /* Sneaky update here, we need to sort the color-band points to be in order, | /* Sneaky update here, we need to sort the color-band points to be in order, | ||||
| * however the RNA pointer then is wrong, so we update it */ | * however the RNA pointer then is wrong, so we update it */ | ||||
| Context not available. | |||||
| 0, | 0, | ||||
| 2.0f * unit, | 2.0f * unit, | ||||
| UI_UNIT_Y, | UI_UNIT_Y, | ||||
| NULL, | nullptr, | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| Context not available. | |||||
| ys + UI_UNIT_Y, | ys + UI_UNIT_Y, | ||||
| 2.0f * unit, | 2.0f * unit, | ||||
| UI_UNIT_Y, | UI_UNIT_Y, | ||||
| NULL, | nullptr, | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| Context not available. | |||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| ""); | ""); | ||||
| UI_but_funcN_set(bt, rna_update_cb, MEM_dupallocN(cb), NULL); | UI_but_funcN_set(bt, rna_update_cb, MEM_dupallocN(cb), nullptr); | ||||
| row = uiLayoutRow(layout, false); | row = uiLayoutRow(layout, false); | ||||
| Context not available. | |||||
| UI_UNIT_Y, | UI_UNIT_Y, | ||||
| &coba->cur, | &coba->cur, | ||||
| 0.0, | 0.0, | ||||
| (float)MAX2(0, coba->tot - 1), | float(MAX2(0, coba->tot - 1)), | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| TIP_("Choose active color stop")); | TIP_("Choose active color stop")); | ||||
| Context not available. | |||||
| UI_UNIT_Y, | UI_UNIT_Y, | ||||
| &coba->cur, | &coba->cur, | ||||
| 0.0, | 0.0, | ||||
| (float)MAX2(0, coba->tot - 1), | float(MAX2(0, coba->tot - 1)), | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| TIP_("Choose active color stop")); | TIP_("Choose active color stop")); | ||||
| Context not available. | |||||
| } | } | ||||
| if (STREQ(prop_identifier, "color")) { | if (STREQ(prop_identifier, "color")) { | ||||
| UI_but_funcN_set(but, rna_update_cb, MEM_dupallocN(cb), NULL); | UI_but_funcN_set(but, rna_update_cb, MEM_dupallocN(cb), nullptr); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| Context not available. | |||||
| return; | return; | ||||
| } | } | ||||
| RNAUpdateCb *cb = MEM_callocN(sizeof(RNAUpdateCb), "RNAUpdateCb"); | RNAUpdateCb *cb = MEM_cnew<RNAUpdateCb>("RNAUpdateCb"); | ||||
| cb->ptr = *ptr; | cb->ptr = *ptr; | ||||
| cb->prop = prop; | cb->prop = prop; | ||||
| Context not available. | |||||
| ID *id = cptr.owner_id; | ID *id = cptr.owner_id; | ||||
| UI_block_lock_set(block, (id && ID_IS_LINKED(id)), ERROR_LIBDATA_MESSAGE); | UI_block_lock_set(block, (id && ID_IS_LINKED(id)), ERROR_LIBDATA_MESSAGE); | ||||
| colorband_buttons_layout(layout, block, cptr.data, &rect, cb, expand); | colorband_buttons_layout(layout, block, static_cast<ColorBand *>(cptr.data), &rect, cb, expand); | ||||
| UI_block_lock_clear(block); | UI_block_lock_clear(block); | ||||
| Context not available. | |||||
| 0, | 0, | ||||
| UI_UNIT_X * icon_scale, | UI_UNIT_X * icon_scale, | ||||
| UI_UNIT_Y * icon_scale, | UI_UNIT_Y * icon_scale, | ||||
| NULL, | nullptr, | ||||
| 0.0, | 0.0, | ||||
| 0.0, | 0.0, | ||||
| 0.0, | 0.0, | ||||
| Context not available. | |||||
| /** \name Icon viewer Template | /** \name Icon viewer Template | ||||
| * \{ */ | * \{ */ | ||||
| typedef struct IconViewMenuArgs { | struct IconViewMenuArgs { | ||||
| PointerRNA ptr; | PointerRNA ptr; | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| bool show_labels; | bool show_labels; | ||||
| float icon_scale; | float icon_scale; | ||||
| } IconViewMenuArgs; | }; | ||||
| /* ID Search browse menu, open */ | /* ID Search browse menu, open */ | ||||
| static uiBlock *ui_icon_view_menu_cb(bContext *C, ARegion *region, void *arg_litem) | static uiBlock *ui_icon_view_menu_cb(bContext *C, ARegion *region, void *arg_litem) | ||||
| Context not available. | |||||
| bool free; | bool free; | ||||
| const EnumPropertyItem *item; | const EnumPropertyItem *item; | ||||
| RNA_property_enum_items(C, &args.ptr, args.prop, &item, NULL, &free); | RNA_property_enum_items(C, &args.ptr, args.prop, &item, nullptr, &free); | ||||
| for (int a = 0; item[a].identifier; a++) { | for (int a = 0; item[a].identifier; a++) { | ||||
| const int x = (a % 8) * w; | const int x = (a % 8) * w; | ||||
| Context not available. | |||||
| value, | value, | ||||
| -1, | -1, | ||||
| -1, | -1, | ||||
| NULL); | nullptr); | ||||
| } | } | ||||
| else { | else { | ||||
| but = uiDefIconButR_prop(block, | but = uiDefIconButR_prop(block, | ||||
| Context not available. | |||||
| value, | value, | ||||
| -1, | -1, | ||||
| -1, | -1, | ||||
| NULL); | nullptr); | ||||
| } | } | ||||
| ui_def_but_icon(but, icon, UI_HAS_ICON | UI_BUT_ICON_PREVIEW); | ui_def_but_icon(but, icon, UI_HAS_ICON | UI_BUT_ICON_PREVIEW); | ||||
| } | } | ||||
| Context not available. | |||||
| int tot_items; | int tot_items; | ||||
| bool free_items; | bool free_items; | ||||
| const EnumPropertyItem *items; | const EnumPropertyItem *items; | ||||
| RNA_property_enum_items(block->evil_C, ptr, prop, &items, &tot_items, &free_items); | RNA_property_enum_items( | ||||
| static_cast<bContext *>(block->evil_C), ptr, prop, &items, &tot_items, &free_items); | |||||
| const int value = RNA_property_enum_get(ptr, prop); | const int value = RNA_property_enum_get(ptr, prop); | ||||
| int icon = ICON_NONE; | int icon = ICON_NONE; | ||||
| RNA_enum_icon_from_value(items, value, &icon); | RNA_enum_icon_from_value(items, value, &icon); | ||||
| uiBut *but; | uiBut *but; | ||||
| if (RNA_property_editable(ptr, prop)) { | if (RNA_property_editable(ptr, prop)) { | ||||
| IconViewMenuArgs *cb_args = MEM_callocN(sizeof(IconViewMenuArgs), __func__); | IconViewMenuArgs *cb_args = MEM_cnew<IconViewMenuArgs>(__func__); | ||||
| cb_args->ptr = *ptr; | cb_args->ptr = *ptr; | ||||
| cb_args->prop = prop; | cb_args->prop = prop; | ||||
| cb_args->show_labels = show_labels; | cb_args->show_labels = show_labels; | ||||
| Context not available. | |||||
| 0, | 0, | ||||
| UI_UNIT_X * icon_scale, | UI_UNIT_X * icon_scale, | ||||
| UI_UNIT_Y * icon_scale, | UI_UNIT_Y * icon_scale, | ||||
| NULL, | nullptr, | ||||
| 0.0, | 0.0, | ||||
| 0.0, | 0.0, | ||||
| 0.0, | 0.0, | ||||
| Context not available. | |||||
| return BLI_rctf_size_x(&cumap->curr) > CURVE_ZOOM_MAX * BLI_rctf_size_x(&cumap->clipr); | return BLI_rctf_size_x(&cumap->curr) > CURVE_ZOOM_MAX * BLI_rctf_size_x(&cumap->clipr); | ||||
| } | } | ||||
| static void curvemap_buttons_zoom_in(bContext *C, void *cumap_v, void *UNUSED(arg)) | static void curvemap_buttons_zoom_in(bContext *C, void *cumap_v, void * /*arg*/) | ||||
| { | { | ||||
| CurveMapping *cumap = cumap_v; | CurveMapping *cumap = static_cast<CurveMapping *>(cumap_v); | ||||
| if (curvemap_can_zoom_in(cumap)) { | if (curvemap_can_zoom_in(cumap)) { | ||||
| const float dx = 0.1154f * BLI_rctf_size_x(&cumap->curr); | const float dx = 0.1154f * BLI_rctf_size_x(&cumap->curr); | ||||
| Context not available. | |||||
| ED_region_tag_redraw(CTX_wm_region(C)); | ED_region_tag_redraw(CTX_wm_region(C)); | ||||
| } | } | ||||
| static void curvemap_buttons_zoom_out(bContext *C, void *cumap_v, void *UNUSED(unused)) | static void curvemap_buttons_zoom_out(bContext *C, void *cumap_v, void * /*unused*/) | ||||
| { | { | ||||
| CurveMapping *cumap = cumap_v; | CurveMapping *cumap = static_cast<CurveMapping *>(cumap_v); | ||||
| float d, d1; | float d, d1; | ||||
| if (curvemap_can_zoom_out(cumap)) { | if (curvemap_can_zoom_out(cumap)) { | ||||
| Context not available. | |||||
| ED_region_tag_redraw(CTX_wm_region(C)); | ED_region_tag_redraw(CTX_wm_region(C)); | ||||
| } | } | ||||
| static void curvemap_buttons_setclip(bContext *UNUSED(C), void *cumap_v, void *UNUSED(arg)) | static void curvemap_buttons_setclip(bContext * /*C*/, void *cumap_v, void * /*arg*/) | ||||
| { | { | ||||
| CurveMapping *cumap = cumap_v; | CurveMapping *cumap = static_cast<CurveMapping *>(cumap_v); | ||||
| BKE_curvemapping_changed(cumap, false); | BKE_curvemapping_changed(cumap, false); | ||||
| } | } | ||||
| static void curvemap_buttons_delete(bContext *C, void *cb_v, void *cumap_v) | static void curvemap_buttons_delete(bContext *C, void *cb_v, void *cumap_v) | ||||
| { | { | ||||
| CurveMapping *cumap = cumap_v; | CurveMapping *cumap = static_cast<CurveMapping *>(cumap_v); | ||||
| BKE_curvemap_remove(cumap->cm + cumap->cur, SELECT); | BKE_curvemap_remove(cumap->cm + cumap->cur, SELECT); | ||||
| BKE_curvemapping_changed(cumap, false); | BKE_curvemapping_changed(cumap, false); | ||||
| rna_update_cb(C, cb_v, NULL); | rna_update_cb(C, cb_v, nullptr); | ||||
| } | } | ||||
| /* NOTE: this is a block-menu, needs 0 events, otherwise the menu closes */ | /* NOTE: this is a block-menu, needs 0 events, otherwise the menu closes */ | ||||
| static uiBlock *curvemap_clipping_func(bContext *C, ARegion *region, void *cumap_v) | static uiBlock *curvemap_clipping_func(bContext *C, ARegion *region, void *cumap_v) | ||||
| { | { | ||||
| CurveMapping *cumap = cumap_v; | CurveMapping *cumap = static_cast<CurveMapping *>(cumap_v); | ||||
| uiBut *bt; | uiBut *bt; | ||||
| const float width = 8 * UI_UNIT_X; | const float width = 8 * UI_UNIT_X; | ||||
| Context not available. | |||||
| 10, | 10, | ||||
| 0, | 0, | ||||
| ""); | ""); | ||||
| UI_but_func_set(bt, curvemap_buttons_setclip, cumap, NULL); | UI_but_func_set(bt, curvemap_buttons_setclip, cumap, nullptr); | ||||
| UI_block_align_begin(block); | UI_block_align_begin(block); | ||||
| bt = uiDefButF(block, | bt = uiDefButF(block, | ||||
| Context not available. | |||||
| static void curvemap_tools_dofunc(bContext *C, void *cumap_v, int event) | static void curvemap_tools_dofunc(bContext *C, void *cumap_v, int event) | ||||
| { | { | ||||
| CurveMapping *cumap = cumap_v; | CurveMapping *cumap = static_cast<CurveMapping *>(cumap_v); | ||||
| CurveMap *cuma = cumap->cm + cumap->cur; | CurveMap *cuma = cumap->cm + cumap->cur; | ||||
| switch (event) { | switch (event) { | ||||
| Context not available. | |||||
| yco -= UI_UNIT_Y, | yco -= UI_UNIT_Y, | ||||
| menuwidth, | menuwidth, | ||||
| UI_UNIT_Y, | UI_UNIT_Y, | ||||
| NULL, | nullptr, | ||||
| 0.0, | 0.0, | ||||
| 0.0, | 0.0, | ||||
| 0, | 0, | ||||
| Context not available. | |||||
| yco -= UI_UNIT_Y, | yco -= UI_UNIT_Y, | ||||
| menuwidth, | menuwidth, | ||||
| UI_UNIT_Y, | UI_UNIT_Y, | ||||
| NULL, | nullptr, | ||||
| 0.0, | 0.0, | ||||
| 0.0, | 0.0, | ||||
| 0, | 0, | ||||
| Context not available. | |||||
| yco -= UI_UNIT_Y, | yco -= UI_UNIT_Y, | ||||
| menuwidth, | menuwidth, | ||||
| UI_UNIT_Y, | UI_UNIT_Y, | ||||
| NULL, | nullptr, | ||||
| 0.0, | 0.0, | ||||
| 0.0, | 0.0, | ||||
| 0, | 0, | ||||
| Context not available. | |||||
| yco -= UI_UNIT_Y, | yco -= UI_UNIT_Y, | ||||
| menuwidth, | menuwidth, | ||||
| UI_UNIT_Y, | UI_UNIT_Y, | ||||
| NULL, | nullptr, | ||||
| 0.0, | 0.0, | ||||
| 0.0, | 0.0, | ||||
| 0, | 0, | ||||
| Context not available. | |||||
| static uiBlock *curvemap_tools_posslope_func(bContext *C, ARegion *region, void *cumap_v) | static uiBlock *curvemap_tools_posslope_func(bContext *C, ARegion *region, void *cumap_v) | ||||
| { | { | ||||
| return curvemap_tools_func(C, region, cumap_v, true, UICURVE_FUNC_RESET_POS); | return curvemap_tools_func( | ||||
| C, region, static_cast<CurveMapping *>(cumap_v), true, UICURVE_FUNC_RESET_POS); | |||||
| } | } | ||||
| static uiBlock *curvemap_tools_negslope_func(bContext *C, ARegion *region, void *cumap_v) | static uiBlock *curvemap_tools_negslope_func(bContext *C, ARegion *region, void *cumap_v) | ||||
| { | { | ||||
| return curvemap_tools_func(C, region, cumap_v, true, UICURVE_FUNC_RESET_NEG); | return curvemap_tools_func( | ||||
| C, region, static_cast<CurveMapping *>(cumap_v), true, UICURVE_FUNC_RESET_NEG); | |||||
| } | } | ||||
| static uiBlock *curvemap_brush_tools_func(bContext *C, ARegion *region, void *cumap_v) | static uiBlock *curvemap_brush_tools_func(bContext *C, ARegion *region, void *cumap_v) | ||||
| { | { | ||||
| return curvemap_tools_func(C, region, cumap_v, false, UICURVE_FUNC_RESET_NEG); | return curvemap_tools_func( | ||||
| C, region, static_cast<CurveMapping *>(cumap_v), false, UICURVE_FUNC_RESET_NEG); | |||||
| } | } | ||||
| static uiBlock *curvemap_brush_tools_negslope_func(bContext *C, ARegion *region, void *cumap_v) | static uiBlock *curvemap_brush_tools_negslope_func(bContext *C, ARegion *region, void *cumap_v) | ||||
| { | { | ||||
| return curvemap_tools_func(C, region, cumap_v, false, UICURVE_FUNC_RESET_POS); | return curvemap_tools_func( | ||||
| C, region, static_cast<CurveMapping *>(cumap_v), false, UICURVE_FUNC_RESET_POS); | |||||
| } | } | ||||
| static void curvemap_tools_handle_vector(bContext *C, void *cumap_v, void *UNUSED(arg)) | static void curvemap_tools_handle_vector(bContext *C, void *cumap_v, void * /*arg*/) | ||||
| { | { | ||||
| curvemap_tools_dofunc(C, cumap_v, UICURVE_FUNC_HANDLE_VECTOR); | curvemap_tools_dofunc(C, cumap_v, UICURVE_FUNC_HANDLE_VECTOR); | ||||
| } | } | ||||
| static void curvemap_tools_handle_auto(bContext *C, void *cumap_v, void *UNUSED(arg)) | static void curvemap_tools_handle_auto(bContext *C, void *cumap_v, void * /*arg*/) | ||||
| { | { | ||||
| curvemap_tools_dofunc(C, cumap_v, UICURVE_FUNC_HANDLE_AUTO); | curvemap_tools_dofunc(C, cumap_v, UICURVE_FUNC_HANDLE_AUTO); | ||||
| } | } | ||||
| static void curvemap_tools_handle_auto_clamped(bContext *C, void *cumap_v, void *UNUSED(arg)) | static void curvemap_tools_handle_auto_clamped(bContext *C, void *cumap_v, void * /*arg*/) | ||||
| { | { | ||||
| curvemap_tools_dofunc(C, cumap_v, UICURVE_FUNC_HANDLE_AUTO_ANIM); | curvemap_tools_dofunc(C, cumap_v, UICURVE_FUNC_HANDLE_AUTO_ANIM); | ||||
| } | } | ||||
| static void curvemap_buttons_redraw(bContext *C, void *UNUSED(arg1), void *UNUSED(arg2)) | static void curvemap_buttons_redraw(bContext *C, void * /*arg1*/, void * /*arg2*/) | ||||
| { | { | ||||
| ED_region_tag_redraw(CTX_wm_region(C)); | ED_region_tag_redraw(CTX_wm_region(C)); | ||||
| } | } | ||||
| static void curvemap_buttons_update(bContext *C, void *arg1_v, void *cumap_v) | static void curvemap_buttons_update(bContext *C, void *arg1_v, void *cumap_v) | ||||
| { | { | ||||
| CurveMapping *cumap = cumap_v; | CurveMapping *cumap = static_cast<CurveMapping *>(cumap_v); | ||||
| BKE_curvemapping_changed(cumap, true); | BKE_curvemapping_changed(cumap, true); | ||||
| rna_update_cb(C, arg1_v, NULL); | rna_update_cb(C, arg1_v, nullptr); | ||||
| } | } | ||||
| static void curvemap_buttons_reset(bContext *C, void *cb_v, void *cumap_v) | static void curvemap_buttons_reset(bContext *C, void *cb_v, void *cumap_v) | ||||
| { | { | ||||
| CurveMapping *cumap = cumap_v; | CurveMapping *cumap = static_cast<CurveMapping *>(cumap_v); | ||||
| cumap->preset = CURVE_PRESET_LINE; | cumap->preset = CURVE_PRESET_LINE; | ||||
| for (int a = 0; a < CM_TOT; a++) { | for (int a = 0; a < CM_TOT; a++) { | ||||
| BKE_curvemap_reset(cumap->cm + a, &cumap->clipr, cumap->preset, CURVEMAP_SLOPE_POSITIVE); | BKE_curvemap_reset(cumap->cm + a, &cumap->clipr, cumap->preset, CURVEMAP_SLOPE_POSITIVE); | ||||
| Context not available. | |||||
| cumap->black[0] = cumap->black[1] = cumap->black[2] = 0.0f; | cumap->black[0] = cumap->black[1] = cumap->black[2] = 0.0f; | ||||
| cumap->white[0] = cumap->white[1] = cumap->white[2] = 1.0f; | cumap->white[0] = cumap->white[1] = cumap->white[2] = 1.0f; | ||||
| BKE_curvemapping_set_black_white(cumap, NULL, NULL); | BKE_curvemapping_set_black_white(cumap, nullptr, nullptr); | ||||
| BKE_curvemapping_changed(cumap, false); | BKE_curvemapping_changed(cumap, false); | ||||
| rna_update_cb(C, cb_v, NULL); | rna_update_cb(C, cb_v, nullptr); | ||||
| } | } | ||||
| /** | /** | ||||
| Context not available. | |||||
| bool tone, | bool tone, | ||||
| RNAUpdateCb *cb) | RNAUpdateCb *cb) | ||||
| { | { | ||||
| CurveMapping *cumap = ptr->data; | CurveMapping *cumap = static_cast<CurveMapping *>(ptr->data); | ||||
| CurveMap *cm = &cumap->cm[cumap->cur]; | CurveMap *cm = &cumap->cm[cumap->cur]; | ||||
| uiBut *bt; | uiBut *bt; | ||||
| const float dx = UI_UNIT_X; | const float dx = UI_UNIT_X; | ||||
| Context not available. | |||||
| if (tone) { | if (tone) { | ||||
| uiLayout *split = uiLayoutSplit(layout, 0.0f, false); | uiLayout *split = uiLayoutSplit(layout, 0.0f, false); | ||||
| uiItemR(uiLayoutRow(split, false), ptr, "tone", UI_ITEM_R_EXPAND, NULL, ICON_NONE); | uiItemR(uiLayoutRow(split, false), ptr, "tone", UI_ITEM_R_EXPAND, nullptr, ICON_NONE); | ||||
| } | } | ||||
| /* curve chooser */ | /* curve chooser */ | ||||
| Context not available. | |||||
| if (cumap->cm[0].curve) { | if (cumap->cm[0].curve) { | ||||
| bt = uiDefButI( | bt = uiDefButI( | ||||
| block, UI_BTYPE_ROW, 0, "X", 0, 0, dx, dx, &cumap->cur, 0.0, 0.0, 0.0, 0.0, ""); | block, UI_BTYPE_ROW, 0, "X", 0, 0, dx, dx, &cumap->cur, 0.0, 0.0, 0.0, 0.0, ""); | ||||
| UI_but_func_set(bt, curvemap_buttons_redraw, NULL, NULL); | UI_but_func_set(bt, curvemap_buttons_redraw, nullptr, nullptr); | ||||
| } | } | ||||
| if (cumap->cm[1].curve) { | if (cumap->cm[1].curve) { | ||||
| bt = uiDefButI( | bt = uiDefButI( | ||||
| block, UI_BTYPE_ROW, 0, "Y", 0, 0, dx, dx, &cumap->cur, 0.0, 1.0, 0.0, 0.0, ""); | block, UI_BTYPE_ROW, 0, "Y", 0, 0, dx, dx, &cumap->cur, 0.0, 1.0, 0.0, 0.0, ""); | ||||
| UI_but_func_set(bt, curvemap_buttons_redraw, NULL, NULL); | UI_but_func_set(bt, curvemap_buttons_redraw, nullptr, nullptr); | ||||
| } | } | ||||
| if (cumap->cm[2].curve) { | if (cumap->cm[2].curve) { | ||||
| bt = uiDefButI( | bt = uiDefButI( | ||||
| block, UI_BTYPE_ROW, 0, "Z", 0, 0, dx, dx, &cumap->cur, 0.0, 2.0, 0.0, 0.0, ""); | block, UI_BTYPE_ROW, 0, "Z", 0, 0, dx, dx, &cumap->cur, 0.0, 2.0, 0.0, 0.0, ""); | ||||
| UI_but_func_set(bt, curvemap_buttons_redraw, NULL, NULL); | UI_but_func_set(bt, curvemap_buttons_redraw, nullptr, nullptr); | ||||
| } | } | ||||
| } | } | ||||
| else if (labeltype == 'c') { | else if (labeltype == 'c') { | ||||
| Context not available. | |||||
| if (cumap->cm[3].curve) { | if (cumap->cm[3].curve) { | ||||
| bt = uiDefButI( | bt = uiDefButI( | ||||
| block, UI_BTYPE_ROW, 0, "C", 0, 0, dx, dx, &cumap->cur, 0.0, 3.0, 0.0, 0.0, ""); | block, UI_BTYPE_ROW, 0, "C", 0, 0, dx, dx, &cumap->cur, 0.0, 3.0, 0.0, 0.0, ""); | ||||
| UI_but_func_set(bt, curvemap_buttons_redraw, NULL, NULL); | UI_but_func_set(bt, curvemap_buttons_redraw, nullptr, nullptr); | ||||
| } | } | ||||
| if (cumap->cm[0].curve) { | if (cumap->cm[0].curve) { | ||||
| bt = uiDefButI( | bt = uiDefButI( | ||||
| block, UI_BTYPE_ROW, 0, "R", 0, 0, dx, dx, &cumap->cur, 0.0, 0.0, 0.0, 0.0, ""); | block, UI_BTYPE_ROW, 0, "R", 0, 0, dx, dx, &cumap->cur, 0.0, 0.0, 0.0, 0.0, ""); | ||||
| UI_but_func_set(bt, curvemap_buttons_redraw, NULL, NULL); | UI_but_func_set(bt, curvemap_buttons_redraw, nullptr, nullptr); | ||||
| } | } | ||||
| if (cumap->cm[1].curve) { | if (cumap->cm[1].curve) { | ||||
| bt = uiDefButI( | bt = uiDefButI( | ||||
| block, UI_BTYPE_ROW, 0, "G", 0, 0, dx, dx, &cumap->cur, 0.0, 1.0, 0.0, 0.0, ""); | block, UI_BTYPE_ROW, 0, "G", 0, 0, dx, dx, &cumap->cur, 0.0, 1.0, 0.0, 0.0, ""); | ||||
| UI_but_func_set(bt, curvemap_buttons_redraw, NULL, NULL); | UI_but_func_set(bt, curvemap_buttons_redraw, nullptr, nullptr); | ||||
| } | } | ||||
| if (cumap->cm[2].curve) { | if (cumap->cm[2].curve) { | ||||
| bt = uiDefButI( | bt = uiDefButI( | ||||
| block, UI_BTYPE_ROW, 0, "B", 0, 0, dx, dx, &cumap->cur, 0.0, 2.0, 0.0, 0.0, ""); | block, UI_BTYPE_ROW, 0, "B", 0, 0, dx, dx, &cumap->cur, 0.0, 2.0, 0.0, 0.0, ""); | ||||
| UI_but_func_set(bt, curvemap_buttons_redraw, NULL, NULL); | UI_but_func_set(bt, curvemap_buttons_redraw, nullptr, nullptr); | ||||
| } | } | ||||
| } | } | ||||
| else if (labeltype == 'h') { | else if (labeltype == 'h') { | ||||
| Context not available. | |||||
| if (cumap->cm[0].curve) { | if (cumap->cm[0].curve) { | ||||
| bt = uiDefButI( | bt = uiDefButI( | ||||
| block, UI_BTYPE_ROW, 0, "H", 0, 0, dx, dx, &cumap->cur, 0.0, 0.0, 0.0, 0.0, ""); | block, UI_BTYPE_ROW, 0, "H", 0, 0, dx, dx, &cumap->cur, 0.0, 0.0, 0.0, 0.0, ""); | ||||
| UI_but_func_set(bt, curvemap_buttons_redraw, NULL, NULL); | UI_but_func_set(bt, curvemap_buttons_redraw, nullptr, nullptr); | ||||
| } | } | ||||
| if (cumap->cm[1].curve) { | if (cumap->cm[1].curve) { | ||||
| bt = uiDefButI( | bt = uiDefButI( | ||||
| block, UI_BTYPE_ROW, 0, "S", 0, 0, dx, dx, &cumap->cur, 0.0, 1.0, 0.0, 0.0, ""); | block, UI_BTYPE_ROW, 0, "S", 0, 0, dx, dx, &cumap->cur, 0.0, 1.0, 0.0, 0.0, ""); | ||||
| UI_but_func_set(bt, curvemap_buttons_redraw, NULL, NULL); | UI_but_func_set(bt, curvemap_buttons_redraw, nullptr, nullptr); | ||||
| } | } | ||||
| if (cumap->cm[2].curve) { | if (cumap->cm[2].curve) { | ||||
| bt = uiDefButI( | bt = uiDefButI( | ||||
| block, UI_BTYPE_ROW, 0, "V", 0, 0, dx, dx, &cumap->cur, 0.0, 2.0, 0.0, 0.0, ""); | block, UI_BTYPE_ROW, 0, "V", 0, 0, dx, dx, &cumap->cur, 0.0, 2.0, 0.0, 0.0, ""); | ||||
| UI_but_func_set(bt, curvemap_buttons_redraw, NULL, NULL); | UI_but_func_set(bt, curvemap_buttons_redraw, nullptr, nullptr); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| Context not available. | |||||
| 0, | 0, | ||||
| dx, | dx, | ||||
| dx, | dx, | ||||
| NULL, | nullptr, | ||||
| 0.0, | 0.0, | ||||
| 0.0, | 0.0, | ||||
| 0.0, | 0.0, | ||||
| 0.0, | 0.0, | ||||
| TIP_("Zoom in")); | TIP_("Zoom in")); | ||||
| UI_but_func_set(bt, curvemap_buttons_zoom_in, cumap, NULL); | UI_but_func_set(bt, curvemap_buttons_zoom_in, cumap, nullptr); | ||||
| if (!curvemap_can_zoom_in(cumap)) { | if (!curvemap_can_zoom_in(cumap)) { | ||||
| UI_but_disable(bt, ""); | UI_but_disable(bt, ""); | ||||
| } | } | ||||
| Context not available. | |||||
| 0, | 0, | ||||
| dx, | dx, | ||||
| dx, | dx, | ||||
| NULL, | nullptr, | ||||
| 0.0, | 0.0, | ||||
| 0.0, | 0.0, | ||||
| 0.0, | 0.0, | ||||
| 0.0, | 0.0, | ||||
| TIP_("Zoom out")); | TIP_("Zoom out")); | ||||
| UI_but_func_set(bt, curvemap_buttons_zoom_out, cumap, NULL); | UI_but_func_set(bt, curvemap_buttons_zoom_out, cumap, nullptr); | ||||
| if (!curvemap_can_zoom_out(cumap)) { | if (!curvemap_can_zoom_out(cumap)) { | ||||
| UI_but_disable(bt, ""); | UI_but_disable(bt, ""); | ||||
| } | } | ||||
| Context not available. | |||||
| bt = uiDefIconBlockBut( | bt = uiDefIconBlockBut( | ||||
| block, curvemap_clipping_func, cumap, 0, icon, 0, 0, dx, dx, TIP_("Clipping Options")); | block, curvemap_clipping_func, cumap, 0, icon, 0, 0, dx, dx, TIP_("Clipping Options")); | ||||
| bt->drawflag &= ~UI_BUT_ICON_LEFT; | bt->drawflag &= ~UI_BUT_ICON_LEFT; | ||||
| UI_but_funcN_set(bt, rna_update_cb, MEM_dupallocN(cb), NULL); | UI_but_funcN_set(bt, rna_update_cb, MEM_dupallocN(cb), nullptr); | ||||
| if (brush && neg_slope) { | if (brush && neg_slope) { | ||||
| bt = uiDefIconBlockBut( | bt = uiDefIconBlockBut( | ||||
| Context not available. | |||||
| bt = uiDefIconBlockBut( | bt = uiDefIconBlockBut( | ||||
| block, curvemap_tools_posslope_func, cumap, 0, 0, 0, 0, dx, dx, TIP_("Tools")); | block, curvemap_tools_posslope_func, cumap, 0, 0, 0, 0, dx, dx, TIP_("Tools")); | ||||
| } | } | ||||
| UI_but_funcN_set(bt, rna_update_cb, MEM_dupallocN(cb), NULL); | UI_but_funcN_set(bt, rna_update_cb, MEM_dupallocN(cb), nullptr); | ||||
| UI_block_funcN_set(block, rna_update_cb, MEM_dupallocN(cb), NULL); | UI_block_funcN_set(block, rna_update_cb, MEM_dupallocN(cb), nullptr); | ||||
| /* Curve itself. */ | /* Curve itself. */ | ||||
| const int size = max_ii(uiLayoutGetWidth(layout), UI_UNIT_X); | const int size = max_ii(uiLayoutGetWidth(layout), UI_UNIT_X); | ||||
| row = uiLayoutRow(layout, false); | row = uiLayoutRow(layout, false); | ||||
| uiButCurveMapping *curve_but = (uiButCurveMapping *)uiDefBut( | uiButCurveMapping *curve_but = (uiButCurveMapping *)uiDefBut( | ||||
| block, UI_BTYPE_CURVE, 0, "", 0, 0, size, 8.0f * UI_UNIT_X, cumap, 0.0f, 1.0f, -1, 0, ""); | block, UI_BTYPE_CURVE, 0, "", 0, 0, size, 8.0f * UI_UNIT_X, cumap, 0.0f, 1.0f, -1, 0, ""); | ||||
| curve_but->gradient_type = bg; | curve_but->gradient_type = eButGradientType(bg); | ||||
| /* Sliders for selected curve point. */ | /* Sliders for selected curve point. */ | ||||
| int i; | int i; | ||||
| CurveMapPoint *cmp = NULL; | CurveMapPoint *cmp = nullptr; | ||||
| bool point_last_or_first = false; | bool point_last_or_first = false; | ||||
| for (i = 0; i < cm->totpoint; i++) { | for (i = 0; i < cm->totpoint; i++) { | ||||
| if (cm->curve[i].flag & CUMA_SELECT) { | if (cm->curve[i].flag & CUMA_SELECT) { | ||||
| Context not available. | |||||
| UI_UNIT_Y, | UI_UNIT_Y, | ||||
| UI_UNIT_X, | UI_UNIT_X, | ||||
| UI_UNIT_Y, | UI_UNIT_Y, | ||||
| NULL, | nullptr, | ||||
| 0.0, | 0.0, | ||||
| 0.0, | 0.0, | ||||
| 0.0, | 0.0, | ||||
| 0.0, | 0.0, | ||||
| TIP_("Auto Handle")); | TIP_("Auto Handle")); | ||||
| UI_but_func_set(bt, curvemap_tools_handle_auto, cumap, NULL); | UI_but_func_set(bt, curvemap_tools_handle_auto, cumap, nullptr); | ||||
| if (((cmp->flag & CUMA_HANDLE_AUTO_ANIM) == false) && | if (((cmp->flag & CUMA_HANDLE_AUTO_ANIM) == false) && | ||||
| ((cmp->flag & CUMA_HANDLE_VECTOR) == false)) { | ((cmp->flag & CUMA_HANDLE_VECTOR) == false)) { | ||||
| bt->flag |= UI_SELECT_DRAW; | bt->flag |= UI_SELECT_DRAW; | ||||
| Context not available. | |||||
| UI_UNIT_Y, | UI_UNIT_Y, | ||||
| UI_UNIT_X, | UI_UNIT_X, | ||||
| UI_UNIT_Y, | UI_UNIT_Y, | ||||
| NULL, | nullptr, | ||||
| 0.0, | 0.0, | ||||
| 0.0, | 0.0, | ||||
| 0.0, | 0.0, | ||||
| 0.0, | 0.0, | ||||
| TIP_("Vector Handle")); | TIP_("Vector Handle")); | ||||
| UI_but_func_set(bt, curvemap_tools_handle_vector, cumap, NULL); | UI_but_func_set(bt, curvemap_tools_handle_vector, cumap, nullptr); | ||||
| if (cmp->flag & CUMA_HANDLE_VECTOR) { | if (cmp->flag & CUMA_HANDLE_VECTOR) { | ||||
| bt->flag |= UI_SELECT_DRAW; | bt->flag |= UI_SELECT_DRAW; | ||||
| } | } | ||||
| Context not available. | |||||
| UI_UNIT_Y, | UI_UNIT_Y, | ||||
| UI_UNIT_X, | UI_UNIT_X, | ||||
| UI_UNIT_Y, | UI_UNIT_Y, | ||||
| NULL, | nullptr, | ||||
| 0.0, | 0.0, | ||||
| 0.0, | 0.0, | ||||
| 0.0, | 0.0, | ||||
| 0.0, | 0.0, | ||||
| TIP_("Auto Clamped")); | TIP_("Auto Clamped")); | ||||
| UI_but_func_set(bt, curvemap_tools_handle_auto_clamped, cumap, NULL); | UI_but_func_set(bt, curvemap_tools_handle_auto_clamped, cumap, nullptr); | ||||
| if (cmp->flag & CUMA_HANDLE_AUTO_ANIM) { | if (cmp->flag & CUMA_HANDLE_AUTO_ANIM) { | ||||
| bt->flag |= UI_SELECT_DRAW; | bt->flag |= UI_SELECT_DRAW; | ||||
| } | } | ||||
| Context not available. | |||||
| 0, | 0, | ||||
| dx, | dx, | ||||
| dx, | dx, | ||||
| NULL, | nullptr, | ||||
| 0.0, | 0.0, | ||||
| 0.0, | 0.0, | ||||
| 0.0, | 0.0, | ||||
| Context not available. | |||||
| /* black/white levels */ | /* black/white levels */ | ||||
| if (levels) { | if (levels) { | ||||
| uiLayout *split = uiLayoutSplit(layout, 0.0f, false); | uiLayout *split = uiLayoutSplit(layout, 0.0f, false); | ||||
| uiItemR(uiLayoutColumn(split, false), ptr, "black_level", UI_ITEM_R_EXPAND, NULL, ICON_NONE); | uiItemR( | ||||
| uiItemR(uiLayoutColumn(split, false), ptr, "white_level", UI_ITEM_R_EXPAND, NULL, ICON_NONE); | uiLayoutColumn(split, false), ptr, "black_level", UI_ITEM_R_EXPAND, nullptr, ICON_NONE); | ||||
| uiItemR( | |||||
| uiLayoutColumn(split, false), ptr, "white_level", UI_ITEM_R_EXPAND, nullptr, ICON_NONE); | |||||
| uiLayoutRow(layout, false); | uiLayoutRow(layout, false); | ||||
| bt = uiDefBut(block, | bt = uiDefBut(block, | ||||
| Context not available. | |||||
| 0, | 0, | ||||
| UI_UNIT_X * 10, | UI_UNIT_X * 10, | ||||
| UI_UNIT_Y, | UI_UNIT_Y, | ||||
| NULL, | nullptr, | ||||
| 0.0f, | 0.0f, | ||||
| 0.0f, | 0.0f, | ||||
| 0, | 0, | ||||
| Context not available. | |||||
| UI_but_funcN_set(bt, curvemap_buttons_reset, MEM_dupallocN(cb), cumap); | UI_but_funcN_set(bt, curvemap_buttons_reset, MEM_dupallocN(cb), cumap); | ||||
| } | } | ||||
| UI_block_funcN_set(block, NULL, NULL, NULL); | UI_block_funcN_set(block, nullptr, nullptr, nullptr); | ||||
| } | } | ||||
| void uiTemplateCurveMapping(uiLayout *layout, | void uiTemplateCurveMapping(uiLayout *layout, | ||||
| Context not available. | |||||
| return; | return; | ||||
| } | } | ||||
| RNAUpdateCb *cb = MEM_callocN(sizeof(RNAUpdateCb), "RNAUpdateCb"); | RNAUpdateCb *cb = MEM_cnew<RNAUpdateCb>("RNAUpdateCb"); | ||||
| cb->ptr = *ptr; | cb->ptr = *ptr; | ||||
| cb->prop = prop; | cb->prop = prop; | ||||
| Context not available. | |||||
| static void CurveProfile_presets_dofunc(bContext *C, void *profile_v, int event) | static void CurveProfile_presets_dofunc(bContext *C, void *profile_v, int event) | ||||
| { | { | ||||
| CurveProfile *profile = profile_v; | CurveProfile *profile = static_cast<CurveProfile *>(profile_v); | ||||
| profile->preset = event; | profile->preset = event; | ||||
| BKE_curveprofile_reset(profile); | BKE_curveprofile_reset(profile); | ||||
| Context not available. | |||||
| yco -= UI_UNIT_Y, | yco -= UI_UNIT_Y, | ||||
| 0, | 0, | ||||
| UI_UNIT_Y, | UI_UNIT_Y, | ||||
| NULL, | nullptr, | ||||
| 0.0, | 0.0, | ||||
| 0.0, | 0.0, | ||||
| 0, | 0, | ||||
| Context not available. | |||||
| yco -= UI_UNIT_Y, | yco -= UI_UNIT_Y, | ||||
| 0, | 0, | ||||
| UI_UNIT_Y, | UI_UNIT_Y, | ||||
| NULL, | nullptr, | ||||
| 0.0, | 0.0, | ||||
| 0.0, | 0.0, | ||||
| 0, | 0, | ||||
| Context not available. | |||||
| yco -= UI_UNIT_Y, | yco -= UI_UNIT_Y, | ||||
| 0, | 0, | ||||
| UI_UNIT_Y, | UI_UNIT_Y, | ||||
| NULL, | nullptr, | ||||
| 0.0, | 0.0, | ||||
| 0.0, | 0.0, | ||||
| 0, | 0, | ||||
| Context not available. | |||||
| yco -= UI_UNIT_Y, | yco -= UI_UNIT_Y, | ||||
| 0, | 0, | ||||
| UI_UNIT_Y, | UI_UNIT_Y, | ||||
| NULL, | nullptr, | ||||
| 0.0, | 0.0, | ||||
| 0.0, | 0.0, | ||||
| 0, | 0, | ||||
| Context not available. | |||||
| yco -= UI_UNIT_Y, | yco -= UI_UNIT_Y, | ||||
| 0, | 0, | ||||
| UI_UNIT_Y, | UI_UNIT_Y, | ||||
| NULL, | nullptr, | ||||
| 0.0, | 0.0, | ||||
| 0.0, | 0.0, | ||||
| 0, | 0, | ||||
| Context not available. | |||||
| ""); | ""); | ||||
| UI_block_direction_set(block, UI_DIR_DOWN); | UI_block_direction_set(block, UI_DIR_DOWN); | ||||
| UI_block_bounds_set_text(block, (int)(3.0f * UI_UNIT_X)); | UI_block_bounds_set_text(block, int(3.0f * UI_UNIT_X)); | ||||
| return block; | return block; | ||||
| } | } | ||||
| Context not available. | |||||
| static void CurveProfile_tools_dofunc(bContext *C, void *profile_v, int event) | static void CurveProfile_tools_dofunc(bContext *C, void *profile_v, int event) | ||||
| { | { | ||||
| CurveProfile *profile = profile_v; | CurveProfile *profile = static_cast<CurveProfile *>(profile_v); | ||||
| switch (event) { | switch (event) { | ||||
| case UIPROFILE_FUNC_RESET: /* reset */ | case UIPROFILE_FUNC_RESET: /* reset */ | ||||
| Context not available. | |||||
| yco -= UI_UNIT_Y, | yco -= UI_UNIT_Y, | ||||
| 0, | 0, | ||||
| UI_UNIT_Y, | UI_UNIT_Y, | ||||
| NULL, | nullptr, | ||||
| 0.0, | 0.0, | ||||
| 0.0, | 0.0, | ||||
| 0, | 0, | ||||
| Context not available. | |||||
| yco -= UI_UNIT_Y, | yco -= UI_UNIT_Y, | ||||
| 0, | 0, | ||||
| UI_UNIT_Y, | UI_UNIT_Y, | ||||
| NULL, | nullptr, | ||||
| 0.0, | 0.0, | ||||
| 0.0, | 0.0, | ||||
| 0, | 0, | ||||
| Context not available. | |||||
| ""); | ""); | ||||
| UI_block_direction_set(block, UI_DIR_DOWN); | UI_block_direction_set(block, UI_DIR_DOWN); | ||||
| UI_block_bounds_set_text(block, (int)(3.0f * UI_UNIT_X)); | UI_block_bounds_set_text(block, int(3.0f * UI_UNIT_X)); | ||||
| return block; | return block; | ||||
| } | } | ||||
| Context not available. | |||||
| return BLI_rctf_size_x(&profile->view_rect) < BLI_rctf_size_x(&profile->clip_rect); | return BLI_rctf_size_x(&profile->view_rect) < BLI_rctf_size_x(&profile->clip_rect); | ||||
| } | } | ||||
| static void CurveProfile_buttons_zoom_in(bContext *C, void *profile_v, void *UNUSED(arg)) | static void CurveProfile_buttons_zoom_in(bContext *C, void *profile_v, void * /*arg*/) | ||||
| { | { | ||||
| CurveProfile *profile = profile_v; | CurveProfile *profile = static_cast<CurveProfile *>(profile_v); | ||||
| if (CurveProfile_can_zoom_in(profile)) { | if (CurveProfile_can_zoom_in(profile)) { | ||||
| const float dx = 0.1154f * BLI_rctf_size_x(&profile->view_rect); | const float dx = 0.1154f * BLI_rctf_size_x(&profile->view_rect); | ||||
| Context not available. | |||||
| ED_region_tag_redraw(CTX_wm_region(C)); | ED_region_tag_redraw(CTX_wm_region(C)); | ||||
| } | } | ||||
| static void CurveProfile_buttons_zoom_out(bContext *C, void *profile_v, void *UNUSED(arg)) | static void CurveProfile_buttons_zoom_out(bContext *C, void *profile_v, void * /*arg*/) | ||||
| { | { | ||||
| CurveProfile *profile = profile_v; | CurveProfile *profile = static_cast<CurveProfile *>(profile_v); | ||||
| if (CurveProfile_can_zoom_out(profile)) { | if (CurveProfile_can_zoom_out(profile)) { | ||||
| float d = 0.15f * BLI_rctf_size_x(&profile->view_rect); | float d = 0.15f * BLI_rctf_size_x(&profile->view_rect); | ||||
| Context not available. | |||||
| static void CurveProfile_clipping_toggle(bContext *C, void *cb_v, void *profile_v) | static void CurveProfile_clipping_toggle(bContext *C, void *cb_v, void *profile_v) | ||||
| { | { | ||||
| CurveProfile *profile = profile_v; | CurveProfile *profile = static_cast<CurveProfile *>(profile_v); | ||||
| profile->flag ^= PROF_USE_CLIP; | profile->flag ^= PROF_USE_CLIP; | ||||
| BKE_curveprofile_update(profile, PROF_UPDATE_NONE); | BKE_curveprofile_update(profile, PROF_UPDATE_NONE); | ||||
| rna_update_cb(C, cb_v, NULL); | rna_update_cb(C, cb_v, nullptr); | ||||
| } | } | ||||
| static void CurveProfile_buttons_reverse(bContext *C, void *cb_v, void *profile_v) | static void CurveProfile_buttons_reverse(bContext *C, void *cb_v, void *profile_v) | ||||
| { | { | ||||
| CurveProfile *profile = profile_v; | CurveProfile *profile = static_cast<CurveProfile *>(profile_v); | ||||
| BKE_curveprofile_reverse(profile); | BKE_curveprofile_reverse(profile); | ||||
| BKE_curveprofile_update(profile, PROF_UPDATE_NONE); | BKE_curveprofile_update(profile, PROF_UPDATE_NONE); | ||||
| rna_update_cb(C, cb_v, NULL); | rna_update_cb(C, cb_v, nullptr); | ||||
| } | } | ||||
| static void CurveProfile_buttons_delete(bContext *C, void *cb_v, void *profile_v) | static void CurveProfile_buttons_delete(bContext *C, void *cb_v, void *profile_v) | ||||
| { | { | ||||
| CurveProfile *profile = profile_v; | CurveProfile *profile = static_cast<CurveProfile *>(profile_v); | ||||
| BKE_curveprofile_remove_by_flag(profile, SELECT); | BKE_curveprofile_remove_by_flag(profile, SELECT); | ||||
| BKE_curveprofile_update(profile, PROF_UPDATE_NONE); | BKE_curveprofile_update(profile, PROF_UPDATE_NONE); | ||||
| rna_update_cb(C, cb_v, NULL); | rna_update_cb(C, cb_v, nullptr); | ||||
| } | } | ||||
| static void CurveProfile_buttons_update(bContext *C, void *arg1_v, void *profile_v) | static void CurveProfile_buttons_update(bContext *C, void *arg1_v, void *profile_v) | ||||
| { | { | ||||
| CurveProfile *profile = profile_v; | CurveProfile *profile = static_cast<CurveProfile *>(profile_v); | ||||
| BKE_curveprofile_update(profile, PROF_UPDATE_REMOVE_DOUBLES | PROF_UPDATE_CLIP); | BKE_curveprofile_update(profile, PROF_UPDATE_REMOVE_DOUBLES | PROF_UPDATE_CLIP); | ||||
| rna_update_cb(C, arg1_v, NULL); | rna_update_cb(C, arg1_v, nullptr); | ||||
| } | } | ||||
| static void CurveProfile_buttons_reset(bContext *C, void *arg1_v, void *profile_v) | static void CurveProfile_buttons_reset(bContext *C, void *arg1_v, void *profile_v) | ||||
| { | { | ||||
| CurveProfile *profile = profile_v; | CurveProfile *profile = static_cast<CurveProfile *>(profile_v); | ||||
| BKE_curveprofile_reset(profile); | BKE_curveprofile_reset(profile); | ||||
| BKE_curveprofile_update(profile, PROF_UPDATE_NONE); | BKE_curveprofile_update(profile, PROF_UPDATE_NONE); | ||||
| rna_update_cb(C, arg1_v, NULL); | rna_update_cb(C, arg1_v, nullptr); | ||||
| } | } | ||||
| static void CurveProfile_buttons_layout(uiLayout *layout, PointerRNA *ptr, RNAUpdateCb *cb) | static void CurveProfile_buttons_layout(uiLayout *layout, PointerRNA *ptr, RNAUpdateCb *cb) | ||||
| { | { | ||||
| CurveProfile *profile = ptr->data; | CurveProfile *profile = static_cast<CurveProfile *>(ptr->data); | ||||
| uiBut *bt; | uiBut *bt; | ||||
| uiBlock *block = uiLayoutGetBlock(layout); | uiBlock *block = uiLayoutGetBlock(layout); | ||||
| Context not available. | |||||
| uiLayout *row = uiLayoutRow(layout, true); | uiLayout *row = uiLayoutRow(layout, true); | ||||
| bt = uiDefBlockBut( | bt = uiDefBlockBut( | ||||
| block, CurveProfile_buttons_presets, profile, "Preset", 0, 0, UI_UNIT_X, UI_UNIT_X, ""); | block, CurveProfile_buttons_presets, profile, "Preset", 0, 0, UI_UNIT_X, UI_UNIT_X, ""); | ||||
| UI_but_funcN_set(bt, rna_update_cb, MEM_dupallocN(cb), NULL); | UI_but_funcN_set(bt, rna_update_cb, MEM_dupallocN(cb), nullptr); | ||||
| /* Show a "re-apply" preset button when it has been changed from the preset. */ | /* Show a "re-apply" preset button when it has been changed from the preset. */ | ||||
| if (profile->flag & PROF_DIRTY_PRESET) { | if (profile->flag & PROF_DIRTY_PRESET) { | ||||
| Context not available. | |||||
| 0, | 0, | ||||
| UI_UNIT_X, | UI_UNIT_X, | ||||
| UI_UNIT_X, | UI_UNIT_X, | ||||
| NULL, | nullptr, | ||||
| 0.0, | 0.0, | ||||
| 0.0, | 0.0, | ||||
| 0.0, | 0.0, | ||||
| Context not available. | |||||
| 0, | 0, | ||||
| UI_UNIT_X, | UI_UNIT_X, | ||||
| UI_UNIT_X, | UI_UNIT_X, | ||||
| NULL, | nullptr, | ||||
| 0.0, | 0.0, | ||||
| 0.0, | 0.0, | ||||
| 0.0, | 0.0, | ||||
| 0.0, | 0.0, | ||||
| TIP_("Zoom in")); | TIP_("Zoom in")); | ||||
| UI_but_func_set(bt, CurveProfile_buttons_zoom_in, profile, NULL); | UI_but_func_set(bt, CurveProfile_buttons_zoom_in, profile, nullptr); | ||||
| if (!CurveProfile_can_zoom_in(profile)) { | if (!CurveProfile_can_zoom_in(profile)) { | ||||
| UI_but_disable(bt, ""); | UI_but_disable(bt, ""); | ||||
| } | } | ||||
| Context not available. | |||||
| 0, | 0, | ||||
| UI_UNIT_X, | UI_UNIT_X, | ||||
| UI_UNIT_X, | UI_UNIT_X, | ||||
| NULL, | nullptr, | ||||
| 0.0, | 0.0, | ||||
| 0.0, | 0.0, | ||||
| 0.0, | 0.0, | ||||
| 0.0, | 0.0, | ||||
| TIP_("Zoom out")); | TIP_("Zoom out")); | ||||
| UI_but_func_set(bt, CurveProfile_buttons_zoom_out, profile, NULL); | UI_but_func_set(bt, CurveProfile_buttons_zoom_out, profile, nullptr); | ||||
| if (!CurveProfile_can_zoom_out(profile)) { | if (!CurveProfile_can_zoom_out(profile)) { | ||||
| UI_but_disable(bt, ""); | UI_but_disable(bt, ""); | ||||
| } | } | ||||
| Context not available. | |||||
| 0, | 0, | ||||
| UI_UNIT_X, | UI_UNIT_X, | ||||
| UI_UNIT_X, | UI_UNIT_X, | ||||
| NULL, | nullptr, | ||||
| 0.0, | 0.0, | ||||
| 0.0, | 0.0, | ||||
| 0.0, | 0.0, | ||||
| Context not available. | |||||
| 0, | 0, | ||||
| UI_UNIT_X, | UI_UNIT_X, | ||||
| UI_UNIT_X, | UI_UNIT_X, | ||||
| NULL, | nullptr, | ||||
| 0.0, | 0.0, | ||||
| 0.0, | 0.0, | ||||
| 0.0, | 0.0, | ||||
| Context not available. | |||||
| /* Reset view, reset curve */ | /* Reset view, reset curve */ | ||||
| bt = uiDefIconBlockBut( | bt = uiDefIconBlockBut( | ||||
| block, CurveProfile_buttons_tools, profile, 0, 0, 0, 0, UI_UNIT_X, UI_UNIT_X, TIP_("Tools")); | block, CurveProfile_buttons_tools, profile, 0, 0, 0, 0, UI_UNIT_X, UI_UNIT_X, TIP_("Tools")); | ||||
| UI_but_funcN_set(bt, rna_update_cb, MEM_dupallocN(cb), NULL); | UI_but_funcN_set(bt, rna_update_cb, MEM_dupallocN(cb), nullptr); | ||||
| UI_block_funcN_set(block, rna_update_cb, MEM_dupallocN(cb), NULL); | UI_block_funcN_set(block, rna_update_cb, MEM_dupallocN(cb), nullptr); | ||||
| /* The path itself */ | /* The path itself */ | ||||
| int path_width = max_ii(uiLayoutGetWidth(layout), UI_UNIT_X); | int path_width = max_ii(uiLayoutGetWidth(layout), UI_UNIT_X); | ||||
| path_width = min_ii(path_width, (int)(16.0f * UI_UNIT_X)); | path_width = min_ii(path_width, int(16.0f * UI_UNIT_X)); | ||||
| const int path_height = path_width; | const int path_height = path_width; | ||||
| uiLayoutRow(layout, false); | uiLayoutRow(layout, false); | ||||
| uiDefBut(block, | uiDefBut(block, | ||||
| Context not available. | |||||
| int i; | int i; | ||||
| float *selection_x, *selection_y; | float *selection_x, *selection_y; | ||||
| bool point_last_or_first = false; | bool point_last_or_first = false; | ||||
| CurveProfilePoint *point = NULL; | CurveProfilePoint *point = nullptr; | ||||
| for (i = 0; i < profile->path_len; i++) { | for (i = 0; i < profile->path_len; i++) { | ||||
| if (profile->path[i].flag & PROF_SELECT) { | if (profile->path[i].flag & PROF_SELECT) { | ||||
| point = &profile->path[i]; | point = &profile->path[i]; | ||||
| Context not available. | |||||
| 0, | 0, | ||||
| UI_UNIT_X, | UI_UNIT_X, | ||||
| UI_UNIT_X, | UI_UNIT_X, | ||||
| NULL, | nullptr, | ||||
| 0.0, | 0.0, | ||||
| 0.0, | 0.0, | ||||
| 0.0, | 0.0, | ||||
| Context not available. | |||||
| } | } | ||||
| } | } | ||||
| uiItemR(layout, ptr, "use_sample_straight_edges", 0, NULL, ICON_NONE); | uiItemR(layout, ptr, "use_sample_straight_edges", 0, nullptr, ICON_NONE); | ||||
| uiItemR(layout, ptr, "use_sample_even_lengths", 0, NULL, ICON_NONE); | uiItemR(layout, ptr, "use_sample_even_lengths", 0, nullptr, ICON_NONE); | ||||
| UI_block_funcN_set(block, NULL, NULL, NULL); | UI_block_funcN_set(block, nullptr, nullptr, nullptr); | ||||
| } | } | ||||
| void uiTemplateCurveProfile(uiLayout *layout, PointerRNA *ptr, const char *propname) | void uiTemplateCurveProfile(uiLayout *layout, PointerRNA *ptr, const char *propname) | ||||
| Context not available. | |||||
| } | } | ||||
| /* Share update functionality with the CurveMapping widget template. */ | /* Share update functionality with the CurveMapping widget template. */ | ||||
| RNAUpdateCb *cb = MEM_callocN(sizeof(RNAUpdateCb), "RNAUpdateCb"); | RNAUpdateCb *cb = MEM_cnew<RNAUpdateCb>("RNAUpdateCb"); | ||||
| cb->ptr = *ptr; | cb->ptr = *ptr; | ||||
| cb->prop = prop; | cb->prop = prop; | ||||
| Context not available. | |||||
| uiLayout *col = uiLayoutColumn(layout, true); | uiLayout *col = uiLayoutColumn(layout, true); | ||||
| uiLayout *row = uiLayoutRow(col, true); | uiLayout *row = uiLayoutRow(col, true); | ||||
| uiBut *but = NULL; | uiBut *but = nullptr; | ||||
| uiButHSVCube *hsv_but; | uiButHSVCube *hsv_but; | ||||
| switch (U.color_picker_type) { | switch (U.color_picker_type) { | ||||
| case USER_CP_SQUARE_SV: | case USER_CP_SQUARE_SV: | ||||
| Context not available. | |||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| ""); | ""); | ||||
| hsv_but->gradient_type = UI_GRAD_SV + 3; | hsv_but->gradient_type = eButGradientType(UI_GRAD_SV + 3); | ||||
| break; | break; | ||||
| case USER_CP_SQUARE_HS: | case USER_CP_SQUARE_HS: | ||||
| uiItemS(col); | uiItemS(col); | ||||
| Context not available. | |||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| ""); | ""); | ||||
| hsv_but->gradient_type = UI_GRAD_HS + 3; | hsv_but->gradient_type = eButGradientType(UI_GRAD_HS + 3); | ||||
| break; | break; | ||||
| case USER_CP_SQUARE_HV: | case USER_CP_SQUARE_HV: | ||||
| uiItemS(col); | uiItemS(col); | ||||
| Context not available. | |||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| ""); | ""); | ||||
| hsv_but->gradient_type = UI_GRAD_HV + 3; | hsv_but->gradient_type = eButGradientType(UI_GRAD_HV + 3); | ||||
| break; | break; | ||||
| /* user default */ | /* user default */ | ||||
| Context not available. | |||||
| } | } | ||||
| } | } | ||||
| static void ui_template_palette_menu(bContext *UNUSED(C), uiLayout *layout, void *UNUSED(but_p)) | static void ui_template_palette_menu(bContext * /* C*/, uiLayout *layout, void * /*but_p*/) | ||||
| { | { | ||||
| uiLayout *row; | uiLayout *row; | ||||
| Context not available. | |||||
| uiItemEnumO_value(row, IFACE_("Luminance"), ICON_NONE, "PALETTE_OT_sort", "type", 4); | uiItemEnumO_value(row, IFACE_("Luminance"), ICON_NONE, "PALETTE_OT_sort", "type", 4); | ||||
| } | } | ||||
| void uiTemplatePalette(uiLayout *layout, | void uiTemplatePalette(uiLayout *layout, PointerRNA *ptr, const char *propname, bool /*colors*/) | ||||
| PointerRNA *ptr, | |||||
| const char *propname, | |||||
| bool UNUSED(colors)) | |||||
| { | { | ||||
| PropertyRNA *prop = RNA_struct_find_property(ptr, propname); | PropertyRNA *prop = RNA_struct_find_property(ptr, propname); | ||||
| uiBut *but = NULL; | uiBut *but = nullptr; | ||||
| const int cols_per_row = MAX2(uiLayoutGetWidth(layout) / UI_UNIT_X, 1); | const int cols_per_row = MAX2(uiLayoutGetWidth(layout) / UI_UNIT_X, 1); | ||||
| Context not available. | |||||
| uiBlock *block = uiLayoutGetBlock(layout); | uiBlock *block = uiLayoutGetBlock(layout); | ||||
| Palette *palette = cptr.data; | Palette *palette = static_cast<Palette *>(cptr.data); | ||||
| uiLayout *col = uiLayoutColumn(layout, true); | uiLayout *col = uiLayoutColumn(layout, true); | ||||
| uiLayoutRow(col, true); | uiLayoutRow(col, true); | ||||
| Context not available. | |||||
| 0, | 0, | ||||
| UI_UNIT_X, | UI_UNIT_X, | ||||
| UI_UNIT_Y, | UI_UNIT_Y, | ||||
| NULL); | nullptr); | ||||
| uiDefIconButO(block, | uiDefIconButO(block, | ||||
| UI_BTYPE_BUT, | UI_BTYPE_BUT, | ||||
| "PALETTE_OT_color_delete", | "PALETTE_OT_color_delete", | ||||
| Context not available. | |||||
| 0, | 0, | ||||
| UI_UNIT_X, | UI_UNIT_X, | ||||
| UI_UNIT_Y, | UI_UNIT_Y, | ||||
| NULL); | nullptr); | ||||
| if (palette->colors.first != NULL) { | if (palette->colors.first != nullptr) { | ||||
| but = uiDefIconButO(block, | but = uiDefIconButO(block, | ||||
| UI_BTYPE_BUT, | UI_BTYPE_BUT, | ||||
| "PALETTE_OT_color_move", | "PALETTE_OT_color_move", | ||||
| Context not available. | |||||
| 0, | 0, | ||||
| UI_UNIT_X, | UI_UNIT_X, | ||||
| UI_UNIT_Y, | UI_UNIT_Y, | ||||
| NULL); | nullptr); | ||||
| UI_but_operator_ptr_get(but); | UI_but_operator_ptr_get(but); | ||||
| RNA_enum_set(but->opptr, "type", -1); | RNA_enum_set(but->opptr, "type", -1); | ||||
| Context not available. | |||||
| 0, | 0, | ||||
| UI_UNIT_X, | UI_UNIT_X, | ||||
| UI_UNIT_Y, | UI_UNIT_Y, | ||||
| NULL); | nullptr); | ||||
| UI_but_operator_ptr_get(but); | UI_but_operator_ptr_get(but); | ||||
| RNA_enum_set(but->opptr, "type", 1); | RNA_enum_set(but->opptr, "type", 1); | ||||
| /* Menu. */ | /* Menu. */ | ||||
| uiDefIconMenuBut( | uiDefIconMenuBut( | ||||
| block, ui_template_palette_menu, NULL, ICON_SORTSIZE, 0, 0, UI_UNIT_X, UI_UNIT_Y, ""); | block, ui_template_palette_menu, nullptr, ICON_SORTSIZE, 0, 0, UI_UNIT_X, UI_UNIT_Y, ""); | ||||
| } | } | ||||
| col = uiLayoutColumn(layout, true); | col = uiLayoutColumn(layout, true); | ||||
| Context not available. | |||||
| static void handle_layer_buttons(bContext *C, void *arg1, void *arg2) | static void handle_layer_buttons(bContext *C, void *arg1, void *arg2) | ||||
| { | { | ||||
| uiBut *but = arg1; | uiBut *but = static_cast<uiBut *>(arg1); | ||||
| const int cur = POINTER_AS_INT(arg2); | const int cur = POINTER_AS_INT(arg2); | ||||
| wmWindow *win = CTX_wm_window(C); | wmWindow *win = CTX_wm_window(C); | ||||
| const bool shift = win->eventstate->modifier & KM_SHIFT; | const bool shift = win->eventstate->modifier & KM_SHIFT; | ||||
| Context not available. | |||||
| const int cols = (layers / 2) + (layers % 2); | const int cols = (layers / 2) + (layers % 2); | ||||
| const int groups = ((cols / 2) < cols_per_group) ? (1) : (cols / cols_per_group); | const int groups = ((cols / 2) < cols_per_group) ? (1) : (cols / cols_per_group); | ||||
| PropertyRNA *used_prop = NULL; | PropertyRNA *used_prop = nullptr; | ||||
| if (used_ptr && used_propname) { | if (used_ptr && used_propname) { | ||||
| used_prop = RNA_struct_find_property(used_ptr, used_propname); | used_prop = RNA_struct_find_property(used_ptr, used_propname); | ||||
| if (!used_prop) { | if (!used_prop) { | ||||
| Context not available. | |||||
| } | } | ||||
| if (RNA_property_array_length(used_ptr, used_prop) < layers) { | if (RNA_property_array_length(used_ptr, used_prop) < layers) { | ||||
| used_prop = NULL; | used_prop = nullptr; | ||||
| } | } | ||||
| } | } | ||||
| Context not available. | |||||
| #define B_STOPFILE 7 | #define B_STOPFILE 7 | ||||
| #define B_STOPOTHER 8 | #define B_STOPOTHER 8 | ||||
| static void do_running_jobs(bContext *C, void *UNUSED(arg), int event) | static void do_running_jobs(bContext *C, void * /*arg*/, int event) | ||||
| { | { | ||||
| switch (event) { | switch (event) { | ||||
| case B_STOPRENDER: | case B_STOPRENDER: | ||||
| G.is_break = true; | G.is_break = true; | ||||
| break; | break; | ||||
| case B_STOPCAST: | case B_STOPCAST: | ||||
| WM_jobs_stop(CTX_wm_manager(C), CTX_wm_screen(C), NULL); | WM_jobs_stop(CTX_wm_manager(C), CTX_wm_screen(C), nullptr); | ||||
| break; | break; | ||||
| case B_STOPANIM: | case B_STOPANIM: | ||||
| WM_operator_name_call(C, "SCREEN_OT_animation_play", WM_OP_INVOKE_SCREEN, NULL, NULL); | WM_operator_name_call(C, "SCREEN_OT_animation_play", WM_OP_INVOKE_SCREEN, nullptr, nullptr); | ||||
| break; | break; | ||||
| case B_STOPCOMPO: | case B_STOPCOMPO: | ||||
| WM_jobs_stop(CTX_wm_manager(C), CTX_data_scene(C), NULL); | WM_jobs_stop(CTX_wm_manager(C), CTX_data_scene(C), nullptr); | ||||
| break; | break; | ||||
| case B_STOPSEQ: | case B_STOPSEQ: | ||||
| WM_jobs_stop(CTX_wm_manager(C), CTX_data_scene(C), NULL); | WM_jobs_stop(CTX_wm_manager(C), CTX_data_scene(C), nullptr); | ||||
| break; | break; | ||||
| case B_STOPCLIP: | case B_STOPCLIP: | ||||
| WM_jobs_stop(CTX_wm_manager(C), CTX_data_scene(C), NULL); | WM_jobs_stop(CTX_wm_manager(C), CTX_data_scene(C), nullptr); | ||||
| break; | break; | ||||
| case B_STOPFILE: | case B_STOPFILE: | ||||
| WM_jobs_stop(CTX_wm_manager(C), CTX_data_scene(C), NULL); | WM_jobs_stop(CTX_wm_manager(C), CTX_data_scene(C), nullptr); | ||||
| break; | break; | ||||
| case B_STOPOTHER: | case B_STOPOTHER: | ||||
| G.is_break = true; | G.is_break = true; | ||||
| Context not available. | |||||
| void *owner; | void *owner; | ||||
| }; | }; | ||||
| static char *progress_tooltip_func(bContext *UNUSED(C), void *argN, const char *UNUSED(tip)) | static char *progress_tooltip_func(bContext * /*C*/, void *argN, const char * /*tip*/) | ||||
| { | { | ||||
| struct ProgressTooltip_Store *arg = argN; | ProgressTooltip_Store *arg = static_cast<ProgressTooltip_Store *>(argN); | ||||
| wmWindowManager *wm = arg->wm; | wmWindowManager *wm = arg->wm; | ||||
| void *owner = arg->owner; | void *owner = arg->owner; | ||||
| Context not available. | |||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| wmWindowManager *wm = CTX_wm_manager(C); | wmWindowManager *wm = CTX_wm_manager(C); | ||||
| ScrArea *area = CTX_wm_area(C); | ScrArea *area = CTX_wm_area(C); | ||||
| void *owner = NULL; | void *owner = nullptr; | ||||
| int handle_event, icon = 0; | int handle_event, icon = 0; | ||||
| uiBlock *block = uiLayoutGetBlock(layout); | uiBlock *block = uiLayoutGetBlock(layout); | ||||
| UI_block_layout_set_current(block, layout); | UI_block_layout_set_current(block, layout); | ||||
| UI_block_func_handle_set(block, do_running_jobs, NULL); | UI_block_func_handle_set(block, do_running_jobs, nullptr); | ||||
| /* another scene can be rendering too, for example via compositor */ | /* another scene can be rendering too, for example via compositor */ | ||||
| LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) { | LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) { | ||||
| Context not available. | |||||
| /* get percentage done and set it as the UI text */ | /* get percentage done and set it as the UI text */ | ||||
| const float progress = WM_jobs_progress(wm, owner); | const float progress = WM_jobs_progress(wm, owner); | ||||
| char text[8]; | char text[8]; | ||||
| BLI_snprintf(text, 8, "%d%%", (int)(progress * 100)); | BLI_snprintf(text, 8, "%d%%", int(progress * 100)); | ||||
| const char *name = active ? WM_jobs_name(wm, owner) : "Canceling..."; | const char *name = active ? WM_jobs_name(wm, owner) : "Canceling..."; | ||||
| Context not available. | |||||
| 0, | 0, | ||||
| textwidth + UI_UNIT_X * 1.5f, | textwidth + UI_UNIT_X * 1.5f, | ||||
| UI_UNIT_Y, | UI_UNIT_Y, | ||||
| NULL, | nullptr, | ||||
| 0.0f, | 0.0f, | ||||
| 0.0f, | 0.0f, | ||||
| 0.0f, | 0.0f, | ||||
| Context not available. | |||||
| block = uiLayoutGetBlock(row); | block = uiLayoutGetBlock(row); | ||||
| { | { | ||||
| struct ProgressTooltip_Store *tip_arg = MEM_mallocN(sizeof(*tip_arg), __func__); | ProgressTooltip_Store *tip_arg = static_cast<ProgressTooltip_Store *>( | ||||
| MEM_mallocN(sizeof(*tip_arg), __func__)); | |||||
| tip_arg->wm = wm; | tip_arg->wm = wm; | ||||
| tip_arg->owner = owner; | tip_arg->owner = owner; | ||||
| uiButProgressbar *but_progress = (uiButProgressbar *)uiDefIconTextBut(block, | uiButProgressbar *but_progress = (uiButProgressbar *)uiDefIconTextBut(block, | ||||
| Context not available. | |||||
| 0, | 0, | ||||
| UI_UNIT_X * 6.0f, | UI_UNIT_X * 6.0f, | ||||
| UI_UNIT_Y, | UI_UNIT_Y, | ||||
| NULL, | nullptr, | ||||
| 0.0f, | 0.0f, | ||||
| 0.0f, | 0.0f, | ||||
| 0.0f, | 0.0f, | ||||
| 0, | 0, | ||||
| NULL); | nullptr); | ||||
| but_progress->progress = progress; | but_progress->progress = progress; | ||||
| UI_but_func_tooltip_set(&but_progress->but, progress_tooltip_func, tip_arg, MEM_freeN); | UI_but_func_tooltip_set(&but_progress->but, progress_tooltip_func, tip_arg, MEM_freeN); | ||||
| Context not available. | |||||
| 0, | 0, | ||||
| UI_UNIT_X, | UI_UNIT_X, | ||||
| UI_UNIT_Y, | UI_UNIT_Y, | ||||
| NULL, | nullptr, | ||||
| 0.0f, | 0.0f, | ||||
| 0.0f, | 0.0f, | ||||
| 0, | 0, | ||||
| Context not available. | |||||
| 0, | 0, | ||||
| UI_UNIT_X * 5.0f, | UI_UNIT_X * 5.0f, | ||||
| UI_UNIT_Y, | UI_UNIT_Y, | ||||
| NULL, | nullptr, | ||||
| 0.0f, | 0.0f, | ||||
| 0.0f, | 0.0f, | ||||
| 0, | 0, | ||||
| Context not available. | |||||
| UI_fontstyle_set(&style->widgetlabel); | UI_fontstyle_set(&style->widgetlabel); | ||||
| int width = BLF_width(style->widgetlabel.uifont_id, report->message, report->len); | int width = BLF_width(style->widgetlabel.uifont_id, report->message, report->len); | ||||
| width = min_ii((int)(rti->widthfac * width), width); | width = min_ii(int(rti->widthfac * width), width); | ||||
| width = max_ii(width, 10 * UI_DPI_FAC); | width = max_ii(width, 10 * UI_DPI_FAC); | ||||
| UI_block_align_begin(block); | UI_block_align_begin(block); | ||||
| Context not available. | |||||
| 0, | 0, | ||||
| UI_UNIT_X + (6 * UI_DPI_FAC), | UI_UNIT_X + (6 * UI_DPI_FAC), | ||||
| UI_UNIT_Y, | UI_UNIT_Y, | ||||
| NULL, | nullptr, | ||||
| 0.0f, | 0.0f, | ||||
| 0.0f, | 0.0f, | ||||
| 0, | 0, | ||||
| Context not available. | |||||
| 0, | 0, | ||||
| UI_UNIT_X + width, | UI_UNIT_X + width, | ||||
| UI_UNIT_Y, | UI_UNIT_Y, | ||||
| NULL, | nullptr, | ||||
| 0.0f, | 0.0f, | ||||
| 0.0f, | 0.0f, | ||||
| 0, | 0, | ||||
| Context not available. | |||||
| UI_block_emboss_set(block, previous_emboss); | UI_block_emboss_set(block, previous_emboss); | ||||
| } | } | ||||
| void uiTemplateInputStatus(uiLayout *layout, struct bContext *C) | void uiTemplateInputStatus(uiLayout *layout, bContext *C) | ||||
| { | { | ||||
| wmWindow *win = CTX_wm_window(C); | wmWindow *win = CTX_wm_window(C); | ||||
| WorkSpace *workspace = CTX_wm_workspace(C); | WorkSpace *workspace = CTX_wm_workspace(C); | ||||
| Context not available. | |||||
| const char *msg_drag = CTX_TIP_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, | const char *msg_drag = CTX_TIP_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, | ||||
| WM_window_cursor_keymap_status_get(win, i, 1)); | WM_window_cursor_keymap_status_get(win, i, 1)); | ||||
| if (msg || (msg_drag == NULL)) { | if (msg || (msg_drag == nullptr)) { | ||||
| uiItemL(row, msg ? msg : "", (ICON_MOUSE_LMB + i)); | uiItemL(row, msg ? msg : "", (ICON_MOUSE_LMB + i)); | ||||
| } | } | ||||
| Context not available. | |||||
| /** \name Keymap Template | /** \name Keymap Template | ||||
| * \{ */ | * \{ */ | ||||
| static void keymap_item_modified(bContext *UNUSED(C), void *kmi_p, void *UNUSED(unused)) | static void keymap_item_modified(bContext * /*C*/, void *kmi_p, void * /*unused*/) | ||||
| { | { | ||||
| wmKeyMapItem *kmi = (wmKeyMapItem *)kmi_p; | wmKeyMapItem *kmi = (wmKeyMapItem *)kmi_p; | ||||
| WM_keyconfig_update_tag(NULL, kmi); | WM_keyconfig_update_tag(nullptr, kmi); | ||||
| } | } | ||||
| static void template_keymap_item_properties(uiLayout *layout, const char *title, PointerRNA *ptr) | static void template_keymap_item_properties(uiLayout *layout, const char *title, PointerRNA *ptr) | ||||
| Context not available. | |||||
| uiLayout *row = uiLayoutRow(box, false); | uiLayout *row = uiLayoutRow(box, false); | ||||
| /* property value */ | /* property value */ | ||||
| uiItemFullR(row, ptr, prop, -1, 0, 0, NULL, ICON_NONE); | uiItemFullR(row, ptr, prop, -1, 0, 0, nullptr, ICON_NONE); | ||||
| if (is_set) { | if (is_set) { | ||||
| /* unset operator */ | /* unset operator */ | ||||
| Context not available. | |||||
| 0, | 0, | ||||
| UI_UNIT_X, | UI_UNIT_X, | ||||
| UI_UNIT_Y, | UI_UNIT_Y, | ||||
| NULL); | nullptr); | ||||
| but->rnapoin = *ptr; | but->rnapoin = *ptr; | ||||
| but->rnaprop = prop; | but->rnaprop = prop; | ||||
| UI_block_emboss_set(block, UI_EMBOSS); | UI_block_emboss_set(block, UI_EMBOSS); | ||||
| Context not available. | |||||
| PointerRNA propptr = RNA_pointer_get(ptr, "properties"); | PointerRNA propptr = RNA_pointer_get(ptr, "properties"); | ||||
| if (propptr.data) { | if (propptr.data) { | ||||
| uiBut *but = uiLayoutGetBlock(layout)->buttons.last; | uiBut *but = static_cast<uiBut *>(uiLayoutGetBlock(layout)->buttons.last); | ||||
| WM_operator_properties_sanitize(&propptr, false); | WM_operator_properties_sanitize(&propptr, false); | ||||
| template_keymap_item_properties(layout, NULL, &propptr); | template_keymap_item_properties(layout, nullptr, &propptr); | ||||
| /* attach callbacks to compensate for missing properties update, | /* attach callbacks to compensate for missing properties update, | ||||
| * we don't know which keymap (item) is being modified there */ | * we don't know which keymap (item) is being modified there */ | ||||
| for (; but; but = but->next) { | for (; but; but = but->next) { | ||||
| /* operator buttons may store props for use (file selector, T36492) */ | /* operator buttons may store props for use (file selector, T36492) */ | ||||
| if (but->rnaprop) { | if (but->rnaprop) { | ||||
| UI_but_func_set(but, keymap_item_modified, ptr->data, NULL); | UI_but_func_set(but, keymap_item_modified, ptr->data, nullptr); | ||||
| /* Otherwise the keymap will be re-generated which we're trying to edit, | /* Otherwise the keymap will be re-generated which we're trying to edit, | ||||
| * see: T47685 */ | * see: T47685 */ | ||||
| Context not available. | |||||
| /** \name Event Icon Template | /** \name Event Icon Template | ||||
| * \{ */ | * \{ */ | ||||
| bool uiTemplateEventFromKeymapItem(struct uiLayout *layout, | bool uiTemplateEventFromKeymapItem(uiLayout *layout, | ||||
| const char *text, | const char *text, | ||||
| const struct wmKeyMapItem *kmi, | const wmKeyMapItem *kmi, | ||||
| bool text_fallback) | bool text_fallback) | ||||
| { | { | ||||
| bool ok = false; | bool ok = false; | ||||
| Context not available. | |||||
| } | } | ||||
| void uiTemplateColormanagedViewSettings(uiLayout *layout, | void uiTemplateColormanagedViewSettings(uiLayout *layout, | ||||
| bContext *UNUSED(C), | bContext * /*C*/, | ||||
| PointerRNA *ptr, | PointerRNA *ptr, | ||||
| const char *propname) | const char *propname) | ||||
| { | { | ||||
| Context not available. | |||||
| } | } | ||||
| PointerRNA view_transform_ptr = RNA_property_pointer_get(ptr, prop); | PointerRNA view_transform_ptr = RNA_property_pointer_get(ptr, prop); | ||||
| ColorManagedViewSettings *view_settings = view_transform_ptr.data; | ColorManagedViewSettings *view_settings = static_cast<ColorManagedViewSettings *>( | ||||
| view_transform_ptr.data); | |||||
| uiLayout *col = uiLayoutColumn(layout, false); | uiLayout *col = uiLayoutColumn(layout, false); | ||||
| uiItemR(col, &view_transform_ptr, "view_transform", 0, IFACE_("View"), ICON_NONE); | uiItemR(col, &view_transform_ptr, "view_transform", 0, IFACE_("View"), ICON_NONE); | ||||
| uiItemR(col, &view_transform_ptr, "look", 0, IFACE_("Look"), ICON_NONE); | uiItemR(col, &view_transform_ptr, "look", 0, IFACE_("Look"), ICON_NONE); | ||||
| col = uiLayoutColumn(layout, false); | col = uiLayoutColumn(layout, false); | ||||
| uiItemR(col, &view_transform_ptr, "exposure", 0, NULL, ICON_NONE); | uiItemR(col, &view_transform_ptr, "exposure", 0, nullptr, ICON_NONE); | ||||
| uiItemR(col, &view_transform_ptr, "gamma", 0, NULL, ICON_NONE); | uiItemR(col, &view_transform_ptr, "gamma", 0, nullptr, ICON_NONE); | ||||
| col = uiLayoutColumn(layout, false); | col = uiLayoutColumn(layout, false); | ||||
| uiItemR(col, &view_transform_ptr, "use_curve_mapping", 0, NULL, ICON_NONE); | uiItemR(col, &view_transform_ptr, "use_curve_mapping", 0, nullptr, ICON_NONE); | ||||
| if (view_settings->flag & COLORMANAGE_VIEW_USE_CURVES) { | if (view_settings->flag & COLORMANAGE_VIEW_USE_CURVES) { | ||||
| uiTemplateCurveMapping( | uiTemplateCurveMapping( | ||||
| col, &view_transform_ptr, "curve_mapping", 'c', true, false, false, false); | col, &view_transform_ptr, "curve_mapping", 'c', true, false, false, false); | ||||
| Context not available. | |||||
| /** \name Component Menu | /** \name Component Menu | ||||
| * \{ */ | * \{ */ | ||||
| typedef struct ComponentMenuArgs { | struct ComponentMenuArgs { | ||||
| PointerRNA ptr; | PointerRNA ptr; | ||||
| char propname[64]; /* XXX arbitrary */ | char propname[64]; /* XXX arbitrary */ | ||||
| } ComponentMenuArgs; | }; | ||||
| /* NOTE: this is a block-menu, needs 0 events, otherwise the menu closes */ | /* NOTE: this is a block-menu, needs 0 events, otherwise the menu closes */ | ||||
| static uiBlock *component_menu(bContext *C, ARegion *region, void *args_v) | static uiBlock *component_menu(bContext *C, ARegion *region, void *args_v) | ||||
| { | { | ||||
| Context not available. | |||||
| const char *propname, | const char *propname, | ||||
| const char *name) | const char *name) | ||||
| { | { | ||||
| ComponentMenuArgs *args = MEM_callocN(sizeof(ComponentMenuArgs), "component menu template args"); | ComponentMenuArgs *args = MEM_cnew<ComponentMenuArgs>(__func__); | ||||
| args->ptr = *ptr; | args->ptr = *ptr; | ||||
| BLI_strncpy(args->propname, propname, sizeof(args->propname)); | BLI_strncpy(args->propname, propname, sizeof(args->propname)); | ||||
| Context not available. | |||||
| /** \name Node Socket Icon Template | /** \name Node Socket Icon Template | ||||
| * \{ */ | * \{ */ | ||||
| void uiTemplateNodeSocket(uiLayout *layout, bContext *UNUSED(C), float color[4]) | void uiTemplateNodeSocket(uiLayout *layout, bContext * /*C*/, float color[4]) | ||||
| { | { | ||||
| uiBlock *block = uiLayoutGetBlock(layout); | uiBlock *block = uiLayoutGetBlock(layout); | ||||
| UI_block_align_begin(block); | UI_block_align_begin(block); | ||||
| Context not available. | |||||
| * but this requires a better design for extendable color palettes in user prefs. | * but this requires a better design for extendable color palettes in user prefs. | ||||
| */ | */ | ||||
| uiBut *but = uiDefBut( | uiBut *but = uiDefBut( | ||||
| block, UI_BTYPE_NODE_SOCKET, 0, "", 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); | block, UI_BTYPE_NODE_SOCKET, 0, "", 0, 0, UI_UNIT_X, UI_UNIT_Y, nullptr, 0, 0, 0, 0, ""); | ||||
| rgba_float_to_uchar(but->col, color); | rgba_float_to_uchar(but->col, color); | ||||
| UI_block_align_end(block); | UI_block_align_end(block); | ||||
| Context not available. | |||||
| /* Ensure that the context has a CacheFile as this may not be set inside of modifiers panels. */ | /* Ensure that the context has a CacheFile as this may not be set inside of modifiers panels. */ | ||||
| uiLayoutSetContextPointer(layout, "edit_cachefile", fileptr); | uiLayoutSetContextPointer(layout, "edit_cachefile", fileptr); | ||||
| uiItemR(layout, fileptr, "velocity_name", 0, NULL, ICON_NONE); | uiItemR(layout, fileptr, "velocity_name", 0, nullptr, ICON_NONE); | ||||
| uiItemR(layout, fileptr, "velocity_unit", 0, NULL, ICON_NONE); | uiItemR(layout, fileptr, "velocity_unit", 0, nullptr, ICON_NONE); | ||||
| } | } | ||||
| void uiTemplateCacheFileProcedural(uiLayout *layout, const bContext *C, PointerRNA *fileptr) | void uiTemplateCacheFileProcedural(uiLayout *layout, const bContext *C, PointerRNA *fileptr) | ||||
| Context not available. | |||||
| uiLayout *row, *sub; | uiLayout *row, *sub; | ||||
| /* Only enable render procedural option if the active engine supports it. */ | /* Only enable render procedural option if the active engine supports it. */ | ||||
| const struct RenderEngineType *engine_type = CTX_data_engine_type(C); | const RenderEngineType *engine_type = CTX_data_engine_type(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| const bool engine_supports_procedural = RE_engine_supports_alembic_procedural(engine_type, | const bool engine_supports_procedural = RE_engine_supports_alembic_procedural(engine_type, | ||||
| Context not available. | |||||
| row = uiLayoutRow(layout, false); | row = uiLayoutRow(layout, false); | ||||
| uiLayoutSetActive(row, engine_supports_procedural); | uiLayoutSetActive(row, engine_supports_procedural); | ||||
| uiItemR(row, fileptr, "use_render_procedural", 0, NULL, ICON_NONE); | uiItemR(row, fileptr, "use_render_procedural", 0, nullptr, ICON_NONE); | ||||
| const bool use_render_procedural = RNA_boolean_get(fileptr, "use_render_procedural"); | const bool use_render_procedural = RNA_boolean_get(fileptr, "use_render_procedural"); | ||||
| const bool use_prefetch = RNA_boolean_get(fileptr, "use_prefetch"); | const bool use_prefetch = RNA_boolean_get(fileptr, "use_prefetch"); | ||||
| row = uiLayoutRow(layout, false); | row = uiLayoutRow(layout, false); | ||||
| uiLayoutSetEnabled(row, use_render_procedural); | uiLayoutSetEnabled(row, use_render_procedural); | ||||
| uiItemR(row, fileptr, "use_prefetch", 0, NULL, ICON_NONE); | uiItemR(row, fileptr, "use_prefetch", 0, nullptr, ICON_NONE); | ||||
| sub = uiLayoutRow(layout, false); | sub = uiLayoutRow(layout, false); | ||||
| uiLayoutSetEnabled(sub, use_prefetch && use_render_procedural); | uiLayoutSetEnabled(sub, use_prefetch && use_render_procedural); | ||||
| uiItemR(sub, fileptr, "prefetch_cache_size", 0, NULL, ICON_NONE); | uiItemR(sub, fileptr, "prefetch_cache_size", 0, nullptr, ICON_NONE); | ||||
| } | } | ||||
| void uiTemplateCacheFileTimeSettings(uiLayout *layout, PointerRNA *fileptr) | void uiTemplateCacheFileTimeSettings(uiLayout *layout, PointerRNA *fileptr) | ||||
| Context not available. | |||||
| uiLayout *row, *sub, *subsub; | uiLayout *row, *sub, *subsub; | ||||
| row = uiLayoutRow(layout, false); | row = uiLayoutRow(layout, false); | ||||
| uiItemR(row, fileptr, "is_sequence", 0, NULL, ICON_NONE); | uiItemR(row, fileptr, "is_sequence", 0, nullptr, ICON_NONE); | ||||
| row = uiLayoutRowWithHeading(layout, true, IFACE_("Override Frame")); | row = uiLayoutRowWithHeading(layout, true, IFACE_("Override Frame")); | ||||
| sub = uiLayoutRow(row, true); | sub = uiLayoutRow(row, true); | ||||
| Context not available. | |||||
| uiItemDecoratorR(row, fileptr, "frame", 0); | uiItemDecoratorR(row, fileptr, "frame", 0); | ||||
| row = uiLayoutRow(layout, false); | row = uiLayoutRow(layout, false); | ||||
| uiItemR(row, fileptr, "frame_offset", 0, NULL, ICON_NONE); | uiItemR(row, fileptr, "frame_offset", 0, nullptr, ICON_NONE); | ||||
| uiLayoutSetActive(row, !RNA_boolean_get(fileptr, "is_sequence")); | uiLayoutSetActive(row, !RNA_boolean_get(fileptr, "is_sequence")); | ||||
| } | } | ||||
| static void cache_file_layer_item(uiList *UNUSED(ui_list), | static void cache_file_layer_item(uiList * /*ui_list*/, | ||||
| const bContext *UNUSED(C), | const bContext * /*C*/, | ||||
| uiLayout *layout, | uiLayout *layout, | ||||
| PointerRNA *UNUSED(dataptr), | PointerRNA * /*dataptr*/, | ||||
| PointerRNA *itemptr, | PointerRNA *itemptr, | ||||
| int UNUSED(icon), | int /*icon*/, | ||||
| PointerRNA *UNUSED(active_dataptr), | PointerRNA * /*active_dataptr*/, | ||||
| const char *UNUSED(active_propname), | const char * /*active_propname*/, | ||||
| int UNUSED(index), | int /*index*/, | ||||
| int UNUSED(flt_flag)) | int /*flt_flag*/) | ||||
| { | { | ||||
| uiLayout *row = uiLayoutRow(layout, true); | uiLayout *row = uiLayoutRow(layout, true); | ||||
| uiItemR(row, itemptr, "hide_layer", UI_ITEM_R_NO_BG, "", ICON_NONE); | uiItemR(row, itemptr, "hide_layer", UI_ITEM_R_NO_BG, "", ICON_NONE); | ||||
| Context not available. | |||||
| uiItemO(col, "", ICON_ADD, "cachefile.layer_add"); | uiItemO(col, "", ICON_ADD, "cachefile.layer_add"); | ||||
| uiItemO(col, "", ICON_REMOVE, "cachefile.layer_remove"); | uiItemO(col, "", ICON_REMOVE, "cachefile.layer_remove"); | ||||
| CacheFile *file = fileptr->data; | CacheFile *file = static_cast<CacheFile *>(fileptr->data); | ||||
| if (BLI_listbase_count(&file->layers) > 1) { | if (BLI_listbase_count(&file->layers) > 1) { | ||||
| uiItemS_ex(col, 1.0f); | uiItemS_ex(col, 1.0f); | ||||
| uiItemO(col, "", ICON_TRIA_UP, "cachefile.layer_move"); | uiItemO(col, "", ICON_TRIA_UP, "cachefile.layer_move"); | ||||
| Context not available. | |||||
| return; | return; | ||||
| } | } | ||||
| CacheFile *file = fileptr.data; | CacheFile *file = static_cast<CacheFile *>(fileptr.data); | ||||
| uiLayoutSetContextPointer(layout, "edit_cachefile", &fileptr); | uiLayoutSetContextPointer(layout, "edit_cachefile", &fileptr); | ||||
| Context not available. | |||||
| C, | C, | ||||
| ptr, | ptr, | ||||
| propname, | propname, | ||||
| NULL, | nullptr, | ||||
| "CACHEFILE_OT_open", | "CACHEFILE_OT_open", | ||||
| NULL, | nullptr, | ||||
| UI_TEMPLATE_ID_FILTER_ALL, | UI_TEMPLATE_ID_FILTER_ALL, | ||||
| false, | false, | ||||
| NULL); | nullptr); | ||||
| if (!file) { | if (!file) { | ||||
| return; | return; | ||||
| Context not available. | |||||
| uiLayoutSetPropSep(layout, true); | uiLayoutSetPropSep(layout, true); | ||||
| row = uiLayoutRow(layout, true); | row = uiLayoutRow(layout, true); | ||||
| uiItemR(row, &fileptr, "filepath", 0, NULL, ICON_NONE); | uiItemR(row, &fileptr, "filepath", 0, nullptr, ICON_NONE); | ||||
| sub = uiLayoutRow(row, true); | sub = uiLayoutRow(row, true); | ||||
| uiItemO(sub, "", ICON_FILE_REFRESH, "cachefile.reload"); | uiItemO(sub, "", ICON_FILE_REFRESH, "cachefile.reload"); | ||||
| Context not available. | |||||
| "WM_OT_open_mainfile", | "WM_OT_open_mainfile", | ||||
| filename, | filename, | ||||
| BLO_has_bfile_extension(filename) ? ICON_FILE_BLEND : ICON_FILE_BACKUP, | BLO_has_bfile_extension(filename) ? ICON_FILE_BLEND : ICON_FILE_BACKUP, | ||||
| NULL, | nullptr, | ||||
| WM_OP_INVOKE_DEFAULT, | WM_OP_INVOKE_DEFAULT, | ||||
| 0, | 0, | ||||
| &ptr); | &ptr); | ||||
| Context not available. | |||||