2014-10-31 12:17:05 -06:00
|
|
|
// Copyright (c) 2013 GitHub, Inc.
|
2014-04-25 03:49:37 -06:00
|
|
|
// Use of this source code is governed by the MIT license that can be
|
2013-05-06 06:27:09 -06:00
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2021-11-22 00:34:31 -07:00
|
|
|
#ifndef ELECTRON_SHELL_BROWSER_API_ELECTRON_API_MENU_MAC_H_
|
|
|
|
#define ELECTRON_SHELL_BROWSER_API_ELECTRON_API_MENU_MAC_H_
|
2013-05-06 06:27:09 -06:00
|
|
|
|
2020-02-04 13:19:40 -07:00
|
|
|
#include "shell/browser/api/electron_api_menu.h"
|
2013-05-06 06:27:09 -06:00
|
|
|
|
2017-02-16 11:58:02 -07:00
|
|
|
#include <map>
|
2014-03-15 19:13:06 -06:00
|
|
|
|
2020-02-04 13:19:40 -07:00
|
|
|
#import "shell/browser/ui/cocoa/electron_menu_controller.h"
|
2013-05-15 20:54:37 -06:00
|
|
|
|
2022-06-29 13:55:47 -06:00
|
|
|
namespace electron::api {
|
2013-05-06 06:27:09 -06:00
|
|
|
|
|
|
|
class MenuMac : public Menu {
|
|
|
|
protected:
|
2019-10-14 19:15:23 -06:00
|
|
|
explicit MenuMac(gin::Arguments* args);
|
2018-04-17 17:37:22 -06:00
|
|
|
~MenuMac() override;
|
2014-04-21 09:40:10 -06:00
|
|
|
|
2020-06-29 01:06:20 -06:00
|
|
|
void PopupAt(BaseWindow* window,
|
2018-04-17 19:44:10 -06:00
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
int positioning_item,
|
2023-06-29 16:54:06 -06:00
|
|
|
ui::MenuSourceType source_type,
|
2019-11-20 04:17:39 -07:00
|
|
|
base::OnceClosure callback) override;
|
2017-02-15 12:44:25 -07:00
|
|
|
void PopupOnUI(const base::WeakPtr<NativeWindow>& native_window,
|
2017-09-13 15:13:45 -06:00
|
|
|
int32_t window_id,
|
|
|
|
int x,
|
|
|
|
int y,
|
2018-01-01 00:26:19 -07:00
|
|
|
int positioning_item,
|
2019-11-20 04:17:39 -07:00
|
|
|
base::OnceClosure callback);
|
2017-02-16 11:58:02 -07:00
|
|
|
void ClosePopupAt(int32_t window_id) override;
|
2021-06-02 01:32:48 -06:00
|
|
|
std::u16string GetAcceleratorTextAtForTesting(int index) const override;
|
2013-05-06 06:27:09 -06:00
|
|
|
|
|
|
|
private:
|
2013-05-15 20:54:37 -06:00
|
|
|
friend class Menu;
|
|
|
|
|
2021-06-02 01:32:48 -06:00
|
|
|
void ClosePopupOnUI(int32_t window_id);
|
2019-11-20 04:17:39 -07:00
|
|
|
void OnClosed(int32_t window_id, base::OnceClosure callback);
|
2013-05-16 03:25:02 -06:00
|
|
|
|
2023-07-18 16:26:27 -06:00
|
|
|
ElectronMenuController* __strong menu_controller_;
|
2017-02-17 13:16:29 -07:00
|
|
|
|
|
|
|
// window ID -> open context menu
|
2023-07-18 16:26:27 -06:00
|
|
|
std::map<int32_t, ElectronMenuController*> popup_controllers_;
|
2017-02-17 13:16:29 -07:00
|
|
|
|
2021-01-26 11:16:21 -07:00
|
|
|
base::WeakPtrFactory<MenuMac> weak_factory_{this};
|
2013-05-06 06:27:09 -06:00
|
|
|
};
|
|
|
|
|
2022-06-29 13:55:47 -06:00
|
|
|
} // namespace electron::api
|
2013-05-06 06:27:09 -06:00
|
|
|
|
2021-11-22 00:34:31 -07:00
|
|
|
#endif // ELECTRON_SHELL_BROWSER_API_ELECTRON_API_MENU_MAC_H_
|