Canvas Camera

Canvas is a camera-aware facade over U8g2. Apps draw in content coordinates, and the camera converts them to screen coordinates before calling U8g2.

A scrollable App

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
class LongPage final : public IApplication {
public:
LongPage(PixelUI& ui, void*) : IApplication(true), ui_(ui) {}

void draw() override {
Canvas& canvas = ui_.getCanvas();
canvas.setFont(PIXELUI_FONT_TEXT);
canvas.setContentHeight(180);
canvas.drawUTF8(4, 12, "General");
canvas.drawUTF8(4, 92, "Network");
canvas.drawUTF8(4, 172, "About");
}

bool handleInput(InputEvent) override { return false; }

private:
PixelUI& ui_;
};

When useVerticalScroll is enabled, unconsumed UP/DOWN events move the camera by one viewport. An App with its own selection model can call ensureCanvasVisible(), scrollCanvasTo(), or animateCanvasTo().

Canvas transforms coordinate-based U8g2 APIs. Fixed headers, Popups, and Focus overlays drawn directly through getU8G2() are unaffected by the camera. ViewManager saves y position and content height by App stack depth, so the previous scroll position can be restored after the upper App exits.

最新文章
网站信息
文章数目 :
1
本站访客数 :
本站总浏览量 :
最后更新时间 :