mirror of
https://github.com/kunkundi/crossdesk.git
synced 2026-04-09 11:22:42 +08:00
[feat] update update-notification icon
This commit is contained in:
@@ -607,8 +607,8 @@ class Render {
|
|||||||
uint64_t last_frame_time_;
|
uint64_t last_frame_time_;
|
||||||
bool show_new_version_icon_ = false;
|
bool show_new_version_icon_ = false;
|
||||||
bool show_new_version_icon_in_menu_ = true;
|
bool show_new_version_icon_in_menu_ = true;
|
||||||
uint64_t new_version_icon_last_trigger_time_ = 0;
|
double new_version_icon_last_trigger_time_ = 0.0;
|
||||||
uint64_t new_version_icon_render_start_time_ = 0;
|
double new_version_icon_render_start_time_ = 0.0;
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
bool show_request_permission_window_ = true;
|
bool show_request_permission_window_ = true;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -3,7 +3,8 @@
|
|||||||
#include "rd_log.h"
|
#include "rd_log.h"
|
||||||
#include "render.h"
|
#include "render.h"
|
||||||
|
|
||||||
#define NEW_VERSION_ICON_RENDER_TIME_INTERVAL 2000
|
constexpr double kNewVersionIconBlinkIntervalSec = 2.0;
|
||||||
|
constexpr double kNewVersionIconBlinkOnTimeSec = 1.0;
|
||||||
|
|
||||||
namespace crossdesk {
|
namespace crossdesk {
|
||||||
|
|
||||||
@@ -106,13 +107,11 @@ int Render::TitleBar(bool main_window) {
|
|||||||
|
|
||||||
std::string about_str = localization::about[localization_language_index_];
|
std::string about_str = localization::about[localization_language_index_];
|
||||||
if (update_available_) {
|
if (update_available_) {
|
||||||
auto now_time = std::chrono::duration_cast<std::chrono::milliseconds>(
|
const double now_time = ImGui::GetTime();
|
||||||
std::chrono::steady_clock::now().time_since_epoch())
|
|
||||||
.count();
|
|
||||||
|
|
||||||
// every 2 seconds
|
// every 2 seconds
|
||||||
if (now_time - new_version_icon_last_trigger_time_ >=
|
if (now_time - new_version_icon_last_trigger_time_ >=
|
||||||
NEW_VERSION_ICON_RENDER_TIME_INTERVAL) {
|
kNewVersionIconBlinkIntervalSec) {
|
||||||
show_new_version_icon_ = true;
|
show_new_version_icon_ = true;
|
||||||
new_version_icon_render_start_time_ = now_time;
|
new_version_icon_render_start_time_ = now_time;
|
||||||
new_version_icon_last_trigger_time_ = now_time;
|
new_version_icon_last_trigger_time_ = now_time;
|
||||||
@@ -120,9 +119,9 @@ int Render::TitleBar(bool main_window) {
|
|||||||
|
|
||||||
// render for 1 second
|
// render for 1 second
|
||||||
if (show_new_version_icon_) {
|
if (show_new_version_icon_) {
|
||||||
about_str = about_str + " " + ICON_FA_TRIANGLE_EXCLAMATION;
|
about_str = about_str + " " + ICON_FA_CIRCLE_ARROW_UP;
|
||||||
if (now_time - new_version_icon_render_start_time_ >=
|
if (now_time - new_version_icon_render_start_time_ >=
|
||||||
NEW_VERSION_ICON_RENDER_TIME_INTERVAL / 2) {
|
kNewVersionIconBlinkOnTimeSec) {
|
||||||
show_new_version_icon_ = false;
|
show_new_version_icon_ = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -151,13 +150,11 @@ int Render::TitleBar(bool main_window) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (update_available_ && show_new_version_icon_in_menu_) {
|
if (update_available_ && show_new_version_icon_in_menu_) {
|
||||||
auto now_time = std::chrono::duration_cast<std::chrono::milliseconds>(
|
const double now_time = ImGui::GetTime();
|
||||||
std::chrono::steady_clock::now().time_since_epoch())
|
|
||||||
.count();
|
|
||||||
|
|
||||||
// every 2 seconds
|
// every 2 seconds
|
||||||
if (now_time - new_version_icon_last_trigger_time_ >=
|
if (now_time - new_version_icon_last_trigger_time_ >=
|
||||||
NEW_VERSION_ICON_RENDER_TIME_INTERVAL) {
|
kNewVersionIconBlinkIntervalSec) {
|
||||||
show_new_version_icon_ = true;
|
show_new_version_icon_ = true;
|
||||||
new_version_icon_render_start_time_ = now_time;
|
new_version_icon_render_start_time_ = now_time;
|
||||||
new_version_icon_last_trigger_time_ = now_time;
|
new_version_icon_last_trigger_time_ = now_time;
|
||||||
@@ -166,14 +163,13 @@ int Render::TitleBar(bool main_window) {
|
|||||||
// render for 1 second
|
// render for 1 second
|
||||||
if (show_new_version_icon_) {
|
if (show_new_version_icon_) {
|
||||||
ImGui::SetWindowFontScale(0.6f);
|
ImGui::SetWindowFontScale(0.6f);
|
||||||
ImGui::SetCursorPos(
|
ImGui::SetCursorPos(ImVec2(bar_pos_x + title_bar_button_width * 0.21f,
|
||||||
ImVec2(bar_pos_x + title_bar_button_width * 0.15f,
|
bar_pos_y - title_bar_button_width * 0.24f));
|
||||||
bar_pos_y - title_bar_button_width * 0.325f));
|
ImGui::Text(ICON_FA_CIRCLE_ARROW_UP);
|
||||||
ImGui::Text(ICON_FA_TRIANGLE_EXCLAMATION);
|
|
||||||
ImGui::SetWindowFontScale(1.0f);
|
ImGui::SetWindowFontScale(1.0f);
|
||||||
|
|
||||||
if (now_time - new_version_icon_render_start_time_ >=
|
if (now_time - new_version_icon_render_start_time_ >=
|
||||||
NEW_VERSION_ICON_RENDER_TIME_INTERVAL / 2) {
|
kNewVersionIconBlinkOnTimeSec) {
|
||||||
show_new_version_icon_ = false;
|
show_new_version_icon_ = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user