Skip to content

Commit

Permalink
add a new Drum icon
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldavisthefirst committed Dec 29, 2024
1 parent 0133400 commit 791bb3a
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
53 changes: 52 additions & 1 deletion libs/widgets/ardour_icon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1755,7 +1755,54 @@ icon_attachment_bottom (cairo_t* cr, const int width, const int height, const Gt



/*****************************************************************************/
/*****************************************************************************
* Drum icon (take from share/scripts/create_drum_tracks.lua
*/

static void
drumstick (cairo_t* cr, double xp, double lr, double r, double x, double y)
{
cairo_set_line_width (cr, r * .3);
cairo_move_to (cr, x * xp, y);
cairo_close_path (cr);
cairo_stroke (cr);
cairo_set_line_width (cr, r * .2);
cairo_move_to (cr, x * xp, y);
cairo_rel_line_to (cr, lr * x, y);
cairo_stroke (cr);
}

static void
icon_drum (cairo_t* cr, const int width, const int height, const Gtkmm2ext::ActiveState state, const uint32_t fg_color)
{

double x = width * .5;
double y = height * .5;
double r = std::min (x, y) * .7;

cairo_save (cr);
cairo_translate (cr, x, y);
cairo_scale (cr, 1, .5);
cairo_translate (cr, -x, -y);
cairo_arc (cr, x, y, r, 0, 2 * M_PI);
cairo_fill (cr);
cairo_arc (cr, x, y, r, 0, M_PI);
cairo_arc_negative (cr, x, y * 1.6, r, M_PI, 0);
Gtkmm2ext::set_source_rgba (cr, fg_color);
cairo_fill (cr);
cairo_restore (cr);

// cairo_set_source_rgba (cr, .6, .4, .2, 1);
cairo_translate (cr, x, y);
cairo_scale (cr, .7, 1);
cairo_translate (cr, -x, -y);
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);

drumstick (cr, 1.2, 1.2, r, x, y);
drumstick (cr, 0.7, -.5, r, x, y);
}

/****************************************************************************/

bool
ArdourWidgets::ArdourIcon::render (cairo_t* cr,
Expand Down Expand Up @@ -1931,6 +1978,9 @@ ArdourWidgets::ArdourIcon::render (cairo_t* cr
case AttachmentBottom:
icon_attachment_bottom (cr, width, height, state, fg_color);
break;
case Drum:
icon_drum (cr, width, height, state, fg_color);
break;
case NoIcon:
rv = false;
break;
Expand Down Expand Up @@ -2004,3 +2054,4 @@ ArdourWidgets::ArdourIcon::expose_with_text (GdkEventExpose* ev, Gtk::Widget* w,

return true;
}

1 change: 1 addition & 0 deletions libs/widgets/widgets/ardour_icon.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ namespace ArdourWidgets { namespace ArdourIcon {
AttachmentLeft,
AttachmentRight,
AttachmentBottom,
Drum,
NoIcon //< Last
};

Expand Down

0 comments on commit 791bb3a

Please sign in to comment.