diff --git a/apps/CMakeLists.txt b/apps/CMakeLists.txt index a6e1c97..304c8d8 100644 --- a/apps/CMakeLists.txt +++ b/apps/CMakeLists.txt @@ -1,17 +1,14 @@ -# Sample GUI - -add_subdirectory(sample-gui) +add_subdirectory(notes_tk) +add_subdirectory(website-generator) +# Experimental Below if(WIN32) add_subdirectory(directx-practice) endif() # Sample Console -add_executable(sample_console console-main.cpp) -target_link_libraries(sample_console PUBLIC console core network - database geometry audio web) +add_executable(notes_tk_console main.cpp) +target_link_libraries(notes_tk_console PUBLIC console core network database geometry audio web) +set_property(TARGET notes_tk_console PROPERTY FOLDER apps) -set_property(TARGET sample_console PROPERTY FOLDER apps) - -add_subdirectory(website-generator) diff --git a/apps/console-main.cpp b/apps/main.cpp similarity index 100% rename from apps/console-main.cpp rename to apps/main.cpp diff --git a/apps/sample-gui/CMakeLists.txt b/apps/notes_tk/CMakeLists.txt similarity index 88% rename from apps/sample-gui/CMakeLists.txt rename to apps/notes_tk/CMakeLists.txt index a2ff773..f43ebc5 100644 --- a/apps/sample-gui/CMakeLists.txt +++ b/apps/notes_tk/CMakeLists.txt @@ -1,9 +1,9 @@ -set(APP_NAME sample_gui) +set(APP_NAME notes_tk) message(STATUS "Checking dependencies for app: " ${APP_NAME}) list(APPEND client_HEADERS - MediaTool.h + NotesTk.h text_editor/TextEditorView.h text_editor/TextEditorModel.h text_editor/TextEditorController.h @@ -33,15 +33,15 @@ list(APPEND client_LIB_INCLUDES canvas/CanvasView.cpp canvas/CanvasController.cpp web_client/WebClientView.cpp - MediaTool.cpp) + NotesTk.cpp) set(DEPENDENCIES_FOUND True) if(WIN32) - add_executable(${APP_NAME} WIN32 gui-main-win.cpp ${client_LIB_INCLUDES}) + add_executable(${APP_NAME} WIN32 main-win.cpp ${client_LIB_INCLUDES}) else() find_package(X11 QUIET) if(X11_FOUND) - add_executable(${APP_NAME} gui-main.cpp ${client_LIB_INCLUDES} ${client_HEADERS}) + add_executable(${APP_NAME} main.cpp ${client_LIB_INCLUDES} ${client_HEADERS}) else() message(STATUS "X11 not found - skipping") set(DEPENDENCIES_FOUND FALSE) diff --git a/apps/sample-gui/MediaTool.cpp b/apps/notes_tk/NotesTk.cpp similarity index 85% rename from apps/sample-gui/MediaTool.cpp rename to apps/notes_tk/NotesTk.cpp index 864ff79..e6d986b 100644 --- a/apps/sample-gui/MediaTool.cpp +++ b/apps/notes_tk/NotesTk.cpp @@ -1,4 +1,4 @@ -#include "MediaTool.h" +#include "NotesTk.h" #include "TextEditorView.h" #include "AudioEditorView.h" @@ -16,17 +16,17 @@ #include "DesktopManager.h" #include "MainApplication.h" -MediaTool::MediaTool(std::unique_ptr args) +NotesTk::NotesTk(std::unique_ptr args) : GuiApplication(std::move(args)) { } -void MediaTool::initializeViews() +void NotesTk::initializeViews() { auto mainWindow = mDesktopManager->getWindowManager()->getMainWindow(); mainWindow->setSize(800, 600); - mainWindow->setTitle("Media Tool"); + mainWindow->setTitle("NotesTK"); auto tabbedPanel = TabbedPanelWidget::Create(); @@ -41,7 +41,7 @@ void MediaTool::initializeViews() auto audioEditor = AudioEditorView::Create(); audioEditor->setName("audioEditor"); - tabbedPanel->addPanel(std::move(audioEditor), "audio Editor"); + tabbedPanel->addPanel(std::move(audioEditor), "Audio Editor"); auto imageEditor = ImageEditorView::Create(); imageEditor->setName("imageEditor"); @@ -60,12 +60,12 @@ void MediaTool::initializeViews() tabbedPanel->addPanel(std::move(mesh), "Mesh Viewer"); auto topBar = TopBar::Create(); - auto statusBar = StatusBar::Create(); + //auto statusBar = StatusBar::Create(); auto horizontal_spacer = HorizontalSpacer::Create(); horizontal_spacer->addWidgetWithScale(std::move(topBar), 1); horizontal_spacer->addWidgetWithScale(std::move(tabbedPanel), 20); - horizontal_spacer->addWidgetWithScale(std::move(statusBar), 1); + //horizontal_spacer->addWidgetWithScale(std::move(statusBar), 1); mainWindow->setWidget(std::move(horizontal_spacer)); } diff --git a/apps/sample-gui/MediaTool.h b/apps/notes_tk/NotesTk.h similarity index 52% rename from apps/sample-gui/MediaTool.h rename to apps/notes_tk/NotesTk.h index 13541d0..a7139e8 100644 --- a/apps/sample-gui/MediaTool.h +++ b/apps/notes_tk/NotesTk.h @@ -2,10 +2,10 @@ #include "GuiApplication.h" -class MediaTool : public GuiApplication +class NotesTk : public GuiApplication { public: - MediaTool(std::unique_ptr args); + NotesTk(std::unique_ptr args); protected: void initializeViews() override; diff --git a/apps/sample-gui/audio_editor/AudioEditorView.cpp b/apps/notes_tk/audio_editor/AudioEditorView.cpp similarity index 100% rename from apps/sample-gui/audio_editor/AudioEditorView.cpp rename to apps/notes_tk/audio_editor/AudioEditorView.cpp diff --git a/apps/sample-gui/audio_editor/AudioEditorView.h b/apps/notes_tk/audio_editor/AudioEditorView.h similarity index 100% rename from apps/sample-gui/audio_editor/AudioEditorView.h rename to apps/notes_tk/audio_editor/AudioEditorView.h diff --git a/apps/sample-gui/canvas/CanvasController.cpp b/apps/notes_tk/canvas/CanvasController.cpp similarity index 100% rename from apps/sample-gui/canvas/CanvasController.cpp rename to apps/notes_tk/canvas/CanvasController.cpp diff --git a/apps/sample-gui/canvas/CanvasController.h b/apps/notes_tk/canvas/CanvasController.h similarity index 100% rename from apps/sample-gui/canvas/CanvasController.h rename to apps/notes_tk/canvas/CanvasController.h diff --git a/apps/sample-gui/canvas/CanvasView.cpp b/apps/notes_tk/canvas/CanvasView.cpp similarity index 97% rename from apps/sample-gui/canvas/CanvasView.cpp rename to apps/notes_tk/canvas/CanvasView.cpp index 239adb1..c8fbc6e 100644 --- a/apps/sample-gui/canvas/CanvasView.cpp +++ b/apps/notes_tk/canvas/CanvasView.cpp @@ -16,7 +16,6 @@ CanvasView::CanvasView() : mController(CanvasController::Create()) { - std::cout << "Creatin canvas" << std::endl; initialize(); } diff --git a/apps/sample-gui/canvas/CanvasView.h b/apps/notes_tk/canvas/CanvasView.h similarity index 100% rename from apps/sample-gui/canvas/CanvasView.h rename to apps/notes_tk/canvas/CanvasView.h diff --git a/apps/sample-gui/image_editor/ImageEditorView.cpp b/apps/notes_tk/image_editor/ImageEditorView.cpp similarity index 100% rename from apps/sample-gui/image_editor/ImageEditorView.cpp rename to apps/notes_tk/image_editor/ImageEditorView.cpp diff --git a/apps/sample-gui/image_editor/ImageEditorView.h b/apps/notes_tk/image_editor/ImageEditorView.h similarity index 100% rename from apps/sample-gui/image_editor/ImageEditorView.h rename to apps/notes_tk/image_editor/ImageEditorView.h diff --git a/apps/sample-gui/image_editor/ImageViewWidget.cpp b/apps/notes_tk/image_editor/ImageViewWidget.cpp similarity index 93% rename from apps/sample-gui/image_editor/ImageViewWidget.cpp rename to apps/notes_tk/image_editor/ImageViewWidget.cpp index d737064..1bc24c8 100644 --- a/apps/sample-gui/image_editor/ImageViewWidget.cpp +++ b/apps/notes_tk/image_editor/ImageViewWidget.cpp @@ -7,7 +7,6 @@ ImageViewWidget::ImageViewWidget() { - std::cout << "Creating image view widget" << std::endl; mName = "ImageViewWidget"; } diff --git a/apps/sample-gui/image_editor/ImageViewWidget.h b/apps/notes_tk/image_editor/ImageViewWidget.h similarity index 100% rename from apps/sample-gui/image_editor/ImageViewWidget.h rename to apps/notes_tk/image_editor/ImageViewWidget.h diff --git a/apps/sample-gui/gui-main-win.cpp b/apps/notes_tk/main-win.cpp similarity index 100% rename from apps/sample-gui/gui-main-win.cpp rename to apps/notes_tk/main-win.cpp diff --git a/apps/sample-gui/gui-main.cpp b/apps/notes_tk/main.cpp similarity index 84% rename from apps/sample-gui/gui-main.cpp rename to apps/notes_tk/main.cpp index 700ff9a..f864fb8 100644 --- a/apps/sample-gui/gui-main.cpp +++ b/apps/notes_tk/main.cpp @@ -1,6 +1,6 @@ #include -#include "MediaTool.h" +#include "NotesTk.h" #include "MainApplication.h" #include "CommandLineArgs.h" @@ -11,7 +11,7 @@ int main(int argc, char *argv[]) args->recordLaunchPath(); // Start the gui app - auto app = MediaTool(std::move(args)); + auto app = NotesTk(std::move(args)); //app.setUiInterfaceBackend(UiInterfaceFactory::Backend::X11_RASTER); app.run(); diff --git a/apps/sample-gui/mesh_viewer/MeshViewerCanvas.cpp b/apps/notes_tk/mesh_viewer/MeshViewerCanvas.cpp similarity index 100% rename from apps/sample-gui/mesh_viewer/MeshViewerCanvas.cpp rename to apps/notes_tk/mesh_viewer/MeshViewerCanvas.cpp diff --git a/apps/sample-gui/mesh_viewer/MeshViewerCanvas.h b/apps/notes_tk/mesh_viewer/MeshViewerCanvas.h similarity index 100% rename from apps/sample-gui/mesh_viewer/MeshViewerCanvas.h rename to apps/notes_tk/mesh_viewer/MeshViewerCanvas.h diff --git a/apps/sample-gui/mesh_viewer/MeshViewerController.cpp b/apps/notes_tk/mesh_viewer/MeshViewerController.cpp similarity index 100% rename from apps/sample-gui/mesh_viewer/MeshViewerController.cpp rename to apps/notes_tk/mesh_viewer/MeshViewerController.cpp diff --git a/apps/sample-gui/mesh_viewer/MeshViewerController.h b/apps/notes_tk/mesh_viewer/MeshViewerController.h similarity index 100% rename from apps/sample-gui/mesh_viewer/MeshViewerController.h rename to apps/notes_tk/mesh_viewer/MeshViewerController.h diff --git a/apps/sample-gui/mesh_viewer/MeshViewerView.cpp b/apps/notes_tk/mesh_viewer/MeshViewerView.cpp similarity index 100% rename from apps/sample-gui/mesh_viewer/MeshViewerView.cpp rename to apps/notes_tk/mesh_viewer/MeshViewerView.cpp diff --git a/apps/sample-gui/mesh_viewer/MeshViewerView.h b/apps/notes_tk/mesh_viewer/MeshViewerView.h similarity index 100% rename from apps/sample-gui/mesh_viewer/MeshViewerView.h rename to apps/notes_tk/mesh_viewer/MeshViewerView.h diff --git a/apps/sample-gui/text_editor/PlainTextDocument.cpp b/apps/notes_tk/text_editor/PlainTextDocument.cpp similarity index 100% rename from apps/sample-gui/text_editor/PlainTextDocument.cpp rename to apps/notes_tk/text_editor/PlainTextDocument.cpp diff --git a/apps/sample-gui/text_editor/PlainTextDocument.h b/apps/notes_tk/text_editor/PlainTextDocument.h similarity index 100% rename from apps/sample-gui/text_editor/PlainTextDocument.h rename to apps/notes_tk/text_editor/PlainTextDocument.h diff --git a/apps/sample-gui/text_editor/TextEditorController.cpp b/apps/notes_tk/text_editor/TextEditorController.cpp similarity index 100% rename from apps/sample-gui/text_editor/TextEditorController.cpp rename to apps/notes_tk/text_editor/TextEditorController.cpp diff --git a/apps/sample-gui/text_editor/TextEditorController.h b/apps/notes_tk/text_editor/TextEditorController.h similarity index 100% rename from apps/sample-gui/text_editor/TextEditorController.h rename to apps/notes_tk/text_editor/TextEditorController.h diff --git a/apps/sample-gui/text_editor/TextEditorModel.cpp b/apps/notes_tk/text_editor/TextEditorModel.cpp similarity index 100% rename from apps/sample-gui/text_editor/TextEditorModel.cpp rename to apps/notes_tk/text_editor/TextEditorModel.cpp diff --git a/apps/sample-gui/text_editor/TextEditorModel.h b/apps/notes_tk/text_editor/TextEditorModel.h similarity index 100% rename from apps/sample-gui/text_editor/TextEditorModel.h rename to apps/notes_tk/text_editor/TextEditorModel.h diff --git a/apps/sample-gui/text_editor/TextEditorView.cpp b/apps/notes_tk/text_editor/TextEditorView.cpp similarity index 100% rename from apps/sample-gui/text_editor/TextEditorView.cpp rename to apps/notes_tk/text_editor/TextEditorView.cpp diff --git a/apps/sample-gui/text_editor/TextEditorView.h b/apps/notes_tk/text_editor/TextEditorView.h similarity index 100% rename from apps/sample-gui/text_editor/TextEditorView.h rename to apps/notes_tk/text_editor/TextEditorView.h diff --git a/apps/sample-gui/web_client/WebClientView.cpp b/apps/notes_tk/web_client/WebClientView.cpp similarity index 100% rename from apps/sample-gui/web_client/WebClientView.cpp rename to apps/notes_tk/web_client/WebClientView.cpp diff --git a/apps/sample-gui/web_client/WebClientView.h b/apps/notes_tk/web_client/WebClientView.h similarity index 100% rename from apps/sample-gui/web_client/WebClientView.h rename to apps/notes_tk/web_client/WebClientView.h diff --git a/src/fonts/FontGlyph.cpp b/src/fonts/FontGlyph.cpp index faa251c..f5a1432 100644 --- a/src/fonts/FontGlyph.cpp +++ b/src/fonts/FontGlyph.cpp @@ -1,7 +1,7 @@ #include "FontGlyph.h" -FontGlyph::FontGlyph(unsigned width, unsigned height, unsigned bearingX, unsigned bearingY, - unsigned advanceX, std::unique_ptr > image) +FontGlyph::FontGlyph(unsigned width, unsigned height, int bearingX, int bearingY, + int advanceX, std::unique_ptr > image) : mImage(std::move(image)), mWidth(width), mHeight(height), @@ -27,17 +27,17 @@ unsigned FontGlyph::getHeight() const return mHeight; } -unsigned FontGlyph::getBearingX() const +int FontGlyph::getBearingX() const { return mBearingX; } -unsigned FontGlyph::getBearingY() const +int FontGlyph::getBearingY() const { return mBearingY; } -unsigned FontGlyph::getAdvanceX() const +int FontGlyph::getAdvanceX() const { return mAdvanceX; } diff --git a/src/fonts/FontGlyph.h b/src/fonts/FontGlyph.h index 54c3246..ac357a4 100644 --- a/src/fonts/FontGlyph.h +++ b/src/fonts/FontGlyph.h @@ -8,22 +8,22 @@ class FontGlyph { public: - FontGlyph(unsigned width, unsigned height, unsigned bearingX, unsigned bearingY, - unsigned advanceX, std::unique_ptr > image); + FontGlyph(unsigned width, unsigned height, int bearingX, int bearingY, + int advanceX, std::unique_ptr > image); Image* getImage() const; unsigned getWidth() const; unsigned getHeight() const; - unsigned getBearingX() const; - unsigned getBearingY() const; - unsigned getAdvanceX() const; + int getBearingX() const; + int getBearingY() const; + int getAdvanceX() const; private: unsigned mWidth{0}; unsigned mHeight{0}; - unsigned mBearingX{0}; - unsigned mBearingY{0}; - unsigned mAdvanceX{0}; + int mBearingX{0}; + int mBearingY{0}; + int mAdvanceX{0}; std::unique_ptr > mImage; }; diff --git a/src/fonts/FontItem.h b/src/fonts/FontItem.h index c50877f..0083bbc 100644 --- a/src/fonts/FontItem.h +++ b/src/fonts/FontItem.h @@ -50,7 +50,7 @@ public: } private: - unsigned mSize{16}; + unsigned mSize{24}; std::string mFaceName; std::filesystem::path mPath; }; diff --git a/src/fonts/FontsManager.cpp b/src/fonts/FontsManager.cpp index fbaa00c..0414b1a 100644 --- a/src/fonts/FontsManager.cpp +++ b/src/fonts/FontsManager.cpp @@ -29,9 +29,9 @@ IFontEngine* FontsManager::getFontEngine() const return mFontEngine.get(); } -FontGlyph* FontsManager::getGlyph(const std::string& fontFace, int size, char c) +FontGlyph* FontsManager::getGlyph(const std::string& fontFace, int size, uint32_t c) { - auto path = std::filesystem::path("truetype/msttcorefonts/arial.ttf"); + auto path = std::filesystem::path("truetype/liberation/LiberationSans-Regular.ttf"); mFontEngine->loadFontFace(path, size); diff --git a/src/fonts/FontsManager.h b/src/fonts/FontsManager.h index 105c461..ddeb874 100644 --- a/src/fonts/FontsManager.h +++ b/src/fonts/FontsManager.h @@ -15,12 +15,12 @@ public: IFontEngine* getFontEngine() const; - FontGlyph* getGlyph(const std::string& fontFace, int size, char c); + FontGlyph* getGlyph(const std::string& fontFace, int size, uint32_t c); private: std::unique_ptr mFontEngine; - std::unordered_map > mGlyphs; + std::unordered_map > mGlyphs; }; using FontsManagerPtr = std::unique_ptr; diff --git a/src/fonts/FreeTypeFontEngine.cpp b/src/fonts/FreeTypeFontEngine.cpp index 5caf414..94d33a4 100644 --- a/src/fonts/FreeTypeFontEngine.cpp +++ b/src/fonts/FreeTypeFontEngine.cpp @@ -4,6 +4,8 @@ #include "FileLogger.h" #include "FontGlyph.h" +#include + void FreeTypeFontEngine::initialize() { if (mLibrary) @@ -43,7 +45,7 @@ void FreeTypeFontEngine::loadFontFace(const std::filesystem::path& fontFile, int FT_Set_Pixel_Sizes(mWorkingFontFace, penSize, 0); } -std::unique_ptr FreeTypeFontEngine::loadGlyph(unsigned charCode) +std::unique_ptr FreeTypeFontEngine::loadGlyph(uint32_t charCode) { auto glyph_index = FT_Get_Char_Index( mWorkingFontFace, charCode ); if (glyph_index == 0) @@ -89,7 +91,6 @@ std::unique_ptr FreeTypeFontEngine::loadGlyph(unsigned charCode) } } image->setData(data); - auto glyph = std::make_unique(mWorkingFontFace->glyph->bitmap.width, mWorkingFontFace->glyph->bitmap.rows, mWorkingFontFace->glyph->bitmap_left, diff --git a/src/fonts/FreeTypeFontEngine.h b/src/fonts/FreeTypeFontEngine.h index 40a4d5c..b84572d 100644 --- a/src/fonts/FreeTypeFontEngine.h +++ b/src/fonts/FreeTypeFontEngine.h @@ -19,7 +19,7 @@ public: void loadFontFace(const std::filesystem::path& fontFile, int penSize = 16) override; - std::unique_ptr loadGlyph(unsigned charCode) override; + std::unique_ptr loadGlyph(uint32_t charCode) override; private: std::filesystem::path mSystemFontLocation{"/usr/share/fonts/"}; diff --git a/src/fonts/IFontEngine.h b/src/fonts/IFontEngine.h index 082fd43..ccfe7ea 100644 --- a/src/fonts/IFontEngine.h +++ b/src/fonts/IFontEngine.h @@ -15,5 +15,5 @@ public: virtual void loadFontFace(const std::filesystem::path& fontFile, int penSize = 16) = 0; - virtual std::unique_ptr loadGlyph(unsigned charCode) = 0; + virtual std::unique_ptr loadGlyph(uint32_t charCode) = 0; }; diff --git a/src/graphics/opengl/OpenGlTextPainter.cpp b/src/graphics/opengl/OpenGlTextPainter.cpp index 74ea0f3..55b01c7 100644 --- a/src/graphics/opengl/OpenGlTextPainter.cpp +++ b/src/graphics/opengl/OpenGlTextPainter.cpp @@ -27,8 +27,6 @@ #include #include -#include - OpenGlTextPainter::OpenGlTextPainter() { @@ -118,7 +116,7 @@ void OpenGlTextPainter::paint(SceneText* text, DrawingContext* context) auto texture = mFontTextures[c].get(); float xpos = x + texture->getGlyph()->getBearingX(); - float ypos = y - (texture->getGlyph()->getHeight() - texture->getGlyph()->getBearingY()); + float ypos = y - (int(texture->getGlyph()->getHeight()) - texture->getGlyph()->getBearingY()); float w = texture->getGlyph()->getWidth(); float h = texture->getGlyph()->getHeight(); @@ -131,7 +129,6 @@ void OpenGlTextPainter::paint(SceneText* text, DrawingContext* context) { xpos + w, ypos, 1.0f, 1.0f }, { xpos + w, ypos + h, 1.0f, 0.0f } }; - glBindTexture(GL_TEXTURE_2D, texture->getHandle()); glBindBuffer(GL_ARRAY_BUFFER, mVertexBuffer); @@ -140,12 +137,11 @@ void OpenGlTextPainter::paint(SceneText* text, DrawingContext* context) glDrawArrays(GL_TRIANGLES, 0, 6); - x += (texture->getGlyph()->getAdvanceX() >> 6); // bitshift by 6 to get value in pixels (2^6 = 64) + auto offset = (texture->getGlyph()->getAdvanceX() >> 6); // bitshift by 6 to get value in pixels (2^6 = 64) + x += offset; } - line_offset += line_delta; } - glBindVertexArray(0); glBindTexture(GL_TEXTURE_2D, 0); } diff --git a/src/publishing/pdf/PdfPage.cpp b/src/publishing/pdf/PdfPage.cpp index 72a47f6..9cf2b0d 100644 --- a/src/publishing/pdf/PdfPage.cpp +++ b/src/publishing/pdf/PdfPage.cpp @@ -42,8 +42,8 @@ PdfPage::PdfPage(PdfPageTree* parent) std::string pageContent = "BT\n"; pageContent += "/F1 24 Tf\n"; - pageContent += "100 100 Td\n"; - pageContent += "(Hello World) Tj\n"; + pageContent += "100 700 Td\n"; + pageContent += "(Hello \nWorld) Tj\n"; pageContent += "ET"; mContent->setContent(pageContent); diff --git a/src/publishing/pdf/PdfPageTree.h b/src/publishing/pdf/PdfPageTree.h index 41f659f..df67c6f 100644 --- a/src/publishing/pdf/PdfPageTree.h +++ b/src/publishing/pdf/PdfPageTree.h @@ -17,6 +17,5 @@ public: void updateDictionary() override; private: - PdfPagePtr mRootPage; }; diff --git a/src/ui_elements/widgets/TextBox.cpp b/src/ui_elements/widgets/TextBox.cpp index 3c99290..6342d4d 100644 --- a/src/ui_elements/widgets/TextBox.cpp +++ b/src/ui_elements/widgets/TextBox.cpp @@ -57,7 +57,15 @@ bool TextBox::onMyKeyboardEvent(const KeyboardEvent* event) else { const auto keyString = event->getKeyString(); - appendContent(keyString); + if (keyString.length() < 2) + { + appendContent(keyString); + } + else + { + appendContent("?"); + } + } return true; }