fix(ui): finish refresh and diff navigation polish
This commit is contained in:
@@ -10,7 +10,6 @@ public:
|
||||
GitManager();
|
||||
~GitManager();
|
||||
|
||||
bool openRepositoryHandle(RepositoryView &repository, const std::string &path, std::string &error);
|
||||
bool openRepositoryHandle(RepositoryView &repository, const std::string &path, std::string &error);
|
||||
bool openRepository(RepositoryView &repository, const std::string &path, std::string &error);
|
||||
bool initializeRepository(RepositoryView &repository, const std::string &path,
|
||||
|
||||
@@ -48,6 +48,8 @@ AvatarCache* g_avatar_cache = nullptr;
|
||||
std::array<char, 256> g_filter{};
|
||||
std::array<char, 128> g_branch_filter{};
|
||||
std::string g_notice;
|
||||
std::string g_last_footer_notice;
|
||||
std::chrono::steady_clock::time_point g_last_footer_notice_change{};
|
||||
bool g_init_popup = false;
|
||||
bool g_clone_popup = false;
|
||||
bool g_about_popup = false;
|
||||
@@ -304,6 +306,26 @@ void sync_notice_toast() {
|
||||
push_toast(g_notice, infer_toast_kind(g_notice));
|
||||
}
|
||||
|
||||
float footer_notice_alpha() {
|
||||
if (g_notice.empty()) {
|
||||
g_last_footer_notice.clear();
|
||||
return 0.0f;
|
||||
}
|
||||
if (g_notice != g_last_footer_notice) {
|
||||
g_last_footer_notice = g_notice;
|
||||
g_last_footer_notice_change = RefreshClock::now();
|
||||
}
|
||||
if (g_notice.ends_with("...")) return 1.0f;
|
||||
|
||||
constexpr float notice_hold_seconds = 2.0f;
|
||||
constexpr float notice_fade_seconds = 1.5f;
|
||||
const float elapsed = std::chrono::duration<float>(
|
||||
RefreshClock::now() - g_last_footer_notice_change).count();
|
||||
if (elapsed <= notice_hold_seconds) return 1.0f;
|
||||
if (elapsed >= notice_hold_seconds + notice_fade_seconds) return 0.0f;
|
||||
return 1.0f - ((elapsed - notice_hold_seconds) / notice_fade_seconds);
|
||||
}
|
||||
|
||||
void transfer_repository_state(RepositoryView& source, RepositoryView& target) {
|
||||
if (&source == &target) return;
|
||||
target.close();
|
||||
@@ -381,8 +403,8 @@ GitAsyncResult execute_git_async_request(const GitAsyncRequest& request) {
|
||||
bool action_ok = true;
|
||||
switch (request.operation) {
|
||||
case GitAsyncOperation::reload:
|
||||
break;
|
||||
action_ok = manager.reload(repository, result.notice);
|
||||
break;
|
||||
case GitAsyncOperation::capture: {
|
||||
std::string output;
|
||||
action_ok = manager.captureGit(repository, request.arguments, output, result.notice) &&
|
||||
@@ -3528,7 +3550,17 @@ void draw_popups() {
|
||||
|
||||
void draw_footer() {
|
||||
ImGui::Separator();
|
||||
ImGui::TextDisabled("%s", g_notice.empty() ? "Ready" : g_notice.c_str());
|
||||
const float notice_alpha = footer_notice_alpha();
|
||||
const bool show_notice = !g_notice.empty() && notice_alpha > 0.02f;
|
||||
if (show_notice) {
|
||||
ImVec4 notice_color = ImGui::GetStyleColorVec4(ImGuiCol_TextDisabled);
|
||||
notice_color.w *= notice_alpha;
|
||||
ImGui::PushStyleColor(ImGuiCol_TextDisabled, notice_color);
|
||||
ImGui::TextDisabled("%s", g_notice.c_str());
|
||||
ImGui::PopStyleColor();
|
||||
} else {
|
||||
ImGui::TextDisabled("Ready");
|
||||
}
|
||||
const char* version = "Gitree " GITREE_VERSION;
|
||||
const std::string zoom_label = std::string(ICON_TB_MAGNIFYING_GLASS " ") +
|
||||
std::to_string(g_zoom_percent) + "%";
|
||||
|
||||
Reference in New Issue
Block a user