mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-29 15:22:08 +00:00
Implemented setting of window title in Cocoa backend
# Conflicts: # src/posix/cocoa/i_video.mm
This commit is contained in:
parent
c3c637a0cc
commit
35bb9ba9d3
1 changed files with 33 additions and 15 deletions
|
@ -197,9 +197,12 @@ namespace
|
|||
|
||||
@interface CocoaWindow : NSWindow
|
||||
{
|
||||
NSString* m_title;
|
||||
}
|
||||
|
||||
- (BOOL)canBecomeKeyWindow;
|
||||
- (void)setTitle:(NSString*)title;
|
||||
- (void)updateTitle;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -211,6 +214,23 @@ namespace
|
|||
return true;
|
||||
}
|
||||
|
||||
- (void)setTitle:(NSString*)title
|
||||
{
|
||||
m_title = title;
|
||||
|
||||
[self updateTitle];
|
||||
}
|
||||
|
||||
- (void)updateTitle
|
||||
{
|
||||
if (nil == m_title)
|
||||
{
|
||||
m_title = [NSString stringWithFormat:@"%s %s", GAMESIG, GetVersionString()];
|
||||
}
|
||||
|
||||
[super setTitle:m_title];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
@ -271,6 +291,7 @@ public:
|
|||
static void UseHiDPI(bool hiDPI);
|
||||
static void SetCursor(NSCursor* cursor);
|
||||
static void SetWindowVisible(bool visible);
|
||||
static void SetWindowTitle(const char* title);
|
||||
|
||||
private:
|
||||
struct ModeIterator
|
||||
|
@ -717,6 +738,16 @@ void CocoaVideo::SetWindowVisible(bool visible)
|
|||
}
|
||||
}
|
||||
|
||||
void CocoaVideo::SetWindowTitle(const char* title)
|
||||
{
|
||||
if (CocoaVideo* const video = GetInstance())
|
||||
{
|
||||
NSString* const nsTitle = nullptr == title ? nil :
|
||||
[NSString stringWithCString:title encoding:NSISOLatin1StringEncoding];
|
||||
[video->m_window setTitle:nsTitle];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CocoaVideo::SetFullscreenMode(const int width, const int height)
|
||||
{
|
||||
|
@ -813,9 +844,7 @@ void CocoaVideo::SetMode(const int width, const int height, const bool fullscree
|
|||
|
||||
[[NSOpenGLContext currentContext] flushBuffer];
|
||||
|
||||
static NSString* const TITLE_STRING =
|
||||
[NSString stringWithFormat:@"%s %s", GAMESIG, GetVersionString()];
|
||||
[m_window setTitle:TITLE_STRING];
|
||||
[m_window updateTitle];
|
||||
|
||||
if (![m_window isKeyWindow])
|
||||
{
|
||||
|
@ -1523,16 +1552,5 @@ void I_SetMainWindowVisible(bool visible)
|
|||
// each platform has its own specific version of this function.
|
||||
void I_SetWindowTitle(const char* title)
|
||||
{
|
||||
if (title)
|
||||
{
|
||||
static NSString* const TITLE_STRING =
|
||||
[NSString stringWithFormat:@"%s", title];
|
||||
[m_window setTitle:TITLE_STRING];
|
||||
}
|
||||
else
|
||||
{
|
||||
static NSString* const TITLE_STRING =
|
||||
[NSString stringWithFormat:@"%s %s", GAMESIG, GetVersionString()];
|
||||
[m_window setTitle:TITLE_STRING];
|
||||
}
|
||||
CocoaVideo::SetWindowTitle(title);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue