Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/view2d.c
| Show First 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | |||||
| #include "GPU_matrix.h" | #include "GPU_matrix.h" | ||||
| #include "GPU_state.h" | #include "GPU_state.h" | ||||
| #include "WM_api.h" | #include "WM_api.h" | ||||
| #include "BLF_api.h" | #include "BLF_api.h" | ||||
| #include "ED_screen.h" | #include "ED_screen.h" | ||||
| #include "ED_node.h" | |||||
| #include "UI_interface.h" | #include "UI_interface.h" | ||||
| #include "UI_view2d.h" | #include "UI_view2d.h" | ||||
| #include "interface_intern.h" | #include "interface_intern.h" | ||||
| static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize); | static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize); | ||||
| ▲ Show 20 Lines • Show All 1,253 Lines • ▼ Show 20 Lines | typedef struct DotGridLevelInfo { | ||||
| * At lower zoom levels, the points will not be visible and the level will be skipped. */ | * At lower zoom levels, the points will not be visible and the level will be skipped. */ | ||||
| float fade_in_start_zoom; | float fade_in_start_zoom; | ||||
| /* The normalized zoom level at which the grid finishes fading in. | /* The normalized zoom level at which the grid finishes fading in. | ||||
| * At higher zoom levels, the points will be opaque. */ | * At higher zoom levels, the points will be opaque. */ | ||||
| float fade_in_end_zoom; | float fade_in_end_zoom; | ||||
| } DotGridLevelInfo; | } DotGridLevelInfo; | ||||
| static const DotGridLevelInfo level_info[9] = { | static const DotGridLevelInfo level_info[9] = { | ||||
| {128.0f, -0.1f, 0.01f}, | {6.4f, -0.1f, 0.01f}, | ||||
| {64.0f, 0.0f, 0.025f}, | {3.2f, 0.0f, 0.025f}, | ||||
| {32.0f, 0.025f, 0.15f}, | {1.6f, 0.025f, 0.15f}, | ||||
| {16.0f, 0.05f, 0.2f}, | {0.8f, 0.05f, 0.2f}, | ||||
| {8.0f, 0.1f, 0.25f}, | {0.4f, 0.1f, 0.25f}, | ||||
| {4.0f, 0.125f, 0.3f}, | {0.2f, 0.125f, 0.3f}, | ||||
| {2.0f, 0.25f, 0.5f}, | {0.1f, 0.25f, 0.5f}, | ||||
| {1.0f, 0.7f, 0.9f}, | {0.05f, 0.7f, 0.9f}, | ||||
| {0.5f, 0.6f, 0.9f}, | {0.025f, 0.6f, 0.9f}, | ||||
| }; | }; | ||||
| /** | /** | ||||
| * Draw a multi-level grid of dots, with a dynamic number of levels based on the fading. | * Draw a multi-level grid of dots, with a dynamic number of levels based on the fading. | ||||
| * | * | ||||
| * \param grid_color_id: The theme color used for the points. Faded dynamically based on zoom. | * \param grid_color_id: The theme color used for the points. Faded dynamically based on zoom. | ||||
| * \param min_step: The base size of the grid. At different zoom levels, the visible grid may have | * \param min_step: The base size of the grid. At different zoom levels, the visible grid may have | ||||
| * a larger step size. | * a larger step size. | ||||
| Show All 14 Lines | void UI_view2d_dot_grid_draw(const View2D *v2d, | ||||
| immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); | immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); | ||||
| GPU_point_size(3.0f * UI_DPI_FAC); | GPU_point_size(3.0f * UI_DPI_FAC); | ||||
| float color[4]; | float color[4]; | ||||
| UI_GetThemeColor3fv(grid_color_id, color); | UI_GetThemeColor3fv(grid_color_id, color); | ||||
| for (int level = 0; level < grid_levels; level++) { | for (int level = 0; level < grid_levels; level++) { | ||||
| const DotGridLevelInfo *info = &level_info[level]; | const DotGridLevelInfo *info = &level_info[level]; | ||||
| const float step = min_step * info->step_factor; | const float step = min_step * info->step_factor * ED_node_grid_size(); | ||||
HooglyBoogly: It's not quite right to call something specific to the node editor here, since this is supposed… | |||||
| const float alpha_factor = (zoom_normalized - info->fade_in_start_zoom) / | const float alpha_factor = (zoom_normalized - info->fade_in_start_zoom) / | ||||
| (info->fade_in_end_zoom - info->fade_in_start_zoom); | (info->fade_in_end_zoom - info->fade_in_start_zoom); | ||||
| color[3] = clamp_f(BLI_easing_cubic_ease_in_out(alpha_factor, 0.0f, 1.0f, 1.0f), 0.0f, 1.0f); | color[3] = clamp_f(BLI_easing_cubic_ease_in_out(alpha_factor, 0.0f, 1.0f, 1.0f), 0.0f, 1.0f); | ||||
| if (color[3] == 0.0f) { | if (color[3] == 0.0f) { | ||||
| break; | break; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 864 Lines • Show Last 20 Lines | |||||
It's not quite right to call something specific to the node editor here, since this is supposed to be more general. U.widget_unit directly would be simpler.