-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
macOS native bar button items #16922
macOS native bar button items #16922
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some initial comments.
As mentioned I dislike the callback, would be nice if the update could be done the moment the touch bar is clicked, before the actual menu shows, if it's possible to catch that event.
The backend setting doesn't work properly (admittedly, the auto restart is already not working, but there's not even a notification). Maybe remove from the menu for now.
Window menu should be towards the right, and not be the first one, File should go first after the application menu.
SDL/MacOSBarItems.h
Outdated
#ifndef MacOSBarItems_h | ||
#define MacOSBarItems_h |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#pragma once plz
SDL/MacOSBarItems.mm
Outdated
[[BarItemsManager sharedInstance] setupAppBarItems]; | ||
} | ||
|
||
// im soooooo sorry for whoever had to read this impl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unnecessary comment :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code is not nearly bad enough to apologize for, heh.
-[Unknown]
SDL/MacOSBarItems.mm
Outdated
[[NSNotificationCenter defaultCenter] addObserverForName:@"ConfigDidChange" object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) { | ||
NSString *value = [note object]; | ||
// NOTE: Though it may seem like it, | ||
// the next few lines were not written by yandere dev |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A joke reference to Yandere simulator developer who was a meme about DRY violation and exhaustive if/else coding.
Shouldn't be a commend imho as I don't really like the shaming :)
Pic for reference: https://i.redd.it/gyubzyq87xmx.png
if (tab == 1) { | ||
gameBrowsers_[tab]->SetPath(Path(filename)); | ||
} | ||
INFO_LOG(SYSTEM, "Got folder: '%s'", filename.c_str());; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: s/;;/;/.
-[Unknown]
} | ||
INFO_LOG(SYSTEM, "Got folder: '%s'", filename.c_str());; | ||
// switch to the 'Games' tab which has the file browser | ||
tabHolder_->SetCurrentTab(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you had no recent before, then it's actually tab 0. I guess you could check if the first view's tag is "MainScreenRecentGames"
and use 1 if it is.
I realize the old code hardcoded 1 so was actually wrong.
-[Unknown]
UI/GameSettingsScreen.cpp
Outdated
@@ -1563,6 +1575,7 @@ UI::EventReturn GameSettingsScreen::OnAudioDevice(UI::EventParams &e) { | |||
g_Config.sAudioDevice.clear(); | |||
} | |||
System_SendMessage("audio_resetDevice", ""); | |||
PostDarwinNotificationIfPossible("AudioConfigurationHasChanged", "CurrentDeviceWasChanged"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we need to keep this, it should be tied to System_SendMessage()
only. The implementation within System_SendMessage()
would be allowed to call PostDarwinNotificationIfPossible()
, but that would only be within SDL/ or ios/ code.
If there was any PostMessageToWindowsMenubar()
, I would have an identical opinion.
That said, I agree with Henrik - if it's possible to update the menu items on some event prior to loading, that would be better. Sounds like there is a way with NSMenuDelegate.
-[Unknown]
Core/Config.cpp
Outdated
@@ -1301,6 +1301,15 @@ void Config::SetAppendedConfigIni(const Path &path) { | |||
appendedConfigFileName_ = path; | |||
} | |||
|
|||
void Config::updateAfterSettingAutoFrameSkip() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Should be a capital U to follow other methods.
That said, maybe this could be combined with PostLoadCleanup()
instead (it probably should have the iFrameSkip = 1
bit anyway), and we could just run that when needed. Better to be more generic in methods exposed by Config, I'd say.
-[Unknown]
Core/Config.h
Outdated
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Spacious.
-[Unknown]
SDL/MacOSBarItems.mm
Outdated
|
||
[parent addItem:[NSMenuItem separatorItem]]; | ||
|
||
#define MENU_ITEM(variableName, localizedTitleName, SEL, ConfigurationValueName) \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: It feels like this could just be a regular method that returns NSMenuItem *
. It also feels like it could automatically call `[parent addItem:] for you. It's fine, just nitmumbling to myself.
-[Unknown]
SDL/MacOSBarItems.mm
Outdated
[[BarItemsManager sharedInstance] setupAppBarItems]; | ||
} | ||
|
||
// im soooooo sorry for whoever had to read this impl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code is not nearly bad enough to apologize for, heh.
-[Unknown]
SDL/MacOSBarItems.mm
Outdated
-(std::vector<GPUBackend>)allowedGPUBackends { | ||
std::vector<GPUBackend> allBackends = { | ||
GPUBackend::OPENGL, GPUBackend::VULKAN, | ||
GPUBackend::DIRECT3D11, GPUBackend::DIRECT3D9 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll be impressed if anyone ever gets these two working on Cocoa.
-[Unknown]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yeah that's basically impossible, heh, I did think 'hey these can't ever really work on macOS or be enabled' but then got distracted by something else, will remove :p
SDL/SDLMain.cpp
Outdated
@@ -846,6 +852,12 @@ int main(int argc, char *argv[]) { | |||
int mouseWheelMovedDownFrames = 0; | |||
bool mouseCaptured = false; | |||
bool windowHidden = false; | |||
|
|||
#if PPSSPP_PLATFORM(MAC) | |||
// setup menu items for macOS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Overindent.
-[Unknown]
UI/GameSettingsScreen.cpp
Outdated
NativeResized(); | ||
return UI::EVENT_CONTINUE; | ||
}); | ||
OnClickPostDarwinNotification(vSync, "ConfigDidChange", "VSync") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Spaces stranded in a land of tabs. Happens a few other times, but I guess these lines will go away anyway when the menu builds itself.
More importantly, I think we still need the vsync NativeResized()
, at least on other platforms?
-[Unknown]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More importantly, I think we still need the vsync
NativeResized()
, at least on other platforms?
oops, forgot this, thanks for pointing out
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really appreciate the effort to keep the logic mostly in /SDL!
Two of my previous comments still apply:
- Window menu should not be left-most
- Backend selector still doesn't actually work properly (should restart the emu).
UI/DarwinFileSystemServices.mm
Outdated
@@ -109,3 +109,7 @@ - (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocum | |||
forKey:@(PreferredMemoryStickUserDefaultsKey)]; | |||
g_Config.memStickDirectory = path; | |||
} | |||
|
|||
void PostDarwinNotification(const char *name, const char *value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this still needed?
SDL/SDLMain.cpp
Outdated
// setup menu items for macOS | ||
initBarItemsForApp(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wrong indentation
UI/GameSettingsScreen.cpp
Outdated
audioSettings->Add(new CheckBox(&g_Config.bEnableSound, a->T("Enable Sound"))); | ||
|
||
CheckBox *enableSound = audioSettings->Add(new CheckBox(&g_Config.bEnableSound,a->T("Enable Sound"))); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
white space?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still has the bad submodule upgrades. Otherwise, I'm happy to get this in now, can be refined as we go later.
yeah