Skip to content

Commit 2d909be

Browse files
author
Sebi
committed
Adapting to new color definition
1 parent c981275 commit 2d909be

File tree

4 files changed

+28
-39
lines changed

4 files changed

+28
-39
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ target_include_directories(DasherUI PRIVATE ${PROJECT_SOURCE_DIR}/Thirdparty/asi
9292
# Copy Data files
9393
file(GLOB RESOURCE_FILES
9494
${PROJECT_SOURCE_DIR}/DasherCore/Data/alphabets/alphabet*.xml
95-
${PROJECT_SOURCE_DIR}/DasherCore/Data/colours/colour*.xml
95+
${PROJECT_SOURCE_DIR}/DasherCore/Data/colors/color*.xml
9696
${PROJECT_SOURCE_DIR}/DasherCore/Data/control/control*.xml
9797
${PROJECT_SOURCE_DIR}/DasherCore/Data/training/training*.txt
9898
)

DasherCore

src/DasherUIScreen.cpp

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -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

5551
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));
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

9490
void DasherUIScreen::Display(){}
9591

96-
void DasherUIScreen::SetColourScheme(const Dasher::CColourIO::ColourInfo* pColourScheme)
97-
{
98-
this->pColorScheme = pColourScheme;
99-
}
100-
10192
bool DasherUIScreen::IsPointVisible(Dasher::screenint, Dasher::screenint){
10293
return true;
10394
}

src/DasherUIScreen.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,12 @@ class DasherUIScreen : public Dasher::CDasherScreen, public Dasher::CScreenCoord
1111
DasherUIScreen();
1212

1313
std::pair<Dasher::screenint, Dasher::screenint> TextSize(Label* label, unsigned iFontSize) override;
14-
void DrawString(Label* label, Dasher::screenint x, Dasher::screenint y, unsigned iFontSize, int iColour) override;
15-
void DrawRectangle(Dasher::screenint x1, Dasher::screenint y1, Dasher::screenint x2, Dasher::screenint y2, int Colour, int iOutlineColour, int iThickness) override;
16-
void DrawCircle(Dasher::screenint iCX, Dasher::screenint iCY, Dasher::screenint iR, int iFillColour, int iLineColour, int iLineWidth) override;
17-
void Polyline(point* Points, int Number, int iWidth, int Colour) override;
18-
void Polygon(point* Points, int Number, int fillColour, int outlineColour, int lineWidth) override;
14+
void DrawString(Label* label, Dasher::screenint x, Dasher::screenint y, unsigned iFontSize, const Dasher::ColorPalette::Color& Colour) override;
15+
void DrawRectangle(Dasher::screenint x1, Dasher::screenint y1, Dasher::screenint x2, Dasher::screenint y2, const Dasher::ColorPalette::Color& Colour, const Dasher::ColorPalette::Color& OutlineColour, int iThickness) override;
16+
void DrawCircle(Dasher::screenint iCX, Dasher::screenint iCY, Dasher::screenint iR, const Dasher::ColorPalette::Color& iFillColour, const Dasher::ColorPalette::Color& LineColour, int iLineWidth) override;
17+
void Polyline(point* Points, int Number, int iWidth, const Dasher::ColorPalette::Color& Colour) override;
18+
void Polygon(point* Points, int Number, const Dasher::ColorPalette::Color& fillColour, const Dasher::ColorPalette::Color& outlineColour, int lineWidth) override;
1919
void Display() override;
20-
void SetColourScheme(const Dasher::CColourIO::ColourInfo* pColourScheme) override;
2120
bool IsPointVisible(Dasher::screenint x, Dasher::screenint y) override;
2221

2322
bool MultiSizeFonts() override { return true; }
@@ -27,7 +26,6 @@ class DasherUIScreen : public Dasher::CDasherScreen, public Dasher::CScreenCoord
2726
bool GetScreenCoords(Dasher::screenint& iX, Dasher::screenint& iY, Dasher::CDasherView* pView) override;
2827

2928
private:
30-
const Dasher::CColourIO::ColourInfo* pColorScheme;
3129
ImVec2 CanvasPos;
3230
ImVec2 CanvasSize;
3331

0 commit comments

Comments
 (0)