only render avatars if visible

This commit is contained in:
Green Sky 2024-04-23 10:38:42 +02:00
parent c887fdac8a
commit 05b0a2f514
No known key found for this signature in database

View File

@ -95,35 +95,33 @@ void renderAvatar(
const Contact3Handle c, const Contact3Handle c,
ImVec2 box ImVec2 box
) { ) {
ImVec4 color_current = th.getColor<ThemeCol_Contact::avatar_offline>(); // deploy dummy of same size and check visibility
if (c.all_of<Contact::Components::ConnectionState>()) { const auto orig_curser_pos = ImGui::GetCursorPos();
const auto c_state = c.get<Contact::Components::ConnectionState>().state; ImGui::Dummy(box);
if (c_state == Contact::Components::ConnectionState::State::direct) { if (ImGui::IsItemVisible()) {
color_current = th.getColor<ThemeCol_Contact::avatar_online_direct>(); ImGui::SetCursorPos(orig_curser_pos); // reset for actual img
} else if (c_state == Contact::Components::ConnectionState::State::cloud) {
color_current = th.getColor<ThemeCol_Contact::avatar_online_cloud>(); ImVec4 color_current = th.getColor<ThemeCol_Contact::avatar_offline>();
if (c.all_of<Contact::Components::ConnectionState>()) {
const auto c_state = c.get<Contact::Components::ConnectionState>().state;
if (c_state == Contact::Components::ConnectionState::State::direct) {
color_current = th.getColor<ThemeCol_Contact::avatar_online_direct>();
} else if (c_state == Contact::Components::ConnectionState::State::cloud) {
color_current = th.getColor<ThemeCol_Contact::avatar_online_cloud>();
}
} }
// avatar
const auto [id, width, height] = contact_tc.get(c);
ImGui::Image(
id,
box,
{0, 0},
{1, 1},
{1, 1, 1, 1},
color_current
);
} }
// 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
const auto [id, width, height] = contact_tc.get(c);
ImGui::Image(
id,
box,
{0, 0},
{1, 1},
{1, 1, 1, 1},
color_current
);
} }
bool renderContactBig( bool renderContactBig(