Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_handlers.cc
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
| Show First 20 Lines • Show All 4,746 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| static int ui_do_but_VIEW_ITEM(bContext *C, | static int ui_do_but_VIEW_ITEM(bContext *C, | ||||
| uiBut *but, | uiBut *but, | ||||
| uiHandleButtonData *data, | uiHandleButtonData *data, | ||||
| const wmEvent *event) | const wmEvent *event) | ||||
| { | { | ||||
| uiButViewItem *view_item_but = (uiButViewItem *)but; | uiButViewItem *view_item_but = (uiButViewItem *)but; | ||||
| BLI_assert(view_item_but->but.type == UI_BTYPE_VIEW_ITEM); | BLI_assert(view_item_but->type == UI_BTYPE_VIEW_ITEM); | ||||
| if (data->state == BUTTON_STATE_HIGHLIGHT) { | if (data->state == BUTTON_STATE_HIGHLIGHT) { | ||||
| if (event->type == LEFTMOUSE) { | if (event->type == LEFTMOUSE) { | ||||
| switch (event->val) { | switch (event->val) { | ||||
| case KM_PRESS: | case KM_PRESS: | ||||
| /* Extra icons have priority, don't mess with them. */ | /* Extra icons have priority, don't mess with them. */ | ||||
| if (ui_but_extra_operator_icon_mouse_over_get(but, data->region, event)) { | if (ui_but_extra_operator_icon_mouse_over_get(but, data->region, event)) { | ||||
| return WM_UI_HANDLER_BREAK; | return WM_UI_HANDLER_BREAK; | ||||
| ▲ Show 20 Lines • Show All 192 Lines • ▼ Show 20 Lines | switch (snap) { | ||||
| case SNAP_ON_SMALL: | case SNAP_ON_SMALL: | ||||
| temp = 100 * (temp / 100); | temp = 100 * (temp / 100); | ||||
| break; | break; | ||||
| } | } | ||||
| return temp; | return temp; | ||||
| } | } | ||||
| static bool ui_numedit_but_NUM(uiButNumber *number_but, | static bool ui_numedit_but_NUM(uiButNumber *but, | ||||
| uiHandleButtonData *data, | uiHandleButtonData *data, | ||||
| int mx, | int mx, | ||||
| const bool is_motion, | const bool is_motion, | ||||
| const enum eSnapType snap, | const enum eSnapType snap, | ||||
| float fac) | float fac) | ||||
| { | { | ||||
| uiBut *but = &number_but->but; | |||||
| float deler, tempf; | float deler, tempf; | ||||
| int lvalue, temp; | int lvalue, temp; | ||||
| bool changed = false; | bool changed = false; | ||||
| const bool is_float = ui_but_is_float(but); | const bool is_float = ui_but_is_float(but); | ||||
| const PropertyScaleType scale_type = ui_but_scale_type(but); | const PropertyScaleType scale_type = ui_but_scale_type(but); | ||||
| /* prevent unwanted drag adjustments, test motion so modifier keys refresh. */ | /* prevent unwanted drag adjustments, test motion so modifier keys refresh. */ | ||||
| if ((is_motion || data->draglock) && (ui_but_dragedit_update_mval(data, mx) == false)) { | if ((is_motion || data->draglock) && (ui_but_dragedit_update_mval(data, mx) == false)) { | ||||
| return changed; | return changed; | ||||
| } | } | ||||
| ui_block_interaction_begin_ensure( | ui_block_interaction_begin_ensure( | ||||
| static_cast<bContext *>(but->block->evil_C), but->block, data, false); | static_cast<bContext *>(but->block->evil_C), but->block, data, false); | ||||
| if (ui_but_is_cursor_warp(but)) { | if (ui_but_is_cursor_warp(but)) { | ||||
| const float softmin = but->softmin; | const float softmin = but->softmin; | ||||
| const float softmax = but->softmax; | const float softmax = but->softmax; | ||||
| const float softrange = softmax - softmin; | const float softrange = softmax - softmin; | ||||
| const float log_min = (scale_type == PROP_SCALE_LOG) ? | const float log_min = (scale_type == PROP_SCALE_LOG) ? | ||||
| max_ff(max_ff(softmin, UI_PROP_SCALE_LOG_MIN), | max_ff(max_ff(softmin, UI_PROP_SCALE_LOG_MIN), | ||||
| powf(10, -number_but->precision) * 0.5f) : | powf(10, -but->precision) * 0.5f) : | ||||
| 0; | 0; | ||||
| /* Mouse location isn't screen clamped to the screen so use a linear mapping | /* Mouse location isn't screen clamped to the screen so use a linear mapping | ||||
| * 2px == 1-int, or 1px == 1-ClickStep */ | * 2px == 1-int, or 1px == 1-ClickStep */ | ||||
| if (is_float) { | if (is_float) { | ||||
| fac *= 0.01f * number_but->step_size; | fac *= 0.01f * but->step_size; | ||||
| switch (scale_type) { | switch (scale_type) { | ||||
| case PROP_SCALE_LINEAR: { | case PROP_SCALE_LINEAR: { | ||||
| tempf = float(data->startvalue) + float(mx - data->dragstartx) * fac; | tempf = float(data->startvalue) + float(mx - data->dragstartx) * fac; | ||||
| break; | break; | ||||
| } | } | ||||
| case PROP_SCALE_LOG: { | case PROP_SCALE_LOG: { | ||||
| const float startvalue = max_ff(float(data->startvalue), log_min); | const float startvalue = max_ff(float(data->startvalue), log_min); | ||||
| tempf = expf(float(mx - data->dragstartx) * fac) * startvalue; | tempf = expf(float(mx - data->dragstartx) * fac) * startvalue; | ||||
| ▲ Show 20 Lines • Show All 157 Lines • ▼ Show 20 Lines | else { | ||||
| switch (scale_type) { | switch (scale_type) { | ||||
| case PROP_SCALE_LINEAR: { | case PROP_SCALE_LINEAR: { | ||||
| tempf = (softmin + data->dragf * softrange); | tempf = (softmin + data->dragf * softrange); | ||||
| break; | break; | ||||
| } | } | ||||
| case PROP_SCALE_LOG: { | case PROP_SCALE_LOG: { | ||||
| const float log_min = max_ff(max_ff(softmin, UI_PROP_SCALE_LOG_MIN), | const float log_min = max_ff(max_ff(softmin, UI_PROP_SCALE_LOG_MIN), | ||||
| powf(10.0f, -number_but->precision) * 0.5f); | powf(10.0f, -but->precision) * 0.5f); | ||||
| const float base = softmax / log_min; | const float base = softmax / log_min; | ||||
| tempf = powf(base, data->dragf) * log_min; | tempf = powf(base, data->dragf) * log_min; | ||||
| if (tempf <= log_min) { | if (tempf <= log_min) { | ||||
| tempf = 0.0f; | tempf = 0.0f; | ||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| case PROP_SCALE_CUBIC: { | case PROP_SCALE_CUBIC: { | ||||
| ▲ Show 20 Lines • Show All 961 Lines • ▼ Show 20 Lines | static bool ui_numedit_but_UNITVEC( | ||||
| data->draglasty = my; | data->draglasty = my; | ||||
| return changed; | return changed; | ||||
| } | } | ||||
| static void ui_palette_set_active(uiButColor *color_but) | static void ui_palette_set_active(uiButColor *color_but) | ||||
| { | { | ||||
| if (color_but->is_pallete_color) { | if (color_but->is_pallete_color) { | ||||
| Palette *palette = (Palette *)color_but->but.rnapoin.owner_id; | Palette *palette = (Palette *)color_but->rnapoin.owner_id; | ||||
| PaletteColor *color = static_cast<PaletteColor *>(color_but->but.rnapoin.data); | PaletteColor *color = static_cast<PaletteColor *>(color_but->rnapoin.data); | ||||
| palette->active_color = BLI_findindex(&palette->colors, color); | palette->active_color = BLI_findindex(&palette->colors, color); | ||||
| } | } | ||||
| } | } | ||||
| static int ui_do_but_COLOR(bContext *C, uiBut *but, uiHandleButtonData *data, const wmEvent *event) | static int ui_do_but_COLOR(bContext *C, uiBut *but, uiHandleButtonData *data, const wmEvent *event) | ||||
| { | { | ||||
| BLI_assert(but->type == UI_BTYPE_COLOR); | BLI_assert(but->type == UI_BTYPE_COLOR); | ||||
| uiButColor *color_but = (uiButColor *)but; | uiButColor *color_but = (uiButColor *)but; | ||||
| ▲ Show 20 Lines • Show All 5,664 Lines • Show Last 20 Lines | |||||