handle window focus (dont run fade and read while not focused)
Some checks are pending
ContinuousDelivery / linux-ubuntu (push) Waiting to run
ContinuousDelivery / android (map[ndk_abi:arm64-v8a vcpkg_toolkit:arm64-android]) (push) Waiting to run
ContinuousDelivery / android (map[ndk_abi:armeabi-v7a vcpkg_toolkit:arm-neon-android]) (push) Waiting to run
ContinuousDelivery / android (map[ndk_abi:x86_64 vcpkg_toolkit:x64-android]) (push) Waiting to run
ContinuousDelivery / windows (push) Waiting to run
ContinuousDelivery / windows-asan (push) Waiting to run
ContinuousDelivery / release (push) Blocked by required conditions
ContinuousIntegration / linux (push) Waiting to run
ContinuousIntegration / android (map[ndk_abi:arm64-v8a vcpkg_toolkit:arm64-android]) (push) Waiting to run
ContinuousIntegration / android (map[ndk_abi:armeabi-v7a vcpkg_toolkit:arm-neon-android]) (push) Waiting to run
ContinuousIntegration / android (map[ndk_abi:x86_64 vcpkg_toolkit:x64-android]) (push) Waiting to run
ContinuousIntegration / macos (push) Waiting to run
ContinuousIntegration / windows (push) Waiting to run
Some checks are pending
ContinuousDelivery / linux-ubuntu (push) Waiting to run
ContinuousDelivery / android (map[ndk_abi:arm64-v8a vcpkg_toolkit:arm64-android]) (push) Waiting to run
ContinuousDelivery / android (map[ndk_abi:armeabi-v7a vcpkg_toolkit:arm-neon-android]) (push) Waiting to run
ContinuousDelivery / android (map[ndk_abi:x86_64 vcpkg_toolkit:x64-android]) (push) Waiting to run
ContinuousDelivery / windows (push) Waiting to run
ContinuousDelivery / windows-asan (push) Waiting to run
ContinuousDelivery / release (push) Blocked by required conditions
ContinuousIntegration / linux (push) Waiting to run
ContinuousIntegration / android (map[ndk_abi:arm64-v8a vcpkg_toolkit:arm64-android]) (push) Waiting to run
ContinuousIntegration / android (map[ndk_abi:armeabi-v7a vcpkg_toolkit:arm-neon-android]) (push) Waiting to run
ContinuousIntegration / android (map[ndk_abi:x86_64 vcpkg_toolkit:x64-android]) (push) Waiting to run
ContinuousIntegration / macos (push) Waiting to run
ContinuousIntegration / windows (push) Waiting to run
This commit is contained in:
parent
bd6368a8f9
commit
d416d3d595
@ -272,7 +272,7 @@ ChatGui4::~ChatGui4(void) {
|
||||
//}
|
||||
}
|
||||
|
||||
float ChatGui4::render(float time_delta, bool window_hidden) {
|
||||
float ChatGui4::render(float time_delta, bool window_hidden, bool window_focused) {
|
||||
_fss.render();
|
||||
_sip.render(time_delta);
|
||||
_b_tc.update();
|
||||
@ -533,17 +533,17 @@ float ChatGui4::render(float time_delta, bool window_hidden) {
|
||||
Message3Registry& msg_reg = *msg_reg_ptr;
|
||||
|
||||
// do systems TODO: extract
|
||||
{ // fade system
|
||||
if (window_focused) { // fade system
|
||||
std::vector<Message3> to_remove;
|
||||
msg_reg.view<Components::UnreadFade>().each([&to_remove, time_delta](const Message3 e, Components::UnreadFade& fade) {
|
||||
// TODO: configurable
|
||||
const float fade_duration = 7.5f;
|
||||
fade.fade -= 1.f/fade_duration * std::min<float>(time_delta, 1.f/8.f); // fps but not below 8 for smooth-ish fade
|
||||
const float fade_duration = 5.f;
|
||||
fade.fade -= 1.f/fade_duration * std::min<float>(time_delta, 1.f/10.f); // fps but not below 10 for smooth-ish fade
|
||||
if (fade.fade <= 0.f) {
|
||||
to_remove.push_back(e);
|
||||
}
|
||||
});
|
||||
msg_reg.remove<Components::UnreadFade>(to_remove.cbegin(), to_remove.cend());
|
||||
msg_reg.remove<Message::Components::TagUnread, Components::UnreadFade>(to_remove.cbegin(), to_remove.cend());
|
||||
}
|
||||
|
||||
//auto tmp_view = msg_reg.view<Message::Components::ContactFrom, Message::Components::ContactTo, Message::Components::Timestamp>();
|
||||
@ -611,14 +611,22 @@ float ChatGui4::render(float time_delta, bool window_hidden) {
|
||||
// use username as visibility test
|
||||
if (ImGui::IsItemVisible()) {
|
||||
if (msg_reg.all_of<Message::Components::TagUnread>(e)) {
|
||||
// get time now
|
||||
const uint64_t ts_now = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
|
||||
msg_reg.emplace_or_replace<Message::Components::Read>(e, ts_now);
|
||||
msg_reg.remove<Message::Components::TagUnread>(e);
|
||||
msg_reg.emplace_or_replace<Components::UnreadFade>(e, 1.f);
|
||||
|
||||
// we remove the unread tag here
|
||||
_rmm.throwEventUpdate(msg_reg, e);
|
||||
if (!msg_reg.all_of<Components::UnreadFade>(e)) {
|
||||
if (msg_reg.all_of<Message::Components::Read>(e)) {
|
||||
// skip fade, we might get here by merging
|
||||
msg_reg.remove<Message::Components::TagUnread>(e);
|
||||
} else {
|
||||
// get time now
|
||||
const uint64_t ts_now = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
|
||||
msg_reg.emplace_or_replace<Message::Components::Read>(e, ts_now);
|
||||
msg_reg.emplace_or_replace<Components::UnreadFade>(e, 1.f);
|
||||
}
|
||||
_rmm.throwEventUpdate(msg_reg, e);
|
||||
} else if (window_focused) {
|
||||
// remove unread early, when we focus the window
|
||||
msg_reg.remove<Message::Components::TagUnread>(e);
|
||||
_rmm.throwEventUpdate(msg_reg, e);
|
||||
}
|
||||
}
|
||||
|
||||
// track view
|
||||
|
@ -72,7 +72,7 @@ class ChatGui4 : public ObjectStoreEventI {
|
||||
~ChatGui4(void);
|
||||
|
||||
public:
|
||||
float render(float time_delta, bool window_hidden);
|
||||
float render(float time_delta, bool window_hidden, bool window_focused);
|
||||
|
||||
public:
|
||||
void sendFilePath(std::string_view file_path);
|
||||
|
@ -181,15 +181,6 @@ int main(int argc, char** argv) {
|
||||
last_time_render = new_time;
|
||||
}
|
||||
|
||||
//// TODO: seperate out render and tick
|
||||
//const float time_to_next_loop = std::min<float>(screen->nextRender(), screen->nextTick());
|
||||
|
||||
//std::this_thread::sleep_for( // time left to get to 60fps
|
||||
//std::chrono::duration<float, std::chrono::seconds::period>(time_to_next_loop)
|
||||
//- std::chrono::duration<float, std::chrono::seconds::period>(std::chrono::steady_clock::now() - new_time) // time used for rendering
|
||||
//);
|
||||
|
||||
|
||||
#if 1
|
||||
if (render || tick) {
|
||||
// why is windows like this
|
||||
|
@ -328,6 +328,14 @@ bool MainScreen::handleEvent(SDL_Event& e) {
|
||||
return true; // forward?
|
||||
}
|
||||
|
||||
if (e.type == SDL_EVENT_WINDOW_FOCUS_GAINED) {
|
||||
_window_focused = true;
|
||||
}
|
||||
|
||||
if (e.type == SDL_EVENT_WINDOW_FOCUS_LOST) {
|
||||
_window_focused = false;
|
||||
}
|
||||
|
||||
if (
|
||||
_fps_perf_mode <= 1 && (
|
||||
// those are all the events imgui polls
|
||||
@ -391,7 +399,11 @@ Screen* MainScreen::render(float time_delta, bool&) {
|
||||
|
||||
si.render(time_delta);
|
||||
|
||||
const float cg_interval = cg.render(time_delta, _window_hidden); // render
|
||||
if (_window_hidden && _window_focused) {
|
||||
_window_focused = false;
|
||||
}
|
||||
|
||||
const float cg_interval = cg.render(time_delta, _window_hidden, _window_focused); // render
|
||||
sw.render(); // render
|
||||
osui.render();
|
||||
tuiu.render(); // render
|
||||
|
@ -112,6 +112,7 @@ struct MainScreen final : public Screen {
|
||||
bool _show_tool_id_stack {false};
|
||||
bool _show_tool_demo {false};
|
||||
|
||||
bool _window_focused {true};
|
||||
bool _window_hidden {false};
|
||||
uint64_t _window_hidden_ts {0};
|
||||
float _time_since_event {0.f};
|
||||
|
@ -288,8 +288,8 @@ float ToxNetprofUI::render(float time_delta) {
|
||||
if (ImGui::Begin("Tox Netprof histograms", &_show_window_histo)) {
|
||||
if (_enabled) {
|
||||
const float line_height = ImGui::GetTextLineHeight();
|
||||
ImGui::PlotHistogram("udp total count sent##histograms", _udp_tctx.data(), _udp_tctx.size(), 0, nullptr, 0.f, FLT_MAX, {0, 3*line_height});
|
||||
ImGui::PlotHistogram("udp total count received##histograms", _udp_tcrx.data(), _udp_tcrx.size(), 0, nullptr, 0.f, FLT_MAX, {0, 3*line_height});
|
||||
ImGui::PlotHistogram("udp total packets sent##histograms", _udp_tctx.data(), _udp_tctx.size(), 0, nullptr, 0.f, FLT_MAX, {0, 3*line_height});
|
||||
ImGui::PlotHistogram("udp total packets received##histograms", _udp_tcrx.data(), _udp_tcrx.size(), 0, nullptr, 0.f, FLT_MAX, {0, 3*line_height});
|
||||
ImGui::PlotHistogram("udp total bytes sent##histograms", _udp_tbtx.data(), _udp_tbtx.size(), 0, nullptr, 0.f, FLT_MAX, {0, 3*line_height});
|
||||
ImGui::PlotHistogram("udp total bytes received##histograms", _udp_tbrx.data(), _udp_tbrx.size(), 0, nullptr, 0.f, FLT_MAX, {0, 3*line_height});
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user