@@ -41,7 +41,8 @@ local function relayout()
41
41
local hr = props .height / maxh ;
42
42
local outw = hr > wr and maxh * ar or maxw ;
43
43
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" );
45
46
resize_image (active [i ].vid , outw , outh );
46
47
move_image (active [i ].vid , cx , cy );
47
48
cy = cy + outh ;
@@ -62,22 +63,14 @@ local function delete_overlay(ind)
62
63
relayout ();
63
64
end
64
65
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 )
77
70
local new = {
78
71
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 ,
81
74
-- on click, locate source window and switch to that one (if alive)
82
75
click = function ()
83
76
for i ,v in ipairs (active_display ().windows ) do
@@ -89,24 +82,41 @@ local function add_overlay(wnd)
89
82
end
90
83
end ,
91
84
over = function ()
92
- blend_image (overlay , 1.0 );
85
+ blend_image (vid , 1.0 );
93
86
end ,
94
87
out = function ()
95
- blend_image (overlay , gconfig_get (" overlay_opacity" ));
88
+ blend_image (vid , gconfig_get (" overlay_opacity" ));
96
89
end ,
97
90
};
98
91
99
92
-- share the backend, append and place/show
100
93
mouse_addlistener (new , {" click" , " over" , " out" });
101
- image_sharestorage ( wnd . canvas , overlay );
94
+
102
95
table.insert (active , new );
103
- show_image (overlay );
96
+ show_image (vid );
104
97
relayout ();
105
98
end
106
99
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
+
107
116
-- config system hooks so the values get saved
108
117
gconfig_register (" overlay_opacity" , 1.0 );
109
118
gconfig_register (" overlay_corner" , " left" );
119
+ gconfig_register (" overlay_shader_group" , " simple" );
110
120
gconfig_register (" overlay_shader" , " noalpha" );
111
121
gconfig_register (" overlay_size" , 0.1 );
112
122
@@ -154,10 +164,11 @@ local overlay_cfg = {
154
164
return gconfig_get (" overlay_shader" );
155
165
end ,
156
166
set = function ()
157
- return shader_list ({" effect" , " simple" });
167
+ return shader_list ({" effect" , " simple" , " ui " });
158
168
end ,
159
169
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 );
161
172
gconfig_set (" overlay_shader" , key );
162
173
end
163
174
},
0 commit comments