feat(conf): Properties for top/bottom radius #445

This commit is contained in:
Michael Carlberg 2017-03-21 14:49:33 +01:00
parent e303f5248a
commit f3089e88f2
5 changed files with 21 additions and 11 deletions

View File

@ -130,13 +130,12 @@ namespace cairo {
}
context& operator<<(const rounded_corners& c) {
double radius = c.radius / 1.0;
double d = M_PI / 180.0;
cairo_new_sub_path(m_c);
cairo_arc(m_c, c.x + c.w - radius, c.y + radius, radius, -90 * d, 0 * d);
cairo_arc(m_c, c.x + c.w - radius, c.y + c.h - radius, radius, 0 * d, 90 * d);
cairo_arc(m_c, c.x + radius, c.y + c.h - radius, radius, 90 * d, 180 * d);
cairo_arc(m_c, c.x + radius, c.y + radius, radius, 180 * d, 270 * d);
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_close_path(m_c);
return *this;
}

View File

@ -3,6 +3,7 @@
#include <cairo/cairo.h>
#include "common.hpp"
#include "components/types.hpp"
POLYBAR_NS
@ -51,7 +52,7 @@ namespace cairo {
double y;
double w;
double h;
double radius;
struct radius radius;
};
struct textblock {
alignment align;

View File

@ -78,6 +78,15 @@ struct edge_values {
unsigned int bottom{0U};
};
struct radius {
double top{0.0};
double bottom{0.0};
operator bool() const {
return top != 0.0 || bottom != 0.0;
}
};
struct border_settings {
unsigned int color{0xFF000000};
unsigned int size{0U};
@ -135,7 +144,7 @@ struct bar_settings {
std::unordered_map<edge, border_settings, enum_hash> borders{};
double radius{0.0};
struct radius radius {};
int spacing{0};
string separator{};

View File

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

View File

@ -215,7 +215,7 @@ void renderer::begin(xcb_rectangle_t rect) {
m_context->clear();
// Create corner mask
if (m_bar.radius != 0.0 && m_cornermask == nullptr) {
if (m_bar.radius && m_cornermask == nullptr) {
m_context->save();
m_context->push();
// clang-format off