diff --git a/UI/TouchControlLayoutScreen.cpp b/UI/TouchControlLayoutScreen.cpp index 65ebb654cf..99ce023414 100644 --- a/UI/TouchControlLayoutScreen.cpp +++ b/UI/TouchControlLayoutScreen.cpp @@ -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