From e8e143bb3202a47a8a75f20f3c2d9fd1b6f251e1 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 21 Jul 2020 04:41:16 +0200 Subject: [PATCH] Add a horizontal separator widget --- libs/widgets/ardour_spacer.cc | 6 ++++++ libs/widgets/widgets/ardour_spacer.h | 26 ++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/libs/widgets/ardour_spacer.cc b/libs/widgets/ardour_spacer.cc index 230c5f22cf..ad5406a05b 100644 --- a/libs/widgets/ardour_spacer.cc +++ b/libs/widgets/ardour_spacer.cc @@ -27,6 +27,12 @@ ArdourVSpacer::ArdourVSpacer (float r) { } +ArdourHSpacer::ArdourHSpacer (float r) + : CairoWidget () + , ratio (r) +{ +} + ArdourDropShadow::ArdourDropShadow (ShadowMode m, float a) : CairoWidget () , alpha (a) diff --git a/libs/widgets/widgets/ardour_spacer.h b/libs/widgets/widgets/ardour_spacer.h index 4702de4b31..0e98c9f1c9 100644 --- a/libs/widgets/widgets/ardour_spacer.h +++ b/libs/widgets/widgets/ardour_spacer.h @@ -53,6 +53,32 @@ protected: float ratio; }; +class LIBWIDGETS_API ArdourHSpacer : public CairoWidget +{ +public: + ArdourHSpacer (float r = 0.75f); + +protected: + void render (Cairo::RefPtr const& ctx, cairo_rectangle_t*) { + + float width = get_width(); + + float w = width * ratio; + float t = .5f * (width - w); + ctx->rectangle (t, 0, w, 1); + ctx->set_source_rgb (0, 0, 0); + ctx->fill (); + } + + void on_size_request (Gtk::Requisition* req) { + req->width = 0; + req->height = 1; + CairoWidget::on_size_request (req); + } + + float ratio; +}; + class LIBWIDGETS_API ArdourDropShadow : public CairoWidget { public: