From b254905c384d87764cd92ed631f86f3f97caa4de Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 27 Dec 2015 16:36:08 +1100 Subject: Move generic operator props into own file This is unrelated to core operator internals, so move into own file. --- source/blender/windowmanager/intern/wm_operators.c | 209 --------------------- 1 file changed, 209 deletions(-) (limited to 'source/blender/windowmanager/intern/wm_operators.c') diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index a4a56345798..5daa622a029 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1210,215 +1210,6 @@ bool WM_operator_filesel_ensure_ext_imtype(wmOperator *op, const struct ImageFor return false; } -/* default properties for fileselect */ -void WM_operator_properties_filesel(wmOperatorType *ot, int filter, short type, short action, short flag, short display, short sort) -{ - PropertyRNA *prop; - - static EnumPropertyItem file_display_items[] = { - {FILE_DEFAULTDISPLAY, "DEFAULT", 0, "Default", "Automatically determine display type for files"}, - {FILE_SHORTDISPLAY, "LIST_SHORT", ICON_SHORTDISPLAY, "Short List", "Display files as short list"}, - {FILE_LONGDISPLAY, "LIST_LONG", ICON_LONGDISPLAY, "Long List", "Display files as a detailed list"}, - {FILE_IMGDISPLAY, "THUMBNAIL", ICON_IMGDISPLAY, "Thumbnails", "Display files as thumbnails"}, - {0, NULL, 0, NULL, NULL} - }; - - if (flag & WM_FILESEL_FILEPATH) - RNA_def_string_file_path(ot->srna, "filepath", NULL, FILE_MAX, "File Path", "Path to file"); - - if (flag & WM_FILESEL_DIRECTORY) - RNA_def_string_dir_path(ot->srna, "directory", NULL, FILE_MAX, "Directory", "Directory of the file"); - - if (flag & WM_FILESEL_FILENAME) - RNA_def_string_file_name(ot->srna, "filename", NULL, FILE_MAX, "File Name", "Name of the file"); - - if (flag & WM_FILESEL_FILES) - RNA_def_collection_runtime(ot->srna, "files", &RNA_OperatorFileListElement, "Files", ""); - - if (action == FILE_SAVE) { - /* note, this is only used to check if we should highlight the filename area red when the - * filepath is an existing file. */ - prop = RNA_def_boolean(ot->srna, "check_existing", true, "Check Existing", - "Check and warn on overwriting existing files"); - RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); - } - - prop = RNA_def_boolean(ot->srna, "filter_blender", (filter & FILE_TYPE_BLENDER) != 0, "Filter .blend files", ""); - RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); - prop = RNA_def_boolean(ot->srna, "filter_backup", (filter & FILE_TYPE_BLENDER_BACKUP) != 0, "Filter .blend files", ""); - RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); - prop = RNA_def_boolean(ot->srna, "filter_image", (filter & FILE_TYPE_IMAGE) != 0, "Filter image files", ""); - RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); - prop = RNA_def_boolean(ot->srna, "filter_movie", (filter & FILE_TYPE_MOVIE) != 0, "Filter movie files", ""); - RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); - prop = RNA_def_boolean(ot->srna, "filter_python", (filter & FILE_TYPE_PYSCRIPT) != 0, "Filter python files", ""); - RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); - prop = RNA_def_boolean(ot->srna, "filter_font", (filter & FILE_TYPE_FTFONT) != 0, "Filter font files", ""); - RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); - prop = RNA_def_boolean(ot->srna, "filter_sound", (filter & FILE_TYPE_SOUND) != 0, "Filter sound files", ""); - RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); - prop = RNA_def_boolean(ot->srna, "filter_text", (filter & FILE_TYPE_TEXT) != 0, "Filter text files", ""); - RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); - prop = RNA_def_boolean(ot->srna, "filter_btx", (filter & FILE_TYPE_BTX) != 0, "Filter btx files", ""); - RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); - prop = RNA_def_boolean(ot->srna, "filter_collada", (filter & FILE_TYPE_COLLADA) != 0, "Filter COLLADA files", ""); - RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); - prop = RNA_def_boolean(ot->srna, "filter_folder", (filter & FILE_TYPE_FOLDER) != 0, "Filter folders", ""); - RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); - prop = RNA_def_boolean(ot->srna, "filter_blenlib", (filter & FILE_TYPE_BLENDERLIB) != 0, "Filter Blender IDs", ""); - RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); - - prop = RNA_def_int(ot->srna, "filemode", type, FILE_LOADLIB, FILE_SPECIAL, - "File Browser Mode", "The setting for the file browser mode to load a .blend file, a library or a special file", - FILE_LOADLIB, FILE_SPECIAL); - RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); - - if (flag & WM_FILESEL_RELPATH) - RNA_def_boolean(ot->srna, "relative_path", true, "Relative Path", "Select the file relative to the blend file"); - - if ((filter & FILE_TYPE_IMAGE) || (filter & FILE_TYPE_MOVIE)) { - prop = RNA_def_boolean(ot->srna, "show_multiview", 0, "Enable Multi-View", ""); - RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); - prop = RNA_def_boolean(ot->srna, "use_multiview", 0, "Use Multi-View", ""); - RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); - } - - prop = RNA_def_enum(ot->srna, "display_type", file_display_items, display, "Display Type", ""); - RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); - - prop = RNA_def_enum(ot->srna, "sort_method", rna_enum_file_sort_items, sort, "File sorting mode", ""); - RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); - -} - -static void wm_operator_properties_select_action_ex(wmOperatorType *ot, int default_action, - const EnumPropertyItem *select_actions) -{ - RNA_def_enum(ot->srna, "action", select_actions, default_action, "Action", "Selection action to execute"); -} - -void WM_operator_properties_select_action(wmOperatorType *ot, int default_action) -{ - static EnumPropertyItem select_actions[] = { - {SEL_TOGGLE, "TOGGLE", 0, "Toggle", "Toggle selection for all elements"}, - {SEL_SELECT, "SELECT", 0, "Select", "Select all elements"}, - {SEL_DESELECT, "DESELECT", 0, "Deselect", "Deselect all elements"}, - {SEL_INVERT, "INVERT", 0, "Invert", "Invert selection of all elements"}, - {0, NULL, 0, NULL, NULL} - }; - - wm_operator_properties_select_action_ex(ot, default_action, select_actions); -} - -/** - * only SELECT/DESELECT - */ -void WM_operator_properties_select_action_simple(wmOperatorType *ot, int default_action) -{ - static EnumPropertyItem select_actions[] = { - {SEL_SELECT, "SELECT", 0, "Select", "Select all elements"}, - {SEL_DESELECT, "DESELECT", 0, "Deselect", "Deselect all elements"}, - {0, NULL, 0, NULL, NULL} - }; - - wm_operator_properties_select_action_ex(ot, default_action, select_actions); -} - -/** - * Use for all select random operators. - * Adds properties: percent, seed, action. - */ -void WM_operator_properties_select_random(wmOperatorType *ot) -{ - RNA_def_float_percentage( - ot->srna, "percent", 50.f, 0.0f, 100.0f, - "Percent", "Percentage of objects to select randomly", 0.f, 100.0f); - RNA_def_int( - ot->srna, "seed", 0, 0, INT_MAX, - "Random Seed", "Seed for the random number generator", 0, 255); - - WM_operator_properties_select_action_simple(ot, SEL_SELECT); -} - -void WM_operator_properties_select_all(wmOperatorType *ot) -{ - WM_operator_properties_select_action(ot, SEL_TOGGLE); -} - -void WM_operator_properties_border(wmOperatorType *ot) -{ - PropertyRNA *prop; - - prop = RNA_def_int(ot->srna, "xmin", 0, INT_MIN, INT_MAX, "X Min", "", INT_MIN, INT_MAX); - RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); - prop = RNA_def_int(ot->srna, "xmax", 0, INT_MIN, INT_MAX, "X Max", "", INT_MIN, INT_MAX); - RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); - prop = RNA_def_int(ot->srna, "ymin", 0, INT_MIN, INT_MAX, "Y Min", "", INT_MIN, INT_MAX); - RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); - prop = RNA_def_int(ot->srna, "ymax", 0, INT_MIN, INT_MAX, "Y Max", "", INT_MIN, INT_MAX); - RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); -} - -void WM_operator_properties_border_to_rcti(struct wmOperator *op, rcti *rect) -{ - rect->xmin = RNA_int_get(op->ptr, "xmin"); - rect->ymin = RNA_int_get(op->ptr, "ymin"); - rect->xmax = RNA_int_get(op->ptr, "xmax"); - rect->ymax = RNA_int_get(op->ptr, "ymax"); -} - -void WM_operator_properties_border_to_rctf(struct wmOperator *op, rctf *rect) -{ - rcti rect_i; - WM_operator_properties_border_to_rcti(op, &rect_i); - BLI_rctf_rcti_copy(rect, &rect_i); -} - -void WM_operator_properties_gesture_border(wmOperatorType *ot, bool extend) -{ - RNA_def_int(ot->srna, "gesture_mode", 0, INT_MIN, INT_MAX, "Gesture Mode", "", INT_MIN, INT_MAX); - - WM_operator_properties_border(ot); - - if (extend) { - RNA_def_boolean(ot->srna, "extend", true, "Extend", "Extend selection instead of deselecting everything first"); - } -} - -void WM_operator_properties_mouse_select(wmOperatorType *ot) -{ - PropertyRNA *prop; - - prop = RNA_def_boolean(ot->srna, "extend", false, "Extend", - "Extend selection instead of deselecting everything first"); - RNA_def_property_flag(prop, PROP_SKIP_SAVE); - prop = RNA_def_boolean(ot->srna, "deselect", false, "Deselect", "Remove from selection"); - RNA_def_property_flag(prop, PROP_SKIP_SAVE); - prop = RNA_def_boolean(ot->srna, "toggle", false, "Toggle Selection", "Toggle the selection"); - RNA_def_property_flag(prop, PROP_SKIP_SAVE); -} - -void WM_operator_properties_gesture_straightline(wmOperatorType *ot, int cursor) -{ - PropertyRNA *prop; - - prop = RNA_def_int(ot->srna, "xstart", 0, INT_MIN, INT_MAX, "X Start", "", INT_MIN, INT_MAX); - RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); - prop = RNA_def_int(ot->srna, "xend", 0, INT_MIN, INT_MAX, "X End", "", INT_MIN, INT_MAX); - RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); - prop = RNA_def_int(ot->srna, "ystart", 0, INT_MIN, INT_MAX, "Y Start", "", INT_MIN, INT_MAX); - RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); - prop = RNA_def_int(ot->srna, "yend", 0, INT_MIN, INT_MAX, "Y End", "", INT_MIN, INT_MAX); - RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); - - if (cursor) { - prop = RNA_def_int(ot->srna, "cursor", cursor, 0, INT_MAX, - "Cursor", "Mouse cursor style to use during the modal operator", 0, INT_MAX); - RNA_def_property_flag(prop, PROP_HIDDEN); - } -} - - /* op->poll */ int WM_operator_winactive(bContext *C) { -- cgit v1.2.3