Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/animation/anim_markers.c
| Show First 20 Lines • Show All 464 Lines • ▼ Show 20 Lines | else { | ||||
| copy_v4_fl4(color, 0.0f, 0.0f, 0.0f, 0.38f); | copy_v4_fl4(color, 0.0f, 0.0f, 0.0f, 0.38f); | ||||
| } | } | ||||
| draw_marker_line(color, xpos, UI_DPI_FAC * 20, height); | draw_marker_line(color, xpos, UI_DPI_FAC * 20, height); | ||||
| } | } | ||||
| } | } | ||||
| static void draw_marker( | static void draw_marker( | ||||
| const uiFontStyle *fstyle, TimeMarker *marker, int xpos, int flag, int region_height) | const uiFontStyle *fstyle, TimeMarker *marker, int cfra, int xpos, int flag, int region_height) | ||||
| { | { | ||||
| GPU_blend(true); | GPU_blend(true); | ||||
| GPU_blend_set_func_separate( | GPU_blend_set_func_separate( | ||||
| GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); | GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); | ||||
| draw_marker_line_if_necessary(marker, flag, xpos, region_height); | draw_marker_line_if_necessary(marker, flag, xpos, region_height); | ||||
| int icon_id = marker_get_icon_id(marker, flag); | int icon_id = marker_get_icon_id(marker, flag); | ||||
| UI_icon_draw(xpos - 0.55f * UI_DPI_ICON_SIZE, UI_DPI_FAC * 18, icon_id); | UI_icon_draw(xpos - 0.55f * UI_DPI_ICON_SIZE, UI_DPI_FAC * 18, icon_id); | ||||
| GPU_blend(false); | GPU_blend(false); | ||||
| float name_y = UI_DPI_FAC * 18; | float name_y = UI_DPI_FAC * 18; | ||||
| if (marker->flag & SELECT) { | /* Give an offset to the marker name when selected, | ||||
| * or when near the current frame (5 frames range, starting from the current one). */ | |||||
JacquesLucke: Not sure if there is such a thing, but maybe there is a function like `in_range`. That could be… | |||||
| if ((marker->flag & SELECT) || (IN_RANGE_INCL(marker->frame, cfra, cfra - 4))) { | |||||
Not Done Inline ActionsUse /* A full sentence. */ for comments. JacquesLucke: Use `/* A full sentence. */` for comments. | |||||
| name_y += UI_DPI_FAC * 10; | name_y += UI_DPI_FAC * 10; | ||||
| } | } | ||||
| draw_marker_name(fstyle, marker, xpos, name_y); | draw_marker_name(fstyle, marker, xpos, name_y); | ||||
| } | } | ||||
| static void draw_markers_background(rctf *rect) | static void draw_markers_background(rctf *rect) | ||||
| { | { | ||||
| uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | ||||
| ▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| ListBase *markers = ED_context_get_markers(C); | ListBase *markers = ED_context_get_markers(C); | ||||
| if (markers == NULL || BLI_listbase_is_empty(markers)) { | if (markers == NULL || BLI_listbase_is_empty(markers)) { | ||||
| return; | return; | ||||
| } | } | ||||
| ARegion *ar = CTX_wm_region(C); | ARegion *ar = CTX_wm_region(C); | ||||
| View2D *v2d = UI_view2d_fromcontext(C); | View2D *v2d = UI_view2d_fromcontext(C); | ||||
| int cfra = CTX_data_scene(C)->r.cfra; | |||||
| rctf markers_region_rect; | rctf markers_region_rect; | ||||
| get_marker_region_rect(v2d, &markers_region_rect); | get_marker_region_rect(v2d, &markers_region_rect); | ||||
| draw_markers_background(&markers_region_rect); | draw_markers_background(&markers_region_rect); | ||||
| /* no time correction for framelen! space is drawn with old values */ | /* no time correction for framelen! space is drawn with old values */ | ||||
| float xscale, dummy; | float xscale, dummy; | ||||
| UI_view2d_scale_get(v2d, &xscale, &dummy); | UI_view2d_scale_get(v2d, &xscale, &dummy); | ||||
| GPU_matrix_push(); | GPU_matrix_push(); | ||||
| GPU_matrix_scale_2f(1.0f / xscale, 1.0f); | GPU_matrix_scale_2f(1.0f / xscale, 1.0f); | ||||
| int clip_frame_range[2]; | int clip_frame_range[2]; | ||||
| get_marker_clip_frame_range(v2d, xscale, clip_frame_range); | get_marker_clip_frame_range(v2d, xscale, clip_frame_range); | ||||
| const uiFontStyle *fstyle = UI_FSTYLE_WIDGET; | const uiFontStyle *fstyle = UI_FSTYLE_WIDGET; | ||||
| /* Separate loops in order to draw selected markers on top */ | |||||
| for (TimeMarker *marker = markers->first; marker; marker = marker->next) { | for (TimeMarker *marker = markers->first; marker; marker = marker->next) { | ||||
| if ((marker->flag & SELECT) == 0) { | if ((marker->flag & SELECT) == 0) { | ||||
| if (marker_is_in_frame_range(marker, clip_frame_range)) { | if (marker_is_in_frame_range(marker, clip_frame_range)) { | ||||
| draw_marker(fstyle, marker, marker->frame * xscale, flag, ar->winy); | draw_marker(fstyle, marker, cfra, marker->frame * xscale, flag, ar->winy); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| for (TimeMarker *marker = markers->first; marker; marker = marker->next) { | for (TimeMarker *marker = markers->first; marker; marker = marker->next) { | ||||
| if (marker->flag & SELECT) { | if (marker->flag & SELECT) { | ||||
| if (marker_is_in_frame_range(marker, clip_frame_range)) { | if (marker_is_in_frame_range(marker, clip_frame_range)) { | ||||
| draw_marker(fstyle, marker, marker->frame * xscale, flag, ar->winy); | draw_marker(fstyle, marker, cfra, marker->frame * xscale, flag, ar->winy); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| GPU_matrix_pop(); | GPU_matrix_pop(); | ||||
| } | } | ||||
| /* ************************ Marker Wrappers API ********************* */ | /* ************************ Marker Wrappers API ********************* */ | ||||
| ▲ Show 20 Lines • Show All 1,082 Lines • Show Last 20 Lines | |||||
Not sure if there is such a thing, but maybe there is a function like in_range. That could be used to simplify the condition.