MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / MenuWidget

Class MenuWidget

Applications/Shell/menu.cpp:136–165  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

134Lemon::GUI::LayoutContainer* menuContainer;
135
136class MenuWidget : public Lemon::GUI::Widget{
137 MenuObject* obj;
138 Lemon::Graphics::TextObject label = Lemon::Graphics::TextObject();
139
140public:
141 MenuWidget(MenuObject& obj, rect_t bounds) : Widget(bounds){
142 this->obj = &obj;
143
144 label = Lemon::Graphics::TextObject(fixedBounds.pos + (vector2i_t){0, fixedBounds.size.y / 2}, this->obj->name);
145 label.SetColour({255, 255, 255, 255});
146 }
147
148 void Paint(surface_t* surface){
149 if(Lemon::Graphics::PointInRect(fixedBounds, menuWindow->lastMousePos)){
150 Lemon::Graphics::DrawRect(fixedBounds, Lemon::colours[Lemon::Colour::Foreground], surface);
151 }
152
153 label.Render(surface);
154 }
155
156 void OnMouseUp(vector2i_t pos){
157 obj->Open(fixedBounds.pos + (vector2i_t){fixedBounds.size.x, 0});
158 }
159
160 void UpdateFixedBounds(){
161 Widget::UpdateFixedBounds();
162
163 label.SetPos(fixedBounds.pos + (vector2i_t){2, fixedBounds.size.y / 2});
164 }
165};
166
167void OnPaint(surface_t* surface){
168

Callers

nothing calls this directly

Calls 1

TextObjectClass · 0.85

Tested by

no test coverage detected