From 4395da7c7e11351d75c83f242d5d3f677f22bfed Mon Sep 17 00:00:00 2001 From: iota97 Date: Tue, 14 Jan 2020 19:18:27 +0100 Subject: [PATCH 1/3] Render grid --- UI/TouchControlLayoutScreen.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) 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 From b69cdea29ea516a5b767ada32fc97ddee220bcf7 Mon Sep 17 00:00:00 2001 From: iota97 Date: Wed, 15 Jan 2020 18:48:43 +0100 Subject: [PATCH 2/3] Fix line rendering in texmode --- UI/TouchControlLayoutScreen.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/UI/TouchControlLayoutScreen.cpp b/UI/TouchControlLayoutScreen.cpp index 99ce023414..1acafbe3a1 100644 --- a/UI/TouchControlLayoutScreen.cpp +++ b/UI/TouchControlLayoutScreen.cpp @@ -225,10 +225,13 @@ public: void Draw(UIContext &dc) override { if (g_Config.bTouchSnapToGrid) { + dc.BeginNoTex(); 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); + dc.Flush(); + dc.Begin(); } } @@ -352,6 +355,7 @@ void TouchControlLayoutScreen::CreateViews() { root_ = new AnchorLayout(new LayoutParams(FILL_PARENT, FILL_PARENT)); + root_->Add(new SnapGrid(leftColumnWidth+10, bounds.w, 0, bounds.h, 0x3FFFFFFF)); Choice *reset = new Choice(di->T("Reset"), "", false, new AnchorLayoutParams(leftColumnWidth, WRAP_CONTENT, 10, NONE, NONE, 84)); Choice *back = new Choice(di->T("Back"), "", false, new AnchorLayoutParams(leftColumnWidth, WRAP_CONTENT, 10, NONE, NONE, 10)); Choice *visibility = new Choice(co->T("Visibility"), "", false, new AnchorLayoutParams(leftColumnWidth, WRAP_CONTENT, 10, NONE, NONE, 298)); @@ -479,7 +483,6 @@ 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 From 1332e3c1ccb12dff2116632e6f2c07fc22ba889a Mon Sep 17 00:00:00 2001 From: iota97 Date: Thu, 16 Jan 2020 06:16:46 +0100 Subject: [PATCH 3/3] Flush other UI element draw before changing to noTex --- UI/TouchControlLayoutScreen.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/UI/TouchControlLayoutScreen.cpp b/UI/TouchControlLayoutScreen.cpp index 1acafbe3a1..649014a6fd 100644 --- a/UI/TouchControlLayoutScreen.cpp +++ b/UI/TouchControlLayoutScreen.cpp @@ -225,6 +225,7 @@ public: void Draw(UIContext &dc) override { if (g_Config.bTouchSnapToGrid) { + dc.Flush(); dc.BeginNoTex(); for (int x = x1; x < x2; x += g_Config.iTouchSnapGridSize) dc.Draw()->vLine(x, y1, y2, col); @@ -355,7 +356,6 @@ void TouchControlLayoutScreen::CreateViews() { root_ = new AnchorLayout(new LayoutParams(FILL_PARENT, FILL_PARENT)); - root_->Add(new SnapGrid(leftColumnWidth+10, bounds.w, 0, bounds.h, 0x3FFFFFFF)); Choice *reset = new Choice(di->T("Reset"), "", false, new AnchorLayoutParams(leftColumnWidth, WRAP_CONTENT, 10, NONE, NONE, 84)); Choice *back = new Choice(di->T("Back"), "", false, new AnchorLayoutParams(leftColumnWidth, WRAP_CONTENT, 10, NONE, NONE, 10)); Choice *visibility = new Choice(co->T("Visibility"), "", false, new AnchorLayoutParams(leftColumnWidth, WRAP_CONTENT, 10, NONE, NONE, 298)); @@ -483,6 +483,8 @@ 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, 0x3FFFFFFF)); } // return the control which was picked up by the touchEvent. If a control