Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_handlers.c
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
| Show First 20 Lines • Show All 2,233 Lines • ▼ Show 20 Lines | static void ui_but_set_float_array( | ||||
| bContext *C, uiBut *but, uiHandleButtonData *data, float *values, int array_length) | bContext *C, uiBut *but, uiHandleButtonData *data, float *values, int array_length) | ||||
| { | { | ||||
| button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); | button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); | ||||
| for (int i = 0; i < array_length; i++) { | for (int i = 0; i < array_length; i++) { | ||||
| RNA_property_float_set_index(&but->rnapoin, but->rnaprop, i, values[i]); | RNA_property_float_set_index(&but->rnapoin, but->rnaprop, i, values[i]); | ||||
| } | } | ||||
| if (data) { | if (data) { | ||||
| if (but->type == UI_BTYPE_UNITVEC) { | |||||
| BLI_assert(array_length == 3); | |||||
| copy_v3_v3(data->vec, values); | |||||
| } | |||||
| else { | |||||
| data->value = values[but->rnaindex]; | data->value = values[but->rnaindex]; | ||||
| } | } | ||||
| } | |||||
| button_activate_state(C, but, BUTTON_STATE_EXIT); | button_activate_state(C, but, BUTTON_STATE_EXIT); | ||||
| } | } | ||||
| static void float_array_to_string(float *values, | static void float_array_to_string(float *values, | ||||
| int array_length, | int array_length, | ||||
| char *output, | char *output, | ||||
| int output_len_max) | int output_len_max) | ||||
| ▲ Show 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | if (ui_but_string_set_eval_num(C, but, buf_paste, &value)) { | ||||
| ui_but_string_set(C, but, buf_paste); | ui_but_string_set(C, but, buf_paste); | ||||
| button_activate_state(C, but, BUTTON_STATE_EXIT); | button_activate_state(C, but, BUTTON_STATE_EXIT); | ||||
| } | } | ||||
| else { | else { | ||||
| WM_report(RPT_ERROR, "Expected a number"); | WM_report(RPT_ERROR, "Expected a number"); | ||||
| } | } | ||||
| } | } | ||||
| static void ui_but_paste_normalized_vector(bContext *C, uiBut *but, char *buf_paste) | static void ui_but_paste_normalized_vector(bContext *C, | ||||
| uiBut *but, | |||||
| uiHandleButtonData *data, | |||||
| char *buf_paste) | |||||
| { | { | ||||
| float xyz[3]; | float xyz[3]; | ||||
| if (parse_float_array(buf_paste, xyz, 3)) { | if (parse_float_array(buf_paste, xyz, 3)) { | ||||
| if (normalize_v3(xyz) == 0.0f) { | if (normalize_v3(xyz) == 0.0f) { | ||||
| /* better set Z up then have a zero vector */ | /* better set Z up then have a zero vector */ | ||||
| xyz[2] = 1.0; | xyz[2] = 1.0; | ||||
| } | } | ||||
| ui_but_set_float_array(C, but, NULL, xyz, 3); | ui_but_set_float_array(C, but, data, xyz, 3); | ||||
| } | } | ||||
| else { | else { | ||||
| WM_report(RPT_ERROR, "Paste expected 3 numbers, formatted: '[n, n, n]'"); | WM_report(RPT_ERROR, "Paste expected 3 numbers, formatted: '[n, n, n]'"); | ||||
| } | } | ||||
| } | } | ||||
| static void ui_but_copy_color(uiBut *but, char *output, int output_len_max) | static void ui_but_copy_color(uiBut *but, char *output, int output_len_max) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 271 Lines • ▼ Show 20 Lines | case UI_BTYPE_NUM_SLIDER: | ||||
| ui_but_paste_numeric_value(C, but, data, buf_paste); | ui_but_paste_numeric_value(C, but, data, buf_paste); | ||||
| } | } | ||||
| break; | break; | ||||
| case UI_BTYPE_UNITVEC: | case UI_BTYPE_UNITVEC: | ||||
| if (!has_required_data) { | if (!has_required_data) { | ||||
| break; | break; | ||||
| } | } | ||||
| ui_but_paste_normalized_vector(C, but, buf_paste); | ui_but_paste_normalized_vector(C, but, data, buf_paste); | ||||
| break; | break; | ||||
| case UI_BTYPE_COLOR: | case UI_BTYPE_COLOR: | ||||
| if (!has_required_data) { | if (!has_required_data) { | ||||
| break; | break; | ||||
| } | } | ||||
| ui_but_paste_color(C, but, buf_paste); | ui_but_paste_color(C, but, buf_paste); | ||||
| break; | break; | ||||
| ▲ Show 20 Lines • Show All 8,310 Lines • Show Last 20 Lines | |||||