33#include " MainWindow.h"
44#include " imgui/imgui_internal.h"
55
6- DasherUIScreen::DasherUIScreen (): Dasher::CDasherScreen(100 ,100 ), CScreenCoordInput(0 , _(" Mouse Input" ))
6+ DasherUIScreen::DasherUIScreen (): Dasher::CDasherScreen(100 ,100 ), CScreenCoordInput(_(" Mouse Input" ))
77{
88 Font = MainWindow::LoadFonts (50 .0f );
99}
@@ -14,52 +14,49 @@ std::pair<Dasher::screenint, Dasher::screenint> DasherUIScreen::TextSize(Label*
1414 return {static_cast <Dasher::screenint>(Size.x ), static_cast <Dasher::screenint>(Size.y )};
1515}
1616
17- void DasherUIScreen::DrawString (Label* label, Dasher::screenint x, Dasher::screenint y, unsigned iFontSize, int iColour )
17+ void DasherUIScreen::DrawString (Label* label, Dasher::screenint x, Dasher::screenint y, unsigned iFontSize, const Dasher::ColorPalette::Color& Color )
1818{
19- const Dasher::CColourIO::ColourInfo::PaletteColor Color = this -> pColorScheme -> Colors [iColour] ;
20- const ImVec4 ImColor = { static_cast <float >(Color.Red ) / 255 .0f , static_cast <float >(Color.Green ) / 255 .0f , static_cast <float >(Color.Blue ) / 255 .0f , 1 .0f };
19+ if ( Color. isFullyTransparent ()) return ;
20+ const ImVec4 ImColor = { static_cast <float >(Color.Red ) / 255 .0f , static_cast <float >(Color.Green ) / 255 .0f , static_cast <float >(Color.Blue ) / 255 .0f , static_cast < float >(Color. Alpha ) / 255 .0f };
2121 const ImVec2 Pos = { static_cast <float >(x),static_cast <float >(y)};
2222 ImGui::GetWindowDrawList ()->AddText (Font, static_cast <float >(iFontSize), Pos + CanvasPos, ImGui::ColorConvertFloat4ToU32 (ImColor), label->m_strText .c_str ());
2323}
2424
25- void DasherUIScreen::DrawRectangle (Dasher::screenint x1, Dasher::screenint y1, Dasher::screenint x2, Dasher::screenint y2, int Colour, int iOutlineColour , int iThickness)
25+ void DasherUIScreen::DrawRectangle (Dasher::screenint x1, Dasher::screenint y1, Dasher::screenint x2, Dasher::screenint y2, const Dasher::ColorPalette::Color& FillColor, const Dasher::ColorPalette::Color& OutlineColor , int iThickness)
2626{
27- const Dasher::CColourIO::ColourInfo::PaletteColor FillColor = this ->pColorScheme ->Colors [Colour];
28- const ImVec4 ImFillColor = { static_cast <float >(FillColor.Red ) / 255 .0f , static_cast <float >(FillColor.Green ) / 255 .0f , static_cast <float >(FillColor.Blue ) / 255 .0f , 1 .0f };
27+ const ImVec4 ImFillColor = { static_cast <float >(FillColor.Red ) / 255 .0f , static_cast <float >(FillColor.Green ) / 255 .0f , static_cast <float >(FillColor.Blue ) / 255 .0f , static_cast <float >(FillColor.Alpha ) / 255 .0f };
2928 const ImVec2 p1 = { static_cast <float >(x1), static_cast <float >(y1)};
3029 const ImVec2 p2 = { static_cast <float >(x2), static_cast <float >(y2)};
3130
32- ImGui::GetWindowDrawList ()->AddRectFilled (CanvasPos + p1, CanvasPos + p2, ImGui::ColorConvertFloat4ToU32 (ImFillColor));
31+ if (!FillColor. isFullyTransparent ()) ImGui::GetWindowDrawList ()->AddRectFilled (CanvasPos + p1, CanvasPos + p2, ImGui::ColorConvertFloat4ToU32 (ImFillColor));
3332
34- if (iThickness > 0 )
33+ if (iThickness > 0 && !OutlineColor. isFullyTransparent () )
3534 {
36- const Dasher::CColourIO::ColourInfo::PaletteColor OutlineColor = this ->pColorScheme ->Colors [iOutlineColour > 0 ? iOutlineColour : 3 ]; // Apparently Outline Color 3 is the default
37- const ImVec4 ImOutlineColor = { static_cast <float >(OutlineColor.Red ) / 255 .0f , static_cast <float >(OutlineColor.Green ) / 255 .0f , static_cast <float >(OutlineColor.Blue ) / 255 .0f , 1 .0f };
35+ const ImVec4 ImOutlineColor = { static_cast <float >(OutlineColor.Red ) / 255 .0f , static_cast <float >(OutlineColor.Green ) / 255 .0f , static_cast <float >(OutlineColor.Blue ) / 255 .0f , static_cast <float >(FillColor.Alpha ) / 255 .0f };
3836
3937 ImGui::GetWindowDrawList ()->AddRect (CanvasPos + p1, CanvasPos + p2, ImGui::ColorConvertFloat4ToU32 (ImOutlineColor),0 ,0 , static_cast <float >(iThickness));
4038 }
4139}
4240
43- void DasherUIScreen::DrawCircle (Dasher::screenint iCX, Dasher::screenint iCY, Dasher::screenint iR, int iFillColour, int iLineColour , int iLineWidth)
41+ void DasherUIScreen::DrawCircle (Dasher::screenint iCX, Dasher::screenint iCY, Dasher::screenint iR, const Dasher::ColorPalette::Color& FillColor, const Dasher::ColorPalette::Color& LineColor , int iLineWidth)
4442{
45- const Dasher::CColourIO::ColourInfo::PaletteColor FillColor = this ->pColorScheme ->Colors [iFillColour];
46- const ImVec4 ImFillColor = { static_cast <float >(FillColor.Red ) / 255 .0f , static_cast <float >(FillColor.Green ) / 255 .0f , static_cast <float >(FillColor.Blue ) / 255 .0f , 1 .0f };
43+ const ImVec4 ImFillColor = { static_cast <float >(FillColor.Red ) / 255 .0f , static_cast <float >(FillColor.Green ) / 255 .0f , static_cast <float >(FillColor.Blue ) / 255 .0f , static_cast <float >(FillColor.Alpha ) / 255 .0f };
4744
48- ImGui::GetWindowDrawList ()->AddCircleFilled (CanvasPos + ImVec2 (static_cast <float >(iCX), static_cast <float >(iCY)), static_cast <float >(iR), ImGui::ColorConvertFloat4ToU32 (ImFillColor));
45+ if (!FillColor. isFullyTransparent ()) ImGui::GetWindowDrawList ()->AddCircleFilled (CanvasPos + ImVec2 (static_cast <float >(iCX), static_cast <float >(iCY)), static_cast <float >(iR), ImGui::ColorConvertFloat4ToU32 (ImFillColor));
4946
50- if (iLineWidth > 0 )
47+ if (iLineWidth > 0 && !LineColor. isFullyTransparent () )
5148 {
52- const Dasher::CColourIO::ColourInfo::PaletteColor OutlineColor = this ->pColorScheme ->Colors [iLineColour > 0 ? iLineColour : 3 ];
53- const ImVec4 ImOutlineColor = { static_cast <float >(OutlineColor.Red ) / 255 .0f , static_cast <float >(OutlineColor.Green ) / 255 .0f , static_cast <float >(OutlineColor.Blue ) / 255 .0f , 1 .0f };
49+ const ImVec4 ImOutlineColor = { static_cast <float >(LineColor.Red ) / 255 .0f , static_cast <float >(LineColor.Green ) / 255 .0f , static_cast <float >(LineColor.Blue ) / 255 .0f , static_cast <float >(LineColor.Alpha ) / 255 .0f };
5450
55- ImGui::GetWindowDrawList ()->AddCircle (CanvasPos + ImVec2 (static_cast <float >(iCX), static_cast <float >(iCY)), static_cast <float >(iR), ImGui::ColorConvertFloat4ToU32 (ImFillColor ),0 , static_cast <float >(iLineWidth));
51+ ImGui::GetWindowDrawList ()->AddCircle (CanvasPos + ImVec2 (static_cast <float >(iCX), static_cast <float >(iCY)), static_cast <float >(iR), ImGui::ColorConvertFloat4ToU32 (ImOutlineColor ),0 , static_cast <float >(iLineWidth));
5652 }
5753}
5854
59- void DasherUIScreen::Polyline (point* Points, int Number, int iWidth, int Colour )
55+ void DasherUIScreen::Polyline (point* Points, int Number, int iWidth, const Dasher::ColorPalette::Color& LineColor )
6056{
61- const Dasher::CColourIO::ColourInfo::PaletteColor LineColor = this ->pColorScheme ->Colors [Colour];
62- const ImVec4 ImLineColor = { static_cast <float >(LineColor.Red ) / 255 .0f , static_cast <float >(LineColor.Green ) / 255 .0f , static_cast <float >(LineColor.Blue ) / 255 .0f , 1 .0f };
57+ if (LineColor.isFullyTransparent ()) return ;
58+
59+ const ImVec4 ImLineColor = { static_cast <float >(LineColor.Red ) / 255 .0f , static_cast <float >(LineColor.Green ) / 255 .0f , static_cast <float >(LineColor.Blue ) / 255 .0f , static_cast <float >(LineColor.Alpha ) / 255 .0f };
6360
6461 std::vector<ImVec2> points;
6562
@@ -71,10 +68,9 @@ void DasherUIScreen::Polyline(point* Points, int Number, int iWidth, int Colour)
7168 ImGui::GetWindowDrawList ()->AddPolyline (points.data (), Number, ImGui::ColorConvertFloat4ToU32 (ImLineColor), 0 , static_cast <float >(iWidth));
7269}
7370
74- void DasherUIScreen::Polygon (point* Points, int Number, int fillColour, int outlineColour , int lineWidth)
71+ void DasherUIScreen::Polygon (point* Points, int Number, const Dasher::ColorPalette::Color& FillColor, const Dasher::ColorPalette::Color& outlineColor , int lineWidth)
7572{
76- const Dasher::CColourIO::ColourInfo::PaletteColor FillColor = this ->pColorScheme ->Colors [fillColour];
77- const ImVec4 ImFillColor = { static_cast <float >(FillColor.Red ) / 255 .0f , static_cast <float >(FillColor.Green ) / 255 .0f , static_cast <float >(FillColor.Blue ) / 255 .0f , 1 .0f };
73+ const ImVec4 ImFillColor = { static_cast <float >(FillColor.Red ) / 255 .0f , static_cast <float >(FillColor.Green ) / 255 .0f , static_cast <float >(FillColor.Blue ) / 255 .0f , static_cast <float >(FillColor.Alpha ) / 255 .0f };
7874
7975 std::vector<ImVec2> points;
8076
@@ -83,21 +79,16 @@ void DasherUIScreen::Polygon(point* Points, int Number, int fillColour, int outl
8379 points.push_back (CanvasPos + ImVec2 (static_cast <float >(Points[i].x ), static_cast <float >(Points[i].y )));
8480 }
8581
86- ImGui::GetWindowDrawList ()->AddConvexPolyFilled (points.data (), Number, ImGui::ColorConvertFloat4ToU32 (ImFillColor));
82+ if (!FillColor. isFullyTransparent ()) ImGui::GetWindowDrawList ()->AddConvexPolyFilled (points.data (), Number, ImGui::ColorConvertFloat4ToU32 (ImFillColor));
8783
8884 if (lineWidth > 0 )
8985 {
90- Polyline (Points, Number, lineWidth, outlineColour );
86+ Polyline (Points, Number, lineWidth, outlineColor );
9187 }
9288}
9389
9490void DasherUIScreen::Display (){}
9591
96- void DasherUIScreen::SetColourScheme (const Dasher::CColourIO::ColourInfo* pColourScheme)
97- {
98- this ->pColorScheme = pColourScheme;
99- }
100-
10192bool DasherUIScreen::IsPointVisible (Dasher::screenint, Dasher::screenint){
10293 return true ;
10394}
@@ -119,7 +110,7 @@ bool DasherUIScreen::SetCanvasSize(const ImVec2 position, const ImVec2 size)
119110bool DasherUIScreen::GetScreenCoords (Dasher::screenint& iX, Dasher::screenint& iY, Dasher::CDasherView* pView)
120111{
121112 const ImVec2 MousePos = ImGui::GetMousePos ();
122- if ( MousePos. x < 0 || MousePos. y < 0 ) return false ;
113+ if (! ImGui::IsMousePosValid (& MousePos) ) return false ;
123114 iX = static_cast <Dasher::screenint>(MousePos.x - CanvasPos.x );
124115 iY = static_cast <Dasher::screenint>(MousePos.y - CanvasPos.y );
125116 return true ;
0 commit comments