electron/shell/browser/ui/views/menu_bar.h
electron-roller[bot] e72f4f7f26
chore: bump chromium to 123.0.6312.5 (main) (#41337)
* chore: bump chromium in DEPS to 123.0.6300.2

* chore: bump chromium in DEPS to 123.0.6301.2

* chore: update patches

* chore: bump chromium in DEPS to 123.0.6302.0

* chore: bump chromium in DEPS to 123.0.6304.0

* chore: update patches

* chore: bump chromium in DEPS to 123.0.6306.2

* chore: update patches

* chore: bump chromium in DEPS to 123.0.6308.0

* chore: update patches

* Refactor //components/pdf/common constants

https://chromium-review.googlesource.com/c/chromium/src/+/5292816

* Rename URLLoaderFactoryParams::is_corb_enabled to is_orb_enabled.

Refs https://chromium-review.googlesource.com/c/chromium/src/+/5277040

* Add placeholder of speaker-selection permission.

Refs https://chromium-review.googlesource.com/c/chromium/src/+/5278243

* Move kPdfMimeType to //components/pdf/common/constants.h

Refs https://chromium-review.googlesource.com/c/chromium/src/+/5293155

* chore: gen-libc++-filenames.js

* Make GetClassName non virtual

Refs https://chromium-review.googlesource.com/c/chromium/src/+/5293075
Refs https://issues.chromium.org/issues/324596267

* chore: bump chromium in DEPS to 123.0.6310.0

* chore: update filenames.libcxx.gni

* 5282732: Compute input region using correct pixel size.

https://chromium-review.googlesource.com/c/chromium/src/+/5282732

* fixup: Make GetClassName non virtual

* chore: bump chromium in DEPS to 123.0.6312.0

* chore: update patches

* chore: bump chromium in DEPS to 123.0.6312.5

* fixup: Make GetClassName non virtual

* docs: document speaker-selection

https://chromium-review.googlesource.com/c/chromium/src/+/5278243

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: deepak1556 <hop2deep@gmail.com>
Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
2024-02-21 15:27:05 -05:00

100 lines
2.9 KiB
C++

// Copyright (c) 2014 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef ELECTRON_SHELL_BROWSER_UI_VIEWS_MENU_BAR_H_
#define ELECTRON_SHELL_BROWSER_UI_VIEWS_MENU_BAR_H_
#include "base/memory/raw_ptr.h"
#include "shell/browser/native_window_observer.h"
#include "shell/browser/ui/electron_menu_model.h"
#include "shell/browser/ui/views/menu_delegate.h"
#include "shell/browser/ui/views/root_view.h"
#include "ui/base/metadata/metadata_header_macros.h"
#include "ui/base/metadata/metadata_impl_macros.h"
#include "ui/views/accessible_pane_view.h"
namespace views {
class MenuButton;
}
namespace electron {
class MenuBar : public views::AccessiblePaneView,
public MenuDelegate::Observer,
public NativeWindowObserver {
METADATA_HEADER(MenuBar, views::AccessiblePaneView)
public:
MenuBar(NativeWindow* window, RootView* root_view);
~MenuBar() override;
// disable copy
MenuBar(const MenuBar&) = delete;
MenuBar& operator=(const MenuBar&) = delete;
// Replaces current menu with a new one.
void SetMenu(ElectronMenuModel* menu_model);
// Shows underline under accelerators.
void SetAcceleratorVisibility(bool visible);
// Returns true if the submenu has accelerator |key|
bool HasAccelerator(char16_t key);
// Shows the submenu whose accelerator is |key|.
void ActivateAccelerator(char16_t key);
// Returns there are how many items in the root menu.
size_t GetItemCount() const;
// Get the menu under specified screen point.
bool GetMenuButtonFromScreenPoint(const gfx::Point& point,
ElectronMenuModel** menu_model,
views::MenuButton** button);
void ViewHierarchyChanged(
const views::ViewHierarchyChangedDetails& details) override;
private:
// MenuDelegate::Observer:
void OnBeforeExecuteCommand() override;
void OnMenuClosed() override;
// NativeWindowObserver:
void OnWindowBlur() override;
void OnWindowFocus() override;
// views::AccessiblePaneView:
bool AcceleratorPressed(const ui::Accelerator& accelerator) override;
bool SetPaneFocusAndFocusDefault() override;
void OnThemeChanged() override;
// views::FocusChangeListener:
void OnDidChangeFocus(View* focused_before, View* focused_now) override;
// views::View:
void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
void ButtonPressed(size_t id, const ui::Event& event);
void RebuildChildren();
void UpdateViewColors();
void RefreshColorCache(const ui::NativeTheme* theme);
View* FindAccelChild(char16_t key);
SkColor background_color_;
#if BUILDFLAG(IS_LINUX)
SkColor enabled_color_;
SkColor disabled_color_;
#endif
raw_ptr<NativeWindow> window_;
raw_ptr<RootView> root_view_;
raw_ptr<ElectronMenuModel> menu_model_ = nullptr;
bool accelerator_installed_ = false;
};
} // namespace electron
#endif // ELECTRON_SHELL_BROWSER_UI_VIEWS_MENU_BAR_H_