Compare commits
11 Commits
dev-dadc72
...
dev-858b9d
Author | SHA1 | Date | |
---|---|---|---|
858b9dfcfa | |||
bc8b631b84 | |||
52278f6726 | |||
29fd1bfb62 | |||
998000aa3a | |||
e66f4651d0 | |||
854d09f05c | |||
2d6a9acbb6 | |||
b7f0ad6c9a | |||
43f8c22570 | |||
3c7bd2e2cb |
20
.github/workflows/cd.yml
vendored
20
.github/workflows/cd.yml
vendored
@ -7,7 +7,7 @@ on:
|
|||||||
branches: [ master ]
|
branches: [ master ]
|
||||||
|
|
||||||
env:
|
env:
|
||||||
BUILD_TYPE: Release
|
BUILD_TYPE: RelWithDebInfo
|
||||||
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
|
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
@ -17,7 +17,7 @@ jobs:
|
|||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ jobs:
|
|||||||
runs-on: windows-2019
|
runs-on: windows-2019
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
@ -75,8 +75,11 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
arch: amd64
|
arch: amd64
|
||||||
|
|
||||||
|
## sdl_image vendored needs nasm for dav1d
|
||||||
|
#- uses: ilammy/setup-nasm@v1
|
||||||
|
|
||||||
- name: Configure CMake
|
- name: Configure CMake
|
||||||
run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static
|
run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static -DSDL3IMAGE_VENDORED=ON -DSDL3IMAGE_DEPS_SHARED=ON -DSDL3IMAGE_JXL=OFF -DSDL3IMAGE_AVIF=OFF
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
|
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
|
||||||
@ -114,7 +117,7 @@ jobs:
|
|||||||
runs-on: windows-2019
|
runs-on: windows-2019
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
@ -126,8 +129,11 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
arch: amd64
|
arch: amd64
|
||||||
|
|
||||||
|
## sdl_image vendored needs nasm for dav1d
|
||||||
|
#- uses: ilammy/setup-nasm@v1
|
||||||
|
|
||||||
- name: Configure CMake
|
- name: Configure CMake
|
||||||
run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static -DTOMATO_ASAN=ON -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded
|
run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static -DTOMATO_ASAN=ON -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded -DSDL3IMAGE_VENDORED=ON -DSDL3IMAGE_DEPS_SHARED=ON -DSDL3IMAGE_JXL=OFF -DSDL3IMAGE_AVIF=OFF
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
|
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
|
||||||
@ -172,7 +178,7 @@ jobs:
|
|||||||
contents: write
|
contents: write
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
|
13
.github/workflows/ci.yml
vendored
13
.github/workflows/ci.yml
vendored
@ -16,7 +16,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ jobs:
|
|||||||
runs-on: macos-latest
|
runs-on: macos-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
@ -49,12 +49,12 @@ jobs:
|
|||||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
|
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
|
||||||
|
|
||||||
windows:
|
windows:
|
||||||
timeout-minutes: 10
|
timeout-minutes: 15
|
||||||
|
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
@ -66,8 +66,11 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
arch: amd64
|
arch: amd64
|
||||||
|
|
||||||
|
## sdl_image vendored needs nasm for dav1d
|
||||||
|
#- uses: ilammy/setup-nasm@v1
|
||||||
|
|
||||||
- name: Configure CMake
|
- name: Configure CMake
|
||||||
run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static
|
run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static -DSDL3IMAGE_VENDORED=ON -DSDL3IMAGE_DEPS_SHARED=ON -DSDL3IMAGE_JXL=OFF -DSDL3IMAGE_AVIF=OFF
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
|
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
|
||||||
|
1
external/CMakeLists.txt
vendored
1
external/CMakeLists.txt
vendored
@ -21,4 +21,5 @@ add_subdirectory(./imgui)
|
|||||||
add_subdirectory(./stb)
|
add_subdirectory(./stb)
|
||||||
add_subdirectory(./libwebp)
|
add_subdirectory(./libwebp)
|
||||||
add_subdirectory(./qoi)
|
add_subdirectory(./qoi)
|
||||||
|
add_subdirectory(./sdl_image)
|
||||||
|
|
||||||
|
23
external/sdl_image/CMakeLists.txt
vendored
Normal file
23
external/sdl_image/CMakeLists.txt
vendored
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.16...3.24 FATAL_ERROR)
|
||||||
|
|
||||||
|
include(FetchContent)
|
||||||
|
|
||||||
|
if (NOT TARGET SDL3_image::SDL3_image)
|
||||||
|
set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
|
||||||
|
# TODO: make pr to make this an option
|
||||||
|
set(SDL3IMAGE_BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
|
||||||
|
set(SDL3IMAGE_BACKEND_STB OFF CACHE BOOL "" FORCE) # important for security
|
||||||
|
set(SDL3IMAGE_BACKEND_IMAGEIO OFF CACHE BOOL "" FORCE) # some funky apple cmake bug
|
||||||
|
#set(SDL3IMAGE_JXL ON CACHE BOOL "" FORCE) # default to off
|
||||||
|
set(SDL3IMAGE_QOI OFF CACHE BOOL "" FORCE) # we have our own
|
||||||
|
set(SDL3IMAGE_WEBP OFF CACHE BOOL "" FORCE) # we have our own
|
||||||
|
|
||||||
|
FetchContent_Declare(SDL3_image
|
||||||
|
GIT_REPOSITORY https://github.com/libsdl-org/SDL_image
|
||||||
|
# waiting on the imgui pr to get merged so i can update sdl <.<
|
||||||
|
GIT_TAG a45d6e5b84ccc0f3faae6ba7d561709ed600eee7 # tip last check
|
||||||
|
FIND_PACKAGE_ARGS # for the future
|
||||||
|
)
|
||||||
|
FetchContent_MakeAvailable(SDL3_image)
|
||||||
|
endif()
|
||||||
|
|
2
external/solanaceae_contact
vendored
2
external/solanaceae_contact
vendored
Submodule external/solanaceae_contact updated: e40271670b...7710da6c89
2
external/solanaceae_message3
vendored
2
external/solanaceae_message3
vendored
Submodule external/solanaceae_message3 updated: f9f70a05b1...96b76dc67f
2
external/solanaceae_message_serializer
vendored
2
external/solanaceae_message_serializer
vendored
Submodule external/solanaceae_message_serializer updated: 1409485ef1...1a3fcc6757
2
external/solanaceae_tox
vendored
2
external/solanaceae_tox
vendored
Submodule external/solanaceae_tox updated: 25857b8aa7...560eab1f6c
32
flake.lock
generated
32
flake.lock
generated
@ -5,11 +5,11 @@
|
|||||||
"systems": "systems"
|
"systems": "systems"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1694529238,
|
"lastModified": 1710146030,
|
||||||
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
|
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "flake-utils",
|
"repo": "flake-utils",
|
||||||
"rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
|
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@ -20,11 +20,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1709953752,
|
"lastModified": 1713189761,
|
||||||
"narHash": "sha256-LW84B4vM1cn7E6cDNQn2LndT9iJXI1dRE5fwbNFbQa8=",
|
"narHash": "sha256-MPp1dBhlY066IeBo+EPGEUN+s+aSUA+LWkvnzKh+rts=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "fcaa81ed3c273237217330cf342ef1873b77c80a",
|
"rev": "ff44be4d8ff33f797ff3e3f87153d4f3b6a85ffb",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@ -56,7 +56,8 @@
|
|||||||
"flake-utils": "flake-utils",
|
"flake-utils": "flake-utils",
|
||||||
"nixpkgs": "nixpkgs",
|
"nixpkgs": "nixpkgs",
|
||||||
"nlohmann-json": "nlohmann-json",
|
"nlohmann-json": "nlohmann-json",
|
||||||
"sdl3": "sdl3"
|
"sdl3": "sdl3",
|
||||||
|
"sdl3_image": "sdl3_image"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"sdl3": {
|
"sdl3": {
|
||||||
@ -76,6 +77,23 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"sdl3_image": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1712700609,
|
||||||
|
"narHash": "sha256-PVPH1uJ6g65SzHUboeQE6ZkC+72doMz9t9SG2LBo+7I=",
|
||||||
|
"owner": "libsdl-org",
|
||||||
|
"repo": "SDL_image",
|
||||||
|
"rev": "a45d6e5b84ccc0f3faae6ba7d561709ed600eee7",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "libsdl-org",
|
||||||
|
"repo": "SDL_image",
|
||||||
|
"rev": "a45d6e5b84ccc0f3faae6ba7d561709ed600eee7",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"systems": {
|
"systems": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1681028828,
|
"lastModified": 1681028828,
|
||||||
|
15
flake.nix
15
flake.nix
@ -14,9 +14,13 @@
|
|||||||
url = "github:libsdl-org/SDL/0429f5d6a36fc35b551bcc2acd4a40c2db6dab82"; # keep in sync this cmake
|
url = "github:libsdl-org/SDL/0429f5d6a36fc35b551bcc2acd4a40c2db6dab82"; # keep in sync this cmake
|
||||||
flake = false;
|
flake = false;
|
||||||
};
|
};
|
||||||
|
sdl3_image = {
|
||||||
|
url = "github:libsdl-org/SDL_image/a45d6e5b84ccc0f3faae6ba7d561709ed600eee7";
|
||||||
|
flake = false;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { self, nixpkgs, flake-utils, nlohmann-json, sdl3 }:
|
outputs = { self, nixpkgs, flake-utils, nlohmann-json, sdl3, sdl3_image }:
|
||||||
flake-utils.lib.eachDefaultSystem (system:
|
flake-utils.lib.eachDefaultSystem (system:
|
||||||
let
|
let
|
||||||
pkgs = import nixpkgs { inherit system; };
|
pkgs = import nixpkgs { inherit system; };
|
||||||
@ -57,6 +61,13 @@
|
|||||||
libGL
|
libGL
|
||||||
|
|
||||||
pipewire
|
pipewire
|
||||||
|
|
||||||
|
# sdl3_image:
|
||||||
|
libpng
|
||||||
|
libjpeg
|
||||||
|
libjxl
|
||||||
|
libavif
|
||||||
|
#libwebp # still using our own loader
|
||||||
];
|
];
|
||||||
|
|
||||||
buildInputs = with pkgs; [
|
buildInputs = with pkgs; [
|
||||||
@ -74,6 +85,8 @@
|
|||||||
"-DFETCHCONTENT_SOURCE_DIR_ZSTD=${pkgs.zstd.src}" # we dont care about the version (we use 1.4.x features)
|
"-DFETCHCONTENT_SOURCE_DIR_ZSTD=${pkgs.zstd.src}" # we dont care about the version (we use 1.4.x features)
|
||||||
"-DFETCHCONTENT_SOURCE_DIR_LIBWEBP=${pkgs.libwebp.src}"
|
"-DFETCHCONTENT_SOURCE_DIR_LIBWEBP=${pkgs.libwebp.src}"
|
||||||
"-DFETCHCONTENT_SOURCE_DIR_SDL3=${sdl3}"
|
"-DFETCHCONTENT_SOURCE_DIR_SDL3=${sdl3}"
|
||||||
|
"-DFETCHCONTENT_SOURCE_DIR_SDL3_IMAGE=${sdl3_image}"
|
||||||
|
"-DSDL3IMAGE_JXL=ON"
|
||||||
];
|
];
|
||||||
|
|
||||||
# TODO: replace with install command
|
# TODO: replace with install command
|
||||||
|
@ -29,6 +29,8 @@ add_executable(tomato
|
|||||||
./image_loader_webp.cpp
|
./image_loader_webp.cpp
|
||||||
./image_loader_qoi.hpp
|
./image_loader_qoi.hpp
|
||||||
./image_loader_qoi.cpp
|
./image_loader_qoi.cpp
|
||||||
|
./image_loader_sdl_image.hpp
|
||||||
|
./image_loader_sdl_image.cpp
|
||||||
|
|
||||||
./texture_uploader.hpp
|
./texture_uploader.hpp
|
||||||
./sdlrenderer_texture_uploader.hpp
|
./sdlrenderer_texture_uploader.hpp
|
||||||
@ -50,14 +52,14 @@ add_executable(tomato
|
|||||||
./sdl_clipboard_utils.hpp
|
./sdl_clipboard_utils.hpp
|
||||||
./sdl_clipboard_utils.cpp
|
./sdl_clipboard_utils.cpp
|
||||||
|
|
||||||
./file_selector.hpp
|
./chat_gui/file_selector.hpp
|
||||||
./file_selector.cpp
|
./chat_gui/file_selector.cpp
|
||||||
|
|
||||||
./send_image_popup.hpp
|
./chat_gui/send_image_popup.hpp
|
||||||
./send_image_popup.cpp
|
./chat_gui/send_image_popup.cpp
|
||||||
|
|
||||||
./settings_window.hpp
|
./chat_gui/settings_window.hpp
|
||||||
./settings_window.cpp
|
./chat_gui/settings_window.cpp
|
||||||
|
|
||||||
./tox_ui_utils.hpp
|
./tox_ui_utils.hpp
|
||||||
./tox_ui_utils.cpp
|
./tox_ui_utils.cpp
|
||||||
@ -98,5 +100,6 @@ target_link_libraries(tomato PUBLIC
|
|||||||
webpdemux
|
webpdemux
|
||||||
libwebpmux # the f why (needed for anim encode)
|
libwebpmux # the f why (needed for anim encode)
|
||||||
qoi
|
qoi
|
||||||
|
SDL3_image::SDL3_image
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
#include "./send_image_popup.hpp"
|
#include "./send_image_popup.hpp"
|
||||||
|
|
||||||
#include "./image_loader_sdl_bmp.hpp"
|
#include "../image_loader_sdl_bmp.hpp"
|
||||||
#include "./image_loader_stb.hpp"
|
#include "../image_loader_stb.hpp"
|
||||||
#include "./image_loader_webp.hpp"
|
#include "../image_loader_webp.hpp"
|
||||||
#include "./image_loader_qoi.hpp"
|
#include "../image_loader_qoi.hpp"
|
||||||
|
#include "../image_loader_sdl_image.hpp"
|
||||||
|
|
||||||
#include <imgui/imgui.h>
|
#include <imgui/imgui.h>
|
||||||
|
|
||||||
@ -16,7 +17,7 @@ SendImagePopup::SendImagePopup(TextureUploaderI& tu) : _tu(tu) {
|
|||||||
_image_loaders.push_back(std::make_unique<ImageLoaderSDLBMP>());
|
_image_loaders.push_back(std::make_unique<ImageLoaderSDLBMP>());
|
||||||
_image_loaders.push_back(std::make_unique<ImageLoaderQOI>());
|
_image_loaders.push_back(std::make_unique<ImageLoaderQOI>());
|
||||||
_image_loaders.push_back(std::make_unique<ImageLoaderWebP>());
|
_image_loaders.push_back(std::make_unique<ImageLoaderWebP>());
|
||||||
_image_loaders.push_back(std::make_unique<ImageLoaderSTB>());
|
_image_loaders.push_back(std::make_unique<ImageLoaderSDLImage>());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SendImagePopup::reset(void) {
|
void SendImagePopup::reset(void) {
|
@ -5,8 +5,8 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "./image_loader.hpp"
|
#include "../image_loader.hpp"
|
||||||
#include "./texture_cache.hpp"
|
#include "../texture_cache.hpp"
|
||||||
|
|
||||||
struct SendImagePopup {
|
struct SendImagePopup {
|
||||||
TextureUploaderI& _tu;
|
TextureUploaderI& _tu;
|
@ -1,7 +1,5 @@
|
|||||||
#include "./chat_gui4.hpp"
|
#include "./chat_gui4.hpp"
|
||||||
|
|
||||||
#include "./file_selector.hpp"
|
|
||||||
|
|
||||||
#include <solanaceae/message3/components.hpp>
|
#include <solanaceae/message3/components.hpp>
|
||||||
#include <solanaceae/tox_messages/components.hpp>
|
#include <solanaceae/tox_messages/components.hpp>
|
||||||
#include <solanaceae/contact/components.hpp>
|
#include <solanaceae/contact/components.hpp>
|
||||||
@ -197,9 +195,10 @@ float ChatGui4::render(float time_delta) {
|
|||||||
sub_contacts = &_cr.get<Contact::Components::ParentOf>(*_selected_contact).subs;
|
sub_contacts = &_cr.get<Contact::Components::ParentOf>(*_selected_contact).subs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const bool highlight_private {!_cr.all_of<Contact::Components::TagPrivate>(*_selected_contact)};
|
||||||
|
|
||||||
if (ImGui::BeginChild(chat_label.c_str(), {0, 0}, true)) {
|
if (ImGui::BeginChild(chat_label.c_str(), {0, 0}, true)) {
|
||||||
//if (_cr.all_of<Contact::Components::ParentOf>(*_selected_contact)) {
|
if (sub_contacts != nullptr && !_cr.all_of<Contact::Components::TagPrivate>(*_selected_contact) && _cr.all_of<Contact::Components::TagGroup>(*_selected_contact)) {
|
||||||
if (sub_contacts != nullptr) {
|
|
||||||
if (!sub_contacts->empty()) {
|
if (!sub_contacts->empty()) {
|
||||||
if (ImGui::BeginChild("subcontacts", {150, -100}, true)) {
|
if (ImGui::BeginChild("subcontacts", {150, -100}, true)) {
|
||||||
ImGui::Text("subs: %zu", sub_contacts->size());
|
ImGui::Text("subs: %zu", sub_contacts->size());
|
||||||
@ -417,7 +416,7 @@ float ChatGui4::render(float time_delta) {
|
|||||||
std::optional<ImVec4> row_bg;
|
std::optional<ImVec4> row_bg;
|
||||||
|
|
||||||
// private group message
|
// private group message
|
||||||
if (_cr.any_of<Contact::Components::TagSelfWeak, Contact::Components::TagSelfStrong>(c_to.c)) {
|
if (highlight_private && _cr.any_of<Contact::Components::TagSelfWeak, Contact::Components::TagSelfStrong>(c_to.c)) {
|
||||||
const ImVec4 priv_msg_hi_col = ImVec4(0.5f, 0.2f, 0.5f, 0.35f);
|
const ImVec4 priv_msg_hi_col = ImVec4(0.5f, 0.2f, 0.5f, 0.35f);
|
||||||
ImU32 row_bg_color = ImGui::GetColorU32(priv_msg_hi_col);
|
ImU32 row_bg_color = ImGui::GetColorU32(priv_msg_hi_col);
|
||||||
ImGui::TableSetBgColor(ImGuiTableBgTarget_RowBg1, row_bg_color);
|
ImGui::TableSetBgColor(ImGuiTableBgTarget_RowBg1, row_bg_color);
|
||||||
@ -456,8 +455,11 @@ float ChatGui4::render(float time_delta) {
|
|||||||
if (ImGui::TableNextColumn()) {
|
if (ImGui::TableNextColumn()) {
|
||||||
// TODO: theming for hardcoded values
|
// TODO: theming for hardcoded values
|
||||||
|
|
||||||
if (msg_reg.all_of<Message::Components::Remote::TimestampReceived>(e)) {
|
if (!msg_reg.all_of<Message::Components::ReceivedBy>(e)) {
|
||||||
const auto list = msg_reg.get<Message::Components::Remote::TimestampReceived>(e).ts;
|
// TODO: dedup?
|
||||||
|
ImGui::TextDisabled("_");
|
||||||
|
} else {
|
||||||
|
const auto list = msg_reg.get<Message::Components::ReceivedBy>(e).ts;
|
||||||
// wrongly assumes contacts never get removed from a group
|
// wrongly assumes contacts never get removed from a group
|
||||||
if (sub_contacts != nullptr && list.size() < sub_contacts->size()) {
|
if (sub_contacts != nullptr && list.size() < sub_contacts->size()) {
|
||||||
// if partically delivered
|
// if partically delivered
|
||||||
@ -471,6 +473,7 @@ float ChatGui4::render(float time_delta) {
|
|||||||
std::string synced_by_text {"delivery confirmed by:"};
|
std::string synced_by_text {"delivery confirmed by:"};
|
||||||
const int64_t now_ts_s = int64_t(Message::getTimeMS() / 1000u);
|
const int64_t now_ts_s = int64_t(Message::getTimeMS() / 1000u);
|
||||||
|
|
||||||
|
size_t other_contacts {0};
|
||||||
for (const auto& [c, syned_ts] : list) {
|
for (const auto& [c, syned_ts] : list) {
|
||||||
if (_cr.all_of<Contact::Components::TagSelfStrong>(c)) {
|
if (_cr.all_of<Contact::Components::TagSelfStrong>(c)) {
|
||||||
//synced_by_text += "\n sself(!)"; // makes no sense
|
//synced_by_text += "\n sself(!)"; // makes no sense
|
||||||
@ -480,23 +483,26 @@ float ChatGui4::render(float time_delta) {
|
|||||||
} else {
|
} else {
|
||||||
synced_by_text += "\n >" + (_cr.all_of<Contact::Components::Name>(c) ? _cr.get<Contact::Components::Name>(c).name : "<unk>");
|
synced_by_text += "\n >" + (_cr.all_of<Contact::Components::Name>(c) ? _cr.get<Contact::Components::Name>(c).name : "<unk>");
|
||||||
}
|
}
|
||||||
|
other_contacts += 1;
|
||||||
const int64_t seconds_ago = (int64_t(syned_ts / 1000u) - now_ts_s) * -1;
|
const int64_t seconds_ago = (int64_t(syned_ts / 1000u) - now_ts_s) * -1;
|
||||||
synced_by_text += " (" + std::to_string(seconds_ago) + "sec ago)";
|
synced_by_text += " (" + std::to_string(seconds_ago) + "sec ago)";
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::Text("%s", synced_by_text.c_str());
|
if (other_contacts > 0) {
|
||||||
|
ImGui::Text("%s", synced_by_text.c_str());
|
||||||
|
} else {
|
||||||
|
ImGui::TextUnformatted("no delivery confirmation");
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::EndTooltip();
|
ImGui::EndTooltip();
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
ImGui::TextDisabled("_");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
|
|
||||||
// TODO: dedup
|
// TODO: dedup
|
||||||
if (msg_reg.all_of<Message::Components::Remote::TimestampRead>(e)) {
|
if (msg_reg.all_of<Message::Components::ReadBy>(e)) {
|
||||||
const auto list = msg_reg.get<Message::Components::Remote::TimestampRead>(e).ts;
|
const auto list = msg_reg.get<Message::Components::ReadBy>(e).ts;
|
||||||
// wrongly assumes contacts never get removed from a group
|
// wrongly assumes contacts never get removed from a group
|
||||||
if (sub_contacts != nullptr && list.size() < sub_contacts->size()) {
|
if (sub_contacts != nullptr && list.size() < sub_contacts->size()) {
|
||||||
// if partially read
|
// if partially read
|
||||||
@ -1045,13 +1051,13 @@ void ChatGui4::renderMessageExtra(Message3Registry& reg, const Message3 e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: remove?
|
// TODO: remove?
|
||||||
if (reg.all_of<Message::Components::Remote::TimestampReceived>(e)) {
|
if (reg.all_of<Message::Components::ReceivedBy>(e)) {
|
||||||
std::string synced_by_text {"receivedBy:"};
|
std::string synced_by_text {"receivedBy:"};
|
||||||
const int64_t now_ts_s = int64_t(Message::getTimeMS() / 1000u);
|
const int64_t now_ts_s = int64_t(Message::getTimeMS() / 1000u);
|
||||||
|
|
||||||
for (const auto& [c, syned_ts] : reg.get<Message::Components::Remote::TimestampReceived>(e).ts) {
|
for (const auto& [c, syned_ts] : reg.get<Message::Components::ReceivedBy>(e).ts) {
|
||||||
if (_cr.all_of<Contact::Components::TagSelfStrong>(c)) {
|
if (_cr.all_of<Contact::Components::TagSelfStrong>(c)) {
|
||||||
synced_by_text += "\n sself(!)"; // makes no sense
|
synced_by_text += "\n sself"; // required (except when synced externally)
|
||||||
} else if (_cr.all_of<Contact::Components::TagSelfWeak>(c)) {
|
} else if (_cr.all_of<Contact::Components::TagSelfWeak>(c)) {
|
||||||
synced_by_text += "\n wself";
|
synced_by_text += "\n wself";
|
||||||
} else {
|
} else {
|
||||||
@ -1080,7 +1086,6 @@ void ChatGui4::renderContactList(void) {
|
|||||||
bool ChatGui4::renderContactListContactBig(const Contact3 c, const bool selected) {
|
bool ChatGui4::renderContactListContactBig(const Contact3 c, const bool selected) {
|
||||||
// TODO:
|
// TODO:
|
||||||
// - unread message
|
// - unread message
|
||||||
// - avatar img
|
|
||||||
// - connection status
|
// - connection status
|
||||||
// - user status
|
// - user status
|
||||||
// - status message
|
// - status message
|
||||||
@ -1109,10 +1114,27 @@ bool ChatGui4::renderContactListContactBig(const Contact3 c, const bool selected
|
|||||||
}
|
}
|
||||||
|
|
||||||
const bool got_selected = ImGui::Selectable(label.c_str(), show_selected, 0, {0,3*TEXT_BASE_HEIGHT});
|
const bool got_selected = ImGui::Selectable(label.c_str(), show_selected, 0, {0,3*TEXT_BASE_HEIGHT});
|
||||||
|
|
||||||
if (request_incoming || request_outgoing) {
|
if (request_incoming || request_outgoing) {
|
||||||
ImGui::PopStyleColor();
|
ImGui::PopStyleColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ImGui::BeginItemTooltip()) {
|
||||||
|
if (_cr.all_of<Contact::Components::ConnectionState>(c)) {
|
||||||
|
const auto cstate = _cr.get<Contact::Components::ConnectionState>(c).state;
|
||||||
|
ImGui::Text("Connection state: %s",
|
||||||
|
(cstate == Contact::Components::ConnectionState::disconnected)
|
||||||
|
? "offline"
|
||||||
|
: (cstate == Contact::Components::ConnectionState::direct)
|
||||||
|
? "online (direct)"
|
||||||
|
: "online (cloud)"
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
ImGui::TextUnformatted("Connection state: unknown");
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::EndTooltip();
|
||||||
|
}
|
||||||
|
|
||||||
ImVec2 post_curser_pos = ImGui::GetCursorPos();
|
ImVec2 post_curser_pos = ImGui::GetCursorPos();
|
||||||
|
|
||||||
ImVec2 img_curser {
|
ImVec2 img_curser {
|
||||||
@ -1181,14 +1203,16 @@ bool ChatGui4::renderContactListContactBig(const Contact3 c, const bool selected
|
|||||||
ImGui::TextUnformatted("Incoming request/invite");
|
ImGui::TextUnformatted("Incoming request/invite");
|
||||||
} else if (request_outgoing) {
|
} else if (request_outgoing) {
|
||||||
ImGui::TextUnformatted("Outgoing request/invite");
|
ImGui::TextUnformatted("Outgoing request/invite");
|
||||||
|
} else {
|
||||||
|
//ImGui::Text("status message...");
|
||||||
}
|
}
|
||||||
//ImGui::Text("status message...");
|
|
||||||
//ImGui::TextDisabled("hi");
|
//ImGui::TextDisabled("hi");
|
||||||
//ImGui::RenderTextEllipsis
|
//ImGui::RenderTextEllipsis
|
||||||
}
|
}
|
||||||
ImGui::EndGroup();
|
ImGui::EndGroup();
|
||||||
|
|
||||||
ImGui::SetCursorPos(post_curser_pos);
|
ImGui::SetCursorPos(post_curser_pos);
|
||||||
|
|
||||||
return got_selected;
|
return got_selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,8 +7,8 @@
|
|||||||
#include "./texture_cache.hpp"
|
#include "./texture_cache.hpp"
|
||||||
#include "./tox_avatar_loader.hpp"
|
#include "./tox_avatar_loader.hpp"
|
||||||
#include "./message_image_loader.hpp"
|
#include "./message_image_loader.hpp"
|
||||||
#include "./file_selector.hpp"
|
#include "./chat_gui/file_selector.hpp"
|
||||||
#include "./send_image_popup.hpp"
|
#include "./chat_gui/send_image_popup.hpp"
|
||||||
|
|
||||||
#include <entt/container/dense_map.hpp>
|
#include <entt/container/dense_map.hpp>
|
||||||
|
|
||||||
|
118
src/image_loader_sdl_image.cpp
Normal file
118
src/image_loader_sdl_image.cpp
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
#include "./image_loader_sdl_image.hpp"
|
||||||
|
|
||||||
|
#include <SDL3_image/SDL_image.h>
|
||||||
|
|
||||||
|
#include <optional>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
static std::optional<const char*> getExt(SDL_IOStream* ios) {
|
||||||
|
if (IMG_isAVIF(ios)) {
|
||||||
|
return "avif";
|
||||||
|
} else if (IMG_isCUR(ios)) {
|
||||||
|
return "cur";
|
||||||
|
} else if (IMG_isICO(ios)) {
|
||||||
|
return "ico";
|
||||||
|
} else if (IMG_isBMP(ios)) {
|
||||||
|
return "bmp";
|
||||||
|
} else if (IMG_isGIF(ios)) {
|
||||||
|
return "gif";
|
||||||
|
} else if (IMG_isJPG(ios)) {
|
||||||
|
return "jpg";
|
||||||
|
} else if (IMG_isJXL(ios)) {
|
||||||
|
return "jxl";
|
||||||
|
} else if (IMG_isLBM(ios)) {
|
||||||
|
return "lbm";
|
||||||
|
} else if (IMG_isPCX(ios)) {
|
||||||
|
return "pcx";
|
||||||
|
} else if (IMG_isPNG(ios)) {
|
||||||
|
return "png";
|
||||||
|
} else if (IMG_isPNM(ios)) {
|
||||||
|
return "pnm";
|
||||||
|
} else if (IMG_isSVG(ios)) {
|
||||||
|
return "svg";
|
||||||
|
} else if (IMG_isTIF(ios)) {
|
||||||
|
return "tiff";
|
||||||
|
} else if (IMG_isXCF(ios)) {
|
||||||
|
return "xcf";
|
||||||
|
} else if (IMG_isXPM(ios)) {
|
||||||
|
return "xpm";
|
||||||
|
} else if (IMG_isXV(ios)) {
|
||||||
|
return "xv";
|
||||||
|
} else if (IMG_isWEBP(ios)) {
|
||||||
|
return "webp";
|
||||||
|
} else if (IMG_isQOI(ios)) {
|
||||||
|
return "qoi";
|
||||||
|
} else {
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ImageLoaderSDLImage::ImageInfo ImageLoaderSDLImage::loadInfoFromMemory(const uint8_t* data, uint64_t data_size) {
|
||||||
|
ImageInfo res;
|
||||||
|
|
||||||
|
auto* ios = SDL_IOFromConstMem(data, data_size);
|
||||||
|
|
||||||
|
// we ignore tga
|
||||||
|
auto ext_opt = getExt(ios);
|
||||||
|
if (!ext_opt.has_value()) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_Surface* surf = IMG_Load_IO(ios, SDL_TRUE);
|
||||||
|
if (surf == nullptr) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
res.width = surf->w;
|
||||||
|
res.height = surf->h;
|
||||||
|
res.file_ext = ext_opt.value();
|
||||||
|
|
||||||
|
SDL_DestroySurface(surf);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImageLoaderSDLImage::ImageResult ImageLoaderSDLImage::loadFromMemoryRGBA(const uint8_t* data, uint64_t data_size) {
|
||||||
|
ImageResult res;
|
||||||
|
|
||||||
|
auto* ios = SDL_IOFromConstMem(data, data_size);
|
||||||
|
|
||||||
|
// we ignore tga
|
||||||
|
auto ext_opt = getExt(ios);
|
||||||
|
if (!ext_opt.has_value()) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
IMG_Animation* anim = IMG_LoadAnimation_IO(ios, SDL_TRUE);
|
||||||
|
if (anim == nullptr) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < anim->count; i++) {
|
||||||
|
SDL_Surface* conv_surf = SDL_ConvertSurfaceFormat(anim->frames[i], SDL_PIXELFORMAT_RGBA32);
|
||||||
|
if (conv_surf == nullptr) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SDL_LockSurface(conv_surf);
|
||||||
|
|
||||||
|
auto& new_frame = res.frames.emplace_back();
|
||||||
|
new_frame.ms = anim->delays[i];
|
||||||
|
new_frame.data.insert(new_frame.data.cbegin(), (const uint8_t*)conv_surf->pixels, ((const uint8_t*)conv_surf->pixels) + (anim->w*anim->h*4));
|
||||||
|
|
||||||
|
SDL_UnlockSurface(conv_surf);
|
||||||
|
SDL_DestroySurface(conv_surf);
|
||||||
|
}
|
||||||
|
|
||||||
|
res.width = anim->w;
|
||||||
|
res.height = anim->h;
|
||||||
|
res.file_ext = ext_opt.value();
|
||||||
|
|
||||||
|
IMG_FreeAnimation(anim);
|
||||||
|
|
||||||
|
std::cout << "IL_SDLI: loaded img " << res.width << "x" << res.height << "\n";
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
9
src/image_loader_sdl_image.hpp
Normal file
9
src/image_loader_sdl_image.hpp
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "./image_loader.hpp"
|
||||||
|
|
||||||
|
struct ImageLoaderSDLImage : public ImageLoaderI {
|
||||||
|
ImageInfo loadInfoFromMemory(const uint8_t* data, uint64_t data_size) override;
|
||||||
|
ImageResult loadFromMemoryRGBA(const uint8_t* data, uint64_t data_size) override;
|
||||||
|
};
|
||||||
|
|
@ -12,7 +12,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
MainScreen::MainScreen(SDL_Renderer* renderer_, std::string save_path, std::string save_password, std::vector<std::string> plugins) :
|
MainScreen::MainScreen(SDL_Renderer* renderer_, std::string save_path, std::string save_password, std::string new_username, std::vector<std::string> plugins) :
|
||||||
renderer(renderer_),
|
renderer(renderer_),
|
||||||
rmm(cr),
|
rmm(cr),
|
||||||
msnj{cr, {}, {}},
|
msnj{cr, {}, {}},
|
||||||
@ -44,9 +44,10 @@ MainScreen::MainScreen(SDL_Renderer* renderer_, std::string save_path, std::stri
|
|||||||
conf.set("tox", "save_file_path", save_path);
|
conf.set("tox", "save_file_path", save_path);
|
||||||
|
|
||||||
{ // name stuff
|
{ // name stuff
|
||||||
|
// a new profile will not have this set
|
||||||
auto name = tc.toxSelfGetName();
|
auto name = tc.toxSelfGetName();
|
||||||
if (name.empty()) {
|
if (name.empty()) {
|
||||||
name = "tomato";
|
name = new_username;
|
||||||
}
|
}
|
||||||
conf.set("tox", "name", name);
|
conf.set("tox", "name", name);
|
||||||
tc.setSelfName(name); // TODO: this is ugly
|
tc.setSelfName(name); // TODO: this is ugly
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
#include "./message_image_loader.hpp"
|
#include "./message_image_loader.hpp"
|
||||||
|
|
||||||
#include "./chat_gui4.hpp"
|
#include "./chat_gui4.hpp"
|
||||||
#include "./settings_window.hpp"
|
#include "./chat_gui/settings_window.hpp"
|
||||||
#include "./tox_ui_utils.hpp"
|
#include "./tox_ui_utils.hpp"
|
||||||
#include "./tox_dht_cap_histo.hpp"
|
#include "./tox_dht_cap_histo.hpp"
|
||||||
#include "./tox_friend_faux_offline_messaging.hpp"
|
#include "./tox_friend_faux_offline_messaging.hpp"
|
||||||
@ -89,7 +89,7 @@ struct MainScreen final : public Screen {
|
|||||||
uint64_t _window_hidden_ts {0};
|
uint64_t _window_hidden_ts {0};
|
||||||
float _time_since_event {0.f};
|
float _time_since_event {0.f};
|
||||||
|
|
||||||
MainScreen(SDL_Renderer* renderer_, std::string save_path, std::string save_password, std::vector<std::string> plugins);
|
MainScreen(SDL_Renderer* renderer_, std::string save_path, std::string save_password, std::string new_username, std::vector<std::string> plugins);
|
||||||
~MainScreen(void);
|
~MainScreen(void);
|
||||||
|
|
||||||
bool handleEvent(SDL_Event& e) override;
|
bool handleEvent(SDL_Event& e) override;
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#include "./image_loader_webp.hpp"
|
#include "./image_loader_webp.hpp"
|
||||||
#include "./image_loader_sdl_bmp.hpp"
|
#include "./image_loader_sdl_bmp.hpp"
|
||||||
#include "./image_loader_qoi.hpp"
|
#include "./image_loader_qoi.hpp"
|
||||||
#include "./image_loader_stb.hpp"
|
#include "./image_loader_sdl_image.hpp"
|
||||||
|
|
||||||
#include <solanaceae/message3/components.hpp>
|
#include <solanaceae/message3/components.hpp>
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ MediaMetaInfoLoader::MediaMetaInfoLoader(RegistryMessageModel& rmm) : _rmm(rmm)
|
|||||||
_image_loaders.push_back(std::make_unique<ImageLoaderWebP>());
|
_image_loaders.push_back(std::make_unique<ImageLoaderWebP>());
|
||||||
_image_loaders.push_back(std::make_unique<ImageLoaderSDLBMP>());
|
_image_loaders.push_back(std::make_unique<ImageLoaderSDLBMP>());
|
||||||
_image_loaders.push_back(std::make_unique<ImageLoaderQOI>());
|
_image_loaders.push_back(std::make_unique<ImageLoaderQOI>());
|
||||||
_image_loaders.push_back(std::make_unique<ImageLoaderSTB>());
|
_image_loaders.push_back(std::make_unique<ImageLoaderSDLImage>());
|
||||||
|
|
||||||
_rmm.subscribe(this, RegistryMessageModel_Event::message_construct);
|
_rmm.subscribe(this, RegistryMessageModel_Event::message_construct);
|
||||||
_rmm.subscribe(this, RegistryMessageModel_Event::message_updated);
|
_rmm.subscribe(this, RegistryMessageModel_Event::message_updated);
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
#include "./image_loader_sdl_bmp.hpp"
|
#include "./image_loader_sdl_bmp.hpp"
|
||||||
#include "./image_loader_qoi.hpp"
|
#include "./image_loader_qoi.hpp"
|
||||||
#include "./image_loader_stb.hpp"
|
|
||||||
#include "./image_loader_webp.hpp"
|
#include "./image_loader_webp.hpp"
|
||||||
|
#include "./image_loader_sdl_image.hpp"
|
||||||
#include "./media_meta_info_loader.hpp"
|
#include "./media_meta_info_loader.hpp"
|
||||||
|
|
||||||
#include <solanaceae/message3/components.hpp>
|
#include <solanaceae/message3/components.hpp>
|
||||||
@ -22,7 +22,7 @@ MessageImageLoader::MessageImageLoader(void) {
|
|||||||
_image_loaders.push_back(std::make_unique<ImageLoaderSDLBMP>());
|
_image_loaders.push_back(std::make_unique<ImageLoaderSDLBMP>());
|
||||||
_image_loaders.push_back(std::make_unique<ImageLoaderQOI>());
|
_image_loaders.push_back(std::make_unique<ImageLoaderQOI>());
|
||||||
_image_loaders.push_back(std::make_unique<ImageLoaderWebP>());
|
_image_loaders.push_back(std::make_unique<ImageLoaderWebP>());
|
||||||
_image_loaders.push_back(std::make_unique<ImageLoaderSTB>());
|
_image_loaders.push_back(std::make_unique<ImageLoaderSDLImage>());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<TextureEntry> MessageImageLoader::load(TextureUploaderI& tu, Message3Handle m) {
|
std::optional<TextureEntry> MessageImageLoader::load(TextureUploaderI& tu, Message3Handle m) {
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include <imgui/imgui.h>
|
#include <imgui/imgui.h>
|
||||||
#include <imgui/misc/cpp/imgui_stdlib.h>
|
#include <imgui/misc/cpp/imgui_stdlib.h>
|
||||||
|
|
||||||
|
#include <cctype>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
|
||||||
@ -33,13 +34,13 @@ Screen* StartScreen::render(float, bool&) {
|
|||||||
_fss.requestFile(
|
_fss.requestFile(
|
||||||
[](const auto& path) -> bool { return std::filesystem::is_regular_file(path); },
|
[](const auto& path) -> bool { return std::filesystem::is_regular_file(path); },
|
||||||
[this](const auto& path) {
|
[this](const auto& path) {
|
||||||
tox_profile_path = path.string();
|
_tox_profile_path = path.string();
|
||||||
},
|
},
|
||||||
[](){}
|
[](){}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::TextUnformatted(tox_profile_path.c_str());
|
ImGui::TextUnformatted(_tox_profile_path.c_str());
|
||||||
|
|
||||||
ImGui::TextUnformatted("password:");
|
ImGui::TextUnformatted("password:");
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
@ -56,8 +57,22 @@ Screen* StartScreen::render(float, bool&) {
|
|||||||
if (ImGui::BeginTabItem("create profile")) {
|
if (ImGui::BeginTabItem("create profile")) {
|
||||||
_new_save = true;
|
_new_save = true;
|
||||||
|
|
||||||
ImGui::TextUnformatted("TODO: profile path");
|
ImGui::TextUnformatted("username:");
|
||||||
ImGui::TextUnformatted("TODO: profile name");
|
ImGui::SameLine();
|
||||||
|
if (ImGui::InputText("##user_name", &_user_name)) {
|
||||||
|
std::string tmp_copy = _user_name;
|
||||||
|
for (auto& c : tmp_copy) {
|
||||||
|
if (!std::isalnum(static_cast<unsigned char>(c)) && c != '-' && c != '.') {
|
||||||
|
c = '_';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tmp_copy.empty()) {
|
||||||
|
tmp_copy = "unnamed-tomato";
|
||||||
|
}
|
||||||
|
|
||||||
|
_tox_profile_path = tmp_copy + ".tox";
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::TextUnformatted("password:");
|
ImGui::TextUnformatted("password:");
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
@ -69,6 +84,8 @@ Screen* StartScreen::render(float, bool&) {
|
|||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::Checkbox("show password", &_show_password);
|
ImGui::Checkbox("show password", &_show_password);
|
||||||
|
|
||||||
|
ImGui::TextUnformatted("TODO: profile path (current path for now)");
|
||||||
|
|
||||||
ImGui::EndTabItem();
|
ImGui::EndTabItem();
|
||||||
}
|
}
|
||||||
if (ImGui::BeginTabItem("plugins")) {
|
if (ImGui::BeginTabItem("plugins")) {
|
||||||
@ -81,7 +98,6 @@ Screen* StartScreen::render(float, bool&) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
|
|
||||||
ImGui::TextUnformatted(it->c_str());
|
ImGui::TextUnformatted(it->c_str());
|
||||||
|
|
||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
@ -105,7 +121,7 @@ Screen* StartScreen::render(float, bool&) {
|
|||||||
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
if (!_new_save && !std::filesystem::is_regular_file(tox_profile_path)) {
|
if (!_new_save && !std::filesystem::is_regular_file(_tox_profile_path)) {
|
||||||
// load but file missing
|
// load but file missing
|
||||||
|
|
||||||
ImGui::BeginDisabled();
|
ImGui::BeginDisabled();
|
||||||
@ -115,7 +131,7 @@ Screen* StartScreen::render(float, bool&) {
|
|||||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_ForTooltip | ImGuiHoveredFlags_AllowWhenDisabled)) {
|
if (ImGui::IsItemHovered(ImGuiHoveredFlags_ForTooltip | ImGuiHoveredFlags_AllowWhenDisabled)) {
|
||||||
ImGui::SetTooltip("file does not exist");
|
ImGui::SetTooltip("file does not exist");
|
||||||
}
|
}
|
||||||
} else if (_new_save && std::filesystem::exists(tox_profile_path)) {
|
} else if (_new_save && std::filesystem::exists(_tox_profile_path)) {
|
||||||
// new but file exists
|
// new but file exists
|
||||||
|
|
||||||
ImGui::BeginDisabled();
|
ImGui::BeginDisabled();
|
||||||
@ -127,7 +143,7 @@ Screen* StartScreen::render(float, bool&) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (ImGui::Button("load", {60, 25})) {
|
if (ImGui::Button("load", {60, 25})) {
|
||||||
auto new_screen = std::make_unique<MainScreen>(_renderer, tox_profile_path, _password, queued_plugin_paths);
|
auto new_screen = std::make_unique<MainScreen>(_renderer, _tox_profile_path, _password, _user_name, queued_plugin_paths);
|
||||||
return new_screen.release();
|
return new_screen.release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include "./screen.hpp"
|
#include "./screen.hpp"
|
||||||
|
|
||||||
#include "./file_selector.hpp"
|
#include "./chat_gui/file_selector.hpp"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -17,11 +17,12 @@ struct StartScreen final : public Screen {
|
|||||||
FileSelector _fss;
|
FileSelector _fss;
|
||||||
|
|
||||||
bool _new_save {false};
|
bool _new_save {false};
|
||||||
|
std::string _user_name {"unnamed-tomato"};
|
||||||
|
|
||||||
bool _show_password {false};
|
bool _show_password {false};
|
||||||
std::string _password;
|
std::string _password;
|
||||||
|
|
||||||
std::string tox_profile_path {"tomato.tox"};
|
std::string _tox_profile_path {"unnamed-tomato.tox"};
|
||||||
std::vector<std::string> queued_plugin_paths;
|
std::vector<std::string> queued_plugin_paths;
|
||||||
|
|
||||||
StartScreen(void) = delete;
|
StartScreen(void) = delete;
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
#include "./image_loader_sdl_bmp.hpp"
|
#include "./image_loader_sdl_bmp.hpp"
|
||||||
#include "./image_loader_qoi.hpp"
|
#include "./image_loader_qoi.hpp"
|
||||||
#include "./image_loader_stb.hpp"
|
|
||||||
#include "./image_loader_webp.hpp"
|
#include "./image_loader_webp.hpp"
|
||||||
|
#include "./image_loader_sdl_image.hpp"
|
||||||
|
|
||||||
#include <solanaceae/contact/components.hpp>
|
#include <solanaceae/contact/components.hpp>
|
||||||
#include <solanaceae/tox_contacts/components.hpp>
|
#include <solanaceae/tox_contacts/components.hpp>
|
||||||
@ -24,7 +24,7 @@ ToxAvatarLoader::ToxAvatarLoader(Contact3Registry& cr) : _cr(cr) {
|
|||||||
_image_loaders.push_back(std::make_unique<ImageLoaderSDLBMP>());
|
_image_loaders.push_back(std::make_unique<ImageLoaderSDLBMP>());
|
||||||
_image_loaders.push_back(std::make_unique<ImageLoaderQOI>());
|
_image_loaders.push_back(std::make_unique<ImageLoaderQOI>());
|
||||||
_image_loaders.push_back(std::make_unique<ImageLoaderWebP>());
|
_image_loaders.push_back(std::make_unique<ImageLoaderWebP>());
|
||||||
_image_loaders.push_back(std::make_unique<ImageLoaderSTB>());
|
_image_loaders.push_back(std::make_unique<ImageLoaderSDLImage>());
|
||||||
}
|
}
|
||||||
|
|
||||||
static float getHue_6bytes(const uint8_t* data) {
|
static float getHue_6bytes(const uint8_t* data) {
|
||||||
|
@ -107,6 +107,12 @@ ToxFriendFauxOfflineMessaging::dfmc_Ret ToxFriendFauxOfflineMessaging::doFriendM
|
|||||||
|
|
||||||
const uint64_t ts_now = Message::getTimeMS();
|
const uint64_t ts_now = Message::getTimeMS();
|
||||||
|
|
||||||
|
if (!_cr.all_of<Contact::Components::Self>(c)) {
|
||||||
|
return dfmc_Ret::NO_MSG; // error
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto self_c = _cr.get<Contact::Components::Self>(c).self;
|
||||||
|
|
||||||
// filter for unconfirmed messages
|
// filter for unconfirmed messages
|
||||||
|
|
||||||
// we assume sorted
|
// we assume sorted
|
||||||
@ -127,9 +133,8 @@ ToxFriendFauxOfflineMessaging::dfmc_Ret ToxFriendFauxOfflineMessaging::doFriendM
|
|||||||
continue; // skip
|
continue; // skip
|
||||||
}
|
}
|
||||||
|
|
||||||
// exclude
|
if (!mr->any_of<
|
||||||
if (mr->any_of<
|
Message::Components::ReceivedBy
|
||||||
Message::Components::Remote::TimestampReceived // this acts like a tag, which is wrong in groups
|
|
||||||
>(msg)
|
>(msg)
|
||||||
) {
|
) {
|
||||||
continue; // skip
|
continue; // skip
|
||||||
@ -139,6 +144,16 @@ ToxFriendFauxOfflineMessaging::dfmc_Ret ToxFriendFauxOfflineMessaging::doFriendM
|
|||||||
continue; // not outbound (in private)
|
continue; // not outbound (in private)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const auto& ts_received = mr->get<Message::Components::ReceivedBy>(msg).ts;
|
||||||
|
// not target
|
||||||
|
if (ts_received.contains(c)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// needs to contain self
|
||||||
|
if (!ts_received.contains(self_c)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
valid_unsent = true;
|
valid_unsent = true;
|
||||||
|
|
||||||
uint64_t msg_ts = msg_view.get<Message::Components::Timestamp>(msg).ts;
|
uint64_t msg_ts = msg_view.get<Message::Components::Timestamp>(msg).ts;
|
||||||
|
Reference in New Issue
Block a user