Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/animation/anim_channels_defines.c
| Show First 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | |||||
| #include "RNA_access.h" | #include "RNA_access.h" | ||||
| #include "BKE_animsys.h" | #include "BKE_animsys.h" | ||||
| #include "BKE_curve.h" | #include "BKE_curve.h" | ||||
| #include "BKE_key.h" | #include "BKE_key.h" | ||||
| #include "BKE_nla.h" | #include "BKE_nla.h" | ||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "GPU_immediate.h" | |||||
| #include "UI_interface.h" | #include "UI_interface.h" | ||||
| #include "UI_interface_icons.h" | #include "UI_interface_icons.h" | ||||
| #include "UI_resources.h" | #include "UI_resources.h" | ||||
| #include "ED_anim_api.h" | #include "ED_anim_api.h" | ||||
| #include "ED_keyframing.h" | #include "ED_keyframing.h" | ||||
| #include "BIF_gl.h" | #include "BIF_gl.h" | ||||
| ▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | |||||
| /* backdrop for data expanders under top-level Scene/Object */ | /* backdrop for data expanders under top-level Scene/Object */ | ||||
| static void acf_generic_dataexpand_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc) | static void acf_generic_dataexpand_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc) | ||||
| { | { | ||||
| const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); | const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); | ||||
| View2D *v2d = &ac->ar->v2d; | View2D *v2d = &ac->ar->v2d; | ||||
| short offset = (acf->get_offset) ? acf->get_offset(ac, ale) : 0; | short offset = (acf->get_offset) ? acf->get_offset(ac, ale) : 0; | ||||
| float color[3]; | float color[3]; | ||||
| VertexFormat *format = immVertexFormat(); | |||||
| unsigned pos = add_attrib(format, "pos", GL_FLOAT, 2, KEEP_FLOAT); | |||||
| /* set backdrop drawing color */ | /* set backdrop drawing color */ | ||||
| acf->get_backdrop_color(ac, ale, color); | acf->get_backdrop_color(ac, ale, color); | ||||
| glColor3fv(color); | |||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | |||||
| immUniformColor3fv(color); | |||||
| /* no rounded corner - just rectangular box */ | /* no rounded corner - just rectangular box */ | ||||
| glRectf(offset, yminc, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc); | immRectf(pos, offset, yminc, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc); | ||||
| immUnbindProgram(); | |||||
| } | } | ||||
| /* helper method to test if group colors should be drawn */ | /* helper method to test if group colors should be drawn */ | ||||
| static bool acf_show_channel_colors(bAnimContext *ac) | static bool acf_show_channel_colors(bAnimContext *ac) | ||||
| { | { | ||||
| bool showGroupColors = false; | bool showGroupColors = false; | ||||
| if (ac->sl) { | if (ac->sl) { | ||||
| ▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | |||||
| /* backdrop for generic channels */ | /* backdrop for generic channels */ | ||||
| static void acf_generic_channel_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc) | static void acf_generic_channel_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc) | ||||
| { | { | ||||
| const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); | const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); | ||||
| View2D *v2d = &ac->ar->v2d; | View2D *v2d = &ac->ar->v2d; | ||||
| short offset = (acf->get_offset) ? acf->get_offset(ac, ale) : 0; | short offset = (acf->get_offset) ? acf->get_offset(ac, ale) : 0; | ||||
| float color[3]; | float color[3]; | ||||
| VertexFormat *format = immVertexFormat(); | |||||
| unsigned pos = add_attrib(format, "pos", GL_FLOAT, 2, KEEP_FLOAT); | |||||
| /* set backdrop drawing color */ | /* set backdrop drawing color */ | ||||
| acf->get_backdrop_color(ac, ale, color); | acf->get_backdrop_color(ac, ale, color); | ||||
| glColor3fv(color); | |||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | |||||
| immUniformColor3fv(color); | |||||
| /* no rounded corners - just rectangular box */ | /* no rounded corners - just rectangular box */ | ||||
| glRectf(offset, yminc, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc); | immRectf(pos, offset, yminc, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc); | ||||
| immUnbindProgram(); | |||||
| } | } | ||||
| /* Indention + Offset ------------------------------------------- */ | /* Indention + Offset ------------------------------------------- */ | ||||
| /* indention level is always the value in the name */ | /* indention level is always the value in the name */ | ||||
| static short acf_generic_indention_0(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale)) | static short acf_generic_indention_0(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale)) | ||||
| { | { | ||||
| return 0; | return 0; | ||||
| ▲ Show 20 Lines • Show All 3,528 Lines • ▼ Show 20 Lines | void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc, size_t channel_index) | ||||
| */ | */ | ||||
| if (ac->sl) { | if (ac->sl) { | ||||
| if ((ac->spacetype == SPACE_IPO) && | if ((ac->spacetype == SPACE_IPO) && | ||||
| (acf->has_setting(ac, ale, ACHANNEL_SETTING_VISIBLE) || | (acf->has_setting(ac, ale, ACHANNEL_SETTING_VISIBLE) || | ||||
| acf->has_setting(ac, ale, ACHANNEL_SETTING_ALWAYS_VISIBLE))) { | acf->has_setting(ac, ale, ACHANNEL_SETTING_ALWAYS_VISIBLE))) { | ||||
| /* for F-Curves, draw color-preview of curve behind checkbox */ | /* for F-Curves, draw color-preview of curve behind checkbox */ | ||||
| if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) { | if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) { | ||||
| FCurve *fcu = (FCurve *)ale->data; | FCurve *fcu = (FCurve *)ale->data; | ||||
| VertexFormat *format = immVertexFormat(); | |||||
| unsigned pos = add_attrib(format, "pos", GL_FLOAT, 2, KEEP_FLOAT); | |||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | |||||
| /* F-Curve channels need to have a special 'color code' box drawn, which is colored with whatever | /* F-Curve channels need to have a special 'color code' box drawn, which is colored with whatever | ||||
| * color the curve has stored | * color the curve has stored | ||||
| */ | */ | ||||
| glColor3fv(fcu->color); | immUniformColor3fv(fcu->color); | ||||
| /* just a solid color rect | /* just a solid color rect | ||||
| */ | */ | ||||
| glRectf(offset, yminc, offset + ICON_WIDTH, ymaxc); | immRectf(pos, offset, yminc, offset + ICON_WIDTH, ymaxc); | ||||
| immUnbindProgram(); | |||||
| } | } | ||||
| /* icon is drawn as widget now... */ | /* icon is drawn as widget now... */ | ||||
| if (acf->has_setting(ac, ale, ACHANNEL_SETTING_VISIBLE)) { | if (acf->has_setting(ac, ale, ACHANNEL_SETTING_VISIBLE)) { | ||||
| offset += ICON_WIDTH; | offset += ICON_WIDTH; | ||||
| } | } | ||||
| if (acf->has_setting(ac, ale, ACHANNEL_SETTING_ALWAYS_VISIBLE)) { | if (acf->has_setting(ac, ale, ACHANNEL_SETTING_ALWAYS_VISIBLE)) { | ||||
| offset += ICON_WIDTH; | offset += ICON_WIDTH; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc, size_t channel_index) | ||||
| offset = 0; | offset = 0; | ||||
| /* TODO: when drawing sliders, make those draw instead of these toggles if not enough space */ | /* TODO: when drawing sliders, make those draw instead of these toggles if not enough space */ | ||||
| if (v2d) { | if (v2d) { | ||||
| short draw_sliders = 0; | short draw_sliders = 0; | ||||
| float ymin_ofs = 0.0f; | float ymin_ofs = 0.0f; | ||||
| float color[3]; | float color[3]; | ||||
| VertexFormat *format = immVertexFormat(); | |||||
| unsigned pos = add_attrib(format, "pos", GL_FLOAT, 2, KEEP_FLOAT); | |||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | |||||
| /* get and set backdrop color */ | /* get and set backdrop color */ | ||||
| acf->get_backdrop_color(ac, ale, color); | acf->get_backdrop_color(ac, ale, color); | ||||
| glColor3fv(color); | immUniformColor3fv(color); | ||||
| /* check if we need to show the sliders */ | /* check if we need to show the sliders */ | ||||
| if ((ac->sl) && ELEM(ac->spacetype, SPACE_ACTION, SPACE_IPO)) { | if ((ac->sl) && ELEM(ac->spacetype, SPACE_ACTION, SPACE_IPO)) { | ||||
| switch (ac->spacetype) { | switch (ac->spacetype) { | ||||
| case SPACE_ACTION: | case SPACE_ACTION: | ||||
| { | { | ||||
| SpaceAction *saction = (SpaceAction *)ac->sl; | SpaceAction *saction = (SpaceAction *)ac->sl; | ||||
| draw_sliders = (saction->flag & SACTION_SLIDERS); | draw_sliders = (saction->flag & SACTION_SLIDERS); | ||||
| ▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | if ((draw_sliders) && ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE, ANIMTYPE_SHAPEKEY)) { | ||||
| offset += SLIDER_WIDTH; | offset += SLIDER_WIDTH; | ||||
| } | } | ||||
| /* finally draw a backdrop rect behind these | /* finally draw a backdrop rect behind these | ||||
| * - starts from the point where the first toggle/slider starts, | * - starts from the point where the first toggle/slider starts, | ||||
| * - ends past the space that might be reserved for a scroller | * - ends past the space that might be reserved for a scroller | ||||
| */ | */ | ||||
| glRectf(v2d->cur.xmax - (float)offset, yminc + ymin_ofs, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc); | immRectf(pos, v2d->cur.xmax - (float)offset, yminc + ymin_ofs, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc); | ||||
| immUnbindProgram(); | |||||
| } | } | ||||
| } | } | ||||
| /* ------------------ */ | /* ------------------ */ | ||||
| /* callback for (normal) widget settings - send notifiers */ | /* callback for (normal) widget settings - send notifiers */ | ||||
| static void achannel_setting_widget_cb(bContext *C, void *UNUSED(arg1), void *UNUSED(arg2)) | static void achannel_setting_widget_cb(bContext *C, void *UNUSED(arg1), void *UNUSED(arg2)) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 657 Lines • Show Last 20 Lines | |||||