Compare commits
7 Commits
70bc3a47f2
...
dev_contac
Author | SHA1 | Date | |
---|---|---|---|
d795d328d3 | |||
e82a99c312 | |||
6a9e02e241 | |||
54409b01f5 | |||
8ba8b6322f | |||
bc0f21175b | |||
f7471ca4cb |
@ -33,6 +33,7 @@
|
|||||||
android:required="false" />
|
android:required="false" />
|
||||||
|
|
||||||
<!-- Audio recording support -->
|
<!-- Audio recording support -->
|
||||||
|
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
||||||
<uses-feature
|
<uses-feature
|
||||||
android:name="android.hardware.microphone"
|
android:name="android.hardware.microphone"
|
||||||
android:required="false" />
|
android:required="false" />
|
||||||
@ -56,9 +57,6 @@
|
|||||||
<!-- Allow access to the vibrator -->
|
<!-- Allow access to the vibrator -->
|
||||||
<uses-permission android:name="android.permission.VIBRATE" />
|
<uses-permission android:name="android.permission.VIBRATE" />
|
||||||
|
|
||||||
<!-- if you want to capture audio, uncomment this. -->
|
|
||||||
<!-- <uses-permission android:name="android.permission.RECORD_AUDIO" /> -->
|
|
||||||
|
|
||||||
<!-- Create a Java class extending SDLActivity and place it in a
|
<!-- Create a Java class extending SDLActivity and place it in a
|
||||||
directory under app/src/main/java matching the package, e.g. app/src/main/java/com/gamemaker/game/MyGame.java
|
directory under app/src/main/java matching the package, e.g. app/src/main/java/com/gamemaker/game/MyGame.java
|
||||||
|
|
||||||
|
2
external/solanaceae_message3
vendored
2
external/solanaceae_message3
vendored
Submodule external/solanaceae_message3 updated: 9728f71c98...3e6c857c8a
2
external/solanaceae_tox
vendored
2
external/solanaceae_tox
vendored
Submodule external/solanaceae_tox updated: 1a3d9dd187...a0c3336f37
@ -80,6 +80,8 @@ target_sources(tomato PUBLIC
|
|||||||
./chat_gui/icons/group.cpp
|
./chat_gui/icons/group.cpp
|
||||||
./chat_gui/contact_list.hpp
|
./chat_gui/contact_list.hpp
|
||||||
./chat_gui/contact_list.cpp
|
./chat_gui/contact_list.cpp
|
||||||
|
./chat_gui/contact_tree.hpp
|
||||||
|
./chat_gui/contact_tree.cpp
|
||||||
./chat_gui/file_selector.hpp
|
./chat_gui/file_selector.hpp
|
||||||
./chat_gui/file_selector.cpp
|
./chat_gui/file_selector.cpp
|
||||||
./chat_gui/send_image_popup.hpp
|
./chat_gui/send_image_popup.hpp
|
||||||
|
97
src/chat_gui/contact_tree.cpp
Normal file
97
src/chat_gui/contact_tree.cpp
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
#include "./contact_tree.hpp"
|
||||||
|
|
||||||
|
#include <solanaceae/contact/components.hpp>
|
||||||
|
|
||||||
|
#include "./contact_list.hpp"
|
||||||
|
#include "entt/entity/entity.hpp"
|
||||||
|
|
||||||
|
#include <imgui/imgui.h>
|
||||||
|
|
||||||
|
namespace Components {
|
||||||
|
struct TagTreeViewOpen {};
|
||||||
|
};
|
||||||
|
|
||||||
|
ContactTreeWindow::ContactTreeWindow(Contact3Registry& cr, Theme& theme, ContactTextureCache& ctc) : _cr(cr), _theme(theme), _ctc(ctc) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void ContactTreeWindow::render(void) {
|
||||||
|
//{ // main window menubar injection
|
||||||
|
// // assumes the window "tomato" was rendered already by cg
|
||||||
|
// if (ImGui::Begin("tomato")) {
|
||||||
|
// if (ImGui::BeginMenuBar()) {
|
||||||
|
// ImGui::Separator();
|
||||||
|
// if (ImGui::BeginMenu("Settings")) {
|
||||||
|
// if (ImGui::MenuItem("settings window", nullptr, _show_window)) {
|
||||||
|
// _show_window = !_show_window;
|
||||||
|
// }
|
||||||
|
// ImGui::EndMenu();
|
||||||
|
// }
|
||||||
|
// ImGui::EndMenuBar();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// ImGui::End();
|
||||||
|
//}
|
||||||
|
|
||||||
|
if (_show_window) {
|
||||||
|
if (ImGui::Begin("ContactTreeWindow", &_show_window)) {
|
||||||
|
|
||||||
|
if (ImGui::BeginTable("##table", 1, ImGuiTableFlags_None)) {
|
||||||
|
// first we need all root nodes
|
||||||
|
for (const auto [cv_root] : _cr.view<Contact::Components::TagRoot>().each()) {
|
||||||
|
ImGui::TableNextRow();
|
||||||
|
ImGui::PushID(entt::to_integral(cv_root));
|
||||||
|
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
|
||||||
|
Contact3Handle c_root {_cr, cv_root};
|
||||||
|
bool open = c_root.all_of<Components::TagTreeViewOpen>();
|
||||||
|
|
||||||
|
bool has_children = c_root.all_of<Contact::Components::ParentOf>();
|
||||||
|
|
||||||
|
// roots are usually no normal contacts
|
||||||
|
// they should display as a protocol or profile or account
|
||||||
|
// TODO: set some table background instead of full span selected?
|
||||||
|
if (renderContactBig(_theme, _ctc, c_root, 2, false, true)) {
|
||||||
|
// clicked, toggle open
|
||||||
|
if (open) {
|
||||||
|
c_root.remove<Components::TagTreeViewOpen>();
|
||||||
|
open = false;
|
||||||
|
} else {
|
||||||
|
c_root.emplace_or_replace<Components::TagTreeViewOpen>();
|
||||||
|
open = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (open) {
|
||||||
|
// render children
|
||||||
|
|
||||||
|
ImGui::Indent();
|
||||||
|
|
||||||
|
if (c_root.all_of<Contact::Components::ParentOf>()) {
|
||||||
|
for (const auto cv_child : c_root.get<Contact::Components::ParentOf>().subs) {
|
||||||
|
ImGui::PushID(entt::to_integral(cv_child));
|
||||||
|
|
||||||
|
Contact3Handle c_child {_cr, cv_child};
|
||||||
|
renderContactBig(_theme, _ctc, c_child, 2);
|
||||||
|
|
||||||
|
ImGui::PopID();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// TODO: remove
|
||||||
|
ImGui::TableNextRow();
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
ImGui::TextDisabled("no parent of");
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::Unindent();
|
||||||
|
|
||||||
|
}
|
||||||
|
ImGui::PopID();
|
||||||
|
}
|
||||||
|
ImGui::EndTable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ImGui::End();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
23
src/chat_gui/contact_tree.hpp
Normal file
23
src/chat_gui/contact_tree.hpp
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <solanaceae/contact/contact_model3.hpp>
|
||||||
|
|
||||||
|
#include "./texture_cache_defs.hpp"
|
||||||
|
|
||||||
|
// fwd
|
||||||
|
struct Theme;
|
||||||
|
|
||||||
|
class ContactTreeWindow {
|
||||||
|
bool _show_window {true};
|
||||||
|
|
||||||
|
Contact3Registry& _cr;
|
||||||
|
|
||||||
|
Theme& _theme;
|
||||||
|
ContactTextureCache& _ctc;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ContactTreeWindow(Contact3Registry& cr, Theme& theme, ContactTextureCache& ctc);
|
||||||
|
|
||||||
|
void render(void);
|
||||||
|
};
|
||||||
|
|
@ -198,7 +198,7 @@ void FileSelector::render(void) {
|
|||||||
const auto ctime = std::chrono::system_clock::to_time_t(file_time_converted);
|
const auto ctime = std::chrono::system_clock::to_time_t(file_time_converted);
|
||||||
|
|
||||||
const auto ltime = std::localtime(&ctime);
|
const auto ltime = std::localtime(&ctime);
|
||||||
ImGui::TextDisabled("%2d.%2d.%2d - %2d:%2d", ltime->tm_mday, ltime->tm_mon, ltime->tm_year + 1900, ltime->tm_hour, ltime->tm_min);
|
ImGui::TextDisabled("%2d.%2d.%2d - %2d:%2d", ltime->tm_mday, ltime->tm_mon + 1, ltime->tm_year + 1900, ltime->tm_hour, ltime->tm_min);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,7 +201,7 @@ void ChatGui4::setClipboardData(std::vector<std::string> mime_types, std::shared
|
|||||||
ChatGui4::ChatGui4(
|
ChatGui4::ChatGui4(
|
||||||
ConfigModelI& conf,
|
ConfigModelI& conf,
|
||||||
ObjectStore2& os,
|
ObjectStore2& os,
|
||||||
RegistryMessageModel& rmm,
|
RegistryMessageModelI& rmm,
|
||||||
Contact3Registry& cr,
|
Contact3Registry& cr,
|
||||||
TextureUploaderI& tu,
|
TextureUploaderI& tu,
|
||||||
ContactTextureCache& contact_tc,
|
ContactTextureCache& contact_tc,
|
||||||
@ -1118,38 +1118,38 @@ void ChatGui4::renderMessageBodyFile(Message3Registry& reg, const Message3 e) {
|
|||||||
// hacky
|
// hacky
|
||||||
const auto* fts = o.try_get<ObjComp::Ephemeral::File::TransferStats>();
|
const auto* fts = o.try_get<ObjComp::Ephemeral::File::TransferStats>();
|
||||||
if (fts != nullptr && o.any_of<ObjComp::F::SingleInfo, ObjComp::F::CollectionInfo>()) {
|
if (fts != nullptr && o.any_of<ObjComp::F::SingleInfo, ObjComp::F::CollectionInfo>()) {
|
||||||
const auto total_size =
|
const int64_t total_size =
|
||||||
o.all_of<ObjComp::F::SingleInfo>() ?
|
o.all_of<ObjComp::F::SingleInfo>() ?
|
||||||
o.get<ObjComp::F::SingleInfo>().file_size :
|
o.get<ObjComp::F::SingleInfo>().file_size :
|
||||||
o.get<ObjComp::F::CollectionInfo>().total_size
|
o.get<ObjComp::F::CollectionInfo>().total_size
|
||||||
;
|
;
|
||||||
|
|
||||||
uint64_t total {0u};
|
int64_t transfer_total {0u};
|
||||||
float rate {0.f};
|
float transfer_rate {0.f};
|
||||||
if (o.all_of<ObjComp::F::TagLocalHaveAll>() && fts->total_down <= 0) {
|
if (o.all_of<ObjComp::F::TagLocalHaveAll>() && fts->total_down <= 0) {
|
||||||
// if have all AND no dl -> show upload progress
|
// if have all AND no dl -> show upload progress
|
||||||
ImGui::TextUnformatted(" up");
|
ImGui::TextUnformatted(" up");
|
||||||
total = fts->total_up;
|
transfer_total = fts->total_up;
|
||||||
rate = fts->rate_up;
|
transfer_rate = fts->rate_up;
|
||||||
} else {
|
} else {
|
||||||
// else show download progress
|
// else show download progress
|
||||||
ImGui::TextUnformatted("down");
|
ImGui::TextUnformatted("down");
|
||||||
total = fts->total_down;
|
transfer_total = fts->total_down;
|
||||||
rate = fts->rate_down;
|
transfer_rate = fts->rate_down;
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
|
|
||||||
float fraction = float(total) / total_size;
|
float fraction = float(transfer_total) / total_size;
|
||||||
|
|
||||||
char overlay_buf[64];
|
char overlay_buf[64];
|
||||||
if (rate > 0.000001f) {
|
if (transfer_rate > 0.000001f) {
|
||||||
const char* byte_suffix = "???";
|
const char* byte_suffix = "???";
|
||||||
int64_t byte_divider = sizeToHumanReadable(rate, byte_suffix);
|
int64_t byte_divider = sizeToHumanReadable(transfer_rate, byte_suffix);
|
||||||
int64_t seconds_remaining = (total_size - total) / rate;
|
int64_t seconds_remaining = (total_size - transfer_total) / transfer_rate;
|
||||||
if (seconds_remaining > 0) {
|
if (seconds_remaining > 0) {
|
||||||
std::snprintf(overlay_buf, sizeof(overlay_buf), "%.1f%% @ %.1f%s/s %lds ", fraction * 100 + 0.01f, rate/byte_divider, byte_suffix, seconds_remaining);
|
std::snprintf(overlay_buf, sizeof(overlay_buf), "%.1f%% @ %.1f%s/s %lds ", fraction * 100 + 0.01f, transfer_rate/byte_divider, byte_suffix, seconds_remaining);
|
||||||
} else {
|
} else {
|
||||||
std::snprintf(overlay_buf, sizeof(overlay_buf), "%.1f%% @ %.1f%s/s", fraction * 100 + 0.01f, rate/byte_divider, byte_suffix);
|
std::snprintf(overlay_buf, sizeof(overlay_buf), "%.1f%% @ %.1f%s/s", fraction * 100 + 0.01f, transfer_rate/byte_divider, byte_suffix);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
std::snprintf(overlay_buf, sizeof(overlay_buf), "%.1f%%", fraction * 100 + 0.01f);
|
std::snprintf(overlay_buf, sizeof(overlay_buf), "%.1f%%", fraction * 100 + 0.01f);
|
||||||
|
@ -27,7 +27,7 @@ using MessageTextureCache = TextureCache<void*, Message3Handle, MessageImageLoad
|
|||||||
class ChatGui4 {
|
class ChatGui4 {
|
||||||
ConfigModelI& _conf;
|
ConfigModelI& _conf;
|
||||||
ObjectStore2& _os;
|
ObjectStore2& _os;
|
||||||
RegistryMessageModel& _rmm;
|
RegistryMessageModelI& _rmm;
|
||||||
Contact3Registry& _cr;
|
Contact3Registry& _cr;
|
||||||
|
|
||||||
ContactTextureCache& _contact_tc;
|
ContactTextureCache& _contact_tc;
|
||||||
@ -60,7 +60,7 @@ class ChatGui4 {
|
|||||||
ChatGui4(
|
ChatGui4(
|
||||||
ConfigModelI& conf,
|
ConfigModelI& conf,
|
||||||
ObjectStore2& os,
|
ObjectStore2& os,
|
||||||
RegistryMessageModel& rmm,
|
RegistryMessageModelI& rmm,
|
||||||
Contact3Registry& cr,
|
Contact3Registry& cr,
|
||||||
TextureUploaderI& tu,
|
TextureUploaderI& tu,
|
||||||
ContactTextureCache& contact_tc,
|
ContactTextureCache& contact_tc,
|
||||||
|
@ -7,34 +7,21 @@
|
|||||||
SDLVideo2InputDevice::SDLVideo2InputDevice(void) {
|
SDLVideo2InputDevice::SDLVideo2InputDevice(void) {
|
||||||
int devcount {0};
|
int devcount {0};
|
||||||
SDL_CameraID *devices = SDL_GetCameras(&devcount);
|
SDL_CameraID *devices = SDL_GetCameras(&devcount);
|
||||||
std::cout << "SDLVID: SDL Camera Driver: " << SDL_GetCurrentCameraDriver() << "\n";
|
|
||||||
|
|
||||||
if (devices == nullptr || devcount < 1) {
|
if (devices == nullptr || devcount < 1) {
|
||||||
throw int(2); // TODO: proper error code
|
throw int(2); // TODO: proper error code
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "SDLVID: found cameras:\n";
|
// pick the last (usually the newest device)
|
||||||
for (int i = 0; i < devcount; i++) {
|
_dev = devices[devcount-1];
|
||||||
const SDL_CameraID device = devices[i];
|
|
||||||
|
|
||||||
const char *name = SDL_GetCameraName(device);
|
|
||||||
std::cout << " - Camera #" << i << ": " << name << "\n";
|
|
||||||
|
|
||||||
int speccount {0};
|
|
||||||
SDL_CameraSpec** specs = SDL_GetCameraSupportedFormats(device, &speccount);
|
|
||||||
if (specs == nullptr) {
|
|
||||||
std::cout << " - no supported spec\n";
|
|
||||||
} else {
|
|
||||||
for (int spec_i = 0; spec_i < speccount; spec_i++) {
|
|
||||||
std::cout << " - " << specs[spec_i]->width << "x" << specs[spec_i]->height << "@" << float(specs[spec_i]->framerate_numerator)/specs[spec_i]->framerate_denominator << "fps " << SDL_GetPixelFormatName(specs[spec_i]->format) << "\n";
|
|
||||||
|
|
||||||
}
|
|
||||||
SDL_free(specs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SDL_free(devices);
|
SDL_free(devices);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SDLVideo2InputDevice::SDLVideo2InputDevice(const SDL_CameraID dev) : _dev(dev) {
|
||||||
|
// nothing else?
|
||||||
|
}
|
||||||
|
|
||||||
SDLVideo2InputDevice::~SDLVideo2InputDevice(void) {
|
SDLVideo2InputDevice::~SDLVideo2InputDevice(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,19 +31,6 @@ std::shared_ptr<FrameStream2I<SDLVideoFrame>> SDLVideo2InputDevice::subscribe(vo
|
|||||||
// there was previously no stream, we assume no thread
|
// there was previously no stream, we assume no thread
|
||||||
// open device here? or on the thread?
|
// open device here? or on the thread?
|
||||||
|
|
||||||
int devcount {0};
|
|
||||||
SDL_CameraID *devices = SDL_GetCameras(&devcount);
|
|
||||||
|
|
||||||
if (devices == nullptr || devcount < 1) {
|
|
||||||
_ref--;
|
|
||||||
// error/no devices, should we do this in the constructor?
|
|
||||||
SDL_free(devices);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
//auto device = devices[0];
|
|
||||||
auto device = devices[devcount-1];
|
|
||||||
|
|
||||||
SDL_CameraSpec spec {
|
SDL_CameraSpec spec {
|
||||||
// FORCE a different pixel format
|
// FORCE a different pixel format
|
||||||
SDL_PIXELFORMAT_UNKNOWN,
|
SDL_PIXELFORMAT_UNKNOWN,
|
||||||
@ -71,9 +45,9 @@ std::shared_ptr<FrameStream2I<SDLVideoFrame>> SDLVideo2InputDevice::subscribe(vo
|
|||||||
|
|
||||||
// choose a good spec, large res but <= 1080p
|
// choose a good spec, large res but <= 1080p
|
||||||
int speccount {0};
|
int speccount {0};
|
||||||
SDL_CameraSpec** specs = SDL_GetCameraSupportedFormats(device, &speccount);
|
SDL_CameraSpec** specs = SDL_GetCameraSupportedFormats(_dev, &speccount);
|
||||||
if (specs != nullptr) {
|
if (specs != nullptr) {
|
||||||
spec = *specs[0];
|
spec = *specs[speccount-1]; // start with last, as its usually the smallest
|
||||||
for (int spec_i = 1; spec_i < speccount; spec_i++) {
|
for (int spec_i = 1; spec_i < speccount; spec_i++) {
|
||||||
if (specs[spec_i]->height > 1080) {
|
if (specs[spec_i]->height > 1080) {
|
||||||
continue;
|
continue;
|
||||||
@ -104,10 +78,9 @@ std::shared_ptr<FrameStream2I<SDLVideoFrame>> SDLVideo2InputDevice::subscribe(vo
|
|||||||
|
|
||||||
camera = {
|
camera = {
|
||||||
//SDL_OpenCamera(device, nullptr),
|
//SDL_OpenCamera(device, nullptr),
|
||||||
SDL_OpenCamera(device, &spec),
|
SDL_OpenCamera(_dev, &spec),
|
||||||
&SDL_CloseCamera
|
&SDL_CloseCamera
|
||||||
};
|
};
|
||||||
SDL_free(devices);
|
|
||||||
|
|
||||||
if (!camera) {
|
if (!camera) {
|
||||||
std::cerr << "SDLVID error: failed opening camera device\n";
|
std::cerr << "SDLVID error: failed opening camera device\n";
|
||||||
|
@ -15,11 +15,13 @@
|
|||||||
// while a stream is subscribed, have the camera device open
|
// while a stream is subscribed, have the camera device open
|
||||||
// and aquire and push frames from a thread
|
// and aquire and push frames from a thread
|
||||||
struct SDLVideo2InputDevice : public FrameStream2MultiSource<SDLVideoFrame> {
|
struct SDLVideo2InputDevice : public FrameStream2MultiSource<SDLVideoFrame> {
|
||||||
|
SDL_CameraID _dev {0};
|
||||||
|
|
||||||
std::atomic_uint _ref {0};
|
std::atomic_uint _ref {0};
|
||||||
std::thread _thread;
|
std::thread _thread;
|
||||||
|
|
||||||
// TODO: device id
|
|
||||||
SDLVideo2InputDevice(void);
|
SDLVideo2InputDevice(void);
|
||||||
|
SDLVideo2InputDevice(const SDL_CameraID dev);
|
||||||
virtual ~SDLVideo2InputDevice(void);
|
virtual ~SDLVideo2InputDevice(void);
|
||||||
|
|
||||||
// we hook int multi source
|
// we hook int multi source
|
||||||
|
@ -43,6 +43,7 @@ MainScreen::MainScreen(SimpleConfigModel&& conf_, SDL_Renderer* renderer_, Theme
|
|||||||
mil(),
|
mil(),
|
||||||
msg_tc(mil, sdlrtu),
|
msg_tc(mil, sdlrtu),
|
||||||
cg(conf, os, rmm, cr, sdlrtu, contact_tc, msg_tc, theme),
|
cg(conf, os, rmm, cr, sdlrtu, contact_tc, msg_tc, theme),
|
||||||
|
ctw(cr, theme, contact_tc),
|
||||||
sw(conf),
|
sw(conf),
|
||||||
osui(os),
|
osui(os),
|
||||||
tuiu(tc, conf),
|
tuiu(tc, conf),
|
||||||
@ -75,7 +76,7 @@ MainScreen::MainScreen(SimpleConfigModel&& conf_, SDL_Renderer* renderer_, Theme
|
|||||||
|
|
||||||
g_provideInstance<ConfigModelI>("ConfigModelI", "host", &conf);
|
g_provideInstance<ConfigModelI>("ConfigModelI", "host", &conf);
|
||||||
g_provideInstance<Contact3Registry>("Contact3Registry", "1", "host", &cr);
|
g_provideInstance<Contact3Registry>("Contact3Registry", "1", "host", &cr);
|
||||||
g_provideInstance<RegistryMessageModel>("RegistryMessageModel", "host", &rmm);
|
g_provideInstance<RegistryMessageModelI>("RegistryMessageModelI", "host", &rmm);
|
||||||
g_provideInstance<MessageSerializerNJ>("MessageSerializerNJ", "host", &msnj);
|
g_provideInstance<MessageSerializerNJ>("MessageSerializerNJ", "host", &msnj);
|
||||||
|
|
||||||
g_provideInstance<ToxI>("ToxI", "host", &tc);
|
g_provideInstance<ToxI>("ToxI", "host", &tc);
|
||||||
@ -181,21 +182,57 @@ MainScreen::MainScreen(SimpleConfigModel&& conf_, SDL_Renderer* renderer_, Theme
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (SDL_InitSubSystem(SDL_INIT_CAMERA)) {
|
if (SDL_InitSubSystem(SDL_INIT_CAMERA)) {
|
||||||
{ // video in
|
std::cout << "MS: SDL Camera Driver: " << SDL_GetCurrentCameraDriver() << "\n";
|
||||||
ObjectHandle vsrc {os.registry(), os.registry().create()};
|
|
||||||
try {
|
|
||||||
vsrc.emplace<Components::FrameStream2Source<SDLVideoFrame>>(
|
|
||||||
std::make_unique<SDLVideo2InputDevice>()
|
|
||||||
);
|
|
||||||
|
|
||||||
vsrc.emplace<Components::StreamSource>(Components::StreamSource::create<SDLVideoFrame>("SDL Video Default Recording Device"));
|
int devcount {0};
|
||||||
vsrc.emplace<Components::TagDefaultTarget>();
|
SDL_CameraID *devices = SDL_GetCameras(&devcount);
|
||||||
|
|
||||||
os.throwEventConstruct(vsrc);
|
std::cout << "MS: found cameras:\n";
|
||||||
} catch (...) {
|
if (devices != nullptr) {
|
||||||
std::cerr << "MS error: failed constructing default video input source\n";
|
ObjectHandle last_src{};
|
||||||
os.registry().destroy(vsrc);
|
for (int i = 0; i < devcount; i++) {
|
||||||
|
const SDL_CameraID device = devices[i];
|
||||||
|
|
||||||
|
const char *name = SDL_GetCameraName(device);
|
||||||
|
std::cout << " - Camera #" << i << ": " << name << "\n";
|
||||||
|
|
||||||
|
int speccount {0};
|
||||||
|
SDL_CameraSpec** specs = SDL_GetCameraSupportedFormats(device, &speccount);
|
||||||
|
if (specs == nullptr) {
|
||||||
|
std::cout << " - no supported spec\n";
|
||||||
|
} else {
|
||||||
|
for (int spec_i = 0; spec_i < speccount; spec_i++) {
|
||||||
|
std::cout << " - " << specs[spec_i]->width << "x" << specs[spec_i]->height << "@" << float(specs[spec_i]->framerate_numerator)/specs[spec_i]->framerate_denominator << "fps " << SDL_GetPixelFormatName(specs[spec_i]->format) << "\n";
|
||||||
|
|
||||||
|
}
|
||||||
|
SDL_free(specs);
|
||||||
|
|
||||||
|
// create sink for device
|
||||||
|
ObjectHandle vsrc {os.registry(), os.registry().create()};
|
||||||
|
try {
|
||||||
|
vsrc.emplace<Components::FrameStream2Source<SDLVideoFrame>>(
|
||||||
|
std::make_unique<SDLVideo2InputDevice>(device)
|
||||||
|
);
|
||||||
|
|
||||||
|
vsrc.emplace<Components::StreamSource>(Components::StreamSource::create<SDLVideoFrame>("SDL Video '" + std::string(name) + "'"));
|
||||||
|
//vsrc.emplace<Components::TagDefaultTarget>();
|
||||||
|
|
||||||
|
os.throwEventConstruct(vsrc);
|
||||||
|
last_src = vsrc;
|
||||||
|
} catch (...) {
|
||||||
|
std::cerr << "MS error: failed constructing video input source\n";
|
||||||
|
os.registry().destroy(vsrc);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//if (static_cast<bool>(last_src)) {
|
||||||
|
// last_src.emplace<Components::TagDefaultTarget>();
|
||||||
|
//}
|
||||||
|
|
||||||
|
SDL_free(devices);
|
||||||
|
} else {
|
||||||
|
std::cout << " none\n";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
std::cerr << "MS warning: no sdl camera: " << SDL_GetError() << "\n";
|
std::cerr << "MS warning: no sdl camera: " << SDL_GetError() << "\n";
|
||||||
@ -321,6 +358,7 @@ Screen* MainScreen::render(float time_delta, bool&) {
|
|||||||
const float msgtc_interval = msg_tc.update();
|
const float msgtc_interval = msg_tc.update();
|
||||||
|
|
||||||
const float cg_interval = cg.render(time_delta); // render
|
const float cg_interval = cg.render(time_delta); // render
|
||||||
|
ctw.render();
|
||||||
sw.render(); // render
|
sw.render(); // render
|
||||||
osui.render();
|
osui.render();
|
||||||
tuiu.render(); // render
|
tuiu.render(); // render
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include <solanaceae/util/simple_config_model.hpp>
|
#include <solanaceae/util/simple_config_model.hpp>
|
||||||
#include <solanaceae/contact/contact_model3.hpp>
|
#include <solanaceae/contact/contact_model3.hpp>
|
||||||
#include <solanaceae/message3/registry_message_model.hpp>
|
#include <solanaceae/message3/registry_message_model.hpp>
|
||||||
|
#include <solanaceae/message3/registry_message_model_impl.hpp>
|
||||||
#include <solanaceae/message3/message_time_sort.hpp>
|
#include <solanaceae/message3/message_time_sort.hpp>
|
||||||
#include <solanaceae/message3/message_serializer.hpp>
|
#include <solanaceae/message3/message_serializer.hpp>
|
||||||
#include <solanaceae/plugin/plugin_manager.hpp>
|
#include <solanaceae/plugin/plugin_manager.hpp>
|
||||||
@ -29,6 +30,7 @@
|
|||||||
#include "./message_image_loader.hpp"
|
#include "./message_image_loader.hpp"
|
||||||
|
|
||||||
#include "./chat_gui4.hpp"
|
#include "./chat_gui4.hpp"
|
||||||
|
#include "./chat_gui/contact_tree.hpp"
|
||||||
#include "./chat_gui/settings_window.hpp"
|
#include "./chat_gui/settings_window.hpp"
|
||||||
#include "./object_store_ui.hpp"
|
#include "./object_store_ui.hpp"
|
||||||
#include "./tox_ui_utils.hpp"
|
#include "./tox_ui_utils.hpp"
|
||||||
@ -58,7 +60,7 @@ struct MainScreen final : public Screen {
|
|||||||
|
|
||||||
SimpleConfigModel conf;
|
SimpleConfigModel conf;
|
||||||
Contact3Registry cr;
|
Contact3Registry cr;
|
||||||
RegistryMessageModel rmm;
|
RegistryMessageModelImpl rmm;
|
||||||
MessageSerializerNJ msnj;
|
MessageSerializerNJ msnj;
|
||||||
MessageTimeSort mts;
|
MessageTimeSort mts;
|
||||||
|
|
||||||
@ -91,6 +93,7 @@ struct MainScreen final : public Screen {
|
|||||||
TextureCache<void*, Message3Handle, MessageImageLoader> msg_tc;
|
TextureCache<void*, Message3Handle, MessageImageLoader> msg_tc;
|
||||||
|
|
||||||
ChatGui4 cg;
|
ChatGui4 cg;
|
||||||
|
ContactTreeWindow ctw;
|
||||||
SettingsWindow sw;
|
SettingsWindow sw;
|
||||||
ObjectStoreUI osui;
|
ObjectStoreUI osui;
|
||||||
ToxUIUtils tuiu;
|
ToxUIUtils tuiu;
|
||||||
|
@ -120,7 +120,7 @@ void MediaMetaInfoLoader::handleMessage(const Message3Handle& m) {
|
|||||||
_rmm.throwEventUpdate(m);
|
_rmm.throwEventUpdate(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
MediaMetaInfoLoader::MediaMetaInfoLoader(RegistryMessageModel& rmm) : _rmm(rmm) {
|
MediaMetaInfoLoader::MediaMetaInfoLoader(RegistryMessageModelI& rmm) : _rmm(rmm) {
|
||||||
// HACK: make them be added externally?
|
// HACK: make them be added externally?
|
||||||
_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>());
|
||||||
|
@ -13,14 +13,14 @@ namespace Message::Components {
|
|||||||
// adds metadata to file messages
|
// adds metadata to file messages
|
||||||
class MediaMetaInfoLoader : public RegistryMessageModelEventI {
|
class MediaMetaInfoLoader : public RegistryMessageModelEventI {
|
||||||
protected:
|
protected:
|
||||||
RegistryMessageModel& _rmm;
|
RegistryMessageModelI& _rmm;
|
||||||
|
|
||||||
std::vector<std::unique_ptr<ImageLoaderI>> _image_loaders;
|
std::vector<std::unique_ptr<ImageLoaderI>> _image_loaders;
|
||||||
|
|
||||||
void handleMessage(const Message3Handle& m);
|
void handleMessage(const Message3Handle& m);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MediaMetaInfoLoader(RegistryMessageModel& rmm);
|
MediaMetaInfoLoader(RegistryMessageModelI& rmm);
|
||||||
virtual ~MediaMetaInfoLoader(void);
|
virtual ~MediaMetaInfoLoader(void);
|
||||||
|
|
||||||
protected: // rmm
|
protected: // rmm
|
||||||
|
@ -26,7 +26,7 @@ namespace Contact::Components {
|
|||||||
|
|
||||||
ToxFriendFauxOfflineMessaging::ToxFriendFauxOfflineMessaging(
|
ToxFriendFauxOfflineMessaging::ToxFriendFauxOfflineMessaging(
|
||||||
Contact3Registry& cr,
|
Contact3Registry& cr,
|
||||||
RegistryMessageModel& rmm,
|
RegistryMessageModelI& rmm,
|
||||||
ToxContactModel2& tcm,
|
ToxContactModel2& tcm,
|
||||||
ToxI& t,
|
ToxI& t,
|
||||||
ToxEventProviderI& tep
|
ToxEventProviderI& tep
|
||||||
@ -54,7 +54,7 @@ float ToxFriendFauxOfflineMessaging::tick(float time_delta) {
|
|||||||
// cleanup
|
// cleanup
|
||||||
if (_cr.all_of<Contact::Components::NextSendAttempt>(c)) {
|
if (_cr.all_of<Contact::Components::NextSendAttempt>(c)) {
|
||||||
_cr.remove<Contact::Components::NextSendAttempt>(c);
|
_cr.remove<Contact::Components::NextSendAttempt>(c);
|
||||||
auto* mr = static_cast<const RegistryMessageModel&>(_rmm).get(c);
|
auto* mr = static_cast<const RegistryMessageModelI&>(_rmm).get(c);
|
||||||
if (mr != nullptr) {
|
if (mr != nullptr) {
|
||||||
mr->storage<Message::Components::LastSendAttempt>().clear();
|
mr->storage<Message::Components::LastSendAttempt>().clear();
|
||||||
}
|
}
|
||||||
@ -99,7 +99,7 @@ ToxFriendFauxOfflineMessaging::dfmc_Ret ToxFriendFauxOfflineMessaging::doFriendM
|
|||||||
// unacked message
|
// unacked message
|
||||||
// timeouts for exising unacked messages expired (send)
|
// timeouts for exising unacked messages expired (send)
|
||||||
|
|
||||||
auto* mr = static_cast<const RegistryMessageModel&>(_rmm).get(c);
|
auto* mr = static_cast<const RegistryMessageModelI&>(_rmm).get(c);
|
||||||
if (mr == nullptr) {
|
if (mr == nullptr) {
|
||||||
// no messages
|
// no messages
|
||||||
return dfmc_Ret::NO_MSG;
|
return dfmc_Ret::NO_MSG;
|
||||||
|
@ -15,7 +15,7 @@ namespace Contact::Components {
|
|||||||
// timers get reset on connection changes, and send order is preserved.
|
// timers get reset on connection changes, and send order is preserved.
|
||||||
class ToxFriendFauxOfflineMessaging : public ToxEventI {
|
class ToxFriendFauxOfflineMessaging : public ToxEventI {
|
||||||
Contact3Registry& _cr;
|
Contact3Registry& _cr;
|
||||||
RegistryMessageModel& _rmm;
|
RegistryMessageModelI& _rmm;
|
||||||
ToxContactModel2& _tcm;
|
ToxContactModel2& _tcm;
|
||||||
ToxI& _t;
|
ToxI& _t;
|
||||||
ToxEventProviderI& _tep;
|
ToxEventProviderI& _tep;
|
||||||
@ -30,7 +30,7 @@ class ToxFriendFauxOfflineMessaging : public ToxEventI {
|
|||||||
public:
|
public:
|
||||||
ToxFriendFauxOfflineMessaging(
|
ToxFriendFauxOfflineMessaging(
|
||||||
Contact3Registry& cr,
|
Contact3Registry& cr,
|
||||||
RegistryMessageModel& rmm,
|
RegistryMessageModelI& rmm,
|
||||||
ToxContactModel2& tcm,
|
ToxContactModel2& tcm,
|
||||||
ToxI& t,
|
ToxI& t,
|
||||||
ToxEventProviderI& tep
|
ToxEventProviderI& tep
|
||||||
|
Reference in New Issue
Block a user