Skip to content

Commit fd9ae60

Browse files
committed
Merge remote-tracking branch 'remotes/origin/feature/NewColorDefinition' into chore/aggregateBranches
2 parents 054b43a + 96975db commit fd9ae60

File tree

13 files changed

+290
-59
lines changed

13 files changed

+290
-59
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/build
22
/.cache
3+
/.vscode

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,6 @@
1616
[submodule "Thirdparty/nativefiledialog-extended"]
1717
path = Thirdparty/nativefiledialog-extended
1818
url = https://github.com/btzy/nativefiledialog-extended.git
19+
[submodule "Thirdparty/asio"]
20+
path = Thirdparty/asio
21+
url = https://github.com/chriskohlhoff/asio

CMakeLists.txt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ add_subdirectory("Thirdparty/nativefiledialog-extended")
6060

6161
IF (MSVC)
6262
# Hide console window
63-
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup")
63+
#set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup")
6464
ENDIF()
6565

6666
ADD_Executable(DasherUI
@@ -70,20 +70,29 @@ ADD_Executable(DasherUI
7070
${PROJECT_SOURCE_DIR}/src/MainWindow.h
7171
${PROJECT_SOURCE_DIR}/src/DasherUIScreen.cpp
7272
${PROJECT_SOURCE_DIR}/src/DasherUIScreen.h
73+
${PROJECT_SOURCE_DIR}/src/SocketInput.cpp
74+
${PROJECT_SOURCE_DIR}/src/SocketInput.h
75+
${PROJECT_SOURCE_DIR}/src/OSOutput.cpp
76+
${PROJECT_SOURCE_DIR}/src/OSOutput.h
7377
${PROJECT_SOURCE_DIR}/src/main.cpp
7478
)
7579
target_include_directories(DasherUI PUBLIC ${CMAKE_CURRENT_LIST_DIR}/Thirdparty/)
7680
add_dependencies(DasherUI imgui glfw DasherCore)
7781
target_link_libraries(DasherUI PRIVATE imgui glfw OpenGL::GL DasherCore nfd)
7882

83+
###############################
84+
# Third Party Includes
85+
###############################
86+
target_include_directories(DasherUI PRIVATE ${PROJECT_SOURCE_DIR}/Thirdparty/asio/asio/include/)
87+
7988
###############################
8089
# Setting up deloyment
8190
###############################
8291

8392
# Copy Data files
8493
file(GLOB RESOURCE_FILES
8594
${PROJECT_SOURCE_DIR}/DasherCore/Data/alphabets/alphabet*.xml
86-
${PROJECT_SOURCE_DIR}/DasherCore/Data/colours/colour*.xml
95+
${PROJECT_SOURCE_DIR}/DasherCore/Data/colors/color*.xml
8796
${PROJECT_SOURCE_DIR}/DasherCore/Data/control/control*.xml
8897
${PROJECT_SOURCE_DIR}/DasherCore/Data/training/training*.txt
8998
)

Thirdparty/asio

Submodule asio added at 6d7ab80

src/DasherController.cpp

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ DasherController::DasherController(Dasher::CSettingsStore* pSettingsStore): CDas
66
{
77
ScreenModule = std::make_shared<DasherUIScreen>();
88
CDashIntfScreenMsgs::ChangeScreen(ScreenModule.get());
9+
10+
OSOutputModule = std::make_unique<OSOutput>();
911
}
1012

1113
void DasherController::editOutput(const std::string& strText, Dasher::CDasherNode* pNode) {
@@ -15,35 +17,36 @@ void DasherController::editOutput(const std::string& strText, Dasher::CDasherNod
1517
}
1618
Buffer.append(strText);
1719
Cursor += static_cast<unsigned int>(strText.length());
20+
OSOutputModule->outputCharacter(strText);
1821
CDasherInterfaceBase::editOutput(strText, pNode);
1922
}
2023

2124
void DasherController::editDelete(const std::string& strText, Dasher::CDasherNode* pNode) {
2225
if(0 == Buffer.compare(Buffer.length() - strText.length(), strText.length(), strText))
2326
{
2427
Buffer.erase(Buffer.length() - strText.length(), strText.length());
28+
OSOutputModule->deleteCharacter();
2529
}
2630
CDasherInterfaceBase::editDelete(strText, pNode);
2731
}
2832

29-
unsigned DasherController::ctrlMove(bool bForwards, Dasher::CControlManager::EditDistance dist)
33+
unsigned DasherController::ctrlMove(bool bForwards, Dasher::EditDistance dist)
3034
{
31-
if (dist == Dasher::CControlManager::EditDistance::EDIT_CHAR) {
35+
if (dist == Dasher::EditDistance::EDIT_CHAR) {
3236
if (bForwards) Cursor++;
3337
else Cursor--;
3438
}
3539
return Cursor;
3640
}
3741

38-
unsigned DasherController::ctrlDelete(bool bForwards, Dasher::CControlManager::EditDistance dist)
42+
unsigned DasherController::ctrlDelete(bool bForwards, Dasher::EditDistance dist)
3943
{
40-
if(dist == Dasher::CControlManager::EditDistance::EDIT_CHAR) {
44+
if(dist == Dasher::EditDistance::EDIT_CHAR) {
4145

4246
Buffer.erase(Cursor - (bForwards ? 0 : 1), 1);
4347
}
4448
if(!bForwards) Cursor--;
4549
return Cursor;
46-
4750
}
4851

4952
std::string DasherController::GetContext(unsigned iStart, unsigned iLength)
@@ -58,9 +61,9 @@ std::string DasherController::GetAllContext()
5861
return CurrentBuffer;
5962
}
6063

61-
std::string DasherController::GetTextAroundCursor(Dasher::CControlManager::EditDistance iDist) {
64+
std::string DasherController::GetTextAroundCursor(Dasher::EditDistance iDist) {
6265
if (Buffer.length() > Cursor && Buffer.length() >= 2) {
63-
if (iDist == Dasher::CControlManager::EditDistance::EDIT_CHAR) {
66+
if (iDist == Dasher::EditDistance::EDIT_CHAR) {
6467
return Buffer.substr(Cursor - 1, 2);
6568
}
6669

@@ -87,8 +90,13 @@ void DasherController::CreateModules()
8790
{
8891
CDashIntfScreenMsgs::CreateModules();
8992

90-
RegisterModule(ScreenModule.get());
91-
SetDefaultInputDevice(ScreenModule.get());
93+
GetModuleManager()->RegisterInputDeviceModule(ScreenModule.get());
94+
95+
SocketInputModule = std::make_shared<SocketInput>(m_pSettingsStore, this, m_pFramerate);
96+
GetModuleManager()->RegisterInputDeviceModule(SocketInputModule.get());
97+
SocketInputModule->startListen();
98+
99+
GetModuleManager()->SetDefaultInputDevice(SocketInputModule.get());
92100
}
93101

94102
void DasherController::CopyToClipboard(const std::string& text)

src/DasherController.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
#include "imgui_internal.h"
77
#include <memory>
88

9+
#include "OSOutput.h"
10+
#include "SocketInput.h"
11+
912

1013
class DasherController : public Dasher::CDashIntfScreenMsgs
1114
{
@@ -14,11 +17,11 @@ class DasherController : public Dasher::CDashIntfScreenMsgs
1417

1518
void editOutput(const std::string& strText, Dasher::CDasherNode* pNode) override;
1619
void editDelete(const std::string& strText, Dasher::CDasherNode* pNode) override;
17-
unsigned ctrlMove(bool bForwards, Dasher::CControlManager::EditDistance dist) override;
18-
unsigned ctrlDelete(bool bForwards, Dasher::CControlManager::EditDistance dist) override;
20+
unsigned ctrlMove(bool bForwards, Dasher::EditDistance dist) override;
21+
unsigned ctrlDelete(bool bForwards, Dasher::EditDistance dist) override;
1922
std::string GetContext(unsigned iStart, unsigned iLength) override;
2023
std::string GetAllContext() override;
21-
std::string GetTextAroundCursor(Dasher::CControlManager::EditDistance iDist) override;
24+
std::string GetTextAroundCursor(Dasher::EditDistance iDist) override;
2225
int GetAllContextLenght() override;
2326

2427
void Initialize();
@@ -44,4 +47,6 @@ class DasherController : public Dasher::CDashIntfScreenMsgs
4447

4548
//Modules
4649
std::shared_ptr<DasherUIScreen> ScreenModule;
50+
std::shared_ptr<SocketInput> SocketInputModule;
51+
std::shared_ptr<OSOutput> OSOutputModule;
4752
};

src/DasherUIScreen.cpp

Lines changed: 24 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
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

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
}
@@ -119,7 +110,7 @@ bool DasherUIScreen::SetCanvasSize(const ImVec2 position, const ImVec2 size)
119110
bool 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;

src/DasherUIScreen.h

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,19 @@ 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;
22-
23-
bool MultiSizeFonts() override { return true; }
24-
21+
2522
bool SetCanvasSize(ImVec2 CanvasPos, ImVec2 CanvasSize);
2623

2724
bool GetScreenCoords(Dasher::screenint& iX, Dasher::screenint& iY, Dasher::CDasherView* pView) override;
2825

2926
private:
30-
const Dasher::CColourIO::ColourInfo* pColorScheme;
3127
ImVec2 CanvasPos;
3228
ImVec2 CanvasSize;
3329

src/MainWindow.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
MainWindow::MainWindow()
1010
{
11-
ImGui::SetCurrentFont(LoadFonts(14.0f));
11+
ImGui::SetCurrentFont(LoadFonts(22.0f));
1212

1313
Settings = std::make_unique<Dasher::XmlSettingsStore>("Settings.xml", this);
1414
Settings->Load();
@@ -18,7 +18,6 @@ MainWindow::MainWindow()
1818
Controller->Initialize();
1919

2020
Controller->GetPermittedValues(Dasher::SP_ALPHABET_ID, Alphabets);
21-
2221
}
2322

2423
#define FORWARD_KEY(ImGui_Key, DasherKey) { \

src/OSOutput.cpp

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#include "OSOutput.h"
2+
3+
#include <string>
4+
5+
#ifdef _WIN32
6+
#include <codecvt>
7+
8+
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
9+
#include <windows.h>
10+
#include <stringapiset.h>
11+
#include <WinUser.h>
12+
#undef WIN32_LEAN_AND_MEAN
13+
#endif
14+
15+
OSOutput::OSOutput(){}
16+
17+
OSOutput::~OSOutput(){}
18+
19+
void OSOutput::deleteCharacter()
20+
{
21+
#ifdef _WIN32
22+
INPUT fakekey[2];
23+
fakekey[0].type = fakekey[1].type = INPUT_KEYBOARD;
24+
fakekey[0].ki.wVk = fakekey[1].ki.wVk = VK_BACK;
25+
fakekey[0].ki.time = fakekey[1].ki.time = 0;
26+
fakekey[1].ki.dwFlags = KEYEVENTF_KEYUP;
27+
28+
SendInput(2, fakekey, sizeof(INPUT));
29+
#endif
30+
}
31+
32+
void OSOutput::outputCharacter(const std::string &sText)
33+
{
34+
#ifdef _WIN32
35+
INPUT fakekey[2];
36+
if(sText[0] == '\r' && sText[1] == '\n') {
37+
// Newline, so we want to fake an enter
38+
fakekey[0].type = fakekey[1].type = INPUT_KEYBOARD;
39+
fakekey[0].ki.wVk = fakekey[1].ki.wVk = VK_RETURN;
40+
fakekey[0].ki.time = fakekey[1].ki.time = 0;
41+
fakekey[1].ki.dwFlags = KEYEVENTF_KEYUP;
42+
SendInput(2, fakekey, sizeof(INPUT));
43+
}
44+
else {
45+
int wchars_num = MultiByteToWideChar( CP_UTF8 , 0 , sText.c_str() , -1, nullptr , 0 );
46+
wchar_t* wstr = new wchar_t[wchars_num];
47+
MultiByteToWideChar( CP_UTF8 , 0 , sText.c_str() , -1, wstr , wchars_num );
48+
49+
for(int i = 0; i < wchars_num; ++i) {
50+
fakekey[0].type = INPUT_KEYBOARD;
51+
fakekey[0].ki.dwFlags = KEYEVENTF_UNICODE;
52+
fakekey[0].ki.wVk = 0;
53+
fakekey[0].ki.time = NULL;
54+
fakekey[0].ki.wScan = wstr[i];
55+
SendInput(1, fakekey, sizeof(INPUT));
56+
}
57+
58+
delete[] wstr;
59+
}
60+
#endif
61+
}

0 commit comments

Comments
 (0)