Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_templates.c
| Show All 12 Lines | |||||
| * along with this program; if not, write to the Free Software Foundation, | * along with this program; if not, write to the Free Software Foundation, | ||||
| * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
| */ | */ | ||||
| /** \file | /** \file | ||||
| * \ingroup edinterface | * \ingroup edinterface | ||||
| */ | */ | ||||
| #include <CLG_log.h> | |||||
| #include <ctype.h> | #include <ctype.h> | ||||
| #include <stddef.h> | #include <stddef.h> | ||||
| #include <stdlib.h> | #include <stdlib.h> | ||||
| #include <string.h> | #include <string.h> | ||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "DNA_brush_types.h" | #include "DNA_brush_types.h" | ||||
| ▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | |||||
| #include "PIL_time.h" | #include "PIL_time.h" | ||||
| // #define USE_OP_RESET_BUT // we may want to make this optional, disable for now. | // #define USE_OP_RESET_BUT // we may want to make this optional, disable for now. | ||||
| /* defines for templateID/TemplateSearch */ | /* defines for templateID/TemplateSearch */ | ||||
| #define TEMPLATE_SEARCH_TEXTBUT_WIDTH (UI_UNIT_X * 6) | #define TEMPLATE_SEARCH_TEXTBUT_WIDTH (UI_UNIT_X * 6) | ||||
| #define TEMPLATE_SEARCH_TEXTBUT_HEIGHT UI_UNIT_Y | #define TEMPLATE_SEARCH_TEXTBUT_HEIGHT UI_UNIT_Y | ||||
| static CLG_LogRef LOG = {"interface.templates"}; | |||||
| void UI_template_fix_linking(void) | void UI_template_fix_linking(void) | ||||
| { | { | ||||
| } | } | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Header Template | /** \name Header Template | ||||
| * \{ */ | * \{ */ | ||||
| ▲ Show 20 Lines • Show All 5,687 Lines • ▼ Show 20 Lines | RNA_PROP_BEGIN (dataptr, itemptr, prop) { | ||||
| if (filter[0]) { | if (filter[0]) { | ||||
| /* Case-insensitive! */ | /* Case-insensitive! */ | ||||
| if (fnmatch(filter, name, FNM_CASEFOLD) == 0) { | if (fnmatch(filter, name, FNM_CASEFOLD) == 0) { | ||||
| dyn_data->items_filter_flags[i] = UILST_FLT_ITEM; | dyn_data->items_filter_flags[i] = UILST_FLT_ITEM; | ||||
| if (!filter_exclude) { | if (!filter_exclude) { | ||||
| dyn_data->items_shown++; | dyn_data->items_shown++; | ||||
| do_order = order_by_name; | do_order = order_by_name; | ||||
| } | } | ||||
| // printf("%s: '%s' matches '%s'\n", __func__, name, filter); | CLOG_VERBOSE(&LOG, 2, "'%s' matches '%s'", name, filter); | ||||
| } | } | ||||
| else if (filter_exclude) { | else if (filter_exclude) { | ||||
| dyn_data->items_shown++; | dyn_data->items_shown++; | ||||
| do_order = order_by_name; | do_order = order_by_name; | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| do_order = order_by_name; | do_order = order_by_name; | ||||
| ▲ Show 20 Lines • Show All 307 Lines • ▼ Show 20 Lines | |||||
| #if 0 | #if 0 | ||||
| int prev_ii = -1, prev_i; | int prev_ii = -1, prev_i; | ||||
| #endif | #endif | ||||
| if (layout_type == UILST_LAYOUT_COMPACT) { | if (layout_type == UILST_LAYOUT_COMPACT) { | ||||
| dyn_data->items_len = dyn_data->items_shown = RNA_property_collection_length(dataptr, prop); | dyn_data->items_len = dyn_data->items_shown = RNA_property_collection_length(dataptr, prop); | ||||
| } | } | ||||
| else { | else { | ||||
| // printf("%s: filtering...\n", __func__); | CLOG_VERBOSE(&LOG, 1, "filtering..."); | ||||
| filter_items(ui_list, C, dataptr, propname); | filter_items(ui_list, C, dataptr, propname); | ||||
| // printf("%s: filtering done.\n", __func__); | CLOG_VERBOSE(&LOG, 1, "filtering done"); | ||||
| } | } | ||||
| items_shown = dyn_data->items_shown; | items_shown = dyn_data->items_shown; | ||||
| if (items_shown >= 0) { | if (items_shown >= 0) { | ||||
| bool activei_mapping_pending = true; | bool activei_mapping_pending = true; | ||||
| items_ptr = MEM_mallocN(sizeof(_uilist_item) * items_shown, __func__); | items_ptr = MEM_mallocN(sizeof(_uilist_item) * items_shown, __func__); | ||||
| // printf("%s: items shown: %d.\n", __func__, items_shown); | CLOG_INFO(&LOG, "items shown: %d", items_shown); | ||||
| RNA_PROP_BEGIN (dataptr, itemptr, prop) { | RNA_PROP_BEGIN (dataptr, itemptr, prop) { | ||||
| if (!dyn_data->items_filter_flags || | if (!dyn_data->items_filter_flags || | ||||
| ((dyn_data->items_filter_flags[i] & UILST_FLT_ITEM) ^ filter_exclude)) { | ((dyn_data->items_filter_flags[i] & UILST_FLT_ITEM) ^ filter_exclude)) { | ||||
| int ii; | int ii; | ||||
| if (dyn_data->items_filter_neworder) { | if (dyn_data->items_filter_neworder) { | ||||
| ii = dyn_data->items_filter_neworder[idx++]; | ii = dyn_data->items_filter_neworder[idx++]; | ||||
| ii = order_reverse ? items_shown - ii - 1 : ii; | ii = order_reverse ? items_shown - ii - 1 : ii; | ||||
| } | } | ||||
| else { | else { | ||||
| ii = order_reverse ? items_shown - ++idx : idx++; | ii = order_reverse ? items_shown - ++idx : idx++; | ||||
| } | } | ||||
| // printf("%s: ii: %d\n", __func__, ii); | CLOG_VERBOSE(&LOG, 3, "ii: %d", ii); | ||||
| items_ptr[ii].item = itemptr; | items_ptr[ii].item = itemptr; | ||||
| items_ptr[ii].org_idx = i; | items_ptr[ii].org_idx = i; | ||||
| items_ptr[ii].flt_flag = dyn_data->items_filter_flags ? dyn_data->items_filter_flags[i] : | items_ptr[ii].flt_flag = dyn_data->items_filter_flags ? dyn_data->items_filter_flags[i] : | ||||
| 0; | 0; | ||||
| if (activei_mapping_pending && activei == i) { | if (activei_mapping_pending && activei == i) { | ||||
| activei = ii; | activei = ii; | ||||
| /* So that we do not map again activei! */ | /* So that we do not map again activei! */ | ||||
| ▲ Show 20 Lines • Show All 951 Lines • ▼ Show 20 Lines | |||||
| void uiTemplateColorspaceSettings(uiLayout *layout, PointerRNA *ptr, const char *propname) | void uiTemplateColorspaceSettings(uiLayout *layout, PointerRNA *ptr, const char *propname) | ||||
| { | { | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| PointerRNA colorspace_settings_ptr; | PointerRNA colorspace_settings_ptr; | ||||
| prop = RNA_struct_find_property(ptr, propname); | prop = RNA_struct_find_property(ptr, propname); | ||||
| if (!prop) { | if (!prop) { | ||||
| printf( | CLOG_ERROR(&LOG, "property not found: %s.%s", RNA_struct_identifier(ptr->type), propname); | ||||
| "%s: property not found: %s.%s\n", __func__, RNA_struct_identifier(ptr->type), propname); | |||||
| return; | return; | ||||
| } | } | ||||
| colorspace_settings_ptr = RNA_property_pointer_get(ptr, prop); | colorspace_settings_ptr = RNA_property_pointer_get(ptr, prop); | ||||
| uiItemR(layout, &colorspace_settings_ptr, "name", 0, IFACE_("Color Space"), ICON_NONE); | uiItemR(layout, &colorspace_settings_ptr, "name", 0, IFACE_("Color Space"), ICON_NONE); | ||||
| } | } | ||||
| void uiTemplateColormanagedViewSettings(uiLayout *layout, | void uiTemplateColormanagedViewSettings(uiLayout *layout, | ||||
| bContext *UNUSED(C), | bContext *UNUSED(C), | ||||
| PointerRNA *ptr, | PointerRNA *ptr, | ||||
| const char *propname) | const char *propname) | ||||
| { | { | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| PointerRNA view_transform_ptr; | PointerRNA view_transform_ptr; | ||||
| uiLayout *col, *row; | uiLayout *col, *row; | ||||
| ColorManagedViewSettings *view_settings; | ColorManagedViewSettings *view_settings; | ||||
| prop = RNA_struct_find_property(ptr, propname); | prop = RNA_struct_find_property(ptr, propname); | ||||
| if (!prop) { | if (!prop) { | ||||
| printf( | CLOG_ERROR(&LOG, "property not found: %s.%s", RNA_struct_identifier(ptr->type), propname); | ||||
| "%s: property not found: %s.%s\n", __func__, RNA_struct_identifier(ptr->type), propname); | |||||
| return; | return; | ||||
| } | } | ||||
| view_transform_ptr = RNA_property_pointer_get(ptr, prop); | view_transform_ptr = RNA_property_pointer_get(ptr, prop); | ||||
| view_settings = view_transform_ptr.data; | view_settings = view_transform_ptr.data; | ||||
| col = uiLayoutColumn(layout, false); | col = uiLayoutColumn(layout, false); | ||||
| ▲ Show 20 Lines • Show All 114 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| if (!ptr->data) { | if (!ptr->data) { | ||||
| return; | return; | ||||
| } | } | ||||
| PropertyRNA *prop = RNA_struct_find_property(ptr, propname); | PropertyRNA *prop = RNA_struct_find_property(ptr, propname); | ||||
| if (!prop) { | if (!prop) { | ||||
| printf( | CLOG_ERROR(&LOG, "property not found: %s.%s", RNA_struct_identifier(ptr->type), propname); | ||||
| "%s: property not found: %s.%s\n", __func__, RNA_struct_identifier(ptr->type), propname); | |||||
| return; | return; | ||||
| } | } | ||||
| if (RNA_property_type(prop) != PROP_POINTER) { | if (RNA_property_type(prop) != PROP_POINTER) { | ||||
| printf("%s: expected pointer property for %s.%s\n", | CLOG_ERROR( | ||||
| __func__, | &LOG, "expected pointer property for %s.%s", RNA_struct_identifier(ptr->type), propname); | ||||
| RNA_struct_identifier(ptr->type), | |||||
| propname); | |||||
| return; | return; | ||||
| } | } | ||||
| PointerRNA fileptr = RNA_property_pointer_get(ptr, prop); | PointerRNA fileptr = RNA_property_pointer_get(ptr, prop); | ||||
| CacheFile *file = fileptr.data; | CacheFile *file = fileptr.data; | ||||
| uiLayoutSetContextPointer(layout, "edit_cachefile", &fileptr); | uiLayoutSetContextPointer(layout, "edit_cachefile", &fileptr); | ||||
| ▲ Show 20 Lines • Show All 106 Lines • Show Last 20 Lines | |||||