libgui 2.01
libgui is a GUI library for the GameCube, Wii, and Wii U
 
Loading...
Searching...
No Matches
GuiControllerView.h
1/****************************************************************************
2 * libgui
3 * Daryl Borth 2026
4 * GuiControllerView.h
5 ***************************************************************************/
6#pragma once
7#include "GuiControllerDraw.h"
8
15{
16 public:
19 GuiControllerView(const GuiControllerLayout& layout, float scale = 1.0f);
21
23 void setLayout(const GuiControllerLayout& layout);
25 void setScale(float scale);
27 void setHighlight(int id);
29 void setHighlight(const std::vector<int>& ids);
31 const std::vector<int>& getHighlight() const { return highlighted; }
34 void setLeader(bool on, float fromX = 0.0f, float fromY = 0.0f);
36 void setLit(std::function<bool(int)> fn) { lit = fn; }
38 void setStick(int id, float x, float y);
40 bool getSpotCentre(int id, float& x, float& y) const;
41
42 void draw() override;
43 private:
44 struct SpotCache {
45 GuiMesh mesh[4];
46 bool built[4];
47 };
48
49 void rebuild();
50 void clearLabels();
51 void emit(const GuiMesh& m);
52
53 const GuiControllerLayout * layout;
54 float scale;
55 std::vector<int> highlighted;
56 bool leader;
57 float leaderX, leaderY;
58 std::function<bool(int)> lit;
59 std::vector<float> stickX, stickY;
60 GuiMesh body;
61 std::vector<SpotCache> spots;
62 std::vector<GuiText *> labels;
63 std::vector<bool> labelLit;
64 float meshFeather;
65 bool dirty;
66 std::vector<MeshVertex> scratch;
67 float originX, originY;
68 int alpha;
69};
void setLit(std::function< bool(int)> fn)
Sets which controls are drawn as pressed; asked every frame (null for none)
void setHighlight(int id)
Highlights one control (0 = none)
void setLeader(bool on, float fromX=0.0f, float fromY=0.0f)
Draws a line from a point (design-canvas coordinates, such as a list row's edge) to the first highlig...
void draw() override
Called constantly to redraw the element.
void setLayout(const GuiControllerLayout &layout)
Changes the controller drawn.
GuiControllerView(const GuiControllerLayout &layout, float scale=1.0f)
void setStick(int id, float x, float y)
Sets an analog stick's position (-1 to 1 each)
bool getSpotCentre(int id, float &x, float &y) const
Gets the center of a control in design-canvas coordinates (false if the layout has no such control)
const std::vector< int > & getHighlight() const
Gets the highlighted control ids.
void setScale(float scale)
Changes the size.
GuiElement()
Constructor.
Definition GuiElement.cpp:9
Accumulates shapes as a triangle list of MeshVertex.
A controller: its drawing size, silhouette and controls.