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 "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();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "StatusBar.h"
|
||||
|
||||
#include "Color.h"
|
||||
|
||||
StatusBar::StatusBar()
|
||||
{
|
||||
SetBackgroundColor(Color::Create(200, 200, 200));
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "TopBar.h"
|
||||
|
||||
#include "Color.h"
|
||||
|
||||
TopBar::TopBar()
|
||||
{
|
||||
SetBackgroundColor(Color::Create(50, 50, 50));
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "AudioEditorView.h"
|
||||
|
||||
#include "Label.h"
|
||||
#include "Color.h"
|
||||
|
||||
AudioEditorView::AudioEditorView()
|
||||
{
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "ImageEditorView.h"
|
||||
|
||||
#include "Label.h"
|
||||
#include "Color.h"
|
||||
|
||||
ImageEditorView::ImageEditorView()
|
||||
{
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "WebClientView.h"
|
||||
|
||||
#include "Label.h"
|
||||
#include "Color.h"
|
||||
|
||||
WebClientView::WebClientView()
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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})
|
||||
|
||||
|
@ -13,3 +12,5 @@ target_include_directories(database PUBLIC
|
|||
)
|
||||
set_property(TARGET database PROPERTY FOLDER src)
|
||||
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 "TextElement.h"
|
||||
#include "GeometryElement.h"
|
||||
#include "VisualLayer.h"
|
||||
#include "MouseEvent.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
Button::Button()
|
||||
|
|
|
@ -1,7 +1,13 @@
|
|||
#pragma once
|
||||
|
||||
#include "Widget.h"
|
||||
#include "Color.h"
|
||||
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
class PaintEvent;
|
||||
class MouseEvent;
|
||||
|
||||
class Button : public Widget
|
||||
{
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
#include "Label.h"
|
||||
|
||||
#include "TextElement.h"
|
||||
#include "GeometryElement.h"
|
||||
#include "VisualLayer.h"
|
||||
|
||||
Label::Label()
|
||||
: Widget(),
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
#include "Widget.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
class Label : public Widget
|
||||
{
|
||||
private:
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
#include "TextBox.h"
|
||||
|
||||
#include "TextElement.h"
|
||||
#include <string>
|
||||
#include "VisualLayer.h"
|
||||
#include "GeometryElement.h"
|
||||
#include "KeyboardEvent.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
TextBox::TextBox()
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
#include "Widget.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
class TextBox : public Widget
|
||||
{
|
||||
private:
|
||||
|
|
|
@ -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 <algorithm>
|
||||
|
||||
Widget::Widget()
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
#pragma once
|
||||
|
||||
#include "DiscretePoint.h"
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#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<VisualLayerUPtr> mMyLayers;
|
||||
std::vector<std::unique_ptr<VisualLayer> > mMyLayers;
|
||||
std::vector<VisualLayer*> mLayers;
|
||||
std::vector<std::unique_ptr<Widget> > mChildren;
|
||||
unsigned mBorderThickness;
|
||||
ColorUPtr mBackgroundColor;
|
||||
ColorUPtr mBorderColor;
|
||||
std::unique_ptr<Color> mBackgroundColor;
|
||||
std::unique_ptr<Color> 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> color);
|
||||
|
||||
void SetBounds(unsigned width, unsigned height);
|
||||
|
||||
|
|
|
@ -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))
|
||||
{
|
||||
|
|
|
@ -1,18 +1,19 @@
|
|||
#pragma once
|
||||
|
||||
#include "DiscretePoint.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#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<Color> mFillColor;
|
||||
std::unique_ptr<Color> 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> color);
|
||||
void SetStrokeColor(std::unique_ptr<Color> color);
|
||||
};
|
||||
|
||||
using TextElementUPtr = std::unique_ptr<TextElement>;
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
#include "VisualLayer.h"
|
||||
|
||||
#include "GeometryElement.h"
|
||||
#include "TextElement.h"
|
||||
|
||||
VisualLayer::VisualLayer()
|
||||
: mShape(),
|
||||
mText()
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
#pragma once
|
||||
#include <memory>
|
||||
|
||||
#include "GeometryElement.h"
|
||||
#include "TextElement.h"
|
||||
class GeometryElement;
|
||||
class TextElement;
|
||||
|
||||
class VisualLayer
|
||||
{
|
||||
GeometryElementUPtr mShape;
|
||||
TextElementUPtr mText;
|
||||
std::unique_ptr<GeometryElement> mShape;
|
||||
std::unique_ptr<TextElement> 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<GeometryElement> shape);
|
||||
void SetText(std::unique_ptr<TextElement> text);
|
||||
};
|
||||
using VisualLayerUPtr = std::unique_ptr<VisualLayer>;
|
||||
|
|
|
@ -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 )
|
|
@ -1,6 +1,9 @@
|
|||
#include "XcbLayerInterface.h"
|
||||
|
||||
#include "XcbTextInterface.h"
|
||||
#include "RectangleElement.h"
|
||||
#include "VisualLayer.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
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<RectangleElement*>(shape);
|
||||
Pixel loc = rectangle->GetLocation();
|
||||
auto width = static_cast<uint16_t>(rectangle->GetWidth());
|
||||
auto height = static_cast<uint16_t>(rectangle->GetHeight());
|
||||
const auto rectangle = dynamic_cast<RectangleElement*>(shape);
|
||||
const auto loc = rectangle->GetLocation();
|
||||
const auto width = static_cast<uint16_t>(rectangle->GetWidth());
|
||||
const auto height = static_cast<uint16_t>(rectangle->GetHeight());
|
||||
xcb_rectangle_t rectangles[] = { { static_cast<int16_t>(loc.GetX()),
|
||||
static_cast<int16_t>(loc.GetY()), width, height} };
|
||||
XcbLayerInterface::ModifyGcColor(connection, gc, rectangle->GetFillColor());
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
#pragma once
|
||||
|
||||
#include <xcb/xcb.h>
|
||||
#include "VisualLayer.h"
|
||||
#include "Color.h"
|
||||
|
||||
class Color;
|
||||
class VisualLayer;
|
||||
|
||||
class XcbLayerInterface
|
||||
{
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
#include "XcbTextInterface.h"
|
||||
#include "XcbLayerInterface.h"
|
||||
#include "VisualLayer.h"
|
||||
#include "Color.h"
|
||||
#include "RectangleElement.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
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());
|
||||
|
|
Loading…
Reference in a new issue