Compare commits

..

1 Commits

Author SHA1 Message Date
a6df1ecf8e
wip sys tray 2024-10-14 10:16:35 +02:00
10 changed files with 80 additions and 12 deletions

View File

@ -64,8 +64,6 @@ jobs:
strategy:
matrix:
platform:
- vcpkg_toolkit: arm-neon-android
ndk_abi: armeabi-v7a
- vcpkg_toolkit: arm64-android
ndk_abi: arm64-v8a
- vcpkg_toolkit: x64-android

View File

@ -38,8 +38,6 @@ jobs:
strategy:
matrix:
platform:
- vcpkg_toolkit: arm-neon-android
ndk_abi: armeabi-v7a
- vcpkg_toolkit: arm64-android
ndk_abi: arm64-v8a
- vcpkg_toolkit: x64-android

View File

@ -9,7 +9,8 @@ if (NOT TARGET SDL3::SDL3)
set(SDL_DISABLE_ANDROID_JAR OFF CACHE INTERNAL "")
FetchContent_Declare(SDL3
GIT_REPOSITORY https://github.com/libsdl-org/SDL
#GIT_REPOSITORY https://github.com/libsdl-org/SDL
GIT_REPOSITORY https://github.com/Semphriss/SDL
#GIT_TAG 0429f5d6a36fc35b551bcc2acd4a40c2db6dab82 # tip when looking
#GIT_TAG 14f584a94bfd49cf1524db75bf3c419fdf9436cd # tip 26-04-2024
#GIT_TAG 06d6f2cb2518622593570985589700910cf4399f # 13-05-2024 - before
@ -26,7 +27,7 @@ if (NOT TARGET SDL3::SDL3)
#GIT_TAG 9dd8859240703d886941733ad32c1dc6f50d64f0 # tip 19-09-2024
#GIT_TAG afdf325fb4090e93a124519d1a3bc1fbe0ba9025 # bad
#GIT_TAG e292d1f5ace469f718d7b6b4dec8c28e37dcaa0e # tip 05-10-2024 (3.1.3)
GIT_TAG 2654d5d48b8f764148a7c246fea85b32b1133578 # tip 18-10-2024
GIT_TAG c523f0bcfeb5700ee233b7fae3c2b036822b8627
FIND_PACKAGE_ARGS # for the future
)

@ -1 +1 @@
Subproject commit 9a4df12d68373cd19adddde2364843eeac51c28d
Subproject commit 17d2baf7365c3499172dc5afd71171cb3a138d99

View File

@ -63,17 +63,17 @@
"sdl3": {
"flake": false,
"locked": {
"lastModified": 1729218869,
"narHash": "sha256-0KrwC3Yrs1LHwT9SPvknDwPymNmksq6dixM4/KiFqFA=",
"lastModified": 1728073678,
"narHash": "sha256-S7yRcLHMPgq6+gec8l+ESxp2dJ+6Po/UNsBUXptQzMQ=",
"owner": "libsdl-org",
"repo": "SDL",
"rev": "2654d5d48b8f764148a7c246fea85b32b1133578",
"rev": "e292d1f5ace469f718d7b6b4dec8c28e37dcaa0e",
"type": "github"
},
"original": {
"owner": "libsdl-org",
"repo": "SDL",
"rev": "2654d5d48b8f764148a7c246fea85b32b1133578",
"rev": "e292d1f5ace469f718d7b6b4dec8c28e37dcaa0e",
"type": "github"
}
},

View File

@ -11,7 +11,7 @@
flake = false;
};
sdl3 = {
url = "github:libsdl-org/SDL/2654d5d48b8f764148a7c246fea85b32b1133578"; # keep in sync this cmake
url = "github:libsdl-org/SDL/e292d1f5ace469f718d7b6b4dec8c28e37dcaa0e"; # keep in sync this cmake
flake = false;
};
sdl3_image = {

View File

@ -66,6 +66,9 @@ target_sources(tomato PUBLIC
./sdl_clipboard_utils.hpp
./sdl_clipboard_utils.cpp
./sys_tray.hpp
./sys_tray.cpp
./chat_gui/theme.hpp
./chat_gui/theme.cpp
./chat_gui/icons/direct.hpp

View File

@ -29,6 +29,8 @@
#include "./tox_avatar_loader.hpp"
#include "./message_image_loader.hpp"
#include "./sys_tray.hpp"
#include "./chat_gui4.hpp"
#include "./chat_gui/settings_window.hpp"
#include "./object_store_ui.hpp"
@ -91,6 +93,8 @@ struct MainScreen final : public Screen {
MessageImageLoader mil;
TextureCache<void*, Message3Handle, MessageImageLoader> msg_tc;
SystemTray st;
ChatGui4 cg;
SettingsWindow sw;
ObjectStoreUI osui;

52
src/sys_tray.cpp Normal file
View File

@ -0,0 +1,52 @@
#include "./sys_tray.hpp"
#include "./image_loader_sdl_image.hpp"
#include <cstdint>
#include <fstream>
#include <ios>
#include <memory>
#include <iostream>
SystemTray::SystemTray(void) {
std::cout << "adding sys tray\n";
std::ifstream file("../res/icon/tomato_v1_256.png");
file.seekg(0, std::ios::end);
size_t file_size = file.tellg();
file.seekg(0, std::ios::beg);
std::vector<uint8_t> data(file_size);
file.read(reinterpret_cast<char*>(data.data()), file_size);
file.close();
std::cout << "tray icon file size: " << file_size << "\n";
ImageLoaderSDLImage il;
auto image = il.loadFromMemoryRGBA(data.data(), data.size());
std::unique_ptr<SDL_Surface, decltype(&SDL_DestroySurface)> surf = {
SDL_CreateSurfaceFrom(
image.width, image.height,
SDL_PIXELFORMAT_RGBA32,
(void*)image.frames.at(0).data.data(),
4*image.width
),
&SDL_DestroySurface
};
std::cout << "tray dims " << image.width << "x" << image.height << "\n";
// different icons?
_tray = SDL_CreateTray(surf.get(), "tomato");
if (_tray == nullptr) {
std::cerr << "failed to create SystemTray!!\n";
}
}
SystemTray::~SystemTray(void) {
if (_tray != nullptr) {
SDL_DestroyTray(_tray);
_tray = nullptr;
}
}

12
src/sys_tray.hpp Normal file
View File

@ -0,0 +1,12 @@
#pragma once
#include <SDL3/SDL.h>
class SystemTray {
SDL_Tray* _tray {nullptr};
public:
SystemTray(void);
~SystemTray(void);
};