1
0
Fork 0
mirror of https://github.com/polybar/polybar.git synced 2024-11-11 13:50:56 -05:00

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) { context& operator<<(const rounded_corners& c) {
double radius = c.radius / 1.0;
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 - radius, c.y + radius, radius, -90 * d, 0 * 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 - radius, c.y + c.h - radius, radius, 0 * d, 90 * 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 + radius, c.y + c.h - radius, radius, 90 * d, 180 * 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 + radius, c.y + radius, radius, 180 * d, 270 * 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); cairo_close_path(m_c);
return *this; return *this;
} }

View file

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

View file

@ -78,6 +78,15 @@ struct edge_values {
unsigned int bottom{0U}; 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 { struct border_settings {
unsigned int color{0xFF000000}; unsigned int color{0xFF000000};
unsigned int size{0U}; unsigned int size{0U};
@ -135,7 +144,7 @@ struct bar_settings {
std::unordered_map<edge, border_settings, enum_hash> borders{}; std::unordered_map<edge, border_settings, enum_hash> borders{};
double radius{0.0}; struct radius radius {};
int spacing{0}; int spacing{0};
string separator{}; 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.spacing = m_conf.get(bs, "spacing", m_opts.spacing);
m_opts.separator = m_conf.get(bs, "separator", ""s); m_opts.separator = m_conf.get(bs, "separator", ""s);
m_opts.locale = m_conf.get(bs, "locale", ""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); 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.left = m_conf.get(bs, "padding-left", padding);
m_opts.padding.right = m_conf.get(bs, "padding-right", 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(); m_context->clear();
// Create corner mask // Create corner mask
if (m_bar.radius != 0.0 && m_cornermask == nullptr) { if (m_bar.radius && m_cornermask == nullptr) {
m_context->save(); m_context->save();
m_context->push(); m_context->push();
// clang-format off // clang-format off