diff options
author | Joshua Leung <aligorith@gmail.com> | 2016-03-13 14:56:52 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2016-03-13 14:56:52 +0300 |
commit | 6bf9aa3f8e833df488911d6005b1683cca36c51e (patch) | |
tree | 444bde790664f485036dec9a1c51fe7642ff501a /source/blender/editors/interface/interface_icons.c | |
parent | 81e7f6b8a0c99c953ca9659b1b317ae852c6508e (diff) |
Fancy procedural icons for Keyframe Types
The new "default keyframe type" dropdown on the timeline header
(and also the "Keyframe Type" operator/properties in other places)
now has procedurally generated icons which reflect what that keyframe
type will look like when rendered in the Dope Sheet.
This was achieved using the ancient "VICON" (vector icon) stuff
that's lurking around in the dark parts of UI code. From memory,
the only other things that use (or used to use) this stuff included
some of the triangle icons for some dropdown buttons, or something
like that.
Notes:
* Theme colour changes are reflected immediately by these icons.
This is possible because they are all drawn procedurally
* These icons scale with the DPI setting. I manually guessed the size of
these icons. They can be adjusted further if needed.
* I've documented the steps for adding voodoo icons like this on the wiki
(http://wiki.blender.org/index.php/Dev:2.7/Source/Checklists/Vector_Icon)
* It's true that the rendering of these keyframes doesn't quite fit the rest
of the icons in the UI. However, since we're just leveraging the standard
keyframe drawing methods (to avoid discreptancies between the two), we'll
leave it as such for now. Maybe later we can consider blending in a bit of
the glossy keyframe icons in the Icon Sheet?
Diffstat (limited to 'source/blender/editors/interface/interface_icons.c')
-rw-r--r-- | source/blender/editors/interface/interface_icons.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index da0e14574e5..7be153e942e 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -41,6 +41,7 @@ #include "BLI_fileops_types.h" #include "DNA_brush_types.h" +#include "DNA_curve_types.h" #include "DNA_dynamicpaint_types.h" #include "DNA_object_types.h" #include "DNA_screen_types.h" @@ -62,6 +63,7 @@ #include "BIF_glutil.h" #include "ED_datafiles.h" +#include "ED_keyframes_draw.h" #include "ED_render.h" #include "UI_interface.h" @@ -461,6 +463,54 @@ static void vicon_move_down_draw(int x, int y, int w, int h, float UNUSED(alpha) glDisable(GL_LINE_SMOOTH); } +static void vicon_keytype_draw_wrapper(int x, int y, int w, int h, float alpha, short key_type) +{ + /* init dummy theme state for Action Editor - where these colors are defined + * (since we're doing this offscreen, free from any particular space_id) + */ + struct bThemeState theme_state; + int xco, yco; + + UI_Theme_Store(&theme_state); + UI_SetTheme(SPACE_ACTION, RGN_TYPE_WINDOW); + + /* the "x" and "y" given are the bottom-left coordinates of the icon, + * while the draw_keyframe_shape() function needs the midpoint for + * the keyframe + */ + xco = x + w / 2; + yco = y + h / 2; + + /* draw keyframe + * - xscale: 1.0 (since there's no timeline scaling to compensate for) + * - yscale: 0.3 * h (found out experimentally... dunno why!) + * - sel: true (so that "keyframe" state shows the iconic yellow icon) + */ + draw_keyframe_shape(xco, yco, 1.0f, 0.3f * h, true, key_type, KEYFRAME_SHAPE_BOTH, alpha); + + UI_Theme_Restore(&theme_state); +} + +static void vicon_keytype_keyframe_draw(int x, int y, int w, int h, float alpha) +{ + vicon_keytype_draw_wrapper(x, y, w, h, alpha, BEZT_KEYTYPE_KEYFRAME); +} + +static void vicon_keytype_breakdown_draw(int x, int y, int w, int h, float alpha) +{ + vicon_keytype_draw_wrapper(x, y, w, h, alpha, BEZT_KEYTYPE_BREAKDOWN); +} + +static void vicon_keytype_extreme_draw(int x, int y, int w, int h, float alpha) +{ + vicon_keytype_draw_wrapper(x, y, w, h, alpha, BEZT_KEYTYPE_EXTREME); +} + +static void vicon_keytype_jitter_draw(int x, int y, int w, int h, float alpha) +{ + vicon_keytype_draw_wrapper(x, y, w, h, alpha, BEZT_KEYTYPE_JITTER); +} + #ifndef WITH_HEADLESS static void init_brush_icons(void) @@ -686,6 +736,11 @@ static void init_internal_icons(void) def_internal_vicon(VICO_MOVE_DOWN_VEC, vicon_move_down_draw); def_internal_vicon(VICO_X_VEC, vicon_x_draw); def_internal_vicon(VICO_SMALL_TRI_RIGHT_VEC, vicon_small_tri_right_draw); + + def_internal_vicon(VICO_KEYTYPE_KEYFRAME_VEC, vicon_keytype_keyframe_draw); + def_internal_vicon(VICO_KEYTYPE_BREAKDOWN_VEC, vicon_keytype_breakdown_draw); + def_internal_vicon(VICO_KEYTYPE_EXTREME_VEC, vicon_keytype_extreme_draw); + def_internal_vicon(VICO_KEYTYPE_JITTER_VEC, vicon_keytype_jitter_draw); IMB_freeImBuf(b16buf); IMB_freeImBuf(b32buf); |