Add Windows support.

This commit is contained in:
david 2020-07-04 19:43:08 +01:00
parent ee51f3ee09
commit 683ba5447f
37 changed files with 477 additions and 113 deletions

View file

@ -5,7 +5,13 @@ project(media-tools)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
link_libraries(stdc++fs)
set_property( GLOBAL PROPERTY USE_FOLDERS ON)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
find_package(SQLite3)
add_subdirectory(src)
add_subdirectory(apps)

View file

@ -5,7 +5,15 @@ target_include_directories(sample_gui PUBLIC
"${PROJECT_SOURCE_DIR}/src/client"
)
target_link_libraries(sample_gui PUBLIC client windows console core
network database geometry audio graphics web)
network database geometry audio web)
add_executable(sample_gui_win WIN32 gui-main-win.cpp)
target_include_directories(sample_gui PUBLIC
"${PROJECT_SOURCE_DIR}/src/console"
"${PROJECT_SOURCE_DIR}/src/client"
)
target_link_libraries(sample_gui_win PUBLIC client windows console core
network database geometry audio web)
# Sample Console
add_executable(sample_console console-main.cpp)
@ -22,3 +30,8 @@ target_include_directories(xml_practice PUBLIC
"${PROJECT_SOURCE_DIR}/src/web/xml"
)
target_link_libraries(xml_practice PUBLIC core web)
set_property(TARGET sample_console PROPERTY FOLDER apps)
set_property(TARGET sample_gui PROPERTY FOLDER apps)
set_property(TARGET sample_gui_win PROPERTY FOLDER apps)
set_property(TARGET xml_practice PROPERTY FOLDER apps)

82
apps/audio-win.cpp Normal file
View file

@ -0,0 +1,82 @@
// LowLevelAudio.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include "Mmdeviceapi.h"
#include "Functiondiscoverykeys_devpkey.h"
#include <iostream>
const CLSID CLSID_MMDeviceEnumerator = __uuidof(MMDeviceEnumerator);
const IID IID_IMMDeviceEnumerator = __uuidof(IMMDeviceEnumerator);
int main()
{
CoInitialize(nullptr);
IMMDeviceEnumerator* pEnumerator = nullptr;
IMMDeviceCollection* pDeviceCollection = nullptr;
HRESULT hr = S_OK;
hr = CoCreateInstance(CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL,
IID_IMMDeviceEnumerator, (void**)& pEnumerator);
if (!pEnumerator)
{
std::cout << "Failed to populate enumerator" << std::endl;
return 0;
}
hr = pEnumerator->EnumAudioEndpoints(eRender, DEVICE_STATE_ACTIVE, &pDeviceCollection);
UINT count;
hr = pDeviceCollection->GetCount(&count);
if (count == 0)
{
std::cout << "No devices found\n";
}
// Each loop prints the name of an endpoint device.
IMMDevice* pEndpoint = nullptr;
IPropertyStore* pProps = nullptr;
LPWSTR pwszID = nullptr;
for (ULONG i = 0; i < count; i++)
{
// Get pointer to endpoint number i.
hr = pDeviceCollection->Item(i, &pEndpoint);
// Get the endpoint ID string.
hr = pEndpoint->GetId(&pwszID);
hr = pEndpoint->OpenPropertyStore(STGM_READ, &pProps);
PROPVARIANT varName;
// Initialize container for property value.
PropVariantInit(&varName);
// Get the endpoint's friendly-name property.
hr = pProps->GetValue(PKEY_Device_FriendlyName, &varName);
// Print endpoint friendly name and endpoint ID.
std::cout << "Endpoint: " << i << " " << varName.pwszVal << " " << pwszID << std::endl;
CoTaskMemFree(pwszID);
pwszID = nullptr;
PropVariantClear(&varName);
if (pProps)
{
pProps->Release();
pProps = nullptr;
}
if (pEndpoint)
{
pEndpoint->Release();
pEndpoint = nullptr;
}
}
if (pEnumerator)
{
pEnumerator->Release();
pEnumerator = nullptr;
}
if (pDeviceCollection)
{
pDeviceCollection->Release();
pDeviceCollection = nullptr;
}
return 0;
}

73
apps/gui-main-win.cpp Normal file
View file

@ -0,0 +1,73 @@
#ifndef UNICODE
#define UNICODE
#endif
#include "windows.h"
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow)
{
// Register the window class.
const wchar_t CLASS_NAME[] = L"Sample Window Class";
WNDCLASS wc = { };
wc.lpfnWndProc = WindowProc;
wc.hInstance = hInstance;
wc.lpszClassName = CLASS_NAME;
RegisterClass(&wc);
HWND hwnd = CreateWindowEx(
0, // Optional window styles.
CLASS_NAME, // Window class
L"Learn to Program Windows", // Window text
WS_OVERLAPPEDWINDOW, // Window style
// Size and position
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
NULL, // Parent window
NULL, // Menu
hInstance, // Instance handle
NULL // Additional application data
);
if (hwnd == NULL)
{
return 0;
}
ShowWindow(hwnd, nCmdShow);
// Run the message loop.
MSG msg = { };
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_DESTROY:
PostQuitMessage(0);
return 0;
case WM_PAINT:
{
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hwnd, &ps);
FillRect(hdc, &ps.rcPaint, (HBRUSH)(COLOR_WINDOW + 1));
EndPaint(hwnd, &ps);
}
}
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}

View file

@ -1,10 +1,10 @@
#include "AudioManager.h"
AudioManager::AudioManager()
: mAudioDevices(),
mAudioInterface()
: mAudioDevices(),
mAudioInterface()
{
mAudioInterface = AlsaInterface::Create();
mAudioInterface = AudioInterface::Create();
}
AudioManager::~AudioManager()
@ -12,22 +12,22 @@ AudioManager::~AudioManager()
}
std::shared_ptr<AudioManager> AudioManager::Create()
std::unique_ptr<AudioManager> AudioManager::Create()
{
return std::make_shared<AudioManager>();
return std::make_unique<AudioManager>();
}
void AudioManager::AddAudioDevice(AudioDevicePtr device)
{
mAudioDevices.push_back(device);
mAudioDevices.push_back(device);
}
AlsaInterfacePtr AudioManager::GetAudioInterface()
AudioInterface* AudioManager::GetAudioInterface()
{
return mAudioInterface;
return mAudioInterface.get();
}
std::vector<AudioDevicePtr> AudioManager::GetAudioDevices()
{
return mAudioDevices;
return mAudioDevices;
}

View file

@ -3,7 +3,7 @@
#include <memory>
#include <vector>
#include "AlsaInterface.h"
#include "AudioInterface.h"
#include "AudioDevice.h"
class AudioManager
@ -11,22 +11,22 @@ class AudioManager
private:
std::vector<AudioDevicePtr> mAudioDevices;
AlsaInterfacePtr mAudioInterface;
std::vector<AudioDevicePtr> mAudioDevices;
AudioInterfaceUPtr mAudioInterface;
public:
AudioManager();
AudioManager();
~AudioManager();
~AudioManager();
static std::shared_ptr<AudioManager> Create();
static std::unique_ptr<AudioManager> Create();
void AddAudioDevice(AudioDevicePtr device);
void AddAudioDevice(AudioDevicePtr device);
std::vector<AudioDevicePtr> GetAudioDevices();
std::vector<AudioDevicePtr> GetAudioDevices();
AlsaInterfacePtr GetAudioInterface();
AudioInterface* GetAudioInterface();
};
using AudioManagerPtr = std::shared_ptr<AudioManager>;
using AudioManagerUPtr = std::unique_ptr<AudioManager>;

View file

@ -1,7 +1,26 @@
list(APPEND linux_HEADERS
audio_interfaces/AlsaInterface.h
)
list(APPEND audio_HEADERS
AudioDevice.h
AudioManager.h
audio_interfaces/AudioInterface.h
midi/MidiReader.h
midi/MidiTrack.h
midi/MidiDocument.h
midi/MidiEvent.h
midi/MetaMidiEvent.h
midi/MidiChannelEvent.h)
list(APPEND linux_INCLUDES
audio_interfaces/AlsaInterface.cpp
)
list(APPEND audio_LIB_INCLUDES
AudioDevice.cpp
AudioManager.cpp
audio_interfaces/AlsaInterface.cpp
audio_interfaces/AudioInterface.cpp
midi/MidiReader.cpp
midi/MidiTrack.cpp
midi/MidiDocument.cpp
@ -9,8 +28,7 @@ list(APPEND audio_LIB_INCLUDES
midi/MetaMidiEvent.cpp
midi/MidiChannelEvent.cpp)
add_library(audio SHARED ${audio_LIB_INCLUDES})
add_library(audio SHARED ${audio_LIB_INCLUDES} ${audio_HEADERS})
target_include_directories(audio PUBLIC
"${CMAKE_CURRENT_SOURCE_DIR}"
"${PROJECT_SOURCE_DIR}/src/core/file_utilities"
@ -19,4 +37,10 @@ target_include_directories(audio PUBLIC
"${CMAKE_CURRENT_SOURCE_DIR}/midi"
)
target_link_libraries(audio PUBLIC core asound)
list(APPEND linux_LIBS
asound
)
target_link_libraries(audio PUBLIC core)
set_target_properties( audio PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON )
set_property(TARGET audio PROPERTY FOLDER src)

View file

@ -0,0 +1,22 @@
#include "AudioInterface.h"
#include "AudioDevice.h"
AudioInterface::AudioInterface()
{
}
std::unique_ptr<AudioInterface> AudioInterface::Create()
{
return std::make_unique<AudioInterface>();
}
void AudioInterface::OpenDevice(AudioDevicePtr device)
{
}
void AudioInterface::Play(AudioDevicePtr device)
{
}

View file

@ -0,0 +1,21 @@
#pragma once
#include <memory>
class AudioDevice;
using AudioDevicePtr = std::shared_ptr<AudioDevice>;
class AudioInterface
{
public:
AudioInterface();
static std::unique_ptr<AudioInterface> Create();
void OpenDevice(AudioDevicePtr device);
void Play(AudioDevicePtr device);
};
using AudioInterfaceUPtr = std::unique_ptr<AudioInterface>;

View file

@ -123,11 +123,11 @@ bool MidiReader::ProcessSetTempoMetaEvent(std::ifstream& file, MetaMidiEvent& ev
BinaryFile::GetNextByteAsInt(file, length);
mTrackByteCount ++;
char buffer[length];
BinaryFile::GetNextNBytes(file, buffer, length);
std::string buffer;
BinaryFile::GetNextNBytes(file, buffer.data(), length);
mTrackByteCount += length;
int tempo = ByteUtils::ToInt(buffer, length);
int tempo = ByteUtils::ToInt(buffer.data(), length);
const int MICROSECONDS_PER_MINUTE = 60000000;
std::cout << "Got tempo "<< tempo << "|" << MICROSECONDS_PER_MINUTE/tempo<< std::endl;
event.SetValue(tempo);
@ -331,7 +331,7 @@ bool MidiReader::ProcessTrackChunk(std::ifstream& file, bool debug)
mTrackByteCount = 0;
MidiTrack track;
unsigned iter_count = 0;
while(mTrackByteCount < chunkSize)
while(mTrackByteCount < unsigned(chunkSize))
{
std::cout << "-------------" << std::endl;
ProcessEvent(file, track);

View file

@ -1,3 +1,16 @@
list(APPEND client_HEADERS
TopBar.h
StatusBar.h
GuiApplication.h
TabbedPanelWidget.h
text_editor/TextEditorView.h
text_editor/TextEditorModel.h
text_editor/TextEditorController.h
text_editor/PlainTextDocument.h
audio_editor/AudioEditorView.h
image_editor/ImageEditorView.h
web_client/WebClientView.h)
list(APPEND client_LIB_INCLUDES
TopBar.cpp
StatusBar.cpp
@ -11,7 +24,7 @@ list(APPEND client_LIB_INCLUDES
image_editor/ImageEditorView.cpp
web_client/WebClientView.cpp)
add_library(client SHARED ${client_LIB_INCLUDES})
add_library(client SHARED ${client_LIB_INCLUDES} ${client_HEADERS})
target_link_libraries(client ui_elements windows core console database geometry)
@ -24,3 +37,5 @@ target_include_directories(client PUBLIC
"${PROJECT_SOURCE_DIR}/src/console"
"${PROJECT_SOURCE_DIR}/src/ui_elements/widgets"
)
set_property(TARGET client PROPERTY FOLDER src)
set_target_properties( client PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON )

View file

@ -1,12 +1,11 @@
#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"
#include <iostream>
#include "TextEditorView.h"
#include "AudioEditorView.h"
#include "ImageEditorView.h"
@ -16,6 +15,8 @@
#include "StatusBar.h"
#include "HorizontalSpacer.h"
#include <iostream>
GuiApplication::GuiApplication()
: AbstractDesktopApp(),
mMainApplication(),
@ -74,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();
}

View file

@ -1,11 +1,11 @@
#pragma once
#include <memory>
#include "MainApplication.h"
#include "AbstractDesktopApp.h"
#include "DesktopManager.h"
#include <memory>
class GuiApplication : public AbstractDesktopApp
{

View file

@ -1,6 +1,8 @@
list(APPEND console_HEADERS MainApplication.h)
list(APPEND console_LIB_INCLUDES MainApplication.cpp)
add_library(console SHARED ${console_LIB_INCLUDES})
add_library(console SHARED ${console_LIB_INCLUDES} ${console_HEADERS})
target_include_directories(console PUBLIC
"${PROJECT_SOURCE_DIR}/src/core/"
@ -14,4 +16,8 @@ target_include_directories(console PUBLIC
"${PROJECT_SOURCE_DIR}/src/audio/midi"
"${PROJECT_SOURCE_DIR}/src/audio/audio_interfaces"
"${PROJECT_SOURCE_DIR}/src/web"
"${SQLite3_INCLUDE_DIR}"
)
set_property(TARGET console PROPERTY FOLDER src)
target_link_libraries(console PUBLIC core audio network database web)
set_target_properties( console PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON )

View file

@ -15,8 +15,8 @@ private:
CommandLineArgsUPtr mCommandLineArgs;
DatabaseManagerPtr mDatabaseManager;
NetworkManagerPtr mNetworkManager;
AudioManagerPtr mAudioManager;
NetworkManagerUPtr mNetworkManager;
AudioManagerUPtr mAudioManager;
public:

View file

@ -25,14 +25,14 @@ public:
}
}
static int ToInt(char* buffer, unsigned size, bool reverse = true)
static int ToInt(char* buffer, const unsigned size, bool reverse = true)
{
int result;
if(reverse)
{
char reversed[size];
ReverseBuffer(buffer, reversed, size);
std::memcpy(&result, reversed, sizeof(int));
std::string reversed;
ReverseBuffer(buffer, reversed.data(), size);
std::memcpy(&result, reversed.data(), sizeof(int));
}
else
{

View file

@ -1,3 +1,14 @@
list(APPEND core_HEADERS
Event.h
Color.h
CommandLineArgs.h
loggers/FileLogger.h
file_utilities/BinaryFile.h
file_utilities/File.h
file_utilities/FileFormats.h
StringUtils.h
http/HttpResponse.h)
list(APPEND core_LIB_INCLUDES
Event.cpp
Color.cpp
@ -10,10 +21,12 @@ list(APPEND core_LIB_INCLUDES
http/HttpResponse.cpp)
# add the executable
add_library(core SHARED ${core_LIB_INCLUDES})
add_library(core SHARED ${core_LIB_INCLUDES} ${core_HEADERS})
target_include_directories(core PUBLIC
"${CMAKE_CURRENT_SOURCE_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}/file_utilities"
"${CMAKE_CURRENT_SOURCE_DIR}/loggers"
)
set_target_properties( core PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON )
set_property(TARGET core PROPERTY FOLDER src)

View file

@ -13,7 +13,7 @@ File::File(std::filesystem::path path)
std::string File::GetExtension() const
{
return mFullPath.extension();
return mFullPath.extension().string();
}
void File::SetAccessMode(AccessMode mode)

View file

@ -21,7 +21,7 @@ void HttpResponse::SetBody(const std::string& body)
unsigned HttpResponse::GetBodyLength()
{
return mBody.length();
return unsigned(mBody.length());
}
std::string HttpResponse::GetHeaderString()

View file

@ -1,5 +1,5 @@
#include "FileLogger.h"
#include <ctime>
#include <time.h>
#include <iomanip>
@ -37,5 +37,11 @@ void FileLogger::LogLine(const std::string& logType, const std::string& line, co
{
std::time_t t = std::time(nullptr);
const std::string cleanedFileName = fileName.substr(fileName.find_last_of("/\\") + 1);
mFileStream << logType << "|" << std::put_time(std::gmtime(&t), "%T") << "|" << cleanedFileName << "::" << functionName << "::" << lineNumber << "|" << line << std::endl;
std::tm time_buf = { 0 };
#ifdef WIN32
gmtime_s(&time_buf, &t);
#else
std::gmtime_s(&t, &time_buf);
#endif
mFileStream << logType << "|" << std::put_time(&time_buf, "%T") << "|" << cleanedFileName << "::" << functionName << "::" << lineNumber << "|" << line << std::endl;
}

View file

@ -1,13 +1,15 @@
list(APPEND database_LIB_INCLUDES
Database.cpp
DatabaseManager.cpp
database_interfaces/SqliteInterface.cpp)
database_interfaces/SqliteInterface.cpp
${SQLite3_INCLUDE_DIR}/sqlite3.c)
add_library(database SHARED ${database_LIB_INCLUDES})
target_include_directories(database PUBLIC
"${CMAKE_CURRENT_SOURCE_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}/database_interfaces"
"${SQLite3_INCLUDE_DIR}"
)
target_link_libraries(database PUBLIC sqlite3)
set_property(TARGET database PROPERTY FOLDER src)
set_target_properties( database PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON )

View file

@ -5,3 +5,5 @@ list(APPEND geometry_LIB_INCLUDES
# add the library
add_library(geometry SHARED ${geometry_LIB_INCLUDES})
set_target_properties( geometry PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON )
set_property(TARGET geometry PROPERTY FOLDER src)

View file

@ -1,5 +1,8 @@
list(APPEND graphics_LIB_INCLUDES OpenGlInterface)
list(APPEND graphics_LIB_INCLUDES OpenGlInterface.cpp)
list(APPEND graphics_HEADERS OpenGlInterface.h)
add_library(graphics SHARED ${graphics_LIB_INCLUDES})
add_library(graphics SHARED ${graphics_LIB_INCLUDES} ${graphics_HEADERS})
target_link_libraries(graphics PUBLIC GL)
set_property(TARGET graphics PROPERTY FOLDER src)

View file

@ -4,7 +4,7 @@ class OpenGlInterface
{
public:
static void draw();
static void draw();
};

View file

@ -1,14 +1,26 @@
list(APPEND linux_INCLUDES
sockets/UnixSocketInterface.cpp)
list(APPEND network_HEADERS
NetworkManager.h
sockets/Socket.h
sockets/SocketInterface.h
)
list(APPEND network_LIB_INCLUDES
NetworkManager.cpp
sockets/Socket.cpp
sockets/UnixSocketInterface.cpp)
sockets/SocketInterface.cpp
)
add_library(network SHARED ${network_LIB_INCLUDES})
add_library(network SHARED ${network_LIB_INCLUDES} ${network_HEADERS})
target_include_directories(network PUBLIC
"${CMAKE_CURRENT_SOURCE_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}/sockets"
"${PROJECT_SOURCE_DIR}/src/core/http"
)
set_target_properties( network PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON )
target_link_libraries( network PUBLIC core)
target_link_libraries(network PUBLIC core)
set_property(TARGET network PROPERTY FOLDER src)

View file

@ -1,8 +1,8 @@
#include "NetworkManager.h"
NetworkManager::NetworkManager()
: mActiveSockets(),
mSocketInterface()
: mActiveSockets(),
mSocketInterface()
{
}
@ -12,22 +12,22 @@ NetworkManager::~NetworkManager()
}
std::shared_ptr<NetworkManager> NetworkManager::Create()
std::unique_ptr<NetworkManager> NetworkManager::Create()
{
return std::make_shared<NetworkManager>();
return std::make_unique<NetworkManager>();
}
void NetworkManager::Initialize()
{
mSocketInterface = UnixSocketInterface::Create();
mSocketInterface = SocketInterface::Create();
}
void NetworkManager::RunHttpServer()
{
auto socket = Socket::Create();
mSocketInterface->CreateSocket(socket);
mSocketInterface->Listen(socket);
mSocketInterface->Run(socket);
auto socket = Socket::Create();
mSocketInterface->CreateSocket(socket);
mSocketInterface->Listen(socket);
mSocketInterface->Run(socket);
}
void NetworkManager::ShutDown()

View file

@ -4,30 +4,30 @@
#include <vector>
#include "Socket.h"
#include "UnixSocketInterface.h"
#include "SocketInterface.h"
class NetworkManager
{
std::vector<SocketPtr> mActiveSockets;
UnixSocketInterfacePtr mSocketInterface;
std::vector<SocketPtr> mActiveSockets;
SocketInterfaceUPtr mSocketInterface;
public:
NetworkManager();
NetworkManager();
~NetworkManager();
~NetworkManager();
static std::shared_ptr<NetworkManager> Create();
static std::unique_ptr<NetworkManager> Create();
void Initialize();
void Initialize();
void OpenSocket(SocketPtr socket);
void OpenSocket(SocketPtr socket);
void CloseSocket(SocketPtr socket);
void CloseSocket(SocketPtr socket);
void RunHttpServer();
void RunHttpServer();
void ShutDown();
void ShutDown();
};
using NetworkManagerPtr = std::shared_ptr<NetworkManager>;
using NetworkManagerUPtr = std::unique_ptr<NetworkManager>;

View file

@ -0,0 +1,27 @@
#include "SocketInterface.h"
#include "Socket.h"
SocketInterface::SocketInterface()
{
}
std::unique_ptr<SocketInterface> SocketInterface::Create()
{
return std::make_unique<SocketInterface>();
}
void SocketInterface::CreateSocket(SocketPtr socket)
{
}
void SocketInterface::Listen(SocketPtr socket)
{
}
void SocketInterface::Run(SocketPtr socket)
{
}

View file

@ -0,0 +1,20 @@
#pragma
#include <memory>
class Socket;
using SocketPtr = std::shared_ptr<Socket>;
class SocketInterface
{
public:
SocketInterface();
static std::unique_ptr<SocketInterface> Create();
void CreateSocket(SocketPtr socket);
void Listen(SocketPtr socket);
void Run(SocketPtr socket);
};
using SocketInterfaceUPtr = std::unique_ptr<SocketInterface>;

View file

@ -30,3 +30,7 @@ target_include_directories(ui_elements PUBLIC
"${CMAKE_CURRENT_SOURCE_DIR}/desktop_elements"
)
target_link_libraries(ui_elements PUBLIC core geometry)
set_property(TARGET ui_elements PROPERTY FOLDER src)
set_target_properties( ui_elements PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON )

View file

@ -48,7 +48,7 @@ void Button::OnPaintEvent(const PaintEvent* event)
AddBackground(event);
if(!mLabel.empty())
{
unsigned fontOffset = mLabel.size() * 4;
unsigned fontOffset = unsigned(mLabel.size()) * 4;
auto middle = DiscretePoint(mLocation.GetX() + mSize.mWidth/2 - fontOffset,
mLocation.GetY() + mSize.mHeight/2 + 4);
auto textLayer = VisualLayer::Create();

View file

@ -46,8 +46,8 @@ void HorizontalSpacer::AddChildLayers(const PaintEvent* event)
{
delta = size.mMaxHeight;
}
child->SetBounds(mSize.mWidth, delta);
child->SetLocation(DiscretePoint(mLocation.GetX(), mLocation.GetY() + offset));
child->SetBounds(mSize.mWidth, unsigned(delta));
child->SetLocation(DiscretePoint(mLocation.GetX(), mLocation.GetY() + unsigned(offset)));
child->OnPaintEvent(event);
auto layers = child->GetLayers();
mLayers.insert(mLayers.end(), layers.begin(), layers.end());

View file

@ -25,7 +25,7 @@ void Label::OnPaintEvent(const PaintEvent* event)
if(!mLabel.empty())
{
unsigned fontOffset = mLabel.size() * 4;
unsigned fontOffset = unsigned(mLabel.size()) * 4;
auto middle = DiscretePoint(mLocation.GetX() + mSize.mWidth/2 - fontOffset,
mLocation.GetY() + mSize.mHeight/2 + 4);
auto textLayer = VisualLayer::Create();

View file

@ -86,7 +86,7 @@ void TextBox::OnPaintEvent(const PaintEvent* event)
for(const auto& line : seglist)
{
auto loc = DiscretePoint(mLocation.GetX() + mPadding.mLeft,
mLocation.GetY() + mPadding.mTop + offset);
mLocation.GetY() + mPadding.mTop + unsigned(offset));
auto textLayer = VisualLayer::Create();
auto textElement = TextElement::Create(line, loc);
textElement->SetFillColor(Color::Create(*mBackgroundColor));

View file

@ -31,14 +31,14 @@ void VerticalSpacer::AddChildLayers(const PaintEvent* event)
mLayers.clear();
double scaleSum = std::accumulate(mScales.begin(), mScales.end(), 0.0);
double offset = 0;
unsigned delta = mSize.mWidth / mChildren.size();
unsigned delta = mSize.mWidth / unsigned(mChildren.size());
for(std::size_t idx=0; idx<mChildren.size(); idx++)
{
auto& child = mChildren[idx];
double scale = mScales[idx];
double delta = mSize.mWidth * (scale/scaleSum);
child->SetBounds(delta, mSize.mHeight);
child->SetLocation(DiscretePoint(mLocation.GetX() + offset, mLocation.GetY()));
child->SetBounds(unsigned(delta), mSize.mHeight);
child->SetLocation(DiscretePoint(mLocation.GetX() + unsigned(offset), mLocation.GetY()));
child->OnPaintEvent(event);
auto layers = child->GetLayers();
mLayers.insert(mLayers.end(), layers.begin(), layers.end());

View file

@ -23,3 +23,6 @@ target_include_directories(web PUBLIC
"${CMAKE_CURRENT_SOURCE_DIR}/html"
"${CMAKE_CURRENT_SOURCE_DIR}/markdown"
)
set_property(TARGET web PROPERTY FOLDER src)
target_link_libraries(web PUBLIC core)
set_target_properties( web PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON )

View file

@ -1,13 +1,15 @@
list(APPEND windows_LIB_INCLUDES
managers/WindowManager.cpp
managers/DesktopManager.cpp
managers/EventManager.cpp
list(APPEND linux_INCLUDES
ui_interfaces/x11/XcbInterface.cpp
ui_interfaces/x11/XcbLayerInterface.cpp
ui_interfaces/x11/XcbTextInterface.cpp
ui_interfaces/x11/XcbKeyboard.cpp
ui_interfaces/x11/GlxInterface.cpp)
list(APPEND windows_LIB_INCLUDES
managers/WindowManager.cpp
managers/DesktopManager.cpp
managers/EventManager.cpp)
# add the library
add_library(windows SHARED ${windows_LIB_INCLUDES})
@ -16,8 +18,15 @@ target_include_directories(windows PUBLIC
"${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"
)
target_link_libraries(windows PUBLIC X11 X11-xcb xcb core graphics geometry ui_elements)
list(APPEND linux_LIBS
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_target_properties( windows PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON )