electron/shell/browser/ui/views/menu_bar.h

93 lines
2.5 KiB
C
Raw Normal View History

// Copyright (c) 2014 GitHub, Inc.
2014-07-16 14:10:10 +00:00
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
2019-06-19 20:56:58 +00:00
#ifndef SHELL_BROWSER_UI_VIEWS_MENU_BAR_H_
#define SHELL_BROWSER_UI_VIEWS_MENU_BAR_H_
2014-07-16 14:10:10 +00:00
#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/views/accessible_pane_view.h"
2014-07-16 14:10:10 +00:00
2014-07-17 06:23:28 +00:00
namespace views {
class MenuButton;
}
2014-07-17 06:23:28 +00:00
namespace electron {
2014-07-16 14:10:10 +00:00
class MenuBar : public views::AccessiblePaneView,
public MenuDelegate::Observer,
public NativeWindowObserver {
2014-07-16 14:10:10 +00:00
public:
static const char kViewClassName[];
MenuBar(NativeWindow* window, RootView* root_view);
~MenuBar() override;
2014-07-16 14:10:10 +00:00
2014-07-17 06:23:28 +00:00
// Replaces current menu with a new one.
void SetMenu(ElectronMenuModel* menu_model);
2014-07-17 06:23:28 +00:00
// 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);
2014-07-17 06:23:28 +00:00
// Returns there are how many items in the root menu.
int GetItemCount() const;
// Get the menu under specified screen point.
bool GetMenuButtonFromScreenPoint(const gfx::Point& point,
ElectronMenuModel** menu_model,
2014-07-17 06:23:28 +00:00
views::MenuButton** button);
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;
chore: bump chromium to bc8f70ed4cfe2262ea833750eaddb (master) (#22649) * chore: bump chromium in DEPS to 9321f32fb1b3af8fdfce55c7bbfacf3f75118dca * Update patches * Update electron_swiftshader_binaries deps https://chromium-review.googlesource.com/c/chromium/src/+/2056931 * Use Promise with RequestPointerLock calls https://chromium-review.googlesource.com/c/chromium/src/+/2069199 * Replace content::CursorInfo with ui::Cursor https://chromium-review.googlesource.com/c/chromium/src/+/1999201 * Convert MaterialDesignController to a true singleton. https://chromium-review.googlesource.com/c/chromium/src/+/2090877 * Drop WebContentsView::RenderViewCreated hook https://chromium-review.googlesource.com/c/chromium/src/+/2093535 * chore: bump chromium in DEPS to 6478123cfa0102ed754c70eb9bbdd391d676a4dd * Splitting context_menu_params.h into separate browser VS common parts. https://chromium-review.googlesource.com/c/chromium/src/+/2097468 * Fix DCHECK on OnThemeChanged() https://chromium-review.googlesource.com/c/chromium/src/+/2090713 * chore: bump chromium in DEPS to b0269bb003f699bc8ea7dcba8b0795ef963696d7 * Remove no longer needed patch * Check PointerLock requests for new options and update accordingly https://chromium-review.googlesource.com/c/chromium/src/+/2071788 * Address issues from review * Fixup compile error * Add additional library files * chore: bump chromium in DEPS to a41285fb8aebc8f70ed4cfe2262ea833750eaddb * Update patches Co-authored-by: John Kleinschmidt <jkleinsc@github.com>
2020-03-14 20:54:14 +00:00
void OnThemeChanged() override;
// views::FocusChangeListener:
void OnDidChangeFocus(View* focused_before, View* focused_now) override;
2014-07-16 14:10:10 +00:00
// views::View:
const char* GetClassName() const override;
2014-07-16 14:10:10 +00:00
void ButtonPressed(int id, const ui::Event& event);
void RebuildChildren();
void UpdateViewColors();
void RefreshColorCache();
View* FindAccelChild(char16_t key);
SkColor background_color_;
2020-10-20 18:24:52 +00:00
#if defined(OS_LINUX)
SkColor enabled_color_;
SkColor disabled_color_;
#endif
NativeWindow* window_;
RootView* root_view_;
ElectronMenuModel* menu_model_ = nullptr;
bool accelerator_installed_ = false;
2014-07-16 14:10:10 +00:00
DISALLOW_COPY_AND_ASSIGN(MenuBar);
};
} // namespace electron
2014-07-16 14:10:10 +00:00
2019-06-19 20:56:58 +00:00
#endif // SHELL_BROWSER_UI_VIEWS_MENU_BAR_H_