summaryrefslogtreecommitdiff
path: root/buffer.c
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2021-01-06 17:36:07 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2021-01-06 17:36:07 -0500
commit132dcb648981050990e34a44925e6b54d0dc008c (patch)
tree7a41a97308b1921c62d2f5afd12c7cf475f14247 /buffer.c
parent9e055b2e25455fc4fa0376495ccc9335059f3131 (diff)
more open menu, border thickness setting, fixed small text clipping issue
Diffstat (limited to 'buffer.c')
-rw-r--r--buffer.c36
1 files changed, 22 insertions, 14 deletions
diff --git a/buffer.c b/buffer.c
index 3445595..f86eeaa 100644
--- a/buffer.c
+++ b/buffer.c
@@ -1603,10 +1603,13 @@ void buffer_render(TextBuffer *buffer, float x1, float y1, float x2, float y2) {
float char_width = text_font_char_width(font),
char_height = text_font_char_height(font);
float header_height = char_height;
+
Ted *ted = buffer->ted;
Settings *settings = buffer_settings(buffer);
u32 *colors = settings->colors;
+ float border_thickness = settings->border_thickness;
+
// get screen coordinates of cursor
v2 cursor_display_pos = buffer_pos_to_pixels(buffer, buffer->cursor_pos);
// the rectangle that the cursor is rendered as
@@ -1614,15 +1617,15 @@ void buffer_render(TextBuffer *buffer, float x1, float y1, float x2, float y2) {
u32 border_color = colors[COLOR_BORDER]; // color of border around buffer
- // bounding box around buffer & header
+ // bounding box around buffer
+ glBegin(GL_QUADS);
gl_color_rgba(border_color);
- glBegin(GL_LINE_STRIP);
- glVertex2f(x1,y1);
- glVertex2f(x1,y2);
- glVertex2f(x2,y2);
- glVertex2f(x2,y1);
- glVertex2f(x1-1,y1);
+ rect_render_border(rect4(x1, y1, x2, y2), border_thickness);
glEnd();
+ x1 += border_thickness * 0.5f;
+ y1 += border_thickness * 0.5f;
+ x2 -= border_thickness * 0.5f;
+ y2 -= border_thickness * 0.5f;
TextRenderState text_state = {
.x = 0, .y = 0,
@@ -1645,17 +1648,22 @@ void buffer_render(TextBuffer *buffer, float x1, float y1, float x2, float y2) {
x = x2 - checksum_w;
text_render_with_state(font, &text_state, checksum, x, y);
#endif
+
+ y1 += header_height + 0.5f * border_thickness;
+
+ // line separating header from buffer proper
+ glBegin(GL_QUADS);
+ gl_color_rgba(border_color);
+ glVertex2f(x1, y1 - 0.5f * border_thickness);
+ glVertex2f(x2, y1 - 0.5f * border_thickness);
+ glVertex2f(x2, y1 + 0.5f * border_thickness);
+ glVertex2f(x1, y1 + 0.5f * border_thickness);
+ glEnd();
+ y1 += 0.5f * border_thickness;
}
- y1 += header_height;
buffer->x1 = x1; buffer->y1 = y1; buffer->x2 = x2; buffer->y2 = y2;
- // line separating header from buffer proper
- glBegin(GL_LINES);
- gl_color_rgba(border_color);
- glVertex2f(x1, y1);
- glVertex2f(x2, y1);
- glEnd();
// highlight line cursor is on