Render grid

This commit is contained in:
iota97 committed 2020-01-14 19:18:27 +01:00
1 parent c2e8577756
commit 4395da7c7e
1 file changed
+25
+25
View File
@@ -213,6 +213,30 @@ private:
float &spacing_;
};
class SnapGrid : public UI::View {
public:
SnapGrid(int leftMargin, int rightMargin, int topMargin, int bottomMargin, u32 color) {
x1 = leftMargin;
x2 = rightMargin;
y1 = topMargin;
y2 = bottomMargin;
col = color;
}
void Draw(UIContext &dc) override {
if (g_Config.bTouchSnapToGrid) {
for (int x = x1; x < x2; x += g_Config.iTouchSnapGridSize)
dc.Draw()->vLine(x, y1, y2, col);
for (int y = y1; y < y2; y += g_Config.iTouchSnapGridSize)
dc.Draw()->hLine(x1, y, x2, col);
}
}
private:
int x1, x2, y1, y2;
u32 col;
};
TouchControlLayoutScreen::TouchControlLayoutScreen() {
pickedControl_ = 0;
};
@@ -455,6 +479,7 @@ void TouchControlLayoutScreen::CreateViews() {
for (size_t i = 0; i < controls_.size(); i++) {
root_->Add(controls_[i]);
}
root_->Add(new SnapGrid(leftColumnWidth+10, bounds.w, 0, bounds.h, 0x7FFFFFFF));
}
// return the control which was picked up by the touchEvent. If a control