Expose NativeWindow.setThumbarButtons API to all platforms.
This commit is contained in:
parent
78eac4116c
commit
2f1cb8b52a
10 changed files with 35 additions and 52 deletions
|
@ -20,17 +20,12 @@
|
||||||
|
|
||||||
#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 {
|
namespace mate {
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
|
||||||
template<>
|
template<>
|
||||||
struct Converter<atom::ThumbarHost::ThumbarButton> {
|
struct Converter<atom::NativeWindow::ThumbarButton> {
|
||||||
static bool FromV8(v8::Isolate* isolate, v8::Handle<v8::Value> val,
|
static bool FromV8(v8::Isolate* isolate, v8::Handle<v8::Value> val,
|
||||||
atom::ThumbarHost::ThumbarButton* out) {
|
atom::NativeWindow::ThumbarButton* out) {
|
||||||
mate::Dictionary dict;
|
mate::Dictionary dict;
|
||||||
if (!ConvertFromV8(isolate, val, &dict))
|
if (!ConvertFromV8(isolate, val, &dict))
|
||||||
return false;
|
return false;
|
||||||
|
@ -40,7 +35,6 @@ struct Converter<atom::ThumbarHost::ThumbarButton> {
|
||||||
return dict.Get("icon", &(out->icon));
|
return dict.Get("icon", &(out->icon));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
|
||||||
} // namespace mate
|
} // namespace mate
|
||||||
|
|
||||||
|
@ -437,12 +431,10 @@ void Window::SetOverlayIcon(const gfx::Image& overlay,
|
||||||
window_->SetOverlayIcon(overlay, description);
|
window_->SetOverlayIcon(overlay, description);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
|
||||||
void Window::SetThumbarButtons(
|
void Window::SetThumbarButtons(
|
||||||
const std::vector<ThumbarHost::ThumbarButton>& buttons) {
|
const std::vector<NativeWindow::ThumbarButton>& buttons) {
|
||||||
window_->SetThumbarButtons(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;
|
||||||
|
@ -569,9 +561,7 @@ 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)
|
.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)
|
||||||
|
|
|
@ -11,13 +11,10 @@
|
||||||
#include "base/memory/scoped_ptr.h"
|
#include "base/memory/scoped_ptr.h"
|
||||||
#include "ui/gfx/image/image.h"
|
#include "ui/gfx/image/image.h"
|
||||||
#include "atom/browser/api/trackable_object.h"
|
#include "atom/browser/api/trackable_object.h"
|
||||||
|
#include "atom/browser/native_window.h"
|
||||||
#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 {
|
||||||
|
@ -133,10 +130,8 @@ 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(
|
void SetThumbarButtons(
|
||||||
const std::vector<ThumbarHost::ThumbarButton>& buttons);
|
const std::vector<NativeWindow::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();
|
||||||
|
|
|
@ -277,6 +277,11 @@ bool NativeWindow::HasModalDialog() {
|
||||||
return has_dialog_attached_;
|
return has_dialog_attached_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool NativeWindow::SetThumbarButtons(
|
||||||
|
const std::vector<ThumbarButton>& buttons) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void NativeWindow::FocusOnWebView() {
|
void NativeWindow::FocusOnWebView() {
|
||||||
web_contents()->GetRenderViewHost()->Focus();
|
web_contents()->GetRenderViewHost()->Focus();
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,10 +23,6 @@
|
||||||
#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 {
|
||||||
|
@ -63,7 +59,15 @@ struct DraggableRegion;
|
||||||
class NativeWindow : public content::WebContentsObserver,
|
class NativeWindow : public content::WebContentsObserver,
|
||||||
public brightray::InspectableWebContentsViewDelegate {
|
public brightray::InspectableWebContentsViewDelegate {
|
||||||
public:
|
public:
|
||||||
typedef base::Callback<void(const SkBitmap& bitmap)> CapturePageCallback;
|
using CapturePageCallback = base::Callback<void(const SkBitmap& bitmap)>;
|
||||||
|
using ThumbarButtonClickedCallback = base::Closure;
|
||||||
|
|
||||||
|
struct ThumbarButton {
|
||||||
|
std::string tooltip;
|
||||||
|
gfx::Image icon;
|
||||||
|
std::vector<std::string> flags;
|
||||||
|
ThumbarButtonClickedCallback clicked_callback;
|
||||||
|
};
|
||||||
|
|
||||||
class DialogScope {
|
class DialogScope {
|
||||||
public:
|
public:
|
||||||
|
@ -148,10 +152,8 @@ 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(
|
virtual bool SetThumbarButtons(
|
||||||
const std::vector<ThumbarHost::ThumbarButton>& buttons) = 0;
|
const std::vector<ThumbarButton>& buttons);
|
||||||
#endif
|
|
||||||
|
|
||||||
virtual bool IsClosed() const { return is_closed_; }
|
virtual bool IsClosed() const { return is_closed_; }
|
||||||
|
|
||||||
|
|
|
@ -717,17 +717,17 @@ bool NativeWindowViews::IsVisibleOnAllWorkspaces() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
|
||||||
bool NativeWindowViews::SetThumbarButtons(
|
bool NativeWindowViews::SetThumbarButtons(
|
||||||
const std::vector<ThumbarHost::ThumbarButton>& buttons) {
|
const std::vector<NativeWindow::ThumbarButton>& buttons) {
|
||||||
|
#if defined(OS_WIN)
|
||||||
if (atom_desktop_window_tree_host_win_) {
|
if (atom_desktop_window_tree_host_win_) {
|
||||||
return atom_desktop_window_tree_host_win_->SetThumbarButtons(
|
return atom_desktop_window_tree_host_win_->SetThumbarButtons(
|
||||||
views::HWNDForNativeWindow(window_->GetNativeWindow()),
|
views::HWNDForNativeWindow(window_->GetNativeWindow()),
|
||||||
buttons);
|
buttons);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
gfx::AcceleratedWidget NativeWindowViews::GetAcceleratedWidget() {
|
gfx::AcceleratedWidget NativeWindowViews::GetAcceleratedWidget() {
|
||||||
return GetNativeWindow()->GetHost()->GetAcceleratedWidget();
|
return GetNativeWindow()->GetHost()->GetAcceleratedWidget();
|
||||||
|
|
|
@ -82,10 +82,8 @@ 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(
|
bool SetThumbarButtons(
|
||||||
const std::vector<ThumbarHost::ThumbarButton>& buttons) override;
|
const std::vector<NativeWindow::ThumbarButton>& buttons) override;
|
||||||
#endif
|
|
||||||
|
|
||||||
gfx::AcceleratedWidget GetAcceleratedWidget();
|
gfx::AcceleratedWidget GetAcceleratedWidget();
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include <shobjidl.h>
|
#include <shobjidl.h>
|
||||||
|
|
||||||
|
#include "atom/browser/native_window.h"
|
||||||
#include "atom/browser/ui/win/thumbar_host.h"
|
#include "atom/browser/ui/win/thumbar_host.h"
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
@ -22,7 +23,7 @@ AtomDesktopWindowTreeHostWin::~AtomDesktopWindowTreeHostWin() {
|
||||||
|
|
||||||
bool AtomDesktopWindowTreeHostWin::SetThumbarButtons(
|
bool AtomDesktopWindowTreeHostWin::SetThumbarButtons(
|
||||||
HWND window,
|
HWND window,
|
||||||
const std::vector<ThumbarHost::ThumbarButton>& buttons) {
|
const std::vector<NativeWindow::ThumbarButton>& buttons) {
|
||||||
if (!thumbar_host_.get()) {
|
if (!thumbar_host_.get()) {
|
||||||
thumbar_host_.reset(new ThumbarHost(window));
|
thumbar_host_.reset(new ThumbarHost(window));
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "atom/browser/native_window.h"
|
||||||
#include "atom/browser/ui/win/thumbar_host.h"
|
#include "atom/browser/ui/win/thumbar_host.h"
|
||||||
#include "base/memory/scoped_ptr.h"
|
#include "base/memory/scoped_ptr.h"
|
||||||
#include "ui/views/widget/desktop_aura/desktop_window_tree_host_win.h"
|
#include "ui/views/widget/desktop_aura/desktop_window_tree_host_win.h"
|
||||||
|
@ -24,7 +25,7 @@ class AtomDesktopWindowTreeHostWin : public views::DesktopWindowTreeHostWin {
|
||||||
|
|
||||||
bool SetThumbarButtons(
|
bool SetThumbarButtons(
|
||||||
HWND window,
|
HWND window,
|
||||||
const std::vector<ThumbarHost::ThumbarButton>& buttons);
|
const std::vector<NativeWindow::ThumbarButton>& buttons);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool PreHandleMSG(UINT message,
|
bool PreHandleMSG(UINT message,
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
|
|
||||||
#include <shobjidl.h>
|
#include <shobjidl.h>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "base/win/scoped_comptr.h"
|
#include "base/win/scoped_comptr.h"
|
||||||
#include "base/win/win_util.h"
|
#include "base/win/win_util.h"
|
||||||
#include "base/win/wrapped_window_proc.h"
|
#include "base/win/wrapped_window_proc.h"
|
||||||
|
@ -64,7 +66,7 @@ ThumbarHost::~ThumbarHost() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ThumbarHost::SetThumbarButtons(
|
bool ThumbarHost::SetThumbarButtons(
|
||||||
const std::vector<ThumbarHost::ThumbarButton>& buttons) {
|
const std::vector<atom::NativeWindow::ThumbarButton>& buttons) {
|
||||||
if (buttons.size() > kMaxButtonsCount)
|
if (buttons.size() > kMaxButtonsCount)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -112,7 +114,7 @@ bool ThumbarHost::SetThumbarButtons(
|
||||||
if (!is_initialized_) {
|
if (!is_initialized_) {
|
||||||
is_initialized_ = true;
|
is_initialized_ = true;
|
||||||
is_success = taskbar->ThumbBarAddButtons(
|
is_success = taskbar->ThumbBarAddButtons(
|
||||||
window_, kMaxButtonsCount, thumb_buttons) == S_OK;
|
window_, buttons.size(), thumb_buttons) == S_OK;
|
||||||
} else {
|
} else {
|
||||||
is_success = taskbar->ThumbBarUpdateButtons(
|
is_success = taskbar->ThumbBarUpdateButtons(
|
||||||
window_, kMaxButtonsCount, thumb_buttons) == S_OK;
|
window_, kMaxButtonsCount, thumb_buttons) == S_OK;
|
||||||
|
|
|
@ -8,35 +8,24 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "base/callback.h"
|
#include "atom/browser/native_window.h"
|
||||||
#include "ui/gfx/image/image.h"
|
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
class ThumbarHost {
|
class ThumbarHost {
|
||||||
public:
|
public:
|
||||||
using ThumbarButtonClickedCallback = base::Closure;
|
|
||||||
|
|
||||||
struct ThumbarButton {
|
|
||||||
std::string tooltip;
|
|
||||||
gfx::Image icon;
|
|
||||||
std::vector<std::string> flags;
|
|
||||||
ThumbarButtonClickedCallback clicked_callback;
|
|
||||||
};
|
|
||||||
|
|
||||||
explicit ThumbarHost(HWND window);
|
explicit ThumbarHost(HWND window);
|
||||||
~ThumbarHost();
|
~ThumbarHost();
|
||||||
|
|
||||||
bool SetThumbarButtons(
|
bool SetThumbarButtons(
|
||||||
const std::vector<ThumbarHost::ThumbarButton>& buttons);
|
const std::vector<NativeWindow::ThumbarButton>& buttons);
|
||||||
bool HandleThumbarButtonEvent(int button_id);
|
bool HandleThumbarButtonEvent(int button_id);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
using ThumbarButtonClickedCallbackMap = std::map<
|
using ThumbarButtonClickedCallbackMap = std::map<
|
||||||
int, ThumbarButtonClickedCallback>;
|
int, NativeWindow::ThumbarButtonClickedCallback>;
|
||||||
ThumbarButtonClickedCallbackMap thumbar_button_clicked_callback_map_;
|
ThumbarButtonClickedCallbackMap thumbar_button_clicked_callback_map_;
|
||||||
|
|
||||||
bool is_initialized_;
|
bool is_initialized_;
|
||||||
|
|
Loading…
Reference in a new issue