feat(conf) Properties for {bottom,top}-{left,right} radius

This commit is contained in:
Bjoern Hiller 2020-10-21 09:02:52 +02:00 committed by Patrick Ziegler
parent 7493639889
commit 7c662ec44f
3 changed files with 15 additions and 9 deletions

View File

@ -118,10 +118,10 @@ namespace cairo {
context& operator<<(const rounded_corners& c) { context& operator<<(const rounded_corners& c) {
double d = M_PI / 180.0; double d = M_PI / 180.0;
cairo_new_sub_path(m_c); 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.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, c.y + c.h - c.radius.bottom, c.radius.bottom, 0 * d, 90 * 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, c.y + c.h - c.radius.bottom, c.radius.bottom, 90 * d, 180 * 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, c.y + c.radius.top, c.radius.top, 180 * d, 270 * 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); cairo_close_path(m_c);
return *this; return *this;
} }

View File

@ -98,11 +98,13 @@ struct edge_values {
}; };
struct radius { struct radius {
double top{0.0}; double top_left{0.0};
double bottom{0.0}; double top_right{0.0};
double bottom_left{0.0};
double bottom_right{0.0};
operator bool() const { 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;
} }
}; };

View File

@ -161,8 +161,12 @@ bar::bar(connection& conn, signal_emitter& emitter, const config& config, const
m_opts.locale = m_conf.get(bs, "locale", ""s); m_opts.locale = m_conf.get(bs, "locale", ""s);
auto radius = m_conf.get<double>(bs, "radius", 0.0); auto radius = m_conf.get<double>(bs, "radius", 0.0);
m_opts.radius.top = m_conf.get(bs, "radius-top", radius); auto top = m_conf.get(bs, "radius-top", radius);
m_opts.radius.bottom = m_conf.get(bs, "radius-bottom", 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<unsigned int>(bs, "padding", 0U); auto padding = m_conf.get<unsigned int>(bs, "padding", 0U);
m_opts.padding.left = m_conf.get(bs, "padding-left", padding); m_opts.padding.left = m_conf.get(bs, "padding-left", padding);