Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/animation/anim_markers.c
| Context not available. | |||||
| #include "ED_transform.h" | #include "ED_transform.h" | ||||
| #include "ED_types.h" | #include "ED_types.h" | ||||
| #include "GPU_immediate.h" | |||||
| /* ************* Marker API **************** */ | /* ************* Marker API **************** */ | ||||
| /* helper function for getting the list of markers to work on */ | /* helper function for getting the list of markers to work on */ | ||||
| Context not available. | |||||
| /* ************* Marker Drawing ************ */ | /* ************* Marker Drawing ************ */ | ||||
| /* function to draw markers */ | /* function to draw markers - assumes that program has been bound and "pos" | ||||
| * attribute is available | |||||
| */ | |||||
| static void draw_marker( | static void draw_marker( | ||||
| View2D *v2d, const uiFontStyle *fstyle, TimeMarker *marker, int cfra, int flag, | unsigned pos, View2D *v2d, const uiFontStyle *fstyle, TimeMarker *marker, | ||||
| int cfra, int flag, | |||||
| /* avoid re-calculating each time */ | /* avoid re-calculating each time */ | ||||
| const float ypixels, const float xscale, const float yscale) | const float ypixels, const float xscale, const float yscale) | ||||
| { | { | ||||
| Context not available. | |||||
| setlinestyle(3); | setlinestyle(3); | ||||
| if (marker->flag & SELECT) | if (marker->flag & SELECT) | ||||
| glColor4ub(255, 255, 255, 96); | immUniformColor4ub(255, 255, 255, 96); | ||||
| else | else | ||||
| glColor4ub(0, 0, 0, 96); | immUniformColor4ub(0, 0, 0, 96); | ||||
| glBegin(GL_LINES); | |||||
| glVertex2f(xpos + 0.5f, 12.0f); | |||||
| glVertex2f(xpos + 0.5f, (v2d->cur.ymax + 12.0f) * yscale); | |||||
| glEnd(); | |||||
| immBegin(GL_LINES, 2); | |||||
| immVertex2f(pos, xpos + 0.5f, 12.0f); | |||||
| immVertex2f(pos, xpos + 0.5f, (v2d->cur.ymax + 12.0f) * yscale); | |||||
| immEnd(); | |||||
| setlinestyle(0); | setlinestyle(0); | ||||
| } | } | ||||
| Context not available. | |||||
| /* minimal y coordinate which wouldn't be occluded by scroll */ | /* minimal y coordinate which wouldn't be occluded by scroll */ | ||||
| int min_y = 17.0f * UI_DPI_FAC; | int min_y = 17.0f * UI_DPI_FAC; | ||||
| int colorid; | |||||
| if (marker->flag & SELECT) { | if (marker->flag & SELECT) { | ||||
| UI_ThemeColor(TH_TEXT_HI); | colorid = TH_TEXT_HI; | ||||
| x = xpos + 4.0f * UI_DPI_FAC; | x = xpos + 4.0f * UI_DPI_FAC; | ||||
| y = (ypixels <= 39.0f * UI_DPI_FAC) ? (ypixels - 10.0f * UI_DPI_FAC) : 29.0f * UI_DPI_FAC; | y = (ypixels <= 39.0f * UI_DPI_FAC) ? (ypixels - 10.0f * UI_DPI_FAC) : 29.0f * UI_DPI_FAC; | ||||
| y = max_ii(y, min_y); | y = max_ii(y, min_y); | ||||
| } | } | ||||
| else { | else { | ||||
| UI_ThemeColor(TH_TEXT); | colorid = TH_TEXT; | ||||
| if ((marker->frame <= cfra) && (marker->frame + 5 > cfra)) { | if ((marker->frame <= cfra) && (marker->frame + 5 > cfra)) { | ||||
| x = xpos + 8.0f * UI_DPI_FAC; | x = xpos + 8.0f * UI_DPI_FAC; | ||||
| y = (ypixels <= 39.0f * UI_DPI_FAC) ? (ypixels - 10.0f * UI_DPI_FAC) : 29.0f * UI_DPI_FAC; | y = (ypixels <= 39.0f * UI_DPI_FAC) ? (ypixels - 10.0f * UI_DPI_FAC) : 29.0f * UI_DPI_FAC; | ||||
| Context not available. | |||||
| } | } | ||||
| } | } | ||||
| immUniformThemeColor(colorid); | |||||
| #ifdef DURIAN_CAMERA_SWITCH | #ifdef DURIAN_CAMERA_SWITCH | ||||
| if (marker->camera && (marker->camera->restrictflag & OB_RESTRICT_RENDER)) { | if (marker->camera && (marker->camera->restrictflag & OB_RESTRICT_RENDER)) { | ||||
| float col[4]; | float col[4]; | ||||
| glGetFloatv(GL_CURRENT_COLOR, col); | UI_GetThemeColor4fv(colorid, col); | ||||
| col[3] = 0.4; | col[3] = 0.4; | ||||
| glColor4fv(col); | immUniformColor4fv(col); | ||||
merwin: This color is for the text drawing (UI_fontstyle_draw_simple). Leave the glColor4fv but get its… | |||||
| } | } | ||||
| #endif | #endif | ||||
| Context not available. | |||||
| scene = CTX_data_scene(C); | scene = CTX_data_scene(C); | ||||
| v2d = UI_view2d_fromcontext(C); | v2d = UI_view2d_fromcontext(C); | ||||
| VertexFormat *format = immVertexFormat(); | |||||
| unsigned pos = add_attrib(format, "pos", GL_FLOAT, 2, KEEP_FLOAT); | |||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | |||||
| if (flag & DRAW_MARKERS_MARGIN) { | if (flag & DRAW_MARKERS_MARGIN) { | ||||
| const unsigned char shade[4] = {0, 0, 0, 16}; | immUniformColor4ub(0, 0, 0, 16); | ||||
| glColor4ubv(shade); | |||||
| glEnable(GL_BLEND); | glEnable(GL_BLEND); | ||||
| glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | ||||
| glRectf(v2d->cur.xmin, 0, v2d->cur.xmax, UI_MARKER_MARGIN_Y); | immRectf(pos, v2d->cur.xmin, 0, v2d->cur.xmax, UI_MARKER_MARGIN_Y); | ||||
| glDisable(GL_BLEND); | glDisable(GL_BLEND); | ||||
| } | } | ||||
| Context not available. | |||||
| if ((marker->frame >= v2d_clip_range_x[0]) && | if ((marker->frame >= v2d_clip_range_x[0]) && | ||||
| (marker->frame <= v2d_clip_range_x[1])) | (marker->frame <= v2d_clip_range_x[1])) | ||||
| { | { | ||||
| draw_marker(v2d, fstyle, marker, scene->r.cfra, flag, | draw_marker(pos, v2d, fstyle, marker, scene->r.cfra, flag, | ||||
| ypixels, xscale, yscale); | ypixels, xscale, yscale); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| immUnbindProgram(); | |||||
merwinUnsubmitted Done Inline ActionsHave you tried to run this? I don't expect it to work. draw_marker does 3 things right now:
The icon and text label each use their own shader program, and will conflict with 2D_UNIFORM_COLOR used for the lines. If you separate the line drawing into its own function we can draw all lines within one immBegin/End. Which is good! Would have to repeat this loop -- once for lines, again for "other" stuff. merwin: Have you tried to run this? I don't expect it to work.
draw_marker does 3 things right now… | |||||
| glScalef(xscale, 1.0f, 1.0f); | glScalef(xscale, 1.0f, 1.0f); | ||||
| } | } | ||||
| Context not available. | |||||
This color is for the text drawing (UI_fontstyle_draw_simple). Leave the glColor4fv but get its value with UI_GetThemeColor4fv like you're doing.
Something like this: