Changeset View
Changeset View
Standalone View
Standalone View
source/blender/windowmanager/intern/wm_operator_props.c
| Show First 20 Lines • Show All 134 Lines • ▼ Show 20 Lines | void WM_operator_properties_filesel( | ||||
| RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); | 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", ""); | 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); | RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); | ||||
| } | } | ||||
| static void wm_operator_properties_select_action_ex(wmOperatorType *ot, int default_action, | static void wm_operator_properties_select_action_ex(wmOperatorType *ot, int default_action, | ||||
| const EnumPropertyItem *select_actions) | const EnumPropertyItem *select_actions, | ||||
| bool hide_gui) | |||||
| { | { | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| prop = RNA_def_enum(ot->srna, "action", select_actions, default_action, "Action", "Selection action to execute"); | prop = RNA_def_enum(ot->srna, "action", select_actions, default_action, "Action", "Selection action to execute"); | ||||
| if (hide_gui) { | |||||
| RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); | RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); | ||||
| } | } | ||||
| } | |||||
| void WM_operator_properties_select_action(wmOperatorType *ot, int default_action) | void WM_operator_properties_select_action(wmOperatorType *ot, int default_action, bool hide_gui) | ||||
| { | { | ||||
| static const EnumPropertyItem select_actions[] = { | static const EnumPropertyItem select_actions[] = { | ||||
| {SEL_TOGGLE, "TOGGLE", 0, "Toggle", "Toggle selection for all elements"}, | {SEL_TOGGLE, "TOGGLE", 0, "Toggle", "Toggle selection for all elements"}, | ||||
| {SEL_SELECT, "SELECT", 0, "Select", "Select all elements"}, | {SEL_SELECT, "SELECT", 0, "Select", "Select all elements"}, | ||||
| {SEL_DESELECT, "DESELECT", 0, "Deselect", "Deselect all elements"}, | {SEL_DESELECT, "DESELECT", 0, "Deselect", "Deselect all elements"}, | ||||
| {SEL_INVERT, "INVERT", 0, "Invert", "Invert selection of all elements"}, | {SEL_INVERT, "INVERT", 0, "Invert", "Invert selection of all elements"}, | ||||
| {0, NULL, 0, NULL, NULL}, | {0, NULL, 0, NULL, NULL}, | ||||
| }; | }; | ||||
| wm_operator_properties_select_action_ex(ot, default_action, select_actions); | wm_operator_properties_select_action_ex(ot, default_action, select_actions, hide_gui); | ||||
| } | } | ||||
| /** | /** | ||||
| * only SELECT/DESELECT | * only SELECT/DESELECT | ||||
| */ | */ | ||||
| void WM_operator_properties_select_action_simple(wmOperatorType *ot, int default_action) | void WM_operator_properties_select_action_simple(wmOperatorType *ot, int default_action, bool hide_gui) | ||||
| { | { | ||||
| static const EnumPropertyItem select_actions[] = { | static const EnumPropertyItem select_actions[] = { | ||||
| {SEL_SELECT, "SELECT", 0, "Select", "Select all elements"}, | {SEL_SELECT, "SELECT", 0, "Select", "Select all elements"}, | ||||
| {SEL_DESELECT, "DESELECT", 0, "Deselect", "Deselect all elements"}, | {SEL_DESELECT, "DESELECT", 0, "Deselect", "Deselect all elements"}, | ||||
| {0, NULL, 0, NULL, NULL}, | {0, NULL, 0, NULL, NULL}, | ||||
| }; | }; | ||||
| wm_operator_properties_select_action_ex(ot, default_action, select_actions); | wm_operator_properties_select_action_ex(ot, default_action, select_actions, hide_gui); | ||||
| } | } | ||||
| /** | /** | ||||
| * Use for all select random operators. | * Use for all select random operators. | ||||
| * Adds properties: percent, seed, action. | * Adds properties: percent, seed, action. | ||||
| */ | */ | ||||
| void WM_operator_properties_select_random(wmOperatorType *ot) | void WM_operator_properties_select_random(wmOperatorType *ot) | ||||
| { | { | ||||
| RNA_def_float_percentage( | RNA_def_float_percentage( | ||||
| ot->srna, "percent", 50.f, 0.0f, 100.0f, | ot->srna, "percent", 50.f, 0.0f, 100.0f, | ||||
| "Percent", "Percentage of objects to select randomly", 0.f, 100.0f); | "Percent", "Percentage of objects to select randomly", 0.f, 100.0f); | ||||
| RNA_def_int( | RNA_def_int( | ||||
| ot->srna, "seed", 0, 0, INT_MAX, | ot->srna, "seed", 0, 0, INT_MAX, | ||||
| "Random Seed", "Seed for the random number generator", 0, 255); | "Random Seed", "Seed for the random number generator", 0, 255); | ||||
| WM_operator_properties_select_action_simple(ot, SEL_SELECT); | WM_operator_properties_select_action_simple(ot, SEL_SELECT, false); | ||||
| } | } | ||||
| int WM_operator_properties_select_random_seed_increment_get(wmOperator *op) | int WM_operator_properties_select_random_seed_increment_get(wmOperator *op) | ||||
| { | { | ||||
| PropertyRNA *prop = RNA_struct_find_property(op->ptr, "seed"); | PropertyRNA *prop = RNA_struct_find_property(op->ptr, "seed"); | ||||
| int value = RNA_property_int_get(op->ptr, prop); | int value = RNA_property_int_get(op->ptr, prop); | ||||
| if (op->flag & OP_IS_INVOKE) { | if (op->flag & OP_IS_INVOKE) { | ||||
| if (!RNA_property_is_set(op->ptr, prop)) { | if (!RNA_property_is_set(op->ptr, prop)) { | ||||
| value += 1; | value += 1; | ||||
| RNA_property_int_set(op->ptr, prop, value); | RNA_property_int_set(op->ptr, prop, value); | ||||
| } | } | ||||
| } | } | ||||
| return value; | return value; | ||||
| } | } | ||||
| void WM_operator_properties_select_all(wmOperatorType *ot) | void WM_operator_properties_select_all(wmOperatorType *ot) | ||||
| { | { | ||||
| WM_operator_properties_select_action(ot, SEL_TOGGLE); | WM_operator_properties_select_action(ot, SEL_TOGGLE, true); | ||||
| } | } | ||||
| void WM_operator_properties_border(wmOperatorType *ot) | void WM_operator_properties_border(wmOperatorType *ot) | ||||
| { | { | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| prop = RNA_def_int(ot->srna, "xmin", 0, INT_MIN, INT_MAX, "X Min", "", INT_MIN, INT_MAX); | 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); | RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); | ||||
| ▲ Show 20 Lines • Show All 184 Lines • Show Last 20 Lines | |||||