Skip to content
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

Merged
merged 9 commits into from
Mar 28, 2023

Conversation

NSAntoine
Copy link
Contributor

yeah

Copy link
Owner

@hrydgard hrydgard left a 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.

Comment on lines 8 to 9
#ifndef MacOSBarItems_h
#define MacOSBarItems_h
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#pragma once plz

[[BarItemsManager sharedInstance] setupAppBarItems];
}

// im soooooo sorry for whoever had to read this impl
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnecessary comment :)

Copy link
Collaborator

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]

[[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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Contributor

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());;
Copy link
Collaborator

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);
Copy link
Collaborator

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]

@@ -1563,6 +1575,7 @@ UI::EventReturn GameSettingsScreen::OnAudioDevice(UI::EventParams &e) {
g_Config.sAudioDevice.clear();
}
System_SendMessage("audio_resetDevice", "");
PostDarwinNotificationIfPossible("AudioConfigurationHasChanged", "CurrentDeviceWasChanged");
Copy link
Collaborator

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() {
Copy link
Collaborator

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
Comment on lines 575 to 576


Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Spacious.

-[Unknown]


[parent addItem:[NSMenuItem separatorItem]];

#define MENU_ITEM(variableName, localizedTitleName, SEL, ConfigurationValueName) \
Copy link
Collaborator

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]

[[BarItemsManager sharedInstance] setupAppBarItems];
}

// im soooooo sorry for whoever had to read this impl
Copy link
Collaborator

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]

-(std::vector<GPUBackend>)allowedGPUBackends {
std::vector<GPUBackend> allBackends = {
GPUBackend::OPENGL, GPUBackend::VULKAN,
GPUBackend::DIRECT3D11, GPUBackend::DIRECT3D9
Copy link
Collaborator

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]

Copy link
Contributor Author

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Overindent.

-[Unknown]

NativeResized();
return UI::EVENT_CONTINUE;
});
OnClickPostDarwinNotification(vSync, "ConfigDidChange", "VSync")
Copy link
Collaborator

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]

Copy link
Contributor Author

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

Copy link
Owner

@hrydgard hrydgard left a 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).

@@ -109,3 +109,7 @@ - (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocum
forKey:@(PreferredMemoryStickUserDefaultsKey)];
g_Config.memStickDirectory = path;
}

void PostDarwinNotification(const char *name, const char *value) {
Copy link
Owner

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
Comment on lines 855 to 856
// setup menu items for macOS
initBarItemsForApp();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong indentation

audioSettings->Add(new CheckBox(&g_Config.bEnableSound, a->T("Enable Sound")));

CheckBox *enableSound = audioSettings->Add(new CheckBox(&g_Config.bEnableSound,a->T("Enable Sound")));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

white space?

SDL/CocoaBarItems.mm Outdated Show resolved Hide resolved
Copy link
Owner

@hrydgard hrydgard left a 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.

@hrydgard hrydgard merged commit 67896bf into hrydgard:master Mar 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants