diff --git a/src/client/GuiApplication.cpp b/src/client/GuiApplication.cpp index bf39634..598ce8e 100644 --- a/src/client/GuiApplication.cpp +++ b/src/client/GuiApplication.cpp @@ -1,8 +1,8 @@ #include "GuiApplication.h" #include "Widget.h" -//#include "XcbInterface.h" -//#include "XcbKeyboard.h" +#include "XcbInterface.h" +#include "XcbKeyboard.h" #include "Window.h" #include "TextElement.h" #include "WindowManager.h" @@ -75,18 +75,18 @@ void GuiApplication::Run() auto mainWindow = mDesktopManager->GetWindowManager()->GetMainWindow(); SetUpWidget(); - //mDesktopManager->SetKeyboard(XcbKeyboard::Create()); + mDesktopManager->SetKeyboard(XcbKeyboard::Create()); - //bool useOpenGl = false; - //XcbInterface window_interface; - //window_interface.SetUseOpenGl(useOpenGl); - //window_interface.Initialize(); - //window_interface.AddWindow(mainWindow); - //window_interface.ShowWindow(mainWindow); - //if(useOpenGl) - //{ - // window_interface.CreateOpenGlDrawable(mainWindow); - //} - //window_interface.Loop(mDesktopManager.get()); - //window_interface.ShutDown(); + bool useOpenGl = false; + XcbInterface window_interface; + window_interface.SetUseOpenGl(useOpenGl); + window_interface.Initialize(); + window_interface.AddWindow(mainWindow); + window_interface.ShowWindow(mainWindow); + if(useOpenGl) + { + window_interface.CreateOpenGlDrawable(mainWindow); + } + window_interface.Loop(mDesktopManager.get()); + window_interface.ShutDown(); } diff --git a/src/client/StatusBar.cpp b/src/client/StatusBar.cpp index 79242c6..851df2b 100644 --- a/src/client/StatusBar.cpp +++ b/src/client/StatusBar.cpp @@ -1,5 +1,7 @@ #include "StatusBar.h" +#include "Color.h" + StatusBar::StatusBar() { SetBackgroundColor(Color::Create(200, 200, 200)); diff --git a/src/client/TopBar.cpp b/src/client/TopBar.cpp index c5c8c77..24db275 100644 --- a/src/client/TopBar.cpp +++ b/src/client/TopBar.cpp @@ -1,5 +1,7 @@ #include "TopBar.h" +#include "Color.h" + TopBar::TopBar() { SetBackgroundColor(Color::Create(50, 50, 50)); diff --git a/src/client/audio_editor/AudioEditorView.cpp b/src/client/audio_editor/AudioEditorView.cpp index bd637ec..06a90b6 100644 --- a/src/client/audio_editor/AudioEditorView.cpp +++ b/src/client/audio_editor/AudioEditorView.cpp @@ -1,5 +1,7 @@ #include "AudioEditorView.h" + #include "Label.h" +#include "Color.h" AudioEditorView::AudioEditorView() { diff --git a/src/client/image_editor/ImageEditorView.cpp b/src/client/image_editor/ImageEditorView.cpp index c553d69..b1519d6 100644 --- a/src/client/image_editor/ImageEditorView.cpp +++ b/src/client/image_editor/ImageEditorView.cpp @@ -1,5 +1,7 @@ #include "ImageEditorView.h" + #include "Label.h" +#include "Color.h" ImageEditorView::ImageEditorView() { diff --git a/src/client/web_client/WebClientView.cpp b/src/client/web_client/WebClientView.cpp index f1c2f5f..7fad55c 100644 --- a/src/client/web_client/WebClientView.cpp +++ b/src/client/web_client/WebClientView.cpp @@ -1,5 +1,7 @@ #include "WebClientView.h" + #include "Label.h" +#include "Color.h" WebClientView::WebClientView() { diff --git a/src/core/loggers/FileLogger.cpp b/src/core/loggers/FileLogger.cpp index ea152e6..052cdaa 100644 --- a/src/core/loggers/FileLogger.cpp +++ b/src/core/loggers/FileLogger.cpp @@ -41,7 +41,7 @@ void FileLogger::LogLine(const std::string& logType, const std::string& line, co #ifdef WIN32 gmtime_s(&time_buf, &t); #else - std::gmtime_s(&t, &time_buf); + gmtime_r(&t, &time_buf); #endif mFileStream << logType << "|" << std::put_time(&time_buf, "%T") << "|" << cleanedFileName << "::" << functionName << "::" << lineNumber << "|" << line << std::endl; } diff --git a/src/database/CMakeLists.txt b/src/database/CMakeLists.txt index b2a0878..ea43f2a 100644 --- a/src/database/CMakeLists.txt +++ b/src/database/CMakeLists.txt @@ -1,8 +1,7 @@ list(APPEND database_LIB_INCLUDES Database.cpp DatabaseManager.cpp - database_interfaces/SqliteInterface.cpp - ${SQLite3_INCLUDE_DIR}/sqlite3.c) + database_interfaces/SqliteInterface.cpp) add_library(database SHARED ${database_LIB_INCLUDES}) @@ -12,4 +11,6 @@ target_include_directories(database PUBLIC "${SQLite3_INCLUDE_DIR}" ) set_property(TARGET database PROPERTY FOLDER src) -set_target_properties( database PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON ) \ No newline at end of file +set_target_properties( database PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON ) + +target_link_libraries(database PUBLIC ${SQLite3_LIBRARIES}) \ No newline at end of file diff --git a/src/ui_elements/widgets/Button.cpp b/src/ui_elements/widgets/Button.cpp index db42e8d..310d391 100644 --- a/src/ui_elements/widgets/Button.cpp +++ b/src/ui_elements/widgets/Button.cpp @@ -1,4 +1,10 @@ #include "Button.h" + +#include "TextElement.h" +#include "GeometryElement.h" +#include "VisualLayer.h" +#include "MouseEvent.h" + #include Button::Button() diff --git a/src/ui_elements/widgets/Button.h b/src/ui_elements/widgets/Button.h index 33df3d2..3cfb3de 100644 --- a/src/ui_elements/widgets/Button.h +++ b/src/ui_elements/widgets/Button.h @@ -1,7 +1,13 @@ #pragma once #include "Widget.h" +#include "Color.h" + #include +#include + +class PaintEvent; +class MouseEvent; class Button : public Widget { diff --git a/src/ui_elements/widgets/Label.cpp b/src/ui_elements/widgets/Label.cpp index d580ee2..dd4b2e8 100644 --- a/src/ui_elements/widgets/Label.cpp +++ b/src/ui_elements/widgets/Label.cpp @@ -1,5 +1,8 @@ #include "Label.h" + #include "TextElement.h" +#include "GeometryElement.h" +#include "VisualLayer.h" Label::Label() : Widget(), diff --git a/src/ui_elements/widgets/Label.h b/src/ui_elements/widgets/Label.h index e8beffb..6ea6ad3 100644 --- a/src/ui_elements/widgets/Label.h +++ b/src/ui_elements/widgets/Label.h @@ -2,6 +2,8 @@ #include "Widget.h" +#include + class Label : public Widget { private: diff --git a/src/ui_elements/widgets/TextBox.cpp b/src/ui_elements/widgets/TextBox.cpp index 09c423a..19a4508 100644 --- a/src/ui_elements/widgets/TextBox.cpp +++ b/src/ui_elements/widgets/TextBox.cpp @@ -1,6 +1,10 @@ #include "TextBox.h" + #include "TextElement.h" -#include +#include "VisualLayer.h" +#include "GeometryElement.h" +#include "KeyboardEvent.h" + #include TextBox::TextBox() diff --git a/src/ui_elements/widgets/TextBox.h b/src/ui_elements/widgets/TextBox.h index 6a878c1..ad71200 100644 --- a/src/ui_elements/widgets/TextBox.h +++ b/src/ui_elements/widgets/TextBox.h @@ -2,6 +2,8 @@ #include "Widget.h" +#include + class TextBox : public Widget { private: diff --git a/src/ui_elements/widgets/Widget.cpp b/src/ui_elements/widgets/Widget.cpp index 5109784..086a8e8 100644 --- a/src/ui_elements/widgets/Widget.cpp +++ b/src/ui_elements/widgets/Widget.cpp @@ -1,6 +1,13 @@ -#include "RectangleElement.h" #include "Widget.h" +#include "RectangleElement.h" +#include "MouseEvent.h" +#include "KeyboardEvent.h" +#include "PaintEvent.h" +#include "VisualLayer.h" +#include "TextElement.h" +#include "Color.h" + #include Widget::Widget() diff --git a/src/ui_elements/widgets/Widget.h b/src/ui_elements/widgets/Widget.h index 241b06e..40e6f30 100644 --- a/src/ui_elements/widgets/Widget.h +++ b/src/ui_elements/widgets/Widget.h @@ -1,14 +1,16 @@ #pragma once +#include "DiscretePoint.h" + #include #include -#include "DiscretePoint.h" -#include "VisualLayer.h" -#include "PaintEvent.h" -#include "Color.h" -#include "MouseEvent.h" -#include "KeyboardEvent.h" +class MouseEvent; +class KeyboardEvent; +class PaintEvent; + +class VisualLayer; +class Color; class Widget { @@ -34,12 +36,12 @@ protected: BoundedSize mSize; BoundaryOffset mPadding; BoundaryOffset mMargin; - std::vector mMyLayers; + std::vector > mMyLayers; std::vector mLayers; std::vector > mChildren; unsigned mBorderThickness; - ColorUPtr mBackgroundColor; - ColorUPtr mBorderColor; + std::unique_ptr mBackgroundColor; + std::unique_ptr mBorderColor; bool mVisible; public: @@ -66,7 +68,7 @@ public: bool Contains(const DiscretePoint& loc) const; - void SetBackgroundColor(ColorUPtr color); + void SetBackgroundColor(std::unique_ptr color); void SetBounds(unsigned width, unsigned height); diff --git a/src/ui_elements/widgets/elements/TextElement.cpp b/src/ui_elements/widgets/elements/TextElement.cpp index 064dca3..56b3b94 100644 --- a/src/ui_elements/widgets/elements/TextElement.cpp +++ b/src/ui_elements/widgets/elements/TextElement.cpp @@ -1,9 +1,11 @@ #include "TextElement.h" +#include "Color.h" + TextElement::TextElement(const std::string& content, const DiscretePoint& loc) : mContent(content), mLocation(loc), - mFontLabel("7x14"), + mFontLabel("fixed"), mFillColor(Color::Create(255, 255, 255)), mStrokeColor(Color::Create(0, 0, 0)) { diff --git a/src/ui_elements/widgets/elements/TextElement.h b/src/ui_elements/widgets/elements/TextElement.h index 1d7de10..29b26a3 100644 --- a/src/ui_elements/widgets/elements/TextElement.h +++ b/src/ui_elements/widgets/elements/TextElement.h @@ -1,18 +1,19 @@ #pragma once +#include "DiscretePoint.h" + #include #include -#include "DiscretePoint.h" -#include "Color.h" +class Color; class TextElement { std::string mContent; DiscretePoint mLocation; std::string mFontLabel; - ColorUPtr mFillColor; - ColorUPtr mStrokeColor; + std::unique_ptr mFillColor; + std::unique_ptr mStrokeColor; public: @@ -29,8 +30,8 @@ public: std::string GetContent() const; std::string GetFontLabel() const; void SetContent(const std::string& content); - void SetFillColor(ColorUPtr color); - void SetStrokeColor(ColorUPtr color); + void SetFillColor(std::unique_ptr color); + void SetStrokeColor(std::unique_ptr color); }; using TextElementUPtr = std::unique_ptr; diff --git a/src/ui_elements/widgets/elements/VisualLayer.cpp b/src/ui_elements/widgets/elements/VisualLayer.cpp index dddfaa7..a175def 100644 --- a/src/ui_elements/widgets/elements/VisualLayer.cpp +++ b/src/ui_elements/widgets/elements/VisualLayer.cpp @@ -1,5 +1,8 @@ #include "VisualLayer.h" +#include "GeometryElement.h" +#include "TextElement.h" + VisualLayer::VisualLayer() : mShape(), mText() diff --git a/src/ui_elements/widgets/elements/VisualLayer.h b/src/ui_elements/widgets/elements/VisualLayer.h index 02673bd..5016c9e 100644 --- a/src/ui_elements/widgets/elements/VisualLayer.h +++ b/src/ui_elements/widgets/elements/VisualLayer.h @@ -1,13 +1,13 @@ #pragma once #include -#include "GeometryElement.h" -#include "TextElement.h" +class GeometryElement; +class TextElement; class VisualLayer { - GeometryElementUPtr mShape; - TextElementUPtr mText; + std::unique_ptr mShape; + std::unique_ptr mText; public: @@ -19,7 +19,7 @@ public: TextElement* GetText() const; bool HasShape() const; bool HasText() const; - void SetShape(GeometryElementUPtr shape); - void SetText(TextElementUPtr text); + void SetShape(std::unique_ptr shape); + void SetText(std::unique_ptr text); }; using VisualLayerUPtr = std::unique_ptr; diff --git a/src/windows/CMakeLists.txt b/src/windows/CMakeLists.txt index 2166dde..be9cba7 100644 --- a/src/windows/CMakeLists.txt +++ b/src/windows/CMakeLists.txt @@ -11,22 +11,19 @@ list(APPEND windows_LIB_INCLUDES managers/EventManager.cpp) # add the library -add_library(windows SHARED ${windows_LIB_INCLUDES}) +add_library(windows SHARED ${windows_LIB_INCLUDES} ${linux_INCLUDES}) target_include_directories(windows PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/managers" "${CMAKE_CURRENT_SOURCE_DIR}/ui_interfaces/x11" "${PROJECT_SOURCE_DIR}/src/geometry" + "${PROJECT_SOURCE_DIR}/src/graphics" "${PROJECT_SOURCE_DIR}/src/ui_elements" "${PROJECT_SOURCE_DIR}/src/ui_elements/widgets" ) -list(APPEND linux_LIBS - managers/WindowManager.cpp - managers/DesktopManager.cpp - managers/EventManager.cpp) -target_link_libraries(windows PUBLIC core geometry ui_elements) +target_link_libraries(windows PUBLIC X11 X11-xcb xcb core geometry graphics ui_elements) set_property(TARGET windows PROPERTY FOLDER src) set_target_properties( windows PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON ) \ No newline at end of file diff --git a/src/windows/ui_interfaces/x11/XcbLayerInterface.cpp b/src/windows/ui_interfaces/x11/XcbLayerInterface.cpp index c008a64..39a7d95 100644 --- a/src/windows/ui_interfaces/x11/XcbLayerInterface.cpp +++ b/src/windows/ui_interfaces/x11/XcbLayerInterface.cpp @@ -1,6 +1,9 @@ #include "XcbLayerInterface.h" + #include "XcbTextInterface.h" #include "RectangleElement.h" +#include "VisualLayer.h" + #include uint32_t XcbLayerInterface::GetColor(const Color* color) @@ -36,10 +39,10 @@ void XcbLayerInterface::AddLayer(xcb_connection_t* connection, auto shape = layer->GetShape(); if(shape->GetType() == GeometryElement::Type::Rectangle) { - auto rectangle = dynamic_cast(shape); - Pixel loc = rectangle->GetLocation(); - auto width = static_cast(rectangle->GetWidth()); - auto height = static_cast(rectangle->GetHeight()); + const auto rectangle = dynamic_cast(shape); + const auto loc = rectangle->GetLocation(); + const auto width = static_cast(rectangle->GetWidth()); + const auto height = static_cast(rectangle->GetHeight()); xcb_rectangle_t rectangles[] = { { static_cast(loc.GetX()), static_cast(loc.GetY()), width, height} }; XcbLayerInterface::ModifyGcColor(connection, gc, rectangle->GetFillColor()); diff --git a/src/windows/ui_interfaces/x11/XcbLayerInterface.h b/src/windows/ui_interfaces/x11/XcbLayerInterface.h index 41d2c46..799f4e0 100644 --- a/src/windows/ui_interfaces/x11/XcbLayerInterface.h +++ b/src/windows/ui_interfaces/x11/XcbLayerInterface.h @@ -1,8 +1,9 @@ #pragma once #include -#include "VisualLayer.h" -#include "Color.h" + +class Color; +class VisualLayer; class XcbLayerInterface { diff --git a/src/windows/ui_interfaces/x11/XcbTextInterface.cpp b/src/windows/ui_interfaces/x11/XcbTextInterface.cpp index 7bdc441..8382503 100644 --- a/src/windows/ui_interfaces/x11/XcbTextInterface.cpp +++ b/src/windows/ui_interfaces/x11/XcbTextInterface.cpp @@ -1,12 +1,15 @@ #include "XcbTextInterface.h" #include "XcbLayerInterface.h" +#include "VisualLayer.h" +#include "Color.h" +#include "RectangleElement.h" + #include xcb_gcontext_t XcbTextInterface::GetFontGC(xcb_connection_t *connection, - xcb_screen_t *screen, xcb_window_t window, const char*font_name, + xcb_screen_t *screen, xcb_window_t window, const char* font_name, const TextElement* textElement) { - /* get font */ xcb_font_t font = xcb_generate_id(connection); xcb_open_font(connection, font, strlen(font_name), font_name); @@ -28,11 +31,11 @@ void XcbTextInterface::AddTextElement(xcb_connection_t* connection, const TextElement* textElement) { /* get graphics context */ - xcb_gcontext_t gc = XcbTextInterface::GetFontGC(connection, screen, window, + auto gc = XcbTextInterface::GetFontGC(connection, screen, window, textElement->GetFontLabel().c_str(), textElement); /* draw the text */ - std::string content = textElement->GetContent(); + const auto content = textElement->GetContent(); Pixel loc = textElement->GetLocation(); xcb_image_text_8(connection, content.length(), window, gc, loc.GetX(), loc.GetY(), content.c_str());