Highlight links with a underline on mouseover
This commit is contained in:
+11
-3
@@ -4,6 +4,7 @@ uniform vec4 steps; // xstart, ystart, dx, dy
|
||||
uniform vec2 sprite_layout; // dx, dy
|
||||
uniform ivec2 color_indices; // which color to use as fg and which as bg
|
||||
uniform uvec4 default_colors; // The default colors
|
||||
uniform uvec4 url_range; // The range for the currently highlighted URL (start_x, end_x, start_y, end_y)
|
||||
uniform ColorTable {
|
||||
uint color_table[256]; // The color table
|
||||
};
|
||||
@@ -71,10 +72,16 @@ vec3 apply_selection(vec3 color, uint which) {
|
||||
return is_selected * color_to_vec(which) + (1.0 - is_selected) * color;
|
||||
}
|
||||
|
||||
uint in_range(uvec4 range, uint x, uint y) {
|
||||
if (range[0] <= x && x <= range[1] && range[2] <= y && y <= range[3]) return ONE;
|
||||
return ZERO;
|
||||
}
|
||||
|
||||
void main() {
|
||||
uint instance_id = uint(gl_InstanceID);
|
||||
uint r = instance_id / dimensions.x;
|
||||
uint c = instance_id - r * dimensions.x;
|
||||
uint in_url = in_range(url_range, c, r);
|
||||
float left = steps[0] + c * steps[2];
|
||||
float top = steps[1] - r * steps[3];
|
||||
vec2 xpos = vec2(left, left + steps[2]);
|
||||
@@ -87,10 +94,11 @@ void main() {
|
||||
uint fg = colors[color_indices[reverse]];
|
||||
uint bg = colors[color_indices[ONE - reverse]];
|
||||
uint resolved_fg = as_color(fg, default_colors[color_indices[0]]);
|
||||
uint decoration = colors[2];
|
||||
uint underline;
|
||||
foreground = apply_selection(color_to_vec(resolved_fg), default_colors[2]);
|
||||
background = apply_selection(to_color(bg, default_colors[color_indices[1]]), default_colors[3]);
|
||||
decoration_fg = to_color(decoration, resolved_fg);
|
||||
underline_pos = to_sprite_pos(pos, (text_attrs >> 26) & DECORATION_MASK, ZERO, ZERO);
|
||||
if (in_url == ONE) { underline = ONE; decoration_fg = color_to_vec(uint(255)); }
|
||||
else { underline = (text_attrs >> 26) & DECORATION_MASK; decoration_fg = to_color(colors[2], resolved_fg); }
|
||||
underline_pos = to_sprite_pos(pos, underline, ZERO, ZERO);
|
||||
strike_pos = to_sprite_pos(pos, ((text_attrs >> 31) & STRIKE_MASK) * THREE, ZERO, ZERO);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user