[feat] show net traffic stats in control bar

This commit is contained in:
dijunkun
2024-11-19 16:56:30 +08:00
parent ca32ebeefe
commit 8132d62c02
7 changed files with 988 additions and 805 deletions

View File

@@ -17,6 +17,21 @@ int Render::ControlWindow() {
}
}
time_duration = ImGui::GetTime() - net_traffic_stats_button_pressed_time_;
if (control_window_height_is_changing_) {
if (control_bar_expand_ && net_traffic_stats_button_pressed_) {
control_window_height_ =
control_window_min_height_ +
(control_window_max_height_ - control_window_min_height_) * 4 *
time_duration;
} else if (control_bar_expand_ && !net_traffic_stats_button_pressed_) {
control_window_height_ =
control_window_max_height_ -
(control_window_max_height_ - control_window_min_height_) * 4 *
time_duration;
}
}
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(1, 1, 1, 1));
ImGui::PushStyleVar(ImGuiStyleVar_WindowMinSize, ImVec2(0, 0));
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 10.0f);
@@ -96,6 +111,24 @@ int Render::ControlWindow() {
}
}
if (control_bar_expand_ && control_window_height_is_changing_) {
if (net_traffic_stats_button_pressed_) {
if (control_window_height_ >= control_window_max_height_) {
control_window_height_ = control_window_max_height_;
control_window_height_is_changing_ = false;
} else {
control_window_height_is_changing_ = true;
}
} else {
if (control_window_height_ <= control_window_min_height_) {
control_window_height_ = control_window_min_height_;
control_window_height_is_changing_ = false;
} else {
control_window_height_is_changing_ = true;
}
}
}
ImGui::Begin("ControlWindow", nullptr,
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize |
ImGuiWindowFlags_NoScrollbar |