Skip to content

Commit bcaad93

Browse files
author
void
committed
dd target/window/slice=overlay
FossilOrigin-Name: e6b4d0691a38ebb949fa3306b52458145f4d6671108fe3afa7d257b9f2298a28
1 parent 12dbbe9 commit bcaad93

File tree

3 files changed

+52
-22
lines changed

3 files changed

+52
-22
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# 0.7.0 (ongoing):
22

3+
* reworked initial setup to query preferences
4+
35
* global/audio extended with toggles for spatial audio and device reassignment
46

57
* new tool: typer (global/input/text)
@@ -86,6 +88,8 @@ minor:
8688

8789
* overlay tool updated to respect statusbar size and side orientations
8890

91+
* added slice to overlay tool option for window slicing
92+
8993
* default HUD sort order split into two, one for browse/ and one for other paths
9094

9195
* dropped 'simple' display mode in favor of the direct scanout control

durden/menus/target/window.lua

+16-1
Original file line numberDiff line numberDiff line change
@@ -1092,13 +1092,21 @@ return {
10921092
label = "Slice",
10931093
kind = "value",
10941094
description = "Slice out a window canvas region into a new window",
1095-
set = {"Active", "Passive", "Active-Dynamic", "Passive-Dynamic"},
1095+
set = function()
1096+
local res =
1097+
{"Active", "Passive", "Active-Dynamic", "Passive-Dynamic"}
1098+
if tools_overlay_add then
1099+
table.insert(res, "Overlay")
1100+
end
1101+
return res
1102+
end,
10961103
eval = function() return not mouse_blocked(); end,
10971104
external_block = true,
10981105
handler = function(ctx, val)
10991106
local wnd = active_display().selected;
11001107
local dyn = val == "Active-Dynamic" or val == "Passive-Dynamic"
11011108
local act = val == "Active" or val == "Active-Dynamic"
1109+
local olay = val == "Overlay"
11021110

11031111
suppl_wnd_slice(active_display().selected,
11041112
function(cwin, t, l, d, r, w, h)
@@ -1113,6 +1121,13 @@ return {
11131121
-- the crop region accordingly so that it is centered around the mouse
11141122
-- cursor
11151123
setup_slice_wnd(cwin, wnd, dyn, w, h);
1124+
1125+
if olay then
1126+
local vid = null_surface(32, 32)
1127+
image_sharestorage(cwin.canvas, vid)
1128+
cwin:destroy()
1129+
tools_overlay_add(vid, wnd)
1130+
end
11161131
end);
11171132
end
11181133
},

durden/tools/overlay.lua

+32-21
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ local function relayout()
4141
local hr = props.height/ maxh;
4242
local outw = hr > wr and maxh * ar or maxw;
4343
local outh = hr < wr and maxw / ar or maxh;
44-
shader_setup(active[i].vid, "simple", gconfig_get("overlay_shader"));
44+
shader_setup(active[i].vid,
45+
gconfig_get("overlay_shader_group"), gconfig_get("overlay_shader"), "active");
4546
resize_image(active[i].vid, outw, outh);
4647
move_image(active[i].vid, cx, cy);
4748
cy = cy + outh;
@@ -62,22 +63,14 @@ local function delete_overlay(ind)
6263
relayout();
6364
end
6465

65-
local function add_overlay(wnd)
66-
-- don't permit overallocation of space
67-
if (#active >= math.floor(1.0 / gconfig_get("overlay_size"))) then
68-
return;
69-
end
70-
71-
-- can't assume there's VIDs left
72-
local overlay = null_surface(wnd.width, wnd.height);
73-
if (not valid_vid(overlay)) then
74-
return;
75-
end
76-
66+
-- slightly ugly layering violation, target/slice has a set of options and we
67+
-- have no way of appending ourselves to that, so the slice handler checks if
68+
-- this tool is there and, if so, exposes it that way.
69+
function tools_overlay_add(vid, wnd)
7770
local new = {
7871
name = "overlay_hnd",
79-
vid = overlay,
80-
own = function(ctx, vid) return vid == overlay; end,
72+
vid = vid,
73+
own = function(ctx, v) return v == vid; end,
8174
-- on click, locate source window and switch to that one (if alive)
8275
click = function()
8376
for i,v in ipairs(active_display().windows) do
@@ -89,24 +82,41 @@ local function add_overlay(wnd)
8982
end
9083
end,
9184
over = function()
92-
blend_image(overlay, 1.0);
85+
blend_image(vid, 1.0);
9386
end,
9487
out = function()
95-
blend_image(overlay, gconfig_get("overlay_opacity"));
88+
blend_image(vid, gconfig_get("overlay_opacity"));
9689
end,
9790
};
9891

9992
-- share the backend, append and place/show
10093
mouse_addlistener(new, {"click", "over", "out"});
101-
image_sharestorage(wnd.canvas, overlay);
94+
10295
table.insert(active, new);
103-
show_image(overlay);
96+
show_image(vid);
10497
relayout();
10598
end
10699

100+
local function add_overlay(wnd)
101+
-- don't permit overallocation of space
102+
if (#active >= math.floor(1.0 / gconfig_get("overlay_size"))) then
103+
return;
104+
end
105+
106+
-- can't assume there's VIDs left
107+
local overlay = null_surface(wnd.width, wnd.height);
108+
if (not valid_vid(overlay)) then
109+
return;
110+
end
111+
112+
image_sharestorage(wnd.canvas, overlay);
113+
tools_overlay_add(overlay, wnd)
114+
end
115+
107116
-- config system hooks so the values get saved
108117
gconfig_register("overlay_opacity", 1.0);
109118
gconfig_register("overlay_corner", "left");
119+
gconfig_register("overlay_shader_group", "simple");
110120
gconfig_register("overlay_shader", "noalpha");
111121
gconfig_register("overlay_size", 0.1);
112122

@@ -154,10 +164,11 @@ local overlay_cfg = {
154164
return gconfig_get("overlay_shader");
155165
end,
156166
set = function()
157-
return shader_list({"effect", "simple"});
167+
return shader_list({"effect", "simple", "ui"});
158168
end,
159169
handler = function(ctx, val)
160-
local key, dom = shader_getkey(val, {"effect", "simple"});
170+
local key, dom = shader_getkey(val, {"effect", "simple", "ui"});
171+
gconfig_set("overlay_shader_group", dom);
161172
gconfig_set("overlay_shader", key);
162173
end
163174
},

0 commit comments

Comments
 (0)