Compare commits
5 Commits
dev-4b0d95
...
dev-605a73
Author | SHA1 | Date | |
---|---|---|---|
605a730b59 | |||
3e15798afc | |||
cf697622cb | |||
05b0a2f514 | |||
c887fdac8a |
2
external/solanaceae_contact
vendored
2
external/solanaceae_contact
vendored
Submodule external/solanaceae_contact updated: 7710da6c89...e8b069c803
2
external/solanaceae_tox
vendored
2
external/solanaceae_tox
vendored
Submodule external/solanaceae_tox updated: 560eab1f6c...2807239dea
@ -95,6 +95,12 @@ void renderAvatar(
|
|||||||
const Contact3Handle c,
|
const Contact3Handle c,
|
||||||
ImVec2 box
|
ImVec2 box
|
||||||
) {
|
) {
|
||||||
|
// deploy dummy of same size and check visibility
|
||||||
|
const auto orig_curser_pos = ImGui::GetCursorPos();
|
||||||
|
ImGui::Dummy(box);
|
||||||
|
if (ImGui::IsItemVisible()) {
|
||||||
|
ImGui::SetCursorPos(orig_curser_pos); // reset for actual img
|
||||||
|
|
||||||
ImVec4 color_current = th.getColor<ThemeCol_Contact::avatar_offline>();
|
ImVec4 color_current = th.getColor<ThemeCol_Contact::avatar_offline>();
|
||||||
if (c.all_of<Contact::Components::ConnectionState>()) {
|
if (c.all_of<Contact::Components::ConnectionState>()) {
|
||||||
const auto c_state = c.get<Contact::Components::ConnectionState>().state;
|
const auto c_state = c.get<Contact::Components::ConnectionState>().state;
|
||||||
@ -105,14 +111,6 @@ void renderAvatar(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// icon pos
|
|
||||||
auto p0 = ImGui::GetCursorScreenPos();
|
|
||||||
p0.x += box.x * 0.5f;
|
|
||||||
p0.y += box.y * 0.5f;
|
|
||||||
auto p1_o = box;
|
|
||||||
p1_o.x *= 0.5f;
|
|
||||||
p1_o.y *= 0.5f;
|
|
||||||
|
|
||||||
// avatar
|
// avatar
|
||||||
const auto [id, width, height] = contact_tc.get(c);
|
const auto [id, width, height] = contact_tc.get(c);
|
||||||
ImGui::Image(
|
ImGui::Image(
|
||||||
@ -123,7 +121,7 @@ void renderAvatar(
|
|||||||
{1, 1, 1, 1},
|
{1, 1, 1, 1},
|
||||||
color_current
|
color_current
|
||||||
);
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool renderContactBig(
|
bool renderContactBig(
|
||||||
@ -135,6 +133,7 @@ bool renderContactBig(
|
|||||||
const bool selectable,
|
const bool selectable,
|
||||||
const bool selected
|
const bool selected
|
||||||
) {
|
) {
|
||||||
|
ImGui::BeginGroup();
|
||||||
if (line_height < 1) {
|
if (line_height < 1) {
|
||||||
line_height = 1;
|
line_height = 1;
|
||||||
}
|
}
|
||||||
@ -187,8 +186,18 @@ bool renderContactBig(
|
|||||||
ImGui::TextUnformatted("Connection state: unknown");
|
ImGui::TextUnformatted("Connection state: unknown");
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: add a whole bunch more info
|
if (
|
||||||
|
const auto* slt = c.try_get<Contact::Components::StatusText>();
|
||||||
|
slt != nullptr &&
|
||||||
|
!slt->text.empty()
|
||||||
|
) {
|
||||||
|
ImGui::SeparatorText("Status Text");
|
||||||
|
//ImGui::PushStyleColor(ImGuiCol_Text, ImGui::GetStyle().Colors[ImGuiCol_TextDisabled]);
|
||||||
|
ImGui::TextUnformatted(slt->text.c_str());
|
||||||
|
//ImGui::PopStyleColor();
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: add a whole bunch more info
|
||||||
ImGui::EndTooltip();
|
ImGui::EndTooltip();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,7 +214,8 @@ bool renderContactBig(
|
|||||||
|
|
||||||
renderAvatar(th, contact_tc, c, {img_y, img_y});
|
renderAvatar(th, contact_tc, c, {img_y, img_y});
|
||||||
|
|
||||||
ImGui::SameLine();
|
const float same_line_spacing = ImGui::GetStyle().ItemSpacing.x*0.5f;
|
||||||
|
ImGui::SameLine(0.f, same_line_spacing);
|
||||||
ImGui::BeginGroup();
|
ImGui::BeginGroup();
|
||||||
{
|
{
|
||||||
{ // line 1
|
{ // line 1
|
||||||
@ -215,19 +225,24 @@ bool renderContactBig(
|
|||||||
p0.y += ImGui::GetStyle().FramePadding.y;
|
p0.y += ImGui::GetStyle().FramePadding.y;
|
||||||
ImVec2 p1_o = {img_y, img_y}; // img_y is 1 line_height in this case
|
ImVec2 p1_o = {img_y, img_y}; // img_y is 1 line_height in this case
|
||||||
|
|
||||||
|
const ImU32 col_back = ImGui::GetColorU32(th.getColor<ThemeCol_Contact::icon_backdrop>());
|
||||||
if (cstate->state == Contact::Components::ConnectionState::direct) { // direct icon
|
if (cstate->state == Contact::Components::ConnectionState::direct) { // direct icon
|
||||||
const ImU32 col_back = ImGui::GetColorU32({0.0f, 0.0f, 0.0f, 0.4f});
|
drawIconDirect(
|
||||||
const ImU32 col_main = ImGui::GetColorU32({0.0f, 1.f, 0.0f, 1.0f});
|
p0,
|
||||||
|
p1_o,
|
||||||
drawIconDirect(p0, p1_o, col_main, col_back);
|
ImGui::GetColorU32(th.getColor<ThemeCol_Contact::avatar_online_direct>()),
|
||||||
|
col_back
|
||||||
|
);
|
||||||
} else if (cstate->state == Contact::Components::ConnectionState::cloud) { // cloud icon
|
} else if (cstate->state == Contact::Components::ConnectionState::cloud) { // cloud icon
|
||||||
const ImU32 col_back = ImGui::GetColorU32({0.0f, 0.0f, 0.0f, 0.4f});
|
drawIconCloud(
|
||||||
const ImU32 col_main = ImGui::GetColorU32({0.0f, 1.f, 0.0f, 1.0f});
|
p0,
|
||||||
|
p1_o,
|
||||||
drawIconCloud(p0, p1_o, col_main, col_back);
|
ImGui::GetColorU32(th.getColor<ThemeCol_Contact::avatar_online_cloud>()),
|
||||||
|
col_back
|
||||||
|
);
|
||||||
}
|
}
|
||||||
ImGui::Dummy(p1_o);
|
ImGui::Dummy(p1_o);
|
||||||
ImGui::SameLine();
|
ImGui::SameLine(0.f, same_line_spacing);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::Text("%s%s", unread?"* ":"", (c.all_of<Contact::Components::Name>() ? c.get<Contact::Components::Name>().name.c_str() : "<unk>"));
|
ImGui::Text("%s%s", unread?"* ":"", (c.all_of<Contact::Components::Name>() ? c.get<Contact::Components::Name>().name.c_str() : "<unk>"));
|
||||||
@ -247,22 +262,39 @@ bool renderContactBig(
|
|||||||
const float box_hight = TEXT_BASE_HEIGHT - ImGui::GetStyle().FramePadding.y*2;
|
const float box_hight = TEXT_BASE_HEIGHT - ImGui::GetStyle().FramePadding.y*2;
|
||||||
ImVec2 p1_o = {box_hight, box_hight};
|
ImVec2 p1_o = {box_hight, box_hight};
|
||||||
|
|
||||||
|
const ImU32 col_back = ImGui::GetColorU32(th.getColor<ThemeCol_Contact::icon_backdrop>());
|
||||||
if (cstate->state == Contact::Components::ConnectionState::direct) { // direct icon
|
if (cstate->state == Contact::Components::ConnectionState::direct) { // direct icon
|
||||||
const ImU32 col_back = ImGui::GetColorU32({0.0f, 0.0f, 0.0f, 0.4f});
|
drawIconDirect(
|
||||||
const ImU32 col_main = ImGui::GetColorU32({0.0f, 1.f, 0.0f, 1.0f});
|
p0,
|
||||||
|
p1_o,
|
||||||
drawIconDirect(p0, p1_o, col_main, col_back);
|
ImGui::GetColorU32(th.getColor<ThemeCol_Contact::avatar_online_direct>()),
|
||||||
|
col_back
|
||||||
|
);
|
||||||
} else if (cstate->state == Contact::Components::ConnectionState::cloud) { // cloud icon
|
} else if (cstate->state == Contact::Components::ConnectionState::cloud) { // cloud icon
|
||||||
const ImU32 col_back = ImGui::GetColorU32({0.0f, 0.0f, 0.0f, 0.4f});
|
drawIconCloud(
|
||||||
const ImU32 col_main = ImGui::GetColorU32({0.0f, 1.f, 0.0f, 1.0f});
|
p0,
|
||||||
|
p1_o,
|
||||||
drawIconCloud(p0, p1_o, col_main, col_back);
|
ImGui::GetColorU32(th.getColor<ThemeCol_Contact::avatar_online_cloud>()),
|
||||||
|
col_back
|
||||||
|
);
|
||||||
}
|
}
|
||||||
ImGui::Dummy(p1_o);
|
ImGui::Dummy(p1_o);
|
||||||
ImGui::SameLine();
|
ImGui::SameLine(0.f, same_line_spacing);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::TextDisabled("status message...");
|
if (
|
||||||
|
const auto* slt = c.try_get<Contact::Components::StatusText>();
|
||||||
|
slt != nullptr &&
|
||||||
|
!slt->text.empty() &&
|
||||||
|
slt->first_line_length > 0 &&
|
||||||
|
slt->first_line_length <= slt->text.size()
|
||||||
|
) {
|
||||||
|
ImGui::PushStyleColor(ImGuiCol_Text, ImGui::GetStyle().Colors[ImGuiCol_TextDisabled]);
|
||||||
|
ImGui::TextUnformatted(slt->text.c_str(), slt->text.c_str() + slt->first_line_length);
|
||||||
|
ImGui::PopStyleColor();
|
||||||
|
} else {
|
||||||
|
ImGui::TextDisabled(""); // or dummy?
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// line 3
|
// line 3
|
||||||
@ -276,6 +308,7 @@ bool renderContactBig(
|
|||||||
|
|
||||||
ImGui::SetCursorPos(post_curser_pos);
|
ImGui::SetCursorPos(post_curser_pos);
|
||||||
|
|
||||||
|
ImGui::EndGroup();
|
||||||
return got_selected;
|
return got_selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,8 +13,17 @@ enum class ThemeCol_Contact {
|
|||||||
avatar_online_direct,
|
avatar_online_direct,
|
||||||
avatar_online_cloud,
|
avatar_online_cloud,
|
||||||
avatar_offline,
|
avatar_offline,
|
||||||
|
|
||||||
|
icon_backdrop,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void renderAvatar(
|
||||||
|
const Theme& th,
|
||||||
|
ContactTextureCache& contact_tc,
|
||||||
|
const Contact3Handle c,
|
||||||
|
ImVec2 box
|
||||||
|
);
|
||||||
|
|
||||||
// returns true if clicked, if selectable, will highlight on hover and respect selected
|
// returns true if clicked, if selectable, will highlight on hover and respect selected
|
||||||
// TODO: refine
|
// TODO: refine
|
||||||
// +------+
|
// +------+
|
||||||
|
@ -41,12 +41,14 @@ bool Theme::store(void) {
|
|||||||
Theme getDefaultThemeDark(void) {
|
Theme getDefaultThemeDark(void) {
|
||||||
Theme t;
|
Theme t;
|
||||||
|
|
||||||
t.setColor<ThemeCol_Contact::request_incoming>({0.98f, 0.41f, 0.26f, 0.52f});
|
t.setColor<ThemeCol_Contact::request_incoming >({0.98f, 0.41f, 0.26f, 0.52f});
|
||||||
t.setColor<ThemeCol_Contact::request_outgoing>({0.98f, 0.26f, 0.41f, 0.52f});
|
t.setColor<ThemeCol_Contact::request_outgoing >({0.98f, 0.26f, 0.41f, 0.52f});
|
||||||
|
|
||||||
t.setColor<ThemeCol_Contact::avatar_online_direct>({0.3, 1, 0, 1});
|
t.setColor<ThemeCol_Contact::avatar_online_direct >({0.3f, 1.0f, 0.0f, 1.0f});
|
||||||
t.setColor<ThemeCol_Contact::avatar_online_cloud>({0, 1, 0.8, 1});
|
t.setColor<ThemeCol_Contact::avatar_online_cloud >({0.0f, 1.0f, 0.8f, 1.0f});
|
||||||
t.setColor<ThemeCol_Contact::avatar_offline>({0.4, 0.4, 0.4, 1});
|
t.setColor<ThemeCol_Contact::avatar_offline >({0.4f, 0.4f, 0.4f, 1.0f});
|
||||||
|
|
||||||
|
t.setColor<ThemeCol_Contact::icon_backdrop >({0.0f, 0.0f, 0.0f, 0.4f});
|
||||||
|
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
@ -227,7 +227,7 @@ float ChatGui4::render(float time_delta) {
|
|||||||
|
|
||||||
if (sub_contacts != nullptr && !_cr.all_of<Contact::Components::TagPrivate>(*_selected_contact) && _cr.all_of<Contact::Components::TagGroup>(*_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->empty()) {
|
if (!sub_contacts->empty()) {
|
||||||
if (ImGui::BeginChild("subcontacts", {175, -100}, true)) {
|
if (ImGui::BeginChild("subcontacts", {TEXT_BASE_WIDTH * 18.f, -100.f}, true)) {
|
||||||
ImGui::Text("subs: %zu", sub_contacts->size());
|
ImGui::Text("subs: %zu", sub_contacts->size());
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
for (const auto& c : *sub_contacts) {
|
for (const auto& c : *sub_contacts) {
|
||||||
@ -298,7 +298,7 @@ float ChatGui4::render(float time_delta) {
|
|||||||
ImGuiTableFlags_SizingFixedFit
|
ImGuiTableFlags_SizingFixedFit
|
||||||
;
|
;
|
||||||
if (msg_reg_ptr != nullptr && ImGui::BeginTable("chat_table", 5, table_flags)) {
|
if (msg_reg_ptr != nullptr && ImGui::BeginTable("chat_table", 5, table_flags)) {
|
||||||
ImGui::TableSetupColumn("name", 0, TEXT_BASE_WIDTH * 15.f);
|
ImGui::TableSetupColumn("name", 0, TEXT_BASE_WIDTH * 16.f);
|
||||||
ImGui::TableSetupColumn("message", ImGuiTableColumnFlags_WidthStretch);
|
ImGui::TableSetupColumn("message", ImGuiTableColumnFlags_WidthStretch);
|
||||||
ImGui::TableSetupColumn("delivered/read");
|
ImGui::TableSetupColumn("delivered/read");
|
||||||
ImGui::TableSetupColumn("timestamp");
|
ImGui::TableSetupColumn("timestamp");
|
||||||
@ -386,6 +386,10 @@ float ChatGui4::render(float time_delta) {
|
|||||||
|
|
||||||
// name
|
// name
|
||||||
if (ImGui::TableNextColumn()) {
|
if (ImGui::TableNextColumn()) {
|
||||||
|
const float img_y {TEXT_BASE_HEIGHT - ImGui::GetStyle().FramePadding.y*2};
|
||||||
|
renderAvatar(_theme, _contact_tc, {_cr, c_from.c}, {img_y, img_y});
|
||||||
|
ImGui::SameLine(0.f, ImGui::GetStyle().ItemSpacing.x*0.5f);
|
||||||
|
|
||||||
if (_cr.all_of<Contact::Components::Name>(c_from.c)) {
|
if (_cr.all_of<Contact::Components::Name>(c_from.c)) {
|
||||||
ImGui::TextUnformatted(_cr.get<Contact::Components::Name>(c_from.c).name.c_str());
|
ImGui::TextUnformatted(_cr.get<Contact::Components::Name>(c_from.c).name.c_str());
|
||||||
} else {
|
} else {
|
||||||
@ -1116,6 +1120,7 @@ bool ChatGui4::renderContactListContactSmall(const Contact3 c, const bool select
|
|||||||
return ImGui::Selectable(label.c_str(), selected);
|
return ImGui::Selectable(label.c_str(), selected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
bool ChatGui4::renderSubContactListContact(const Contact3 c, const bool selected) const {
|
bool ChatGui4::renderSubContactListContact(const Contact3 c, const bool selected) const {
|
||||||
std::string label;
|
std::string label;
|
||||||
|
|
||||||
@ -1138,6 +1143,7 @@ bool ChatGui4::renderSubContactListContact(const Contact3 c, const bool selected
|
|||||||
|
|
||||||
return ImGui::Selectable(label.c_str(), selected);
|
return ImGui::Selectable(label.c_str(), selected);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void ChatGui4::pasteFile(const char* mime_type) {
|
void ChatGui4::pasteFile(const char* mime_type) {
|
||||||
size_t data_size = 0;
|
size_t data_size = 0;
|
||||||
|
@ -79,7 +79,7 @@ class ChatGui4 {
|
|||||||
|
|
||||||
void renderContactList(void);
|
void renderContactList(void);
|
||||||
bool renderContactListContactSmall(const Contact3 c, const bool selected) const;
|
bool renderContactListContactSmall(const Contact3 c, const bool selected) const;
|
||||||
bool renderSubContactListContact(const Contact3 c, const bool selected) const;
|
//bool renderSubContactListContact(const Contact3 c, const bool selected) const;
|
||||||
|
|
||||||
void pasteFile(const char* mime_type);
|
void pasteFile(const char* mime_type);
|
||||||
};
|
};
|
||||||
|
@ -187,7 +187,8 @@ std::optional<TextureEntry> ToxAvatarLoader::load(TextureUploaderI& tu, Contact3
|
|||||||
if (!_cr.any_of<
|
if (!_cr.any_of<
|
||||||
Contact::Components::ToxFriendPersistent,
|
Contact::Components::ToxFriendPersistent,
|
||||||
Contact::Components::ToxGroupPersistent,
|
Contact::Components::ToxGroupPersistent,
|
||||||
Contact::Components::ToxGroupPeerPersistent
|
Contact::Components::ToxGroupPeerPersistent,
|
||||||
|
Contact::Components::ID
|
||||||
>(c)) {
|
>(c)) {
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
@ -199,6 +200,12 @@ std::optional<TextureEntry> ToxAvatarLoader::load(TextureUploaderI& tu, Contact3
|
|||||||
pixels = generateToxIdenticon(_cr.get<Contact::Components::ToxGroupPersistent>(c).chat_id);
|
pixels = generateToxIdenticon(_cr.get<Contact::Components::ToxGroupPersistent>(c).chat_id);
|
||||||
} else if (_cr.all_of<Contact::Components::ToxGroupPeerPersistent>(c)) {
|
} else if (_cr.all_of<Contact::Components::ToxGroupPeerPersistent>(c)) {
|
||||||
pixels = generateToxIdenticon(_cr.get<Contact::Components::ToxGroupPeerPersistent>(c).peer_key);
|
pixels = generateToxIdenticon(_cr.get<Contact::Components::ToxGroupPeerPersistent>(c).peer_key);
|
||||||
|
} else if (_cr.all_of<Contact::Components::ID>(c)) {
|
||||||
|
// TODO: should we really use toxidenticons for other protocols?
|
||||||
|
// (this is required for self)
|
||||||
|
auto id_copy = _cr.get<Contact::Components::ID>(c).data;
|
||||||
|
id_copy.resize(32);
|
||||||
|
pixels = generateToxIdenticon(id_copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureEntry new_entry;
|
TextureEntry new_entry;
|
||||||
|
Reference in New Issue
Block a user