only render avatars if visible
This commit is contained in:
		| @@ -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( | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user