From 7c662ec44fe3b5ed80fbd47b010d31b7a6560ac2 Mon Sep 17 00:00:00 2001 From: Bjoern Hiller Date: Wed, 21 Oct 2020 09:02:52 +0200 Subject: [PATCH] feat(conf) Properties for {bottom,top}-{left,right} radius --- include/cairo/context.hpp | 8 ++++---- include/components/types.hpp | 8 +++++--- src/components/bar.cpp | 8 ++++++-- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/include/cairo/context.hpp b/include/cairo/context.hpp index be881c50..42e692f5 100644 --- a/include/cairo/context.hpp +++ b/include/cairo/context.hpp @@ -118,10 +118,10 @@ namespace cairo { context& operator<<(const rounded_corners& c) { double d = M_PI / 180.0; cairo_new_sub_path(m_c); - cairo_arc(m_c, c.x + c.w - c.radius.top, c.y + c.radius.top, c.radius.top, -90 * d, 0 * d); - cairo_arc(m_c, c.x + c.w - c.radius.bottom, c.y + c.h - c.radius.bottom, c.radius.bottom, 0 * d, 90 * d); - cairo_arc(m_c, c.x + c.radius.bottom, c.y + c.h - c.radius.bottom, c.radius.bottom, 90 * d, 180 * d); - cairo_arc(m_c, c.x + c.radius.top, c.y + c.radius.top, c.radius.top, 180 * d, 270 * d); + cairo_arc(m_c, c.x + c.w - c.radius.top_right, c.y + c.radius.top_right, c.radius.top_right, -90 * d, 0 * d); + cairo_arc(m_c, c.x + c.w - c.radius.bottom_right, c.y + c.h - c.radius.bottom_right, c.radius.bottom_right, 0 * d, 90 * d); + cairo_arc(m_c, c.x + c.radius.bottom_left, c.y + c.h - c.radius.bottom_left, c.radius.bottom_left, 90 * d, 180 * d); + cairo_arc(m_c, c.x + c.radius.top_left, c.y + c.radius.top_left, c.radius.top_left, 180 * d, 270 * d); cairo_close_path(m_c); return *this; } diff --git a/include/components/types.hpp b/include/components/types.hpp index c1baefa1..acc7b5bc 100644 --- a/include/components/types.hpp +++ b/include/components/types.hpp @@ -98,11 +98,13 @@ struct edge_values { }; struct radius { - double top{0.0}; - double bottom{0.0}; + double top_left{0.0}; + double top_right{0.0}; + double bottom_left{0.0}; + double bottom_right{0.0}; operator bool() const { - return top != 0.0 || bottom != 0.0; + return top_left != 0.0 || top_right != 0.0 || bottom_left != 0.0 || bottom_right != 0.0; } }; diff --git a/src/components/bar.cpp b/src/components/bar.cpp index 4fdfbce5..4ce27a40 100644 --- a/src/components/bar.cpp +++ b/src/components/bar.cpp @@ -161,8 +161,12 @@ bar::bar(connection& conn, signal_emitter& emitter, const config& config, const m_opts.locale = m_conf.get(bs, "locale", ""s); auto radius = m_conf.get(bs, "radius", 0.0); - m_opts.radius.top = m_conf.get(bs, "radius-top", radius); - m_opts.radius.bottom = m_conf.get(bs, "radius-bottom", radius); + auto top = m_conf.get(bs, "radius-top", radius); + m_opts.radius.top_left = m_conf.get(bs, "radius-top-left", top); + m_opts.radius.top_right = m_conf.get(bs, "radius-top-right", top); + auto bottom = m_conf.get(bs, "radius-bottom", radius); + m_opts.radius.bottom_left = m_conf.get(bs, "radius-bottom-left", bottom); + m_opts.radius.bottom_right = m_conf.get(bs, "radius-bottom-right", bottom); auto padding = m_conf.get(bs, "padding", 0U); m_opts.padding.left = m_conf.get(bs, "padding-left", padding);