Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <mail@jlucke.com>2019-05-02 13:00:12 +0300
committerJacques Lucke <mail@jlucke.com>2019-05-02 13:00:12 +0300
commit667af6cf411918ba181afc1a7d6bcb474f9fadb8 (patch)
treed9d8831caff733df9293db42d87fbc9733ba1415 /source/blender/editors/space_graph/graph_draw.c
parent5b14b5654231a50874fd9103d2adb306f62aec8d (diff)
Refactor grid and scale indicator text drawing
This affects the timeline, dopesheet, graph editor, sequencer, clip editor and nla editor. Removed structs and enums: `V2D_ARG_DUMMY`, `eView2D_Units`, `eView2D_Clamp`, `eView2D_Gridlines`, `View2DGrid`. A main goal of this refactor is to get rid of the very generic `View2DGrid` struct. The drawing code became very complex because there were many different combinations of settings. This refactor implements a different approach. Instead of one very generic API, there are many slighly different functions that do exactly, what we need in the different editors. Only very little code is duplicated, because the API functions compose some shared low level code. This structure makes the code much easier to debug and change, because every function has much fewer responsibilities. Additionally, this refactor fixes some long standing bugs. E.g. when `Show Seconds` is enabled, you zoom in and pan the view. Or that the step size between displayed frame numbers was always `>= 2`, no matter how close you zoom in. Reviewers: brecht Differential Revision: https://developer.blender.org/D4776
Diffstat (limited to 'source/blender/editors/space_graph/graph_draw.c')
-rw-r--r--source/blender/editors/space_graph/graph_draw.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c
index 5f118151a33..dfc59a79c49 100644
--- a/source/blender/editors/space_graph/graph_draw.c
+++ b/source/blender/editors/space_graph/graph_draw.c
@@ -493,20 +493,18 @@ static void draw_fcurve_samples(SpaceGraph *sipo, ARegion *ar, FCurve *fcu)
/* Helper func - just draw the F-Curve by sampling the visible region
* (for drawing curves with modifiers). */
static void draw_fcurve_curve(
- bAnimContext *ac, ID *id, FCurve *fcu_, View2D *v2d, View2DGrid *grid, unsigned int pos)
+ bAnimContext *ac, ID *id, FCurve *fcu_, View2D *v2d, unsigned int pos)
{
SpaceGraph *sipo = (SpaceGraph *)ac->sl;
float samplefreq;
float stime, etime;
float unitFac, offset;
- float dx, dy;
short mapping_flag = ANIM_get_normalization_flags(ac);
int i, n;
/* when opening a blend file on a different sized screen or while dragging the toolbar this can
* happen best just bail out in this case. */
- UI_view2d_grid_size(grid, &dx, &dy);
- if (dx <= 0.0f) {
+ if (UI_view2d_scale_get_x(v2d) <= 0.0f) {
return;
}
@@ -529,11 +527,11 @@ static void draw_fcurve_curve(
* loop (i.e. too close to 0), then clamp it to a determined "safe" value. The value
* chosen here is just the coarsest value which still looks reasonable...
*/
- /* grid->dx represents the number of 'frames' between gridlines,
- * but we divide by U.v2d_min_gridsize to get pixels-steps */
+
/* TODO: perhaps we should have 1.0 frames
* as upper limit so that curves don't get too distorted? */
- samplefreq = dx / (U.v2d_min_gridsize * U.pixelsize);
+ float pixels_per_sample = 1.5f;
+ samplefreq = pixels_per_sample / UI_view2d_scale_get_x(v2d);
if (sipo->flag & SIPO_BEAUTYDRAW_OFF) {
/* Low Precision = coarse lower-bound clamping
@@ -1043,8 +1041,7 @@ void graph_draw_ghost_curves(bAnimContext *ac, SpaceGraph *sipo, ARegion *ar)
/* This is called twice from space_graph.c -> graph_main_region_draw()
* Unselected then selected F-Curves are drawn so that they do not occlude each other.
*/
-void graph_draw_curves(
- bAnimContext *ac, SpaceGraph *sipo, ARegion *ar, View2DGrid *grid, short sel)
+void graph_draw_curves(bAnimContext *ac, SpaceGraph *sipo, ARegion *ar, short sel)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
@@ -1131,7 +1128,7 @@ void graph_draw_curves(
/* draw a curve affected by modifiers or only allowed to have integer values
* by sampling it at various small-intervals over the visible region
*/
- draw_fcurve_curve(ac, ale->id, fcu, &ar->v2d, grid, shdr_pos);
+ draw_fcurve_curve(ac, ale->id, fcu, &ar->v2d, shdr_pos);
}
else if (((fcu->bezt) || (fcu->fpt)) && (fcu->totvert)) {
/* just draw curve based on defined data (i.e. no modifiers) */
@@ -1140,7 +1137,7 @@ void graph_draw_curves(
draw_fcurve_curve_bezts(ac, ale->id, fcu, &ar->v2d, shdr_pos);
}
else {
- draw_fcurve_curve(ac, ale->id, fcu, &ar->v2d, grid, shdr_pos);
+ draw_fcurve_curve(ac, ale->id, fcu, &ar->v2d, shdr_pos);
}
}
else if (fcu->fpt) {