win: Add BrowserWindow.setThumbarButtons API.
This commit is contained in:
parent
488a69d461
commit
54af048f04
10 changed files with 343 additions and 0 deletions
|
@ -20,6 +20,30 @@
|
||||||
|
|
||||||
#include "atom/common/node_includes.h"
|
#include "atom/common/node_includes.h"
|
||||||
|
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
#include "atom/browser/ui/win/thumbar_host.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace mate {
|
||||||
|
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
template<>
|
||||||
|
struct Converter<atom::ThumbarHost::ThumbarButton> {
|
||||||
|
static bool FromV8(v8::Isolate* isolate, v8::Handle<v8::Value> val,
|
||||||
|
atom::ThumbarHost::ThumbarButton* out) {
|
||||||
|
mate::Dictionary dict;
|
||||||
|
if (!ConvertFromV8(isolate, val, &dict))
|
||||||
|
return false;
|
||||||
|
dict.Get("click", &(out->clicked_callback));
|
||||||
|
dict.Get("tooltip", &(out->tooltip));
|
||||||
|
dict.Get("flags", &out->flags);
|
||||||
|
return dict.Get("icon", &(out->icon));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
} // namespace mate
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
namespace api {
|
namespace api {
|
||||||
|
@ -413,6 +437,13 @@ void Window::SetOverlayIcon(const gfx::Image& overlay,
|
||||||
window_->SetOverlayIcon(overlay, description);
|
window_->SetOverlayIcon(overlay, description);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
void Window::SetThumbarButtons(
|
||||||
|
const std::vector<ThumbarHost::ThumbarButton>& buttons) {
|
||||||
|
window_->SetThumbarButtons(buttons);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void Window::SetMenu(v8::Isolate* isolate, v8::Local<v8::Value> value) {
|
void Window::SetMenu(v8::Isolate* isolate, v8::Local<v8::Value> value) {
|
||||||
mate::Handle<Menu> menu;
|
mate::Handle<Menu> menu;
|
||||||
if (value->IsObject() &&
|
if (value->IsObject() &&
|
||||||
|
@ -538,6 +569,9 @@ void Window::BuildPrototype(v8::Isolate* isolate,
|
||||||
.SetMethod("capturePage", &Window::CapturePage)
|
.SetMethod("capturePage", &Window::CapturePage)
|
||||||
.SetMethod("setProgressBar", &Window::SetProgressBar)
|
.SetMethod("setProgressBar", &Window::SetProgressBar)
|
||||||
.SetMethod("setOverlayIcon", &Window::SetOverlayIcon)
|
.SetMethod("setOverlayIcon", &Window::SetOverlayIcon)
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
.SetMethod("setThumbarButtons", &Window::SetThumbarButtons)
|
||||||
|
#endif
|
||||||
.SetMethod("setMenu", &Window::SetMenu)
|
.SetMethod("setMenu", &Window::SetMenu)
|
||||||
.SetMethod("setAutoHideMenuBar", &Window::SetAutoHideMenuBar)
|
.SetMethod("setAutoHideMenuBar", &Window::SetAutoHideMenuBar)
|
||||||
.SetMethod("isMenuBarAutoHide", &Window::IsMenuBarAutoHide)
|
.SetMethod("isMenuBarAutoHide", &Window::IsMenuBarAutoHide)
|
||||||
|
|
|
@ -14,6 +14,10 @@
|
||||||
#include "atom/browser/native_window_observer.h"
|
#include "atom/browser/native_window_observer.h"
|
||||||
#include "native_mate/handle.h"
|
#include "native_mate/handle.h"
|
||||||
|
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
#include "atom/browser/ui/win/thumbar_host.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
class GURL;
|
class GURL;
|
||||||
|
|
||||||
namespace gfx {
|
namespace gfx {
|
||||||
|
@ -129,6 +133,10 @@ class Window : public mate::TrackableObject<Window>,
|
||||||
void SetProgressBar(double progress);
|
void SetProgressBar(double progress);
|
||||||
void SetOverlayIcon(const gfx::Image& overlay,
|
void SetOverlayIcon(const gfx::Image& overlay,
|
||||||
const std::string& description);
|
const std::string& description);
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
void SetThumbarButtons(
|
||||||
|
const std::vector<ThumbarHost::ThumbarButton>& buttons);
|
||||||
|
#endif
|
||||||
void SetMenu(v8::Isolate* isolate, v8::Local<v8::Value> menu);
|
void SetMenu(v8::Isolate* isolate, v8::Local<v8::Value> menu);
|
||||||
void SetAutoHideMenuBar(bool auto_hide);
|
void SetAutoHideMenuBar(bool auto_hide);
|
||||||
bool IsMenuBarAutoHide();
|
bool IsMenuBarAutoHide();
|
||||||
|
|
44
atom/browser/atom_desktop_window_tree_host_win.cc
Normal file
44
atom/browser/atom_desktop_window_tree_host_win.cc
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
// Copyright (c) 2015 GitHub, Inc.
|
||||||
|
// Use of this source code is governed by the MIT license that can be
|
||||||
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
#include "atom/browser/atom_desktop_window_tree_host_win.h"
|
||||||
|
#include "atom/browser/ui/win/thumbar_host.h"
|
||||||
|
|
||||||
|
namespace atom {
|
||||||
|
|
||||||
|
AtomDesktopWindowTreeHostWin::AtomDesktopWindowTreeHostWin(
|
||||||
|
views::internal::NativeWidgetDelegate* native_widget_delegate,
|
||||||
|
views::DesktopNativeWidgetAura* desktop_native_widget_aura)
|
||||||
|
: views::DesktopWindowTreeHostWin(native_widget_delegate,
|
||||||
|
desktop_native_widget_aura) {
|
||||||
|
}
|
||||||
|
|
||||||
|
AtomDesktopWindowTreeHostWin::~AtomDesktopWindowTreeHostWin() {
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AtomDesktopWindowTreeHostWin::SetThumbarButtons(
|
||||||
|
HWND window,
|
||||||
|
const std::vector<ThumbarHost::ThumbarButton>& buttons) {
|
||||||
|
if (!thumbar_host_.get()) {
|
||||||
|
thumbar_host_.reset(new ThumbarHost(window));
|
||||||
|
}
|
||||||
|
return thumbar_host_->SetThumbarButtons(buttons);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AtomDesktopWindowTreeHostWin::PreHandleMSG(UINT message,
|
||||||
|
WPARAM w_param,
|
||||||
|
LPARAM l_param,
|
||||||
|
LRESULT* result) {
|
||||||
|
switch (message) {
|
||||||
|
case WM_COMMAND: {
|
||||||
|
int id = LOWORD(w_param);
|
||||||
|
if (thumbar_host_ && thumbar_host_->HandleThumbarButtonEvent(id))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace atom
|
41
atom/browser/atom_desktop_window_tree_host_win.h
Normal file
41
atom/browser/atom_desktop_window_tree_host_win.h
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
// Copyright (c) 2015 GitHub, Inc.
|
||||||
|
// Use of this source code is governed by the MIT license that can be
|
||||||
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
#ifndef ATOM_BROWSER_ATOM_DESKTOP_WINDOW_TREE_HOST_WIN_H_
|
||||||
|
#define ATOM_BROWSER_ATOM_DESKTOP_WINDOW_TREE_HOST_WIN_H_
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "atom/browser/ui/win/thumbar_host.h"
|
||||||
|
#include "base/memory/scoped_ptr.h"
|
||||||
|
#include "ui/views/widget/desktop_aura/desktop_window_tree_host_win.h"
|
||||||
|
|
||||||
|
namespace atom {
|
||||||
|
|
||||||
|
class AtomDesktopWindowTreeHostWin : public views::DesktopWindowTreeHostWin {
|
||||||
|
public:
|
||||||
|
AtomDesktopWindowTreeHostWin(
|
||||||
|
views::internal::NativeWidgetDelegate* native_widget_delegate,
|
||||||
|
views::DesktopNativeWidgetAura* desktop_native_widget_aura);
|
||||||
|
~AtomDesktopWindowTreeHostWin();
|
||||||
|
|
||||||
|
bool SetThumbarButtons(
|
||||||
|
HWND window,
|
||||||
|
const std::vector<ThumbarHost::ThumbarButton>& buttons);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool PreHandleMSG(UINT message,
|
||||||
|
WPARAM w_param,
|
||||||
|
LPARAM l_param,
|
||||||
|
LRESULT* result) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
scoped_ptr<ThumbarHost> thumbar_host_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace atom
|
||||||
|
|
||||||
|
#endif // ATOM_BROWSER_ATOM_DESKTOP_WINDOW_TREE_HOST_WIN_H_
|
|
@ -23,6 +23,10 @@
|
||||||
#include "ui/gfx/image/image.h"
|
#include "ui/gfx/image/image.h"
|
||||||
#include "ui/gfx/image/image_skia.h"
|
#include "ui/gfx/image/image_skia.h"
|
||||||
|
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
#include "atom/browser/ui/win/thumbar_host.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
class SkRegion;
|
class SkRegion;
|
||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
|
@ -144,6 +148,10 @@ class NativeWindow : public content::WebContentsObserver,
|
||||||
const std::string& description) = 0;
|
const std::string& description) = 0;
|
||||||
virtual void SetVisibleOnAllWorkspaces(bool visible) = 0;
|
virtual void SetVisibleOnAllWorkspaces(bool visible) = 0;
|
||||||
virtual bool IsVisibleOnAllWorkspaces() = 0;
|
virtual bool IsVisibleOnAllWorkspaces() = 0;
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
virtual bool SetThumbarButtons(
|
||||||
|
const std::vector<ThumbarHost::ThumbarButton>& buttons) = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
virtual bool IsClosed() const { return is_closed_; }
|
virtual bool IsClosed() const { return is_closed_; }
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include "ui/views/controls/webview/unhandled_keyboard_event_handler.h"
|
#include "ui/views/controls/webview/unhandled_keyboard_event_handler.h"
|
||||||
#include "ui/views/controls/webview/webview.h"
|
#include "ui/views/controls/webview/webview.h"
|
||||||
#include "ui/views/window/client_view.h"
|
#include "ui/views/window/client_view.h"
|
||||||
|
#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
|
||||||
#include "ui/views/widget/native_widget_private.h"
|
#include "ui/views/widget/native_widget_private.h"
|
||||||
#include "ui/views/widget/widget.h"
|
#include "ui/views/widget/widget.h"
|
||||||
#include "ui/wm/core/shadow_types.h"
|
#include "ui/wm/core/shadow_types.h"
|
||||||
|
@ -44,6 +45,7 @@
|
||||||
#include "ui/gfx/x/x11_types.h"
|
#include "ui/gfx/x/x11_types.h"
|
||||||
#include "ui/views/window/native_frame_view.h"
|
#include "ui/views/window/native_frame_view.h"
|
||||||
#elif defined(OS_WIN)
|
#elif defined(OS_WIN)
|
||||||
|
#include "atom/browser/atom_desktop_window_tree_host_win.h"
|
||||||
#include "atom/browser/ui/views/win_frame_view.h"
|
#include "atom/browser/ui/views/win_frame_view.h"
|
||||||
#include "base/win/scoped_comptr.h"
|
#include "base/win/scoped_comptr.h"
|
||||||
#include "base/win/windows_version.h"
|
#include "base/win/windows_version.h"
|
||||||
|
@ -215,6 +217,14 @@ NativeWindowViews::NativeWindowViews(
|
||||||
if (transparent())
|
if (transparent())
|
||||||
params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
|
params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
|
||||||
|
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
params.native_widget =
|
||||||
|
new views::DesktopNativeWidgetAura(window_.get());
|
||||||
|
atom_desktop_window_tree_host_win_ = new AtomDesktopWindowTreeHostWin(
|
||||||
|
window_.get(),
|
||||||
|
static_cast<views::DesktopNativeWidgetAura*>(params.native_widget));
|
||||||
|
params.desktop_window_tree_host = atom_desktop_window_tree_host_win_;
|
||||||
|
#endif
|
||||||
#if defined(USE_X11)
|
#if defined(USE_X11)
|
||||||
std::string name = Browser::Get()->GetName();
|
std::string name = Browser::Get()->GetName();
|
||||||
// Set WM_WINDOW_ROLE.
|
// Set WM_WINDOW_ROLE.
|
||||||
|
@ -707,6 +717,18 @@ bool NativeWindowViews::IsVisibleOnAllWorkspaces() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
bool NativeWindowViews::SetThumbarButtons(
|
||||||
|
const std::vector<ThumbarHost::ThumbarButton>& buttons) {
|
||||||
|
if (atom_desktop_window_tree_host_win_) {
|
||||||
|
return atom_desktop_window_tree_host_win_->SetThumbarButtons(
|
||||||
|
views::HWNDForNativeWindow(window_->GetNativeWindow()),
|
||||||
|
buttons);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
gfx::AcceleratedWidget NativeWindowViews::GetAcceleratedWidget() {
|
gfx::AcceleratedWidget NativeWindowViews::GetAcceleratedWidget() {
|
||||||
return GetNativeWindow()->GetHost()->GetAcceleratedWidget();
|
return GetNativeWindow()->GetHost()->GetAcceleratedWidget();
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,9 @@ namespace atom {
|
||||||
class GlobalMenuBarX11;
|
class GlobalMenuBarX11;
|
||||||
class MenuBar;
|
class MenuBar;
|
||||||
class WindowStateWatcher;
|
class WindowStateWatcher;
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
class AtomDesktopWindowTreeHostWin;
|
||||||
|
#endif
|
||||||
|
|
||||||
class NativeWindowViews : public NativeWindow,
|
class NativeWindowViews : public NativeWindow,
|
||||||
public views::WidgetDelegateView,
|
public views::WidgetDelegateView,
|
||||||
|
@ -79,6 +82,10 @@ class NativeWindowViews : public NativeWindow,
|
||||||
bool IsMenuBarVisible() override;
|
bool IsMenuBarVisible() override;
|
||||||
void SetVisibleOnAllWorkspaces(bool visible) override;
|
void SetVisibleOnAllWorkspaces(bool visible) override;
|
||||||
bool IsVisibleOnAllWorkspaces() override;
|
bool IsVisibleOnAllWorkspaces() override;
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
bool SetThumbarButtons(
|
||||||
|
const std::vector<ThumbarHost::ThumbarButton>& buttons) override;
|
||||||
|
#endif
|
||||||
|
|
||||||
gfx::AcceleratedWidget GetAcceleratedWidget();
|
gfx::AcceleratedWidget GetAcceleratedWidget();
|
||||||
|
|
||||||
|
@ -154,6 +161,8 @@ class NativeWindowViews : public NativeWindow,
|
||||||
// Handles window state events.
|
// Handles window state events.
|
||||||
scoped_ptr<WindowStateWatcher> window_state_watcher_;
|
scoped_ptr<WindowStateWatcher> window_state_watcher_;
|
||||||
#elif defined(OS_WIN)
|
#elif defined(OS_WIN)
|
||||||
|
// Weak ref.
|
||||||
|
AtomDesktopWindowTreeHostWin* atom_desktop_window_tree_host_win_;
|
||||||
// Records window was whether restored from minimized state or maximized
|
// Records window was whether restored from minimized state or maximized
|
||||||
// state.
|
// state.
|
||||||
bool is_minimized_;
|
bool is_minimized_;
|
||||||
|
|
122
atom/browser/ui/win/thumbar_host.cc
Normal file
122
atom/browser/ui/win/thumbar_host.cc
Normal file
|
@ -0,0 +1,122 @@
|
||||||
|
// Copyright (c) 2015 GitHub, Inc.
|
||||||
|
// Use of this source code is governed by the MIT license that can be
|
||||||
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
#include "atom/browser/ui/win/thumbar_host.h"
|
||||||
|
|
||||||
|
#include <shobjidl.h>
|
||||||
|
|
||||||
|
#include "base/win/scoped_comptr.h"
|
||||||
|
#include "base/win/win_util.h"
|
||||||
|
#include "base/win/wrapped_window_proc.h"
|
||||||
|
#include "base/strings/utf_string_conversions.h"
|
||||||
|
#include "third_party/skia/include/core/SkBitmap.h"
|
||||||
|
#include "ui/gfx/icon_util.h"
|
||||||
|
#include "ui/gfx/win/hwnd_util.h"
|
||||||
|
|
||||||
|
namespace atom {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
// The thumbnail toolbar has a maximum of seven buttons due to the limited room.
|
||||||
|
const int kMaxButtonsCount = 7;
|
||||||
|
|
||||||
|
bool GetThumbarButtonFlags(const std::vector<std::string>& flags,
|
||||||
|
THUMBBUTTONFLAGS* out) {
|
||||||
|
if (flags.empty()) {
|
||||||
|
*out = THBF_ENABLED;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
THUMBBUTTONFLAGS result = static_cast<THUMBBUTTONFLAGS>(0);
|
||||||
|
for (const auto& flag : flags) {
|
||||||
|
if (flag == "enabled") {
|
||||||
|
result |= THBF_ENABLED;
|
||||||
|
} else if (flag == "disabled") {
|
||||||
|
result |= THBF_DISABLED;
|
||||||
|
} else if (flag == "dismissonclick") {
|
||||||
|
result |= THBF_DISMISSONCLICK;
|
||||||
|
} else if (flag == "nobackground") {
|
||||||
|
result |= THBF_NOBACKGROUND;
|
||||||
|
} else if (flag == "hidden") {
|
||||||
|
result |= THBF_HIDDEN;
|
||||||
|
} else if (flag == "noninteractive") {
|
||||||
|
result |= THBF_NONINTERACTIVE;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*out = result;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
ThumbarHost::ThumbarHost(HWND window) : is_initialized_(false),
|
||||||
|
window_(window) {
|
||||||
|
}
|
||||||
|
|
||||||
|
ThumbarHost::~ThumbarHost() {
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ThumbarHost::SetThumbarButtons(
|
||||||
|
const std::vector<ThumbarHost::ThumbarButton>& buttons) {
|
||||||
|
THUMBBUTTON thumb_buttons[kMaxButtonsCount];
|
||||||
|
thumbar_button_clicked_callback_map_.clear();
|
||||||
|
|
||||||
|
// Once a toolbar with a set of buttons is added to thumbnail, there is no way
|
||||||
|
// to remove it without re-creating the window.
|
||||||
|
// To achieve to re-set thumbar buttons, we initialize the buttons with
|
||||||
|
// HIDDEN state and only updated the caller's specified buttons.
|
||||||
|
//
|
||||||
|
// Initialize all thumb buttons with HIDDEN state.
|
||||||
|
for (int i = 0; i < kMaxButtonsCount; ++i) {
|
||||||
|
thumb_buttons[i].iId = i;
|
||||||
|
thumb_buttons[i].dwFlags = THBF_HIDDEN;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the callers' specified buttons.
|
||||||
|
for (size_t i = 0; i < buttons.size(); ++i) {
|
||||||
|
if (!GetThumbarButtonFlags(buttons[i].flags, &thumb_buttons[i].dwFlags))
|
||||||
|
return false;
|
||||||
|
thumb_buttons[i].dwMask = THB_ICON | THB_FLAGS;
|
||||||
|
thumb_buttons[i].hIcon = IconUtil::CreateHICONFromSkBitmap(
|
||||||
|
buttons[i].icon.AsBitmap());
|
||||||
|
if (!buttons[i].tooltip.empty()) {
|
||||||
|
thumb_buttons[i].dwMask |= THB_TOOLTIP;
|
||||||
|
wcscpy_s(thumb_buttons[i].szTip,
|
||||||
|
base::UTF8ToUTF16(buttons[i].tooltip).c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
thumbar_button_clicked_callback_map_[i] =
|
||||||
|
buttons[i].clicked_callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
base::win::ScopedComPtr<ITaskbarList3> taskbar;
|
||||||
|
if (FAILED(taskbar.CreateInstance(CLSID_TaskbarList,
|
||||||
|
nullptr,
|
||||||
|
CLSCTX_INPROC_SERVER)) ||
|
||||||
|
FAILED(taskbar->HrInit())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!is_initialized_) {
|
||||||
|
is_initialized_ = true;
|
||||||
|
return taskbar->ThumbBarAddButtons(
|
||||||
|
window_, kMaxButtonsCount, thumb_buttons) == S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
return taskbar->ThumbBarUpdateButtons(
|
||||||
|
window_, kMaxButtonsCount, thumb_buttons) == S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ThumbarHost::HandleThumbarButtonEvent(int button_id) {
|
||||||
|
if (thumbar_button_clicked_callback_map_.find(button_id) !=
|
||||||
|
thumbar_button_clicked_callback_map_.end()) {
|
||||||
|
auto callback = thumbar_button_clicked_callback_map_[button_id];
|
||||||
|
if (!callback.is_null())
|
||||||
|
callback.Run();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace atom
|
51
atom/browser/ui/win/thumbar_host.h
Normal file
51
atom/browser/ui/win/thumbar_host.h
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
// Copyright (c) 2015 GitHub, Inc.
|
||||||
|
// Use of this source code is governed by the MIT license that can be
|
||||||
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
#ifndef ATOM_BROWSER_UI_WIN_THUMBAR_HOST_H_
|
||||||
|
#define ATOM_BROWSER_UI_WIN_THUMBAR_HOST_H_
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "base/callback.h"
|
||||||
|
#include "ui/gfx/image/image.h"
|
||||||
|
|
||||||
|
namespace atom {
|
||||||
|
|
||||||
|
class ThumbarHost {
|
||||||
|
public:
|
||||||
|
using ThumbarButtonClickedCallback = base::Callback<void(void)>;
|
||||||
|
|
||||||
|
struct ThumbarButton {
|
||||||
|
std::string tooltip;
|
||||||
|
gfx::Image icon;
|
||||||
|
std::vector<std::string> flags;
|
||||||
|
ThumbarButtonClickedCallback clicked_callback;
|
||||||
|
};
|
||||||
|
|
||||||
|
explicit ThumbarHost(HWND window);
|
||||||
|
~ThumbarHost();
|
||||||
|
|
||||||
|
bool SetThumbarButtons(
|
||||||
|
const std::vector<ThumbarHost::ThumbarButton>& buttons);
|
||||||
|
bool HandleThumbarButtonEvent(int button_id);
|
||||||
|
|
||||||
|
private:
|
||||||
|
using ThumbarButtonClickedCallbackMap = std::map<
|
||||||
|
int, ThumbarButtonClickedCallback>;
|
||||||
|
ThumbarButtonClickedCallbackMap thumbar_button_clicked_callback_map_;
|
||||||
|
|
||||||
|
bool is_initialized_;
|
||||||
|
|
||||||
|
HWND window_;
|
||||||
|
|
||||||
|
DISALLOW_COPY_AND_ASSIGN(ThumbarHost);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace atom
|
||||||
|
|
||||||
|
#endif // ATOM_BROWSER_UI_WIN_THUMBAR_HOST_H_
|
|
@ -119,6 +119,8 @@
|
||||||
'atom/browser/atom_browser_main_parts.h',
|
'atom/browser/atom_browser_main_parts.h',
|
||||||
'atom/browser/atom_browser_main_parts_linux.cc',
|
'atom/browser/atom_browser_main_parts_linux.cc',
|
||||||
'atom/browser/atom_browser_main_parts_mac.mm',
|
'atom/browser/atom_browser_main_parts_mac.mm',
|
||||||
|
"atom/browser/atom_desktop_window_tree_host_win.cc",
|
||||||
|
"atom/browser/atom_desktop_window_tree_host_win.h",
|
||||||
'atom/browser/atom_javascript_dialog_manager.cc',
|
'atom/browser/atom_javascript_dialog_manager.cc',
|
||||||
'atom/browser/atom_javascript_dialog_manager.h',
|
'atom/browser/atom_javascript_dialog_manager.h',
|
||||||
'atom/browser/atom_quota_permission_context.cc',
|
'atom/browser/atom_quota_permission_context.cc',
|
||||||
|
@ -206,6 +208,8 @@
|
||||||
'atom/browser/ui/win/notify_icon_host.h',
|
'atom/browser/ui/win/notify_icon_host.h',
|
||||||
'atom/browser/ui/win/notify_icon.cc',
|
'atom/browser/ui/win/notify_icon.cc',
|
||||||
'atom/browser/ui/win/notify_icon.h',
|
'atom/browser/ui/win/notify_icon.h',
|
||||||
|
'atom/browser/ui/win/thumbar_host.cc',
|
||||||
|
'atom/browser/ui/win/thumbar_host.h',
|
||||||
'atom/browser/ui/x/window_state_watcher.cc',
|
'atom/browser/ui/x/window_state_watcher.cc',
|
||||||
'atom/browser/ui/x/window_state_watcher.h',
|
'atom/browser/ui/x/window_state_watcher.h',
|
||||||
'atom/browser/ui/x/x_window_utils.cc',
|
'atom/browser/ui/x/x_window_utils.cc',
|
||||||
|
|
Loading…
Reference in a new issue