From dc2adb634b6af7e2b4dc78881c4c8a14f05af2de Mon Sep 17 00:00:00 2001 From: BZ Date: Thu, 25 Jun 2020 14:35:19 +0200 Subject: [PATCH] add option for anti-aliased rounded corners --- README.md | 4 ++-- init.lua | 26 +++++++++++++++++++++++--- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 88980d0..9deb77e 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ Features: - Full titlebar functionality without sacrificing space - Improved mouse controls - Custom client menu +- Anti-aliased rounded corners - Various configuration options - Easy installation @@ -53,6 +54,7 @@ Customization: | `button_positions` | { "top" } | button positions | | `buttons` | { "floating", "minimize", "maximize", "close" } | possible values: { "floating", "minimize", "maximize", "close", "sticky", "top" } | | `border_width` | dpi(6) | width of border | +| `rounded_corner` | dpi(0) | border radius of rounded corners | | `show_button_tooltips` | false | show a tooltip on button mouse over | | `show_title_tooltips` | false | show a tooltip of client title on border mouse over (might cause issues when sloppy focus mode (focus follows mouse) is enabled) | | `align_horizontal` | "right" | alignment of buttons on top and bottom positions. possible values: { "left", "center", "right" } | @@ -102,7 +104,6 @@ require("smart_borders"){ buttons = { "floating", "minimize", "maximize", "close" }, layout = "fixed", - button_ratio = 0.3, align_horizontal = "center", button_size = 40, button_floating_size = 60, @@ -154,4 +155,3 @@ require("smart_borders"){ } ``` - diff --git a/init.lua b/init.lua index c736335..f94655a 100644 --- a/init.lua +++ b/init.lua @@ -135,11 +135,26 @@ function module.menu_client(c) return list end + +local rounded_corner_shape = function(radius, position) + if position == "bottom" then + return function(cr, width, height) + gears.shape.partially_rounded_rect(cr, width, height, false, false, true, true, radius) + end + elseif position == "top" then + return function(cr, width, height) + gears.shape.partially_rounded_rect(cr, width, height, true, true, false, false, radius) + end + end + return nil +end + local function new(config) local cfg = config or {} local positions = cfg.positions or { "left", "right", "top", "bottom" } local button_positions = cfg.button_positions or { "top" } local border_width = cfg.border_width or dpi(6) + local rounded_corner = cfg.rounded_corner or nil local color_normal = cfg.color_normal or "#56666f" local color_focus = cfg.color_focus or "#a1bfcf" @@ -375,7 +390,8 @@ local function new(config) for _, pos in pairs(positions) do local tb = awful.titlebar(c, { size = border_width, - position = pos + position = pos, + bg = "#00000000" }) local btn_layout @@ -429,7 +445,9 @@ local function new(config) tb:setup{ titlebar_widget, - layout = wibox.layout.stack + bg = "#00000000", + shape = rounded_corner and rounded_corner_shape(rounded_corner, pos) or nil, + widget = wibox.container.background() } local ratio_button_layout = wibox.widget.base.make_widget_declarative({ @@ -521,7 +539,9 @@ local function new(config) else tb:setup{ border_bg, - layout = wibox.layout.stack + bg = "#00000000", + shape = rounded_corner and rounded_corner_shape(rounded_corner, pos) or nil, + widget = wibox.container.background } end end