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:
Diffstat (limited to 'source/blender/editors/space_graph')
-rw-r--r--source/blender/editors/space_graph/graph_draw.c19
-rw-r--r--source/blender/editors/space_graph/graph_intern.h2
-rw-r--r--source/blender/editors/space_graph/space_graph.c27
3 files changed, 16 insertions, 32 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) {
diff --git a/source/blender/editors/space_graph/graph_intern.h b/source/blender/editors/space_graph/graph_intern.h
index 606f4bc3fe3..6ec8e54dce9 100644
--- a/source/blender/editors/space_graph/graph_intern.h
+++ b/source/blender/editors/space_graph/graph_intern.h
@@ -28,7 +28,6 @@ struct ARegion;
struct ARegionType;
struct ScrArea;
struct SpaceGraph;
-struct View2DGrid;
struct bAnimContext;
struct bAnimListElem;
struct bContext;
@@ -42,7 +41,6 @@ void graph_draw_channel_names(struct bContext *C, struct bAnimContext *ac, struc
void graph_draw_curves(struct bAnimContext *ac,
struct SpaceGraph *sipo,
struct ARegion *ar,
- struct View2DGrid *grid,
short sel);
void graph_draw_ghost_curves(struct bAnimContext *ac, struct SpaceGraph *sipo, struct ARegion *ar);
diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c
index d8e1b9d2035..86d0b961a31 100644
--- a/source/blender/editors/space_graph/space_graph.c
+++ b/source/blender/editors/space_graph/space_graph.c
@@ -198,10 +198,9 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar)
Scene *scene = CTX_data_scene(C);
bAnimContext ac;
View2D *v2d = &ar->v2d;
- View2DGrid *grid;
View2DScrollers *scrollers;
float col[3];
- short unitx = 0, unity = V2D_UNIT_VALUES, cfra_flag = 0;
+ short cfra_flag = 0;
/* clear and setup matrix */
UI_GetThemeColor3fv(TH_BACK, col);
@@ -211,18 +210,9 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar)
UI_view2d_view_ortho(v2d);
/* grid */
- unitx = ((sipo->mode == SIPO_MODE_ANIMATION) && (sipo->flag & SIPO_DRAWTIME)) ?
- V2D_UNIT_SECONDS :
- V2D_UNIT_FRAMESCALE;
- grid = UI_view2d_grid_calc(CTX_data_scene(C),
- v2d,
- unitx,
- V2D_GRID_NOCLAMP,
- unity,
- V2D_GRID_NOCLAMP,
- ar->winx,
- ar->winy);
- UI_view2d_grid_draw(v2d, grid, V2D_GRIDLINES_ALL);
+ bool display_seconds = (sipo->mode == SIPO_MODE_ANIMATION) && (sipo->flag & SIPO_DRAWTIME);
+ UI_view2d_draw_lines_x__frames_or_seconds(v2d, scene, display_seconds);
+ UI_view2d_draw_lines_y__values(v2d);
ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW);
@@ -237,8 +227,8 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar)
graph_draw_ghost_curves(&ac, sipo, ar);
/* draw curves twice - unselected, then selected, so that the are fewer occlusion problems */
- graph_draw_curves(&ac, sipo, ar, grid, 0);
- graph_draw_curves(&ac, sipo, ar, grid, 1);
+ graph_draw_curves(&ac, sipo, ar, 0);
+ graph_draw_curves(&ac, sipo, ar, 1);
/* XXX the slow way to set tot rect... but for nice sliders needed (ton) */
get_graph_keyframe_extents(
@@ -326,9 +316,8 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar)
UI_view2d_scrollers_free(scrollers);
/* scale numbers */
- UI_view2d_grid_draw_numbers_horizontal(scene, v2d, grid, &v2d->hor, unitx, false);
- UI_view2d_grid_draw_numbers_vertical(scene, v2d, grid, &v2d->vert, unity, 0.0f);
- UI_view2d_grid_free(grid);
+ UI_view2d_draw_scale_x__frames_or_seconds(ar, v2d, &v2d->hor, scene, display_seconds);
+ UI_view2d_draw_scale_y__values(ar, v2d, &v2d->vert);
/* draw current frame number-indicator on top of scrollers */
if ((sipo->mode != SIPO_MODE_DRIVERS) && ((sipo->flag & SIPO_NODRAWCFRANUM) == 0)) {