- system.py runs app.Loop() on the script fiber; each UIUpdate is one CPythonApplication::Process(). Logo -> Login, popup ESC/click and app.Exit teardown (launcher cleared first, as in 40250 Main) work. - Image commands are base-texture quads with UVs (a .sub shares its parent texture); ImageInstance/ExpandedImageInstance OnRender and SetRenderingRect ported verbatim, so scale/rotation/rendering rect are drawn. - CGraphicBase::GetColor / grp.GenerateColor ported (ThinBoard background). - port.app_loop test, python_host_test app-loop checks, MT_TEST_MODE=python_ui. - TODO: .fnt/CGraphicText font pipeline, ExpandedImage blend modes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
57 lines
2.1 KiB
C++
57 lines
2.1 KiB
C++
#include "UIRenderCommands.h"
|
|
|
|
#include <algorithm>
|
|
|
|
namespace {
|
|
std::vector<UIRenderCommand> commands;
|
|
int canvas_width = 0;
|
|
int canvas_height = 0;
|
|
float clip_x1 = 0, clip_y1 = 0, clip_x2 = 0, clip_y2 = 0;
|
|
float saved_x1 = 0, saved_y1 = 0, saved_x2 = 0, saved_y2 = 0;
|
|
}
|
|
|
|
void UIRenderSetSize(int width, int height) { canvas_width = width; canvas_height = height; }
|
|
void UIRenderGetSize(unsigned* width, unsigned* height) {
|
|
if (width) *width = canvas_width;
|
|
if (height) *height = canvas_height;
|
|
}
|
|
void UIRenderBeginFrame() {
|
|
commands.clear();
|
|
clip_x1 = clip_y1 = 0;
|
|
clip_x2 = canvas_width;
|
|
clip_y2 = canvas_height;
|
|
}
|
|
void UIRenderAdd(UIRenderCommand command) {
|
|
command.clip_x1 = clip_x1; command.clip_y1 = clip_y1;
|
|
command.clip_x2 = clip_x2; command.clip_y2 = clip_y2;
|
|
commands.push_back(command);
|
|
}
|
|
const std::vector<UIRenderCommand>& UIRenderCommands() { return commands; }
|
|
void UIRenderSetClip(float x, float y, float width, float height) {
|
|
saved_x1 = clip_x1; saved_y1 = clip_y1; saved_x2 = clip_x2; saved_y2 = clip_y2;
|
|
clip_x1 = x; clip_y1 = y;
|
|
clip_x2 = x + width; clip_y2 = y + height;
|
|
}
|
|
void UIRenderRestoreClip() {
|
|
clip_x1 = saved_x1; clip_y1 = saved_y1;
|
|
clip_x2 = saved_x2; clip_y2 = saved_y2;
|
|
}
|
|
|
|
void UIRenderAddImage(const CGraphicTexture* texture, const float x[4], const float y[4],
|
|
float su, float sv, float eu, float ev, std::uint32_t argb, int blend) {
|
|
UIRenderCommand command{UIRenderCommand::Image, 0, 0, 0, 0, argb};
|
|
for (int i = 0; i < 4; ++i) {
|
|
command.qx[i] = x[i] + 0.5f;
|
|
command.qy[i] = y[i] + 0.5f;
|
|
}
|
|
command.x1 = std::min({command.qx[0], command.qx[1], command.qx[2], command.qx[3]});
|
|
command.y1 = std::min({command.qy[0], command.qy[1], command.qy[2], command.qy[3]});
|
|
command.x2 = std::max({command.qx[0], command.qx[1], command.qx[2], command.qx[3]});
|
|
command.y2 = std::max({command.qy[0], command.qy[1], command.qy[2], command.qy[3]});
|
|
command.text = UIRenderTextureName(texture);
|
|
command.quad = true;
|
|
command.su = su; command.sv = sv; command.eu = eu; command.ev = ev;
|
|
command.blend = blend;
|
|
UIRenderAdd(std::move(command));
|
|
}
|