Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_templates.c
| Show First 20 Lines • Show All 389 Lines • ▼ Show 20 Lines | |||||
| /* ID Search browse menu, do the search */ | /* ID Search browse menu, do the search */ | ||||
| static void id_search_cb(const bContext *C, | static void id_search_cb(const bContext *C, | ||||
| void *arg_template, | void *arg_template, | ||||
| const char *str, | const char *str, | ||||
| uiSearchItems *items) | uiSearchItems *items) | ||||
| { | { | ||||
| TemplateID *template_ui = (TemplateID *)arg_template; | TemplateID *template_ui = (TemplateID *)arg_template; | ||||
| ListBase *lb = template_ui->idlb; | ListBase *lb = template_ui->idlb; | ||||
| ID *id; | |||||
| int flag = RNA_property_flag(template_ui->prop); | int flag = RNA_property_flag(template_ui->prop); | ||||
| /* ID listbase */ | /* ID listbase */ | ||||
| for (id = lb->first; id; id = id->next) { | LISTBASE_FOREACH (ID *, id, lb) { | ||||
| if (!id_search_add(C, template_ui, flag, str, items, id)) { | if (!id_search_add(C, template_ui, flag, str, items, id)) { | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /** | /** | ||||
| * Use id tags for filtering. | * Use id tags for filtering. | ||||
| */ | */ | ||||
| static void id_search_cb_tagged(const bContext *C, | static void id_search_cb_tagged(const bContext *C, | ||||
| void *arg_template, | void *arg_template, | ||||
| const char *str, | const char *str, | ||||
| uiSearchItems *items) | uiSearchItems *items) | ||||
| { | { | ||||
| TemplateID *template_ui = (TemplateID *)arg_template; | TemplateID *template_ui = (TemplateID *)arg_template; | ||||
| ListBase *lb = template_ui->idlb; | ListBase *lb = template_ui->idlb; | ||||
| ID *id; | |||||
| int flag = RNA_property_flag(template_ui->prop); | int flag = RNA_property_flag(template_ui->prop); | ||||
| /* ID listbase */ | /* ID listbase */ | ||||
| for (id = lb->first; id; id = id->next) { | LISTBASE_FOREACH (ID *, id, lb) { | ||||
| if (id->tag & LIB_TAG_DOIT) { | if (id->tag & LIB_TAG_DOIT) { | ||||
| if (!id_search_add(C, template_ui, flag, str, items, id)) { | if (!id_search_add(C, template_ui, flag, str, items, id)) { | ||||
| break; | break; | ||||
| } | } | ||||
| id->tag &= ~LIB_TAG_DOIT; | id->tag &= ~LIB_TAG_DOIT; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 1,983 Lines • ▼ Show 20 Lines | #ifdef USE_OP_RESET_BUT | ||||
| } | } | ||||
| #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 == NULL) { | ||||
| const bool is_popup = (block->flag & UI_BLOCK_KEEP_OPEN) != 0; | const bool is_popup = (block->flag & UI_BLOCK_KEEP_OPEN) != 0; | ||||
| uiBut *but; | |||||
| for (but = block->buttons.first; but; but = but->next) { | LISTBASE_FOREACH (uiBut *, but, &block->buttons) { | ||||
| /* no undo for buttons for operator redo panels */ | /* no undo for buttons for operator redo panels */ | ||||
| UI_but_flag_disable(but, UI_BUT_UNDO); | UI_but_flag_disable(but, UI_BUT_UNDO); | ||||
| /* only for popups, see [#36109] */ | /* only for popups, see [#36109] */ | ||||
| /* if button is operator's default property, and a text-field, enable focus for it | /* if button is operator's default property, and a text-field, enable focus for it | ||||
| * - this is used for allowing operators with popups to rename stuff with fewer clicks | * - this is used for allowing operators with popups to rename stuff with fewer clicks | ||||
| */ | */ | ||||
| ▲ Show 20 Lines • Show All 2,976 Lines • ▼ Show 20 Lines | |||||
| void uiTemplatePalette(uiLayout *layout, | void uiTemplatePalette(uiLayout *layout, | ||||
| PointerRNA *ptr, | PointerRNA *ptr, | ||||
| const char *propname, | const char *propname, | ||||
| bool UNUSED(colors)) | bool UNUSED(colors)) | ||||
| { | { | ||||
| PropertyRNA *prop = RNA_struct_find_property(ptr, propname); | PropertyRNA *prop = RNA_struct_find_property(ptr, propname); | ||||
| PointerRNA cptr; | PointerRNA cptr; | ||||
| Palette *palette; | Palette *palette; | ||||
| PaletteColor *color; | |||||
| uiBlock *block; | uiBlock *block; | ||||
| uiLayout *col; | uiLayout *col; | ||||
| uiBut *but = NULL; | uiBut *but = NULL; | ||||
| int row_cols = 0, col_id = 0; | int row_cols = 0, col_id = 0; | ||||
| int cols_per_row = MAX2(uiLayoutGetWidth(layout) / UI_UNIT_X, 1); | int cols_per_row = MAX2(uiLayoutGetWidth(layout) / UI_UNIT_X, 1); | ||||
| if (!prop) { | if (!prop) { | ||||
| RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname); | RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname); | ||||
| return; | return; | ||||
| } | } | ||||
| cptr = RNA_property_pointer_get(ptr, prop); | cptr = RNA_property_pointer_get(ptr, prop); | ||||
| if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_Palette)) { | if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_Palette)) { | ||||
| return; | return; | ||||
| } | } | ||||
| block = uiLayoutGetBlock(layout); | block = uiLayoutGetBlock(layout); | ||||
| palette = cptr.data; | palette = cptr.data; | ||||
| color = palette->colors.first; | |||||
| col = uiLayoutColumn(layout, true); | col = uiLayoutColumn(layout, true); | ||||
| uiLayoutRow(col, true); | uiLayoutRow(col, true); | ||||
| uiDefIconButO(block, | uiDefIconButO(block, | ||||
| UI_BTYPE_BUT, | UI_BTYPE_BUT, | ||||
| "PALETTE_OT_color_add", | "PALETTE_OT_color_add", | ||||
| WM_OP_INVOKE_DEFAULT, | WM_OP_INVOKE_DEFAULT, | ||||
| ICON_ADD, | ICON_ADD, | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| UI_UNIT_X, | UI_UNIT_X, | ||||
| UI_UNIT_Y, | UI_UNIT_Y, | ||||
| NULL); | NULL); | ||||
| uiDefIconButO(block, | uiDefIconButO(block, | ||||
| UI_BTYPE_BUT, | UI_BTYPE_BUT, | ||||
| "PALETTE_OT_color_delete", | "PALETTE_OT_color_delete", | ||||
| WM_OP_INVOKE_DEFAULT, | WM_OP_INVOKE_DEFAULT, | ||||
| ICON_REMOVE, | ICON_REMOVE, | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| UI_UNIT_X, | UI_UNIT_X, | ||||
| UI_UNIT_Y, | UI_UNIT_Y, | ||||
| NULL); | NULL); | ||||
| if (color) { | if (palette->colors.first != NULL) { | ||||
| but = uiDefIconButO(block, | but = uiDefIconButO(block, | ||||
| UI_BTYPE_BUT, | UI_BTYPE_BUT, | ||||
| "PALETTE_OT_color_move", | "PALETTE_OT_color_move", | ||||
| WM_OP_INVOKE_DEFAULT, | WM_OP_INVOKE_DEFAULT, | ||||
| ICON_TRIA_UP, | ICON_TRIA_UP, | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| UI_UNIT_X, | UI_UNIT_X, | ||||
| Show All 18 Lines | if (palette->colors.first != NULL) { | ||||
| /* 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, NULL, ICON_SORTSIZE, 0, 0, UI_UNIT_X, UI_UNIT_Y, ""); | ||||
| } | } | ||||
| col = uiLayoutColumn(layout, true); | col = uiLayoutColumn(layout, true); | ||||
| uiLayoutRow(col, true); | uiLayoutRow(col, true); | ||||
| for (; color; color = color->next) { | LISTBASE_FOREACH (PaletteColor *, color, &palette->colors) { | ||||
| PointerRNA color_ptr; | PointerRNA color_ptr; | ||||
| if (row_cols >= cols_per_row) { | if (row_cols >= cols_per_row) { | ||||
| uiLayoutRow(col, true); | uiLayoutRow(col, true); | ||||
| row_cols = 0; | row_cols = 0; | ||||
| } | } | ||||
| RNA_pointer_create(&palette->id, &RNA_PaletteColor, color, &color_ptr); | RNA_pointer_create(&palette->id, &RNA_PaletteColor, color, &color_ptr); | ||||
| ▲ Show 20 Lines • Show All 1,137 Lines • ▼ Show 20 Lines | void uiTemplateRunningJobs(uiLayout *layout, bContext *C) | ||||
| void *owner = NULL; | void *owner = NULL; | ||||
| int handle_event, icon = 0; | int handle_event, icon = 0; | ||||
| block = uiLayoutGetBlock(layout); | 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, NULL); | ||||
| Scene *scene; | |||||
| /* another scene can be rendering too, for example via compositor */ | /* another scene can be rendering too, for example via compositor */ | ||||
| for (scene = bmain->scenes.first; scene; scene = scene->id.next) { | LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) { | ||||
| if (WM_jobs_test(wm, scene, WM_JOB_TYPE_ANY)) { | if (WM_jobs_test(wm, scene, WM_JOB_TYPE_ANY)) { | ||||
| handle_event = B_STOPOTHER; | handle_event = B_STOPOTHER; | ||||
| icon = ICON_NONE; | icon = ICON_NONE; | ||||
| owner = scene; | owner = scene; | ||||
| } | } | ||||
| else { | else { | ||||
| continue; | continue; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 697 Lines • ▼ Show 20 Lines | |||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Recent Files Template | /** \name Recent Files Template | ||||
| * \{ */ | * \{ */ | ||||
| int uiTemplateRecentFiles(uiLayout *layout, int rows) | int uiTemplateRecentFiles(uiLayout *layout, int rows) | ||||
| { | { | ||||
| const RecentFile *recent; | |||||
| int i; | int i; | ||||
| LISTBASE_FOREACH_INDEX (RecentFile *, recent, &G.recent_files, i) { | |||||
| for (recent = G.recent_files.first, i = 0; (i < rows) && (recent); recent = recent->next, i++) { | |||||
| const char *filename = BLI_path_basename(recent->filepath); | const char *filename = BLI_path_basename(recent->filepath); | ||||
campbellbarton: Again, counter being removed from for loop. | |||||
| PointerRNA ptr; | PointerRNA ptr; | ||||
| uiItemFullO(layout, | uiItemFullO(layout, | ||||
| "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, | NULL, | ||||
| WM_OP_INVOKE_DEFAULT, | WM_OP_INVOKE_DEFAULT, | ||||
| 0, | 0, | ||||
| &ptr); | &ptr); | ||||
| RNA_string_set(&ptr, "filepath", recent->filepath); | RNA_string_set(&ptr, "filepath", recent->filepath); | ||||
| RNA_boolean_set(&ptr, "display_file_selector", false); | RNA_boolean_set(&ptr, "display_file_selector", false); | ||||
| if (i > rows) { | |||||
| break; | |||||
| } | |||||
| } | } | ||||
| return i; | return i; | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| Show All 12 Lines | |||||
Again, counter being removed from for loop.