Running on Linux again and small clean up.
This commit is contained in:
parent
683ba5447f
commit
2bde5567be
24 changed files with 113 additions and 60 deletions
|
@ -1,8 +1,8 @@
|
||||||
#include "GuiApplication.h"
|
#include "GuiApplication.h"
|
||||||
|
|
||||||
#include "Widget.h"
|
#include "Widget.h"
|
||||||
//#include "XcbInterface.h"
|
#include "XcbInterface.h"
|
||||||
//#include "XcbKeyboard.h"
|
#include "XcbKeyboard.h"
|
||||||
#include "Window.h"
|
#include "Window.h"
|
||||||
#include "TextElement.h"
|
#include "TextElement.h"
|
||||||
#include "WindowManager.h"
|
#include "WindowManager.h"
|
||||||
|
@ -75,18 +75,18 @@ void GuiApplication::Run()
|
||||||
auto mainWindow = mDesktopManager->GetWindowManager()->GetMainWindow();
|
auto mainWindow = mDesktopManager->GetWindowManager()->GetMainWindow();
|
||||||
SetUpWidget();
|
SetUpWidget();
|
||||||
|
|
||||||
//mDesktopManager->SetKeyboard(XcbKeyboard::Create());
|
mDesktopManager->SetKeyboard(XcbKeyboard::Create());
|
||||||
|
|
||||||
//bool useOpenGl = false;
|
bool useOpenGl = false;
|
||||||
//XcbInterface window_interface;
|
XcbInterface window_interface;
|
||||||
//window_interface.SetUseOpenGl(useOpenGl);
|
window_interface.SetUseOpenGl(useOpenGl);
|
||||||
//window_interface.Initialize();
|
window_interface.Initialize();
|
||||||
//window_interface.AddWindow(mainWindow);
|
window_interface.AddWindow(mainWindow);
|
||||||
//window_interface.ShowWindow(mainWindow);
|
window_interface.ShowWindow(mainWindow);
|
||||||
//if(useOpenGl)
|
if(useOpenGl)
|
||||||
//{
|
{
|
||||||
// window_interface.CreateOpenGlDrawable(mainWindow);
|
window_interface.CreateOpenGlDrawable(mainWindow);
|
||||||
//}
|
}
|
||||||
//window_interface.Loop(mDesktopManager.get());
|
window_interface.Loop(mDesktopManager.get());
|
||||||
//window_interface.ShutDown();
|
window_interface.ShutDown();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#include "StatusBar.h"
|
#include "StatusBar.h"
|
||||||
|
|
||||||
|
#include "Color.h"
|
||||||
|
|
||||||
StatusBar::StatusBar()
|
StatusBar::StatusBar()
|
||||||
{
|
{
|
||||||
SetBackgroundColor(Color::Create(200, 200, 200));
|
SetBackgroundColor(Color::Create(200, 200, 200));
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#include "TopBar.h"
|
#include "TopBar.h"
|
||||||
|
|
||||||
|
#include "Color.h"
|
||||||
|
|
||||||
TopBar::TopBar()
|
TopBar::TopBar()
|
||||||
{
|
{
|
||||||
SetBackgroundColor(Color::Create(50, 50, 50));
|
SetBackgroundColor(Color::Create(50, 50, 50));
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#include "AudioEditorView.h"
|
#include "AudioEditorView.h"
|
||||||
|
|
||||||
#include "Label.h"
|
#include "Label.h"
|
||||||
|
#include "Color.h"
|
||||||
|
|
||||||
AudioEditorView::AudioEditorView()
|
AudioEditorView::AudioEditorView()
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#include "ImageEditorView.h"
|
#include "ImageEditorView.h"
|
||||||
|
|
||||||
#include "Label.h"
|
#include "Label.h"
|
||||||
|
#include "Color.h"
|
||||||
|
|
||||||
ImageEditorView::ImageEditorView()
|
ImageEditorView::ImageEditorView()
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#include "WebClientView.h"
|
#include "WebClientView.h"
|
||||||
|
|
||||||
#include "Label.h"
|
#include "Label.h"
|
||||||
|
#include "Color.h"
|
||||||
|
|
||||||
WebClientView::WebClientView()
|
WebClientView::WebClientView()
|
||||||
{
|
{
|
||||||
|
|
|
@ -41,7 +41,7 @@ void FileLogger::LogLine(const std::string& logType, const std::string& line, co
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
gmtime_s(&time_buf, &t);
|
gmtime_s(&time_buf, &t);
|
||||||
#else
|
#else
|
||||||
std::gmtime_s(&t, &time_buf);
|
gmtime_r(&t, &time_buf);
|
||||||
#endif
|
#endif
|
||||||
mFileStream << logType << "|" << std::put_time(&time_buf, "%T") << "|" << cleanedFileName << "::" << functionName << "::" << lineNumber << "|" << line << std::endl;
|
mFileStream << logType << "|" << std::put_time(&time_buf, "%T") << "|" << cleanedFileName << "::" << functionName << "::" << lineNumber << "|" << line << std::endl;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
list(APPEND database_LIB_INCLUDES
|
list(APPEND database_LIB_INCLUDES
|
||||||
Database.cpp
|
Database.cpp
|
||||||
DatabaseManager.cpp
|
DatabaseManager.cpp
|
||||||
database_interfaces/SqliteInterface.cpp
|
database_interfaces/SqliteInterface.cpp)
|
||||||
${SQLite3_INCLUDE_DIR}/sqlite3.c)
|
|
||||||
|
|
||||||
add_library(database SHARED ${database_LIB_INCLUDES})
|
add_library(database SHARED ${database_LIB_INCLUDES})
|
||||||
|
|
||||||
|
@ -13,3 +12,5 @@ target_include_directories(database PUBLIC
|
||||||
)
|
)
|
||||||
set_property(TARGET database PROPERTY FOLDER src)
|
set_property(TARGET database PROPERTY FOLDER src)
|
||||||
set_target_properties( database PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON )
|
set_target_properties( database PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON )
|
||||||
|
|
||||||
|
target_link_libraries(database PUBLIC ${SQLite3_LIBRARIES})
|
|
@ -1,4 +1,10 @@
|
||||||
#include "Button.h"
|
#include "Button.h"
|
||||||
|
|
||||||
|
#include "TextElement.h"
|
||||||
|
#include "GeometryElement.h"
|
||||||
|
#include "VisualLayer.h"
|
||||||
|
#include "MouseEvent.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
Button::Button()
|
Button::Button()
|
||||||
|
|
|
@ -1,7 +1,13 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Widget.h"
|
#include "Widget.h"
|
||||||
|
#include "Color.h"
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
class PaintEvent;
|
||||||
|
class MouseEvent;
|
||||||
|
|
||||||
class Button : public Widget
|
class Button : public Widget
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
#include "Label.h"
|
#include "Label.h"
|
||||||
|
|
||||||
#include "TextElement.h"
|
#include "TextElement.h"
|
||||||
|
#include "GeometryElement.h"
|
||||||
|
#include "VisualLayer.h"
|
||||||
|
|
||||||
Label::Label()
|
Label::Label()
|
||||||
: Widget(),
|
: Widget(),
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
#include "Widget.h"
|
#include "Widget.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
class Label : public Widget
|
class Label : public Widget
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
#include "TextBox.h"
|
#include "TextBox.h"
|
||||||
|
|
||||||
#include "TextElement.h"
|
#include "TextElement.h"
|
||||||
#include <string>
|
#include "VisualLayer.h"
|
||||||
|
#include "GeometryElement.h"
|
||||||
|
#include "KeyboardEvent.h"
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
TextBox::TextBox()
|
TextBox::TextBox()
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
#include "Widget.h"
|
#include "Widget.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
class TextBox : public Widget
|
class TextBox : public Widget
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -1,6 +1,13 @@
|
||||||
#include "RectangleElement.h"
|
|
||||||
#include "Widget.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 <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
Widget::Widget()
|
Widget::Widget()
|
||||||
|
|
|
@ -1,14 +1,16 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "DiscretePoint.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "DiscretePoint.h"
|
class MouseEvent;
|
||||||
#include "VisualLayer.h"
|
class KeyboardEvent;
|
||||||
#include "PaintEvent.h"
|
class PaintEvent;
|
||||||
#include "Color.h"
|
|
||||||
#include "MouseEvent.h"
|
class VisualLayer;
|
||||||
#include "KeyboardEvent.h"
|
class Color;
|
||||||
|
|
||||||
class Widget
|
class Widget
|
||||||
{
|
{
|
||||||
|
@ -34,12 +36,12 @@ protected:
|
||||||
BoundedSize mSize;
|
BoundedSize mSize;
|
||||||
BoundaryOffset mPadding;
|
BoundaryOffset mPadding;
|
||||||
BoundaryOffset mMargin;
|
BoundaryOffset mMargin;
|
||||||
std::vector<VisualLayerUPtr> mMyLayers;
|
std::vector<std::unique_ptr<VisualLayer> > mMyLayers;
|
||||||
std::vector<VisualLayer*> mLayers;
|
std::vector<VisualLayer*> mLayers;
|
||||||
std::vector<std::unique_ptr<Widget> > mChildren;
|
std::vector<std::unique_ptr<Widget> > mChildren;
|
||||||
unsigned mBorderThickness;
|
unsigned mBorderThickness;
|
||||||
ColorUPtr mBackgroundColor;
|
std::unique_ptr<Color> mBackgroundColor;
|
||||||
ColorUPtr mBorderColor;
|
std::unique_ptr<Color> mBorderColor;
|
||||||
bool mVisible;
|
bool mVisible;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -66,7 +68,7 @@ public:
|
||||||
|
|
||||||
bool Contains(const DiscretePoint& loc) const;
|
bool Contains(const DiscretePoint& loc) const;
|
||||||
|
|
||||||
void SetBackgroundColor(ColorUPtr color);
|
void SetBackgroundColor(std::unique_ptr<Color> color);
|
||||||
|
|
||||||
void SetBounds(unsigned width, unsigned height);
|
void SetBounds(unsigned width, unsigned height);
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
#include "TextElement.h"
|
#include "TextElement.h"
|
||||||
|
|
||||||
|
#include "Color.h"
|
||||||
|
|
||||||
TextElement::TextElement(const std::string& content, const DiscretePoint& loc)
|
TextElement::TextElement(const std::string& content, const DiscretePoint& loc)
|
||||||
: mContent(content),
|
: mContent(content),
|
||||||
mLocation(loc),
|
mLocation(loc),
|
||||||
mFontLabel("7x14"),
|
mFontLabel("fixed"),
|
||||||
mFillColor(Color::Create(255, 255, 255)),
|
mFillColor(Color::Create(255, 255, 255)),
|
||||||
mStrokeColor(Color::Create(0, 0, 0))
|
mStrokeColor(Color::Create(0, 0, 0))
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,18 +1,19 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "DiscretePoint.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "DiscretePoint.h"
|
class Color;
|
||||||
#include "Color.h"
|
|
||||||
|
|
||||||
class TextElement
|
class TextElement
|
||||||
{
|
{
|
||||||
std::string mContent;
|
std::string mContent;
|
||||||
DiscretePoint mLocation;
|
DiscretePoint mLocation;
|
||||||
std::string mFontLabel;
|
std::string mFontLabel;
|
||||||
ColorUPtr mFillColor;
|
std::unique_ptr<Color> mFillColor;
|
||||||
ColorUPtr mStrokeColor;
|
std::unique_ptr<Color> mStrokeColor;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -29,8 +30,8 @@ public:
|
||||||
std::string GetContent() const;
|
std::string GetContent() const;
|
||||||
std::string GetFontLabel() const;
|
std::string GetFontLabel() const;
|
||||||
void SetContent(const std::string& content);
|
void SetContent(const std::string& content);
|
||||||
void SetFillColor(ColorUPtr color);
|
void SetFillColor(std::unique_ptr<Color> color);
|
||||||
void SetStrokeColor(ColorUPtr color);
|
void SetStrokeColor(std::unique_ptr<Color> color);
|
||||||
};
|
};
|
||||||
|
|
||||||
using TextElementUPtr = std::unique_ptr<TextElement>;
|
using TextElementUPtr = std::unique_ptr<TextElement>;
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
#include "VisualLayer.h"
|
#include "VisualLayer.h"
|
||||||
|
|
||||||
|
#include "GeometryElement.h"
|
||||||
|
#include "TextElement.h"
|
||||||
|
|
||||||
VisualLayer::VisualLayer()
|
VisualLayer::VisualLayer()
|
||||||
: mShape(),
|
: mShape(),
|
||||||
mText()
|
mText()
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "GeometryElement.h"
|
class GeometryElement;
|
||||||
#include "TextElement.h"
|
class TextElement;
|
||||||
|
|
||||||
class VisualLayer
|
class VisualLayer
|
||||||
{
|
{
|
||||||
GeometryElementUPtr mShape;
|
std::unique_ptr<GeometryElement> mShape;
|
||||||
TextElementUPtr mText;
|
std::unique_ptr<TextElement> mText;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ public:
|
||||||
TextElement* GetText() const;
|
TextElement* GetText() const;
|
||||||
bool HasShape() const;
|
bool HasShape() const;
|
||||||
bool HasText() const;
|
bool HasText() const;
|
||||||
void SetShape(GeometryElementUPtr shape);
|
void SetShape(std::unique_ptr<GeometryElement> shape);
|
||||||
void SetText(TextElementUPtr text);
|
void SetText(std::unique_ptr<TextElement> text);
|
||||||
};
|
};
|
||||||
using VisualLayerUPtr = std::unique_ptr<VisualLayer>;
|
using VisualLayerUPtr = std::unique_ptr<VisualLayer>;
|
||||||
|
|
|
@ -11,22 +11,19 @@ list(APPEND windows_LIB_INCLUDES
|
||||||
managers/EventManager.cpp)
|
managers/EventManager.cpp)
|
||||||
|
|
||||||
# add the library
|
# add the library
|
||||||
add_library(windows SHARED ${windows_LIB_INCLUDES})
|
add_library(windows SHARED ${windows_LIB_INCLUDES} ${linux_INCLUDES})
|
||||||
|
|
||||||
target_include_directories(windows PUBLIC
|
target_include_directories(windows PUBLIC
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}"
|
"${CMAKE_CURRENT_SOURCE_DIR}"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/managers"
|
"${CMAKE_CURRENT_SOURCE_DIR}/managers"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/ui_interfaces/x11"
|
"${CMAKE_CURRENT_SOURCE_DIR}/ui_interfaces/x11"
|
||||||
"${PROJECT_SOURCE_DIR}/src/geometry"
|
"${PROJECT_SOURCE_DIR}/src/geometry"
|
||||||
|
"${PROJECT_SOURCE_DIR}/src/graphics"
|
||||||
"${PROJECT_SOURCE_DIR}/src/ui_elements"
|
"${PROJECT_SOURCE_DIR}/src/ui_elements"
|
||||||
"${PROJECT_SOURCE_DIR}/src/ui_elements/widgets"
|
"${PROJECT_SOURCE_DIR}/src/ui_elements/widgets"
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND linux_LIBS
|
target_link_libraries(windows PUBLIC X11 X11-xcb xcb core geometry graphics ui_elements)
|
||||||
managers/WindowManager.cpp
|
|
||||||
managers/DesktopManager.cpp
|
|
||||||
managers/EventManager.cpp)
|
|
||||||
target_link_libraries(windows PUBLIC core geometry ui_elements)
|
|
||||||
|
|
||||||
set_property(TARGET windows PROPERTY FOLDER src)
|
set_property(TARGET windows PROPERTY FOLDER src)
|
||||||
set_target_properties( windows PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON )
|
set_target_properties( windows PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON )
|
|
@ -1,6 +1,9 @@
|
||||||
#include "XcbLayerInterface.h"
|
#include "XcbLayerInterface.h"
|
||||||
|
|
||||||
#include "XcbTextInterface.h"
|
#include "XcbTextInterface.h"
|
||||||
#include "RectangleElement.h"
|
#include "RectangleElement.h"
|
||||||
|
#include "VisualLayer.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
uint32_t XcbLayerInterface::GetColor(const Color* color)
|
uint32_t XcbLayerInterface::GetColor(const Color* color)
|
||||||
|
@ -36,10 +39,10 @@ void XcbLayerInterface::AddLayer(xcb_connection_t* connection,
|
||||||
auto shape = layer->GetShape();
|
auto shape = layer->GetShape();
|
||||||
if(shape->GetType() == GeometryElement::Type::Rectangle)
|
if(shape->GetType() == GeometryElement::Type::Rectangle)
|
||||||
{
|
{
|
||||||
auto rectangle = dynamic_cast<RectangleElement*>(shape);
|
const auto rectangle = dynamic_cast<RectangleElement*>(shape);
|
||||||
Pixel loc = rectangle->GetLocation();
|
const auto loc = rectangle->GetLocation();
|
||||||
auto width = static_cast<uint16_t>(rectangle->GetWidth());
|
const auto width = static_cast<uint16_t>(rectangle->GetWidth());
|
||||||
auto height = static_cast<uint16_t>(rectangle->GetHeight());
|
const auto height = static_cast<uint16_t>(rectangle->GetHeight());
|
||||||
xcb_rectangle_t rectangles[] = { { static_cast<int16_t>(loc.GetX()),
|
xcb_rectangle_t rectangles[] = { { static_cast<int16_t>(loc.GetX()),
|
||||||
static_cast<int16_t>(loc.GetY()), width, height} };
|
static_cast<int16_t>(loc.GetY()), width, height} };
|
||||||
XcbLayerInterface::ModifyGcColor(connection, gc, rectangle->GetFillColor());
|
XcbLayerInterface::ModifyGcColor(connection, gc, rectangle->GetFillColor());
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <xcb/xcb.h>
|
#include <xcb/xcb.h>
|
||||||
#include "VisualLayer.h"
|
|
||||||
#include "Color.h"
|
class Color;
|
||||||
|
class VisualLayer;
|
||||||
|
|
||||||
class XcbLayerInterface
|
class XcbLayerInterface
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,12 +1,15 @@
|
||||||
#include "XcbTextInterface.h"
|
#include "XcbTextInterface.h"
|
||||||
#include "XcbLayerInterface.h"
|
#include "XcbLayerInterface.h"
|
||||||
|
#include "VisualLayer.h"
|
||||||
|
#include "Color.h"
|
||||||
|
#include "RectangleElement.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
xcb_gcontext_t XcbTextInterface::GetFontGC(xcb_connection_t *connection,
|
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)
|
const TextElement* textElement)
|
||||||
{
|
{
|
||||||
/* get font */
|
|
||||||
xcb_font_t font = xcb_generate_id(connection);
|
xcb_font_t font = xcb_generate_id(connection);
|
||||||
xcb_open_font(connection, font, strlen(font_name), font_name);
|
xcb_open_font(connection, font, strlen(font_name), font_name);
|
||||||
|
|
||||||
|
@ -28,11 +31,11 @@ void XcbTextInterface::AddTextElement(xcb_connection_t* connection,
|
||||||
const TextElement* textElement)
|
const TextElement* textElement)
|
||||||
{
|
{
|
||||||
/* get graphics context */
|
/* get graphics context */
|
||||||
xcb_gcontext_t gc = XcbTextInterface::GetFontGC(connection, screen, window,
|
auto gc = XcbTextInterface::GetFontGC(connection, screen, window,
|
||||||
textElement->GetFontLabel().c_str(), textElement);
|
textElement->GetFontLabel().c_str(), textElement);
|
||||||
|
|
||||||
/* draw the text */
|
/* draw the text */
|
||||||
std::string content = textElement->GetContent();
|
const auto content = textElement->GetContent();
|
||||||
Pixel loc = textElement->GetLocation();
|
Pixel loc = textElement->GetLocation();
|
||||||
xcb_image_text_8(connection, content.length(), window, gc,
|
xcb_image_text_8(connection, content.length(), window, gc,
|
||||||
loc.GetX(), loc.GetY(), content.c_str());
|
loc.GetX(), loc.GetY(), content.c_str());
|
||||||
|
|
Loading…
Reference in a new issue