diff --git a/external/solanaceae_contact b/external/solanaceae_contact index 5397fcc..65d253a 160000 --- a/external/solanaceae_contact +++ b/external/solanaceae_contact @@ -1 +1 @@ -Subproject commit 5397fcc5c24ae7d485fe16311c52703e01f5d69c +Subproject commit 65d253afeaf7e39594ecc0a07864a4f4a87086fd diff --git a/external/solanaceae_tox b/external/solanaceae_tox index b68ef51..a262ab9 160000 --- a/external/solanaceae_tox +++ b/external/solanaceae_tox @@ -1 +1 @@ -Subproject commit b68ef51d641501763b59c7d8d42296c6aa927aaa +Subproject commit a262ab9d3a23cf23169e76dae2c3a3c362285773 diff --git a/src/chat_gui4.cpp b/src/chat_gui4.cpp index 1776f8f..206e65a 100644 --- a/src/chat_gui4.cpp +++ b/src/chat_gui4.cpp @@ -19,10 +19,11 @@ #include ChatGui4::ChatGui4( + ConfigModelI& conf, RegistryMessageModel& rmm, Contact3Registry& cr, TextureUploaderI& tu -) : _rmm(rmm), _cr(cr) { +) : _conf(conf), _rmm(rmm), _cr(cr) { } void ChatGui4::render(void) { @@ -73,6 +74,45 @@ void ChatGui4::render(void) { } } + const bool request_incoming = _cr.all_of(*_selected_contact); + const bool request_outgoing = _cr.all_of(*_selected_contact); + if (request_incoming || request_outgoing) { + // TODO: theming + ImGui::PushStyleColor(ImGuiCol_ChildBg, {0.90f, 0.70f, 0.00f, 0.32f}); + if (ImGui::BeginChild("request", {0, TEXT_BASE_HEIGHT*6.1f}, true, ImGuiWindowFlags_NoScrollbar)) { + if (request_incoming) { + const auto& ri = _cr.get(*_selected_contact); + ImGui::TextUnformatted("You got a request to add this contact."); + + static std::string self_name = _conf.get_string("tox", "name").value_or("default_tomato"); + if (ri.name) { + ImGui::InputText("name to join with", &self_name); + } else { + ImGui::TextUnformatted(""); + } + + static std::string password; + if (ri.password) { + ImGui::InputText("password to join with", &password); + } else { + ImGui::TextUnformatted(""); + } + + if (ImGui::Button("Accept")) { + _cr.get(*_selected_contact)->acceptRequest(*_selected_contact, self_name, password); + password.clear(); + } + ImGui::SameLine(); + if (ImGui::Button("Decline")) { + } + } else { + ImGui::TextUnformatted("You sent a reqeust to add this contact."); + } + } + ImGui::PopStyleColor(); + ImGui::EndChild(); + } + if (ImGui::BeginChild("message_log", {0, -100}, false, ImGuiWindowFlags_MenuBar)) { if (ImGui::BeginMenuBar()) { ImGui::Checkbox("show extra info", &_show_chat_extra_info); @@ -411,8 +451,25 @@ bool ChatGui4::renderContactListContactBig(const Contact3 c) { auto label = "###" + std::to_string(entt::to_integral(c)); + const bool request_incoming = _cr.all_of(c); + const bool request_outgoing = _cr.all_of(c); + ImVec2 orig_curser_pos = ImGui::GetCursorPos(); - bool selected = ImGui::Selectable(label.c_str(), _selected_contact.has_value() && *_selected_contact == c, 0, {0,3*TEXT_BASE_HEIGHT}); + // HACK: fake selected to make it draw a box for us + const bool show_selected = request_incoming || request_outgoing || (_selected_contact.has_value() && *_selected_contact == c); + if (request_incoming) { + // TODO: theming + ImGui::PushStyleColor(ImGuiCol_Header, {0.98f, 0.41f, 0.26f, 0.52f}); + } else if (request_outgoing) { + // TODO: theming + ImGui::PushStyleColor(ImGuiCol_Header, {0.98f, 0.26f, 0.41f, 0.52f}); + } + + const bool selected = ImGui::Selectable(label.c_str(), show_selected, 0, {0,3*TEXT_BASE_HEIGHT}); + + if (request_incoming || request_outgoing) { + ImGui::PopStyleColor(); + } ImVec2 post_curser_pos = ImGui::GetCursorPos(); ImVec2 img_curser { @@ -458,7 +515,13 @@ bool ChatGui4::renderContactListContactBig(const Contact3 c) { ImGui::SameLine(); ImGui::BeginGroup(); { - ImGui::Text("%s", (_cr.all_of(c) ? _cr.get(c).name.c_str() : "")); + if (request_incoming) { + ImGui::TextUnformatted("Incoming request/invite"); + } else if (request_outgoing) { + ImGui::TextUnformatted("Outgoing request/invite"); + } else { + ImGui::Text("%s", (_cr.all_of(c) ? _cr.get(c).name.c_str() : "")); + } //ImGui::Text("status message..."); //ImGui::TextDisabled("hi"); //ImGui::RenderTextEllipsis diff --git a/src/chat_gui4.hpp b/src/chat_gui4.hpp index f809779..29bd44d 100644 --- a/src/chat_gui4.hpp +++ b/src/chat_gui4.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include "./texture_uploader.hpp" #include "./file_selector.hpp" @@ -9,6 +10,7 @@ #include class ChatGui4 { + ConfigModelI& _conf; RegistryMessageModel& _rmm; Contact3Registry& _cr; @@ -23,6 +25,7 @@ class ChatGui4 { public: ChatGui4( + ConfigModelI& conf, RegistryMessageModel& rmm, Contact3Registry& cr, TextureUploaderI& tu diff --git a/src/main_screen.cpp b/src/main_screen.cpp index b9ade31..44c7767 100644 --- a/src/main_screen.cpp +++ b/src/main_screen.cpp @@ -14,7 +14,7 @@ MainScreen::MainScreen(SDL_Renderer* renderer_, std::string save_path) : tmm(rmm, cr, tcm, tc, tc), ttm(rmm, cr, tcm, tc, tc), sdlrtu(renderer_), - cg(rmm, cr, sdlrtu) + cg(conf, rmm, cr, sdlrtu) { tel.subscribeAll(tc); @@ -70,6 +70,7 @@ Screen* MainScreen::poll(bool& quit) { quit = !open; } +#if 0 { // texture tests const size_t width = 8; const size_t height = 8; @@ -96,6 +97,7 @@ Screen* MainScreen::poll(bool& quit) { } ImGui::End(); } +#endif return nullptr; }