1
0
mirror of synced 2025-01-19 01:24:15 +01:00

impr: Show document edited icon in close button on macOS

This commit is contained in:
WerWolv 2024-06-12 19:51:12 +02:00
parent bd085dd495
commit b3b79b3ee8
5 changed files with 27 additions and 0 deletions

View File

@ -265,6 +265,7 @@ namespace hex {
EVENT_DEF(EventProviderDataModified, prv::Provider *, u64, u64, const u8*);
EVENT_DEF(EventProviderDataInserted, prv::Provider *, u64, u64);
EVENT_DEF(EventProviderDataRemoved, prv::Provider *, u64, u64);
EVENT_DEF(EventProviderDirtied, prv::Provider *);
/**
* @brief Called when a project has been loaded

View File

@ -18,6 +18,7 @@
void macosHandleTitlebarDoubleClickGesture(GLFWwindow *window);
bool macosIsWindowBeingResizedByUser(GLFWwindow *window);
void macosMarkContentEdited(GLFWwindow *window, bool edited = true);
}
#endif

View File

@ -338,6 +338,7 @@ namespace hex {
void markDirty() {
get()->markDirty();
EventProviderDirtied::post(get());
}
void resetDirty() {

View File

@ -118,6 +118,12 @@
return cocoaWindow.inLiveResize;
}
void macosMarkContentEdited(GLFWwindow *window, bool edited) {
NSWindow* cocoaWindow = glfwGetCocoaWindow(window);
[cocoaWindow setDocumentEdited:edited];
}
@interface HexDocument : NSDocument
@end

View File

@ -1,3 +1,5 @@
#include <hex/api/project_file_manager.hpp>
#include "window.hpp"
#if defined(OS_MACOS)
@ -62,6 +64,22 @@ namespace hex {
RequestChangeTheme::post("Dark");
});
EventProviderDirtied::subscribe([this](prv::Provider *) {
macosMarkContentEdited(m_window);
});
ProjectFile::registerHandler({
.basePath = "",
.required = true,
.load = [](const std::fs::path &, Tar &) {
return true;
},
.store = [this](const std::fs::path &, Tar &) {
macosMarkContentEdited(m_window, false);
return true;
}
});
if (themeFollowSystem)
EventOSThemeChanged::post();