Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_clip/clip_dopesheet_draw.c
| Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | |||||
| #include "UI_interface.h" | #include "UI_interface.h" | ||||
| #include "UI_resources.h" | #include "UI_resources.h" | ||||
| #include "UI_view2d.h" | #include "UI_view2d.h" | ||||
| #include "BLF_api.h" | #include "BLF_api.h" | ||||
| #include "RNA_access.h" | #include "RNA_access.h" | ||||
| #include "GPU_immediate.h" | |||||
| #include "clip_intern.h" /* own include */ | #include "clip_intern.h" /* own include */ | ||||
| static void track_channel_color(MovieTrackingTrack *track, float default_color[3], float color[3]) | static void track_channel_color(MovieTrackingTrack *track, float default_color[3], float color[3]) | ||||
| { | { | ||||
| if (track->flag & TRACK_CUSTOMCOLOR) { | if (track->flag & TRACK_CUSTOMCOLOR) { | ||||
| float bg[3]; | float bg[3]; | ||||
| UI_GetThemeColor3fv(TH_HEADER, bg); | UI_GetThemeColor3fv(TH_HEADER, bg); | ||||
| Show All 14 Lines | static const float _unit_diamond_shape[4][2] = { | ||||
| {0.0f, 1.0f}, /* top vert */ | {0.0f, 1.0f}, /* top vert */ | ||||
| {1.0f, 0.0f}, /* mid-right */ | {1.0f, 0.0f}, /* mid-right */ | ||||
| {0.0f, -1.0f}, /* bottom vert */ | {0.0f, -1.0f}, /* bottom vert */ | ||||
| {-1.0f, 0.0f} /* mid-left */ | {-1.0f, 0.0f} /* mid-left */ | ||||
| }; | }; | ||||
| static GLuint displist1 = 0; | static GLuint displist1 = 0; | ||||
| static GLuint displist2 = 0; | static GLuint displist2 = 0; | ||||
| int hsize = STRIP_HEIGHT_HALF; | int hsize = STRIP_HEIGHT_HALF; | ||||
| /* initialize 2 display lists for diamond shape - one empty, one filled */ | VertexFormat *format = immVertexFormat(); | ||||
| if (displist1 == 0) { | unsigned pos = add_attrib(format, "pos", GL_FLOAT, 2, KEEP_FLOAT); | ||||
| displist1 = glGenLists(1); | |||||
| glNewList(displist1, GL_COMPILE); | |||||
| glBegin(GL_LINE_LOOP); | |||||
| glVertex2fv(_unit_diamond_shape[0]); | |||||
| glVertex2fv(_unit_diamond_shape[1]); | |||||
| glVertex2fv(_unit_diamond_shape[2]); | |||||
| glVertex2fv(_unit_diamond_shape[3]); | |||||
| glEnd(); | |||||
| glEndList(); | |||||
| } | |||||
| if (displist2 == 0) { | |||||
| displist2 = glGenLists(1); | |||||
| glNewList(displist2, GL_COMPILE); | |||||
| glBegin(GL_QUADS); | |||||
| glVertex2fv(_unit_diamond_shape[0]); | |||||
| glVertex2fv(_unit_diamond_shape[1]); | |||||
| glVertex2fv(_unit_diamond_shape[2]); | |||||
| glVertex2fv(_unit_diamond_shape[3]); | |||||
| glEnd(); | |||||
| glEndList(); | |||||
| } | |||||
| glPushMatrix(); | glPushMatrix(); | ||||
| /* adjust view transform before starting */ | /* adjust view transform before starting */ | ||||
| glTranslatef(x, y, 0.0f); | glTranslatef(x, y, 0.0f); | ||||
| glScalef(1.0f / xscale * hsize, 1.0f / yscale * hsize, 1.0f); | glScalef(1.0f / xscale * hsize, 1.0f / yscale * hsize, 1.0f); | ||||
| /* anti-aliased lines for more consistent appearance */ | /* anti-aliased lines for more consistent appearance */ | ||||
| glEnable(GL_LINE_SMOOTH); | glEnable(GL_LINE_SMOOTH); | ||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | |||||
| /* interior */ | |||||
| if (sel) | if (sel) | ||||
| UI_ThemeColorShadeAlpha(TH_STRIP_SELECT, 50, -255 * (1.0f - alpha)); | immUniformThemeColorShadeAlpha(TH_STRIP_SELECT, 50, -255 * (1.0f - alpha)); | ||||
| else | else | ||||
| glColor4f(0.91f, 0.91f, 0.91f, alpha); | immUniformColor4f(0.91f, 0.91f, 0.91f, alpha); | ||||
| glCallList(displist2); | immBegin(GL_QUADS, 4); | ||||
| immVertex2fv(pos, _unit_diamond_shape[0]); | |||||
| immVertex2fv(pos, _unit_diamond_shape[1]); | |||||
| immVertex2fv(pos, _unit_diamond_shape[2]); | |||||
| immVertex2fv(pos, _unit_diamond_shape[3]); | |||||
| immEnd(); | |||||
| /* exterior - black frame */ | /* exterior - black frame */ | ||||
| glColor4f(0.0f, 0.0f, 0.0f, alpha); | immUniformColor4f(0.0f, 0.0f, 0.0f, alpha); | ||||
| glCallList(displist1); | immBegin(GL_LINE_LOOP, 4); | ||||
| immVertex2fv(pos, _unit_diamond_shape[0]); | |||||
| immVertex2fv(pos, _unit_diamond_shape[1]); | |||||
| immVertex2fv(pos, _unit_diamond_shape[2]); | |||||
| immVertex2fv(pos, _unit_diamond_shape[3]); | |||||
| immEnd(); | |||||
| immUnbindProgram(); | |||||
| glDisable(GL_LINE_SMOOTH); | glDisable(GL_LINE_SMOOTH); | ||||
| /* restore view transform */ | /* restore view transform */ | ||||
| glPopMatrix(); | glPopMatrix(); | ||||
| } | } | ||||
| static void clip_draw_dopesheet_background(ARegion *ar, MovieClip *clip) | static void clip_draw_dopesheet_background(ARegion *ar, MovieClip *clip) | ||||
| { | { | ||||
| View2D *v2d = &ar->v2d; | View2D *v2d = &ar->v2d; | ||||
| MovieTracking *tracking = &clip->tracking; | MovieTracking *tracking = &clip->tracking; | ||||
| MovieTrackingDopesheet *dopesheet = &tracking->dopesheet; | MovieTrackingDopesheet *dopesheet = &tracking->dopesheet; | ||||
| MovieTrackingDopesheetCoverageSegment *coverage_segment; | MovieTrackingDopesheetCoverageSegment *coverage_segment; | ||||
| VertexFormat *format = immVertexFormat(); | |||||
| unsigned pos = add_attrib(format, "pos", GL_FLOAT, 2, KEEP_FLOAT); | |||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | |||||
| for (coverage_segment = dopesheet->coverage_segments.first; | for (coverage_segment = dopesheet->coverage_segments.first; | ||||
| coverage_segment; | coverage_segment; | ||||
| coverage_segment = coverage_segment->next) | coverage_segment = coverage_segment->next) | ||||
| { | { | ||||
| if (coverage_segment->coverage < TRACKING_COVERAGE_OK) { | if (coverage_segment->coverage < TRACKING_COVERAGE_OK) { | ||||
| int start_frame = BKE_movieclip_remap_clip_to_scene_frame(clip, coverage_segment->start_frame); | int start_frame = BKE_movieclip_remap_clip_to_scene_frame(clip, coverage_segment->start_frame); | ||||
| int end_frame = BKE_movieclip_remap_clip_to_scene_frame(clip, coverage_segment->end_frame); | int end_frame = BKE_movieclip_remap_clip_to_scene_frame(clip, coverage_segment->end_frame); | ||||
| if (coverage_segment->coverage == TRACKING_COVERAGE_BAD) { | if (coverage_segment->coverage == TRACKING_COVERAGE_BAD) { | ||||
| glColor4f(1.0f, 0.0f, 0.0f, 0.07f); | immUniformColor4f(1.0f, 0.0f, 0.0f, 0.07f); | ||||
| } | } | ||||
| else | else | ||||
| glColor4f(1.0f, 1.0f, 0.0f, 0.07f); | immUniformColor4f(1.0f, 1.0f, 0.0f, 0.07f); | ||||
| glRectf(start_frame, v2d->cur.ymin, end_frame, v2d->cur.ymax); | immRectf(pos, start_frame, v2d->cur.ymin, end_frame, v2d->cur.ymax); | ||||
| } | } | ||||
| } | } | ||||
| immUnbindProgram(); | |||||
| } | } | ||||
| void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *ar, Scene *scene) | void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *ar, Scene *scene) | ||||
| { | { | ||||
| MovieClip *clip = ED_space_clip_get_clip(sc); | MovieClip *clip = ED_space_clip_get_clip(sc); | ||||
| View2D *v2d = &ar->v2d; | View2D *v2d = &ar->v2d; | ||||
| /* frame range */ | /* frame range */ | ||||
| clip_draw_sfra_efra(v2d, scene); | clip_draw_sfra_efra(v2d, scene); | ||||
| if (clip) { | if (clip) { | ||||
| MovieTracking *tracking = &clip->tracking; | MovieTracking *tracking = &clip->tracking; | ||||
| MovieTrackingDopesheet *dopesheet = &tracking->dopesheet; | MovieTrackingDopesheet *dopesheet = &tracking->dopesheet; | ||||
| MovieTrackingDopesheetChannel *channel; | MovieTrackingDopesheetChannel *channel; | ||||
| float y, xscale, yscale; | float y, xscale, yscale; | ||||
| float strip[4], selected_strip[4]; | float strip[4], selected_strip[4]; | ||||
| float height = (dopesheet->tot_channel * CHANNEL_STEP) + (CHANNEL_HEIGHT); | float height = (dopesheet->tot_channel * CHANNEL_STEP) + (CHANNEL_HEIGHT); | ||||
| VertexFormat *format = immVertexFormat(); | |||||
| unsigned pos = add_attrib(format, "pos", GL_FLOAT, 2, KEEP_FLOAT); | |||||
| /* don't use totrect set, as the width stays the same | /* don't use totrect set, as the width stays the same | ||||
| * (NOTE: this is ok here, the configuration is pretty straightforward) | * (NOTE: this is ok here, the configuration is pretty straightforward) | ||||
| */ | */ | ||||
| v2d->tot.ymin = (float)(-height); | v2d->tot.ymin = (float)(-height); | ||||
| y = (float) CHANNEL_FIRST; | y = (float) CHANNEL_FIRST; | ||||
| UI_view2d_scale_get(v2d, &xscale, &yscale); | UI_view2d_scale_get(v2d, &xscale, &yscale); | ||||
| Show All 23 Lines | for (channel = dopesheet->channels.first; channel; channel = channel->next) { | ||||
| bool sel = (track->flag & TRACK_DOPE_SEL) != 0; | bool sel = (track->flag & TRACK_DOPE_SEL) != 0; | ||||
| /* selection background */ | /* selection background */ | ||||
| if (sel) { | if (sel) { | ||||
| float color[4] = {0.0f, 0.0f, 0.0f, 0.3f}; | float color[4] = {0.0f, 0.0f, 0.0f, 0.3f}; | ||||
| float default_color[4] = {0.8f, 0.93f, 0.8f, 0.3f}; | float default_color[4] = {0.8f, 0.93f, 0.8f, 0.3f}; | ||||
| track_channel_color(track, default_color, color); | track_channel_color(track, default_color, color); | ||||
| glColor4fv(color); | immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | ||||
| immUniformColor4fv(color); | |||||
| glRectf(v2d->cur.xmin, (float) y - CHANNEL_HEIGHT_HALF, | immRectf(pos, v2d->cur.xmin, (float) y - CHANNEL_HEIGHT_HALF, | ||||
| v2d->cur.xmax + EXTRA_SCROLL_PAD, (float) y + CHANNEL_HEIGHT_HALF); | v2d->cur.xmax + EXTRA_SCROLL_PAD, (float) y + CHANNEL_HEIGHT_HALF); | ||||
| immUnbindProgram(); | |||||
| } | } | ||||
| alpha = (track->flag & TRACK_LOCKED) ? 0.5f : 1.0f; | alpha = (track->flag & TRACK_LOCKED) ? 0.5f : 1.0f; | ||||
| /* tracked segments */ | /* tracked segments */ | ||||
| for (i = 0; i < channel->tot_segment; i++) { | for (i = 0; i < channel->tot_segment; i++) { | ||||
| int start_frame = BKE_movieclip_remap_clip_to_scene_frame(clip, channel->segments[2 * i]); | int start_frame = BKE_movieclip_remap_clip_to_scene_frame(clip, channel->segments[2 * i]); | ||||
| int end_frame = BKE_movieclip_remap_clip_to_scene_frame(clip, channel->segments[2 * i + 1]); | int end_frame = BKE_movieclip_remap_clip_to_scene_frame(clip, channel->segments[2 * i + 1]); | ||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | |||||
| if (sel) | if (sel) | ||||
| glColor4fv(selected_strip); | immUniformColor4fv(selected_strip); | ||||
| else | else | ||||
| glColor4fv(strip); | immUniformColor4fv(strip); | ||||
| if (start_frame != end_frame) { | if (start_frame != end_frame) { | ||||
| glRectf(start_frame, (float) y - STRIP_HEIGHT_HALF, | immRectf(pos, start_frame, (float) y - STRIP_HEIGHT_HALF, | ||||
| end_frame, (float) y + STRIP_HEIGHT_HALF); | end_frame, (float) y + STRIP_HEIGHT_HALF); | ||||
| immUnbindProgram(); | |||||
| draw_keyframe_shape(start_frame, y, xscale, yscale, sel, alpha); | draw_keyframe_shape(start_frame, y, xscale, yscale, sel, alpha); | ||||
| draw_keyframe_shape(end_frame, y, xscale, yscale, sel, alpha); | draw_keyframe_shape(end_frame, y, xscale, yscale, sel, alpha); | ||||
merwin: BTW I'm working on draw_keyframe_shape... I'll make sure this & that work well together. | |||||
| } | } | ||||
| else { | else { | ||||
| immUnbindProgram(); | |||||
| draw_keyframe_shape(start_frame, y, xscale, yscale, sel, alpha); | draw_keyframe_shape(start_frame, y, xscale, yscale, sel, alpha); | ||||
| } | } | ||||
| } | } | ||||
| /* keyframes */ | /* keyframes */ | ||||
| i = 0; | i = 0; | ||||
| while (i < track->markersnr) { | while (i < track->markersnr) { | ||||
| MovieTrackingMarker *marker = &track->markers[i]; | MovieTrackingMarker *marker = &track->markers[i]; | ||||
| Show All 29 Lines | void clip_draw_dopesheet_channels(const bContext *C, ARegion *ar) | ||||
| MovieTrackingDopesheet *dopesheet; | MovieTrackingDopesheet *dopesheet; | ||||
| MovieTrackingDopesheetChannel *channel; | MovieTrackingDopesheetChannel *channel; | ||||
| uiStyle *style = UI_style_get(); | uiStyle *style = UI_style_get(); | ||||
| uiBlock *block; | uiBlock *block; | ||||
| int fontid = style->widget.uifont_id; | int fontid = style->widget.uifont_id; | ||||
| int height; | int height; | ||||
| float y; | float y; | ||||
| PropertyRNA *chan_prop_lock; | PropertyRNA *chan_prop_lock; | ||||
| VertexFormat *format = immVertexFormat(); | |||||
| unsigned pos = add_attrib(format, "pos", GL_FLOAT, 2, KEEP_FLOAT); | |||||
| if (!clip) | if (!clip) | ||||
| return; | return; | ||||
| tracking = &clip->tracking; | tracking = &clip->tracking; | ||||
| dopesheet = &tracking->dopesheet; | dopesheet = &tracking->dopesheet; | ||||
| height = (dopesheet->tot_channel * CHANNEL_STEP) + (CHANNEL_HEIGHT); | height = (dopesheet->tot_channel * CHANNEL_STEP) + (CHANNEL_HEIGHT); | ||||
| if (height > BLI_rcti_size_y(&v2d->mask)) { | if (height > BLI_rcti_size_y(&v2d->mask)) { | ||||
| Show All 21 Lines | for (channel = dopesheet->channels.first; channel; channel = channel->next) { | ||||
| if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || | if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || | ||||
| IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax)) | IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax)) | ||||
| { | { | ||||
| MovieTrackingTrack *track = channel->track; | MovieTrackingTrack *track = channel->track; | ||||
| float font_height, color[3]; | float font_height, color[3]; | ||||
| bool sel = (track->flag & TRACK_DOPE_SEL) != 0; | bool sel = (track->flag & TRACK_DOPE_SEL) != 0; | ||||
| track_channel_color(track, NULL, color); | track_channel_color(track, NULL, color); | ||||
| glColor3fv(color); | immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | ||||
| immUniformColor3fv(color); | |||||
| glRectf(v2d->cur.xmin, (float) y - CHANNEL_HEIGHT_HALF, | immRectf(pos, v2d->cur.xmin, (float) y - CHANNEL_HEIGHT_HALF, | ||||
| v2d->cur.xmax + EXTRA_SCROLL_PAD, (float) y + CHANNEL_HEIGHT_HALF); | v2d->cur.xmax + EXTRA_SCROLL_PAD, (float) y + CHANNEL_HEIGHT_HALF); | ||||
| if (sel) | if (sel) | ||||
| UI_ThemeColor(TH_TEXT_HI); | immUniformThemeColor(TH_TEXT_HI); | ||||
| else | else | ||||
| UI_ThemeColor(TH_TEXT); | immUniformThemeColor(TH_TEXT); | ||||
merwinUnsubmitted Done Inline ActionsKeep this (after immUnbindProgram), or update it to UI_ThemeColor(sel ? TH_TEXT_HI : TH_TEXT); BLF_draw still uses old-skool glColor. I'm working on that. merwin: Keep this (after immUnbindProgram), or update it to
```
UI_ThemeColor(sel ? TH_TEXT_HI… | |||||
| immUnbindProgram(); | |||||
| font_height = BLF_height(fontid, channel->name, sizeof(channel->name)); | font_height = BLF_height(fontid, channel->name, sizeof(channel->name)); | ||||
| BLF_position(fontid, v2d->cur.xmin + CHANNEL_PAD, | BLF_position(fontid, v2d->cur.xmin + CHANNEL_PAD, | ||||
| y - font_height / 2.0f, 0.0f); | y - font_height / 2.0f, 0.0f); | ||||
| BLF_draw(fontid, channel->name, strlen(channel->name)); | BLF_draw(fontid, channel->name, strlen(channel->name)); | ||||
| } | } | ||||
| /* adjust y-position for next one */ | /* adjust y-position for next one */ | ||||
| ▲ Show 20 Lines • Show All 41 Lines • Show Last 20 Lines | |||||
BTW I'm working on draw_keyframe_shape... I'll make sure this & that work well together.