aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack Jamison <jackqjamison@gmail.com>2025-10-17 19:58:35 -0400
committerJack Jamison <jackqjamison@gmail.com>2025-10-17 19:59:26 -0400
commit42af50b090f03e920368de3fd6872cf5b62c918e (patch)
treedc032a7e20f35e96b45fec80b3287ade868af6b8
parent3e6eeaaf599f1082c02279bb9269de9644cdfab3 (diff)
fix spacing and sizing and shit
-rw-r--r--config.h8
-rw-r--r--font.c1
-rw-r--r--graphics.c14
-rw-r--r--layer_surface.c4
-rw-r--r--state.h2
5 files changed, 20 insertions, 9 deletions
diff --git a/config.h b/config.h
new file mode 100644
index 0000000..3f304d5
--- /dev/null
+++ b/config.h
@@ -0,0 +1,8 @@
+#ifndef CONFIG_H_
+#define CONFIG_H_
+
+#include <stdint.h>
+
+const uint32_t min_width = 600;
+
+#endif
diff --git a/font.c b/font.c
index 569d283..c085d1d 100644
--- a/font.c
+++ b/font.c
@@ -148,5 +148,6 @@ int atlas_get_strwidth(client_state* state, const char* str) {
void atlas_calc_item_widths(client_state* state) {
array_for_all(item_t, item, state->items) {
item->pixel_len = atlas_get_strwidth(state, item->text);
+ state->required_width = MAX(state->required_width, item->pixel_len + state->line_height / 2.0f);
}
}
diff --git a/graphics.c b/graphics.c
index d701c02..6b9be16 100644
--- a/graphics.c
+++ b/graphics.c
@@ -142,21 +142,22 @@ void render_frame(client_state *state) {
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, state->atlas.texture);
-
- float pen_x = state->line_height / 4.0f;
+ float horizontal_spacing = state->line_height / 2.0f;
+ float pen_x = horizontal_spacing / 2.0f;
float pen_y = state->line_height * state->lines - state->atlas.vert_shift;
+ // draw input buffer
if (state->lines > 0) {
glScissor(pen_x, pen_y + state->atlas.vert_shift, state->width, state->line_height);
}
else {
glScissor(pen_x, pen_y + state->atlas.vert_shift, state->width / 3.0f - pen_x, state->line_height);
}
- // draw input buffer
glBindVertexArray(state->input_buffer_grafix.vao);
glUniform2f(state->offset_uniform, pen_x, pen_y);
glDrawElements(GL_TRIANGLES, state->input_buffer_grafix.num_elements, GL_UNSIGNED_INT, 0);
- // shift pen
+
+ // set up drawing for options
if (state->lines > 0) {
glScissor(0, 0, state->width, pen_y);
pen_y -= state->line_height;
@@ -164,10 +165,9 @@ void render_frame(client_state *state) {
else {
pen_x += state->width / 3.0f;
glScissor(pen_x, 0, state->width, state->line_height);
+ pen_x += horizontal_spacing / 2.0f;
}
- pen_x += state->line_height / 4.0f;
-
// draw options
array_for_all(item_t, item, state->items) {
glBindVertexArray(item->text_buffer.vao);
@@ -179,7 +179,7 @@ void render_frame(client_state *state) {
pen_y -= state->line_height;
}
else {
- pen_x += item->pixel_len + (state->line_height / 2.0f);
+ pen_x += item->pixel_len + horizontal_spacing;
}
}
diff --git a/layer_surface.c b/layer_surface.c
index fc0a7e2..7758dde 100644
--- a/layer_surface.c
+++ b/layer_surface.c
@@ -1,5 +1,5 @@
#include "./state.h"
-#include "array.h"
+#include "config.h"
struct zwlr_layer_surface_v1_listener layer_surface_listener;
@@ -16,8 +16,8 @@ void create_surface(client_state* state) {
uint32_t desired_width = 0;
uint32_t desired_height = state->line_height;
if (state->lines > 0) {
- desired_width = 600; // calculate based on width of option strings
desired_height = (state->lines + 1) * state->line_height;
+ desired_width = MAX(state->required_width, min_width);
}
// create surface
diff --git a/state.h b/state.h
index f1b3327..cada269 100644
--- a/state.h
+++ b/state.h
@@ -89,6 +89,8 @@ typedef struct {
atlas_t atlas;
uint32_t line_height;
+ uint32_t required_width;
+
// arguments
int lines;