integration

This commit is contained in:
Xinhao Yuan 2019-07-06 17:06:14 -04:00
parent 3251f3fba7
commit 745c7cd769
2 changed files with 46 additions and 36 deletions

View File

@ -7,18 +7,24 @@ local api = {
keygrabber = require("awful.keygrabber"), keygrabber = require("awful.keygrabber"),
naughty = require("naughty"), naughty = require("naughty"),
gears = require("gears"), gears = require("gears"),
lgi = require("lgi"),
dpi = require("beautiful.xresources").apply_dpi, dpi = require("beautiful.xresources").apply_dpi,
} }
local function with_alpha(col, alpha)
_, r, g, b, a = col:get_rgba()
return api.lgi.cairo.SolidPattern.create_rgba(r, g, b, alpha)
end
local label_font_family = api.beautiful.get_font( local label_font_family = api.beautiful.get_font(
api.beautiful.mono_font or api.beautiful.font):get_family() api.beautiful.mono_font or api.beautiful.font):get_family()
local label_size = api.dpi(30) local label_size = api.dpi(30)
local info_size = api.dpi(60) local info_size = api.dpi(60)
-- colors are in rgba -- colors are in rgba
local border_color = "#ffffffc0" local border_color = with_alpha(api.gears.color(api.beautiful.border_focus), 0.75)
local active_color = "#6c7ea780" local active_color = with_alpha(api.gears.color(api.beautiful.bg_focus), 0.5)
local open_color = "#00000080" local open_color = with_alpha(api.gears.color(api.beautiful.bg_normal), 0.5)
local closed_color = "#00000080" local closed_color = open_color
local init_max_depth = 2 local init_max_depth = 2
local function is_tiling(c) local function is_tiling(c)
@ -409,10 +415,10 @@ local function create(data)
local sa = shrink_area_with_gap(a, gap) local sa = shrink_area_with_gap(a, gap)
cr:rectangle(sa.x, sa.y, sa.width, sa.height) cr:rectangle(sa.x, sa.y, sa.width, sa.height)
cr:clip() cr:clip()
cr:set_source(api.gears.color(closed_color)) cr:set_source(closed_color)
cr:rectangle(sa.x, sa.y, sa.width, sa.height) cr:rectangle(sa.x, sa.y, sa.width, sa.height)
cr:fill() cr:fill()
cr:set_source(api.gears.color(border_color)) cr:set_source(border_color)
cr:rectangle(sa.x, sa.y, sa.width, sa.height) cr:rectangle(sa.x, sa.y, sa.width, sa.height)
cr:set_line_width(10.0) cr:set_line_width(10.0)
cr:stroke() cr:stroke()
@ -431,7 +437,7 @@ local function create(data)
cr:rectangle(sa.x, sa.y, sa.width, sa.height) cr:rectangle(sa.x, sa.y, sa.width, sa.height)
cr:fill() cr:fill()
cr:set_source(api.gears.color(border_color)) cr:set_source(border_color)
cr:rectangle(sa.x, sa.y, sa.width, sa.height) cr:rectangle(sa.x, sa.y, sa.width, sa.height)
cr:set_line_width(10.0) cr:set_line_width(10.0)
if i ~= #open_areas then if i ~= #open_areas then

View File

@ -7,14 +7,20 @@ local api = {
keygrabber = require("awful.keygrabber"), keygrabber = require("awful.keygrabber"),
naughty = require("naughty"), naughty = require("naughty"),
gears = require("gears"), gears = require("gears"),
lgi = require("lgi"),
dpi = require("beautiful.xresources").apply_dpi, dpi = require("beautiful.xresources").apply_dpi,
} }
local function with_alpha(col, alpha)
_, r, g, b, a = col:get_rgba()
return api.lgi.cairo.SolidPattern.create_rgba(r, g, b, alpha)
end
local label_font_family = api.beautiful.get_font( local label_font_family = api.beautiful.get_font(
api.beautiful.mono_font or api.beautiful.font):get_family() api.beautiful.mono_font or api.beautiful.font):get_family()
local label_size = api.dpi(30) local label_size = api.dpi(30)
local border_color = "#ffffff80" local border_color = with_alpha(api.gears.color(api.beautiful.border_focus), 0.75)
local fill_color = "#00000040" local fill_color = with_alpha(api.gears.color(api.beautiful.bg_normal), 0.5)
-- for comparing floats -- for comparing floats
local threshold = 0.1 local threshold = 0.1
@ -37,8 +43,8 @@ local function start(c)
}) })
infobox.visible = true infobox.visible = true
local traverse_x = c.x + c.width / 2 local traverse_x = c.x
local traverse_y = c.y + c.height / 2 local traverse_y = c.y
local function draw_info(context, cr, width, height) local function draw_info(context, cr, width, height)
cr:set_source_rgba(0, 0, 0, 0) cr:set_source_rgba(0, 0, 0, 0)
@ -47,36 +53,34 @@ local function start(c)
local msg, ext local msg, ext
for i, a in ipairs(regions) do for i, a in ipairs(regions) do
if i ~= c.machi_region then
cr:rectangle(a.x, a.y, a.width, a.height) cr:rectangle(a.x, a.y, a.width, a.height)
cr:clip() cr:clip()
cr:set_source(api.gears.color(fill_color)) -- cr:set_source(fill_color)
cr:rectangle(a.x, a.y, a.width, a.height) -- cr:rectangle(a.x, a.y, a.width, a.height)
cr:fill() -- cr:fill()
cr:set_source(api.gears.color(border_color)) cr:set_source(border_color)
cr:rectangle(a.x, a.y, a.width, a.height) cr:rectangle(a.x, a.y, a.width, a.height)
cr:set_line_width(10.0) cr:set_line_width(10.0)
cr:stroke() cr:stroke()
cr:reset_clip() cr:reset_clip()
cr:select_font_face(label_font_family, "normal", "normal") -- cr:select_font_face(label_font_family, "normal", "normal")
cr:set_font_size(label_size) -- cr:set_font_size(label_size)
cr:set_font_face(cr:get_font_face()) -- cr:set_font_face(cr:get_font_face())
msg = tostring(i) -- msg = tostring(i)
ext = cr:text_extents(msg) -- ext = cr:text_extents(msg)
cr:move_to(a.x + a.width / 2 - ext.width / 2 - ext.x_bearing, a.y + a.height / 2 - ext.height / 2 - ext.y_bearing) -- cr:move_to(a.x + a.width / 2 - ext.width / 2 - ext.x_bearing, a.y + a.height / 2 - ext.height / 2 - ext.y_bearing)
cr:text_path(msg) -- cr:text_path(msg)
cr:set_source_rgba(1, 1, 1, 1)
cr:fill()
end
end
-- -- show the traverse point
-- cr:rectangle(traverse_x - api.dpi(5), traverse_y - api.dpi(5), api.dpi(10), api.dpi(10))
-- cr:set_source_rgba(1, 1, 1, 1) -- cr:set_source_rgba(1, 1, 1, 1)
-- cr:fill() -- cr:fill()
end end
-- show the traverse point
cr:rectangle(traverse_x - api.dpi(5), traverse_y - api.dpi(5), api.dpi(10), api.dpi(10))
cr:set_source_rgba(1, 1, 1, 1)
cr:fill()
end
infobox.bgimage = draw_info infobox.bgimage = draw_info
local kg local kg