impr: Show document edited icon in close button on macOS
This commit is contained in:
parent
bd085dd495
commit
b3b79b3ee8
@ -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
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
void macosHandleTitlebarDoubleClickGesture(GLFWwindow *window);
|
||||
bool macosIsWindowBeingResizedByUser(GLFWwindow *window);
|
||||
void macosMarkContentEdited(GLFWwindow *window, bool edited = true);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -338,6 +338,7 @@ namespace hex {
|
||||
|
||||
void markDirty() {
|
||||
get()->markDirty();
|
||||
EventProviderDirtied::post(get());
|
||||
}
|
||||
|
||||
void resetDirty() {
|
||||
|
@ -118,6 +118,12 @@
|
||||
return cocoaWindow.inLiveResize;
|
||||
}
|
||||
|
||||
void macosMarkContentEdited(GLFWwindow *window, bool edited) {
|
||||
NSWindow* cocoaWindow = glfwGetCocoaWindow(window);
|
||||
|
||||
[cocoaWindow setDocumentEdited:edited];
|
||||
}
|
||||
|
||||
@interface HexDocument : NSDocument
|
||||
|
||||
@end
|
||||
|
@ -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();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user