2023-07-28 18:03:45 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <solanaceae/message3/registry_message_model.hpp>
|
2023-07-29 20:07:59 +02:00
|
|
|
#include <solanaceae/util/config_model.hpp>
|
2023-07-28 18:03:45 +02:00
|
|
|
|
|
|
|
#include "./texture_uploader.hpp"
|
2023-07-31 20:47:22 +02:00
|
|
|
#include "./texture_cache.hpp"
|
2023-08-01 13:21:16 +02:00
|
|
|
#include "./tox_avatar_loader.hpp"
|
2023-08-02 16:36:34 +02:00
|
|
|
#include "./message_image_loader.hpp"
|
2024-04-20 17:57:11 +02:00
|
|
|
#include "./chat_gui/file_selector.hpp"
|
|
|
|
#include "./chat_gui/send_image_popup.hpp"
|
2024-02-05 16:05:45 +01:00
|
|
|
|
|
|
|
#include <entt/container/dense_map.hpp>
|
2023-07-28 18:03:45 +02:00
|
|
|
|
2024-01-30 11:58:01 +01:00
|
|
|
#include <cstdint>
|
2023-07-28 18:03:45 +02:00
|
|
|
#include <vector>
|
2024-01-30 11:58:01 +01:00
|
|
|
#include <string>
|
|
|
|
#include <mutex>
|
|
|
|
#include <memory>
|
2023-07-28 18:03:45 +02:00
|
|
|
|
2024-02-05 16:05:45 +01:00
|
|
|
using ContactTextureCache = TextureCache<void*, Contact3, ToxAvatarLoader>;
|
|
|
|
using MessageTextureCache = TextureCache<void*, Message3Handle, MessageImageLoader>;
|
|
|
|
|
2023-07-28 18:03:45 +02:00
|
|
|
class ChatGui4 {
|
2023-07-29 20:07:59 +02:00
|
|
|
ConfigModelI& _conf;
|
2023-07-28 18:03:45 +02:00
|
|
|
RegistryMessageModel& _rmm;
|
|
|
|
Contact3Registry& _cr;
|
|
|
|
|
2024-02-05 16:05:45 +01:00
|
|
|
ContactTextureCache& _contact_tc;
|
|
|
|
MessageTextureCache& _msg_tc;
|
2023-07-31 20:47:22 +02:00
|
|
|
|
2023-07-28 18:03:45 +02:00
|
|
|
FileSelector _fss;
|
2023-10-04 02:11:06 +02:00
|
|
|
SendImagePopup _sip;
|
2023-07-28 18:03:45 +02:00
|
|
|
|
2024-02-25 18:45:56 +01:00
|
|
|
// TODO: refactor this to allow multiple open contacts
|
2023-07-28 18:03:45 +02:00
|
|
|
std::optional<Contact3> _selected_contact;
|
|
|
|
|
2023-09-01 21:13:36 +02:00
|
|
|
// TODO: per contact
|
|
|
|
std::string _text_input_buffer;
|
|
|
|
|
2023-10-21 18:07:06 +02:00
|
|
|
bool _show_chat_extra_info {false};
|
|
|
|
bool _show_chat_avatar_tf {false};
|
2023-07-28 18:03:45 +02:00
|
|
|
|
|
|
|
float TEXT_BASE_WIDTH {1};
|
|
|
|
float TEXT_BASE_HEIGHT {1};
|
|
|
|
|
2024-01-30 11:58:01 +01:00
|
|
|
// mimetype -> data
|
|
|
|
entt::dense_map<std::string, std::shared_ptr<std::vector<uint8_t>>> _set_clipboard_data;
|
|
|
|
std::mutex _set_clipboard_data_mutex; // might be called out of order
|
|
|
|
friend const void* clipboard_callback(void* userdata, const char* mime_type, size_t* size);
|
|
|
|
void setClipboardData(std::vector<std::string> mime_types, std::shared_ptr<std::vector<uint8_t>>&& data);
|
|
|
|
|
2023-07-28 18:03:45 +02:00
|
|
|
public:
|
|
|
|
ChatGui4(
|
2023-07-29 20:07:59 +02:00
|
|
|
ConfigModelI& conf,
|
2023-07-28 18:03:45 +02:00
|
|
|
RegistryMessageModel& rmm,
|
|
|
|
Contact3Registry& cr,
|
2024-02-05 16:05:45 +01:00
|
|
|
TextureUploaderI& tu,
|
|
|
|
ContactTextureCache& contact_tc,
|
|
|
|
MessageTextureCache& msg_tc
|
2023-07-28 18:03:45 +02:00
|
|
|
);
|
2024-01-30 11:58:01 +01:00
|
|
|
~ChatGui4(void);
|
2023-07-28 18:03:45 +02:00
|
|
|
|
|
|
|
public:
|
2024-02-05 12:50:36 +01:00
|
|
|
float render(float time_delta);
|
2023-07-28 18:03:45 +02:00
|
|
|
|
2023-10-04 02:11:06 +02:00
|
|
|
public:
|
|
|
|
bool any_unread {false};
|
|
|
|
|
2023-10-18 14:23:27 +02:00
|
|
|
void sendFilePath(const char* file_path);
|
|
|
|
|
2023-07-28 18:03:45 +02:00
|
|
|
private:
|
|
|
|
void renderMessageBodyText(Message3Registry& reg, const Message3 e);
|
|
|
|
void renderMessageBodyFile(Message3Registry& reg, const Message3 e);
|
|
|
|
void renderMessageExtra(Message3Registry& reg, const Message3 e);
|
|
|
|
|
|
|
|
void renderContactList(void);
|
2023-08-06 16:07:50 +02:00
|
|
|
bool renderContactListContactBig(const Contact3 c, const bool selected);
|
|
|
|
bool renderContactListContactSmall(const Contact3 c, const bool selected) const;
|
|
|
|
bool renderSubContactListContact(const Contact3 c, const bool selected) const;
|
2023-10-11 21:57:36 +02:00
|
|
|
|
|
|
|
void pasteFile(const char* mime_type);
|
2023-07-28 18:03:45 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|