Proper fix for not drawing blank rects when bg image is present

This commit is contained in:
Kovid Goyal 2020-02-02 20:20:45 +05:30
parent 5b4e0ed483
commit 75c47a8659
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 17 additions and 4 deletions

View File

@ -5,7 +5,8 @@
from itertools import chain
from .fast_data_types import (
BORDERS_PROGRAM, add_borders_rect, compile_program, init_borders_program
BORDERS_PROGRAM, add_borders_rect, compile_program, init_borders_program,
os_window_has_background_image
)
from .utils import load_shaders
@ -63,8 +64,10 @@ class Borders:
draw_window_borders=True,
):
add_borders_rect(self.os_window_id, self.tab_id, 0, 0, 0, 0, BorderColor.default_bg)
for br in chain(current_layout.blank_rects, extra_blank_rects):
add_borders_rect(self.os_window_id, self.tab_id, *br, BorderColor.default_bg)
has_background_image = os_window_has_background_image(self.os_window_id)
if not has_background_image:
for br in chain(current_layout.blank_rects, extra_blank_rects):
add_borders_rect(self.os_window_id, self.tab_id, *br, BorderColor.default_bg)
bw, pw = self.border_width, self.padding_width
if bw + pw <= 0:
return
@ -85,7 +88,7 @@ class Borders:
colors = tuple(color if needed else window_bg for needed in next(border_data))
draw_edges(
self.os_window_id, self.tab_id, colors, bw, g, base_width=pw)
if pw > 0:
if pw > 0 and not has_background_image:
# Draw the background rectangles over the padding region
colors = (window_bg, window_bg, window_bg, window_bg)
draw_edges(

View File

@ -714,6 +714,15 @@ end:
}
PYWRAP1(os_window_has_background_image) {
id_type os_window_id;
PA("K", &os_window_id);
WITH_OS_WINDOW(os_window_id)
if (os_window->bgimage && os_window->bgimage->texture_id > 0) { Py_RETURN_TRUE; }
END_WITH_OS_WINDOW
Py_RETURN_FALSE;
}
PYWRAP1(mark_os_window_for_close) {
id_type os_window_id;
int yes = 1;
@ -990,6 +999,7 @@ static PyMethodDef module_methods[] = {
MW(set_window_render_data, METH_VARARGS),
MW(viewport_for_window, METH_VARARGS),
MW(cell_size_for_window, METH_VARARGS),
MW(os_window_has_background_image, METH_VARARGS),
MW(mark_os_window_for_close, METH_VARARGS),
MW(set_titlebar_color, METH_VARARGS),
MW(focus_os_window, METH_VARARGS),