mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-20 15:35:03 +02:00
Finish porting of borders and layout
This commit is contained in:
@@ -11,20 +11,20 @@ from .fast_data_types import (
|
||||
from .utils import color_as_int, load_shaders, pt_to_px
|
||||
|
||||
|
||||
def vertical_edge(color, width, top, bottom, left):
|
||||
add_borders_rect(left, top, left + width, bottom, color)
|
||||
def vertical_edge(os_window_id, tab_id, color, width, top, bottom, left):
|
||||
add_borders_rect(os_window_id, tab_id, left, top, left + width, bottom, color)
|
||||
|
||||
|
||||
def horizontal_edge(color, height, left, right, top):
|
||||
add_borders_rect(left, top, right, top + height, color)
|
||||
def horizontal_edge(os_window_id, tab_id, color, height, left, right, top):
|
||||
add_borders_rect(os_window_id, tab_id, left, top, right, top + height, color)
|
||||
|
||||
|
||||
def edge(func, color, sz, a, b):
|
||||
return partial(func, color, sz, a, b)
|
||||
def edge(func, os_window_id, tab_id, color, sz, a, b):
|
||||
return partial(func, os_window_id, tab_id, color, sz, a, b)
|
||||
|
||||
|
||||
def border(color, sz, left, top, right, bottom):
|
||||
horz = edge(horizontal_edge, color, sz, left, right)
|
||||
def border(os_window_id, tab_id, color, sz, left, top, right, bottom):
|
||||
horz = edge(horizontal_edge, os_window_id, tab_id, color, sz, left, right)
|
||||
horz(top), horz(bottom - sz) # top, bottom edges
|
||||
vert = edge(vertical_edge, color, sz, top, bottom)
|
||||
vert(left), vert(right - sz) # left, right edges
|
||||
@@ -32,11 +32,17 @@ def border(color, sz, left, top, right, bottom):
|
||||
|
||||
class Borders:
|
||||
|
||||
def __init__(self, opts):
|
||||
program_initialized = False
|
||||
|
||||
def __init__(self, os_window_id, tab_id, opts):
|
||||
self.os_window_id = os_window_id
|
||||
self.tab_id = tab_id
|
||||
self.border_width = pt_to_px(opts.window_border_width)
|
||||
self.padding_width = pt_to_px(opts.window_padding_width)
|
||||
compile_program(BORDERS_PROGRAM, *load_shaders('border'))
|
||||
init_borders_program()
|
||||
if not Borders.program_initialized:
|
||||
compile_program(BORDERS_PROGRAM, *load_shaders('border'))
|
||||
init_borders_program()
|
||||
Borders.program_initialized = True
|
||||
self.background = color_as_int(opts.background)
|
||||
self.active_border = color_as_int(opts.active_border_color)
|
||||
self.inactive_border = color_as_int(opts.inactive_border_color)
|
||||
@@ -49,9 +55,9 @@ class Borders:
|
||||
extra_blank_rects,
|
||||
draw_window_borders=True
|
||||
):
|
||||
add_borders_rect(0, 0, 0, 0, 0)
|
||||
add_borders_rect(self.os_window_id, self.tab_id, 0, 0, 0, 0, 0)
|
||||
for br in chain(current_layout.blank_rects, extra_blank_rects):
|
||||
add_borders_rect(*br, self.background)
|
||||
add_borders_rect(self.os_window_id, self.tab_id, *br, self.background)
|
||||
bw, pw = self.border_width, self.padding_width
|
||||
fw = bw + pw
|
||||
|
||||
@@ -62,6 +68,7 @@ class Borders:
|
||||
# Draw the border rectangles
|
||||
color = self.active_border if w is active_window else self.inactive_border
|
||||
border(
|
||||
self.os_window_id, self.tab_id,
|
||||
color, bw, g.left - fw, g.top - fw, g.right + fw,
|
||||
g.bottom + fw
|
||||
)
|
||||
@@ -69,6 +76,7 @@ class Borders:
|
||||
# Draw the background rectangles over the padding region
|
||||
color = self.background
|
||||
border(
|
||||
self.os_window_id, self.tab_id,
|
||||
color, pw, g.left - pw, g.top - pw, g.right + pw,
|
||||
g.bottom + pw
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user