bettola/client/src/ui/text_view.h
Ritchie Cunningham e7607e3fc0 [Refactor] Created UIRenderer for consistant coord system.
The UI codebase was suffering with complexity due to the need to
manually convert between two different coordinate systems:
- Top-down "screen coordinates" used by SDL for input and windowing.
- Bottom-up "GL coordinates" used by low-level renderers.

This was making layout calculations diffucult and is bug prone.

With this commit, I'm introducing a 'UIRenderer' abstraction layer that
wraps the low-level 'ShapeRenderer' and 'TextRenderer'. This is
responsible for centralising all coordinate system conversations.

All UI components has been refactored to use the 'UIRenderer' so the
entire UI code opeates exclusively in a single, top-down screen
coordinate system as one would expect.
2025-10-04 03:11:48 +01:00

25 lines
489 B
C++

#pragma once
#include <SDL3/SDL_events.h>
#include "ui/text_buffer.h"
#include "ui/ui_renderer.h"
class TextRenderer;
class TextView {
public:
TextView(TextBuffer* buffer, bool handle_ret);
~TextView(void);
bool handle_event(SDL_Event* event);
void render(UIRenderer* ui_renderer, int x, int y, int width, int height,
bool show_cursor);
void scroll(int amount, int content_height);
private:
TextBuffer* _buffer;
int _scroll_offset;
bool _handle_ret;
};