[Bf-blender-cvs] [064eba208ee] blender2.8: revert recent cleanup, keep useful changes
Mike Erwin
noreply at git.blender.org
Wed Apr 5 01:38:59 CEST 2017
Commit: 064eba208ee26ffa0748e308576d65fddad34b0d
Author: Mike Erwin
Date: Tue Apr 4 19:36:07 2017 -0400
Branches: blender2.8
https://developer.blender.org/rB064eba208ee26ffa0748e308576d65fddad34b0d
revert recent cleanup, keep useful changes
Don't want to annoy module owner.
What is kept:
- UI_view2d_scale_get with unused y scale
- corrected comment
- unsigned --> unsigned int
===================================================================
M source/blender/editors/animation/anim_draw.c
M source/blender/editors/animation/anim_markers.c
M source/blender/editors/space_clip/clip_utils.c
M source/blender/editors/space_graph/graph_draw.c
===================================================================
diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c
index f448a281cfc..caa4a6e31f3 100644
--- a/source/blender/editors/animation/anim_draw.c
+++ b/source/blender/editors/animation/anim_draw.c
@@ -71,10 +71,15 @@
/* Draw current frame number in a little green box beside the current frame indicator */
static void draw_cfra_number(Scene *scene, View2D *v2d, const float cfra, const bool time)
{
+ const uiFontStyle *fstyle = UI_FSTYLE_WIDGET;
+ VertexFormat *format = immVertexFormat();
+ unsigned int pos = add_attrib(format, "pos", GL_FLOAT, 2, KEEP_FLOAT);
+ unsigned char col[4];
+ float xscale, x, y;
char numstr[32] = " t"; /* t is the character to start replacing from */
+ int slen;
/* because the frame number text is subject to the same scaling as the contents of the view */
- float xscale;
UI_view2d_scale_get(v2d, &xscale, NULL);
gpuPushMatrix();
gpuScale2f(1.0f / xscale, 1.0f);
@@ -91,15 +96,11 @@ static void draw_cfra_number(Scene *scene, View2D *v2d, const float cfra, const
BLI_timecode_string_from_time_seconds(&numstr[4], sizeof(numstr) - 4, 1, cfra);
}
- const uiFontStyle *fstyle = UI_FSTYLE_WIDGET;
- int slen = UI_fontstyle_string_width(fstyle, numstr) - 1;
+ slen = UI_fontstyle_string_width(fstyle, numstr) - 1;
/* get starting coordinates for drawing */
- float x = cfra * xscale;
- float y = 0.9f * U.widget_unit;
-
- VertexFormat *format = immVertexFormat();
- unsigned int pos = add_attrib(format, "pos", GL_FLOAT, 2, KEEP_FLOAT);
+ x = cfra * xscale;
+ y = 0.9f * U.widget_unit;
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -110,7 +111,6 @@ static void draw_cfra_number(Scene *scene, View2D *v2d, const float cfra, const
immUnbindProgram();
/* draw current frame number */
- unsigned char col[4];
UI_GetThemeColor4ubv(TH_TEXT, col);
UI_fontstyle_draw_simple(fstyle, x - 0.25f * U.widget_unit, y + 0.15f * U.widget_unit, numstr, col);
diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c
index 9b8dd47e4aa..9d7d1535eb3 100644
--- a/source/blender/editors/animation/anim_markers.c
+++ b/source/blender/editors/animation/anim_markers.c
@@ -131,7 +131,8 @@ ListBase *ED_animcontext_get_markers(const bAnimContext *ac)
*/
int ED_markers_post_apply_transform(ListBase *markers, Scene *scene, int mode, float value, char side)
{
- const float cfra = (float)CFRA;
+ TimeMarker *marker;
+ float cfra = (float)CFRA;
int changed_tot = 0;
/* sanity check */
@@ -139,7 +140,7 @@ int ED_markers_post_apply_transform(ListBase *markers, Scene *scene, int mode, f
return changed_tot;
/* affect selected markers - it's unlikely that we will want to affect all in this way? */
- for (TimeMarker *marker = markers->first; marker; marker = marker->next) {
+ for (marker = markers->first; marker; marker = marker->next) {
if (marker->flag & SELECT) {
switch (mode) {
case TFM_TIME_TRANSLATE:
@@ -234,12 +235,13 @@ void ED_markers_get_minmax(ListBase *markers, short sel, float *first, float *la
/* Adds a marker to list of cfra elems */
static void add_marker_to_cfra_elem(ListBase *lb, TimeMarker *marker, short only_sel)
{
+ CfraElem *ce, *cen;
+
/* should this one only be considered if it is selected? */
if ((only_sel) && ((marker->flag & SELECT) == 0))
return;
/* insertion sort - try to find a previous cfra elem */
- CfraElem *ce;
for (ce = lb->first; ce; ce = ce->next) {
if (ce->cfra == marker->frame) {
/* do because of double keys */
@@ -252,7 +254,7 @@ static void add_marker_to_cfra_elem(ListBase *lb, TimeMarker *marker, short only
}
}
- CfraElem *cen = MEM_callocN(sizeof(CfraElem), "add_to_cfra_elem");
+ cen = MEM_callocN(sizeof(CfraElem), "add_to_cfra_elem");
if (ce) BLI_insertlinkbefore(lb, ce, cen);
else BLI_addtail(lb, cen);
@@ -266,6 +268,8 @@ static void add_marker_to_cfra_elem(ListBase *lb, TimeMarker *marker, short only
*/
void ED_markers_make_cfra_list(ListBase *markers, ListBase *lb, short only_sel)
{
+ TimeMarker *marker;
+
if (lb) {
/* Clear the list first, since callers have no way of knowing
* whether this terminated early otherwise. This may lead
@@ -281,7 +285,7 @@ void ED_markers_make_cfra_list(ListBase *markers, ListBase *lb, short only_sel)
return;
}
- for (TimeMarker *marker = markers->first; marker; marker = marker->next)
+ for (marker = markers->first; marker; marker = marker->next)
add_marker_to_cfra_elem(lb, marker, only_sel);
}
@@ -290,8 +294,10 @@ void ED_markers_make_cfra_list(ListBase *markers, ListBase *lb, short only_sel)
/* Get the first selected marker */
TimeMarker *ED_markers_get_first_selected(ListBase *markers)
{
+ TimeMarker *marker;
+
if (markers) {
- for (TimeMarker *marker = markers->first; marker; marker = marker->next) {
+ for (marker = markers->first; marker; marker = marker->next) {
if (marker->flag & SELECT)
return marker;
}
@@ -307,6 +313,8 @@ TimeMarker *ED_markers_get_first_selected(ListBase *markers)
*/
void debug_markers_print_list(ListBase *markers)
{
+ TimeMarker *marker;
+
if (markers == NULL) {
printf("No markers list to print debug for\n");
return;
@@ -314,7 +322,7 @@ void debug_markers_print_list(ListBase *markers)
printf("List of markers follows: -----\n");
- for (TimeMarker *marker = markers->first; marker; marker = marker->next) {
+ for (marker = markers->first; marker; marker = marker->next) {
printf("\t'%s' on %d at %p with %u\n", marker->name, marker->frame, (void *)marker, marker->flag);
}
@@ -383,7 +391,7 @@ static void draw_marker(
float x, y;
/* minimal y coordinate which wouldn't be occluded by scroll */
- const int min_y = 17.0f * UI_DPI_FAC;
+ int min_y = 17.0f * UI_DPI_FAC;
if (marker->flag & SELECT) {
UI_GetThemeColor4ubv(TH_TEXT_HI, text_col);
@@ -419,14 +427,22 @@ void ED_markers_draw(const bContext *C, int flag)
{
const uiFontStyle *fstyle = UI_FSTYLE_WIDGET;
ListBase *markers = ED_context_get_markers(C);
+ View2D *v2d;
TimeMarker *marker;
+ Scene *scene;
+ int select_pass;
+ int v2d_clip_range_x[2];
+ float font_width_max;
+
+ /* cache values */
+ float ypixels, xscale, yscale;
if (markers == NULL || BLI_listbase_is_empty(markers)) {
return;
}
- Scene *scene = CTX_data_scene(C);
- View2D *v2d = UI_view2d_fromcontext(C);
+ scene = CTX_data_scene(C);
+ v2d = UI_view2d_fromcontext(C);
if (flag & DRAW_MARKERS_MARGIN) {
unsigned int pos = add_attrib(immVertexFormat(), "pos", GL_FLOAT, 2, KEEP_FLOAT);
@@ -446,21 +462,18 @@ void ED_markers_draw(const bContext *C, int flag)
}
/* no time correction for framelen! space is drawn with old values */
- float ypixels = BLI_rcti_size_y(&v2d->mask);
- float xscale, yscale;
+ ypixels = BLI_rcti_size_y(&v2d->mask);
UI_view2d_scale_get(v2d, &xscale, &yscale);
gpuPushMatrix();
gpuScale2f(1.0f / xscale, 1.0f);
/* x-bounds with offset for text (adjust for long string, avoid checking string width) */
- float font_width_max = (10 * UI_DPI_FAC) / xscale;
- int v2d_clip_range_x[2] = {
- v2d->cur.xmin - (sizeof(marker->name) * font_width_max),
- v2d->cur.xmax + font_width_max
- };
+ font_width_max = (10 * UI_DPI_FAC) / xscale;
+ v2d_clip_range_x[0] = v2d->cur.xmin - (sizeof(marker->name) * font_width_max);
+ v2d_clip_range_x[1] = v2d->cur.xmax + font_width_max;
/* loop [unselected, selected] */
- for (int select_pass = 0; select_pass <= SELECT; select_pass += SELECT) {
+ for (select_pass = 0; select_pass <= SELECT; select_pass += SELECT) {
/* unselected markers are drawn at the first time */
for (marker = markers->first; marker; marker = marker->next) {
if ((marker->flag & SELECT) == select_pass) {
@@ -821,9 +834,9 @@ static void ed_marker_move_apply(bContext *C, wmOperator *op)
#endif
MarkerMove *mm = op->customdata;
TimeMarker *marker;
-
- const int offs = RNA_int_get(op->ptr, "frames");
- int a;
+ int a, offs;
+
+ offs = RNA_int_get(op->ptr, "frames");
for (a = 0, marker = mm->markers->first; marker; marker = marker->next) {
if (marker->flag & SELECT) {
marker->frame = mm->oldframe[a] + offs;
@@ -994,20 +1007,21 @@ static void MARKER_OT_move(wmOperatorType *ot)
static void ed_marker_duplicate_apply(bContext *C)
{
ListBase *markers = ED_context_get_markers(C);
-
- if (markers == NULL)
+ TimeMarker *marker, *newmarker;
+
+ if (markers == NULL)
return;
/* go through the list of markers, duplicate selected markers and add duplicated copies
* to the beginning of the list (unselect original markers)
*/
- for (TimeMarker *marker = markers->first; marker; marker = marker->next) {
+ for (marker = markers->first; marker; marker = marker->next) {
if (marker->flag & SELECT) {
/* unselect selected marker */
marker->flag &= ~SELECT;
/* create and set up new marker */
- TimeMarker *newmarker = MEM_callocN(sizeof(TimeMarker), "TimeMarker");
+ newmarker = MEM_callocN(sizeof(TimeMarker), "TimeMarker");
newmarker->flag = SELECT;
newmarker->frame = marker->frame;
BLI_strncpy(newmarker->name, marker->name, sizeof(marker->name));
@@ -1103,20 +1117,25 @@ static int ed_marker_select(bContext *C, const wmEvent *event, bool extend, bool
ListBase *markers = ED_context_get_markers(C);
ARegion *ar = CTX_wm_region(C);
View2D *v2d = UI_view2d_fromcontext(C);
+ float viewx;
+ int x, cfra;
if (markers == NULL)
return OPERATOR_PASS_THROUGH;
- const int x = event->x - ar->winrct.xmin;
- const float viewx = UI_view2d_region_to_view_x(v2d, x);
- const int cfra = ED_markers_find_nearest_marker_time(markers, viewx);
-
+ x = event->x - ar->winrct.xmin;
+
+ viewx = UI_view2d_region_to_view_x(v2d, x);
+
+ cfra = ED_markers_find_nearest_marker_time(markers, viewx);
+
select_timeline_marker_frame(markers, cfra, extend);
#ifdef DURIAN_CAMERA_SWITCH
if (camera) {
Scene *scene = CTX_data_scene(C);
+ BaseLegacy *base;
TimeMarker *marker;
int sel = 0;
@@ -1133,7 +1152,7 @@ static int ed_marker_select(bContext *C, const wmEvent *event, bool extend, bool
for (marker = markers->first; marker; marker = marker->next) {
if (marker-
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list