2018-05-01 04:28:22 +00:00
|
|
|
// Copyright (c) 2018 GitHub, Inc.
|
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2021-11-22 07:34:31 +00:00
|
|
|
#ifndef ELECTRON_SHELL_BROWSER_UI_VIEWS_ROOT_VIEW_H_
|
|
|
|
#define ELECTRON_SHELL_BROWSER_UI_VIEWS_ROOT_VIEW_H_
|
2018-05-01 04:28:22 +00:00
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
2023-05-11 20:07:39 +00:00
|
|
|
#include "base/memory/raw_ptr.h"
|
2019-06-19 20:46:59 +00:00
|
|
|
#include "shell/browser/ui/accelerator_util.h"
|
2019-01-31 02:19:47 +00:00
|
|
|
#include "ui/gfx/geometry/insets.h"
|
2018-05-01 04:28:22 +00:00
|
|
|
#include "ui/views/view.h"
|
2018-10-29 18:08:47 +00:00
|
|
|
#include "ui/views/view_tracker.h"
|
2018-05-01 04:28:22 +00:00
|
|
|
|
|
|
|
namespace content {
|
|
|
|
struct NativeWebKeyboardEvent;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace electron {
|
|
|
|
|
|
|
|
class ElectronMenuModel;
|
|
|
|
class MenuBar;
|
|
|
|
class NativeWindow;
|
|
|
|
|
|
|
|
class RootView : public views::View {
|
|
|
|
public:
|
|
|
|
explicit RootView(NativeWindow* window);
|
|
|
|
~RootView() override;
|
|
|
|
|
2021-11-03 11:41:45 +00:00
|
|
|
// disable copy
|
|
|
|
RootView(const RootView&) = delete;
|
|
|
|
RootView& operator=(const RootView&) = delete;
|
|
|
|
|
2018-05-01 04:28:22 +00:00
|
|
|
void SetMenu(ElectronMenuModel* menu_model);
|
|
|
|
bool HasMenu() const;
|
|
|
|
int GetMenuBarHeight() const;
|
|
|
|
void SetAutoHideMenuBar(bool auto_hide);
|
|
|
|
bool IsMenuBarAutoHide() const;
|
|
|
|
void SetMenuBarVisibility(bool visible);
|
|
|
|
bool IsMenuBarVisible() const;
|
|
|
|
void HandleKeyEvent(const content::NativeWebKeyboardEvent& event);
|
|
|
|
void ResetAltState();
|
2018-10-29 18:08:47 +00:00
|
|
|
void RestoreFocus();
|
2018-11-09 21:54:16 +00:00
|
|
|
// Register/Unregister accelerators supported by the menu model.
|
|
|
|
void RegisterAcceleratorsWithFocusManager(ElectronMenuModel* menu_model);
|
|
|
|
void UnregisterAcceleratorsWithFocusManager();
|
2018-05-01 04:28:22 +00:00
|
|
|
|
|
|
|
// views::View:
|
|
|
|
void Layout() override;
|
|
|
|
gfx::Size GetMinimumSize() const override;
|
|
|
|
gfx::Size GetMaximumSize() const override;
|
|
|
|
bool AcceleratorPressed(const ui::Accelerator& accelerator) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
// Parent window, weak ref.
|
2023-05-11 20:07:39 +00:00
|
|
|
raw_ptr<NativeWindow> window_;
|
2018-05-01 04:28:22 +00:00
|
|
|
|
|
|
|
// Menu bar.
|
|
|
|
std::unique_ptr<MenuBar> menu_bar_;
|
|
|
|
bool menu_bar_autohide_ = false;
|
|
|
|
bool menu_bar_visible_ = false;
|
|
|
|
bool menu_bar_alt_pressed_ = false;
|
|
|
|
|
|
|
|
// Map from accelerator to menu item's command id.
|
|
|
|
accelerator_util::AcceleratorTable accelerator_table_;
|
|
|
|
|
2018-10-29 18:08:47 +00:00
|
|
|
std::unique_ptr<views::ViewTracker> last_focused_view_tracker_;
|
2018-05-01 04:28:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace electron
|
|
|
|
|
2021-11-22 07:34:31 +00:00
|
|
|
#endif // ELECTRON_SHELL_BROWSER_UI_VIEWS_ROOT_VIEW_H_
|