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"
|
||||
|
||||
#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> {
|
||||
struct Converter<atom::NativeWindow::ThumbarButton> {
|
||||
static bool FromV8(v8::Isolate* isolate, v8::Handle<v8::Value> val,
|
||||
atom::ThumbarHost::ThumbarButton* out) {
|
||||
atom::NativeWindow::ThumbarButton* out) {
|
||||
mate::Dictionary dict;
|
||||
if (!ConvertFromV8(isolate, val, &dict))
|
||||
return false;
|
||||
|
@ -40,7 +35,6 @@ struct Converter<atom::ThumbarHost::ThumbarButton> {
|
|||
return dict.Get("icon", &(out->icon));
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
} // namespace mate
|
||||
|
||||
|
@ -437,12 +431,10 @@ void Window::SetOverlayIcon(const gfx::Image& overlay,
|
|||
window_->SetOverlayIcon(overlay, description);
|
||||
}
|
||||
|
||||
#if defined(OS_WIN)
|
||||
void Window::SetThumbarButtons(
|
||||
const std::vector<ThumbarHost::ThumbarButton>& buttons) {
|
||||
const std::vector<NativeWindow::ThumbarButton>& buttons) {
|
||||
window_->SetThumbarButtons(buttons);
|
||||
}
|
||||
#endif
|
||||
|
||||
void Window::SetMenu(v8::Isolate* isolate, v8::Local<v8::Value> value) {
|
||||
mate::Handle<Menu> menu;
|
||||
|
@ -569,9 +561,7 @@ void Window::BuildPrototype(v8::Isolate* isolate,
|
|||
.SetMethod("capturePage", &Window::CapturePage)
|
||||
.SetMethod("setProgressBar", &Window::SetProgressBar)
|
||||
.SetMethod("setOverlayIcon", &Window::SetOverlayIcon)
|
||||
#if defined(OS_WIN)
|
||||
.SetMethod("setThumbarButtons", &Window::SetThumbarButtons)
|
||||
#endif
|
||||
.SetMethod("setMenu", &Window::SetMenu)
|
||||
.SetMethod("setAutoHideMenuBar", &Window::SetAutoHideMenuBar)
|
||||
.SetMethod("isMenuBarAutoHide", &Window::IsMenuBarAutoHide)
|
||||
|
|
|
@ -11,13 +11,10 @@
|
|||
#include "base/memory/scoped_ptr.h"
|
||||
#include "ui/gfx/image/image.h"
|
||||
#include "atom/browser/api/trackable_object.h"
|
||||
#include "atom/browser/native_window.h"
|
||||
#include "atom/browser/native_window_observer.h"
|
||||
#include "native_mate/handle.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include "atom/browser/ui/win/thumbar_host.h"
|
||||
#endif
|
||||
|
||||
class GURL;
|
||||
|
||||
namespace gfx {
|
||||
|
@ -133,10 +130,8 @@ class Window : public mate::TrackableObject<Window>,
|
|||
void SetProgressBar(double progress);
|
||||
void SetOverlayIcon(const gfx::Image& overlay,
|
||||
const std::string& description);
|
||||
#if defined(OS_WIN)
|
||||
void SetThumbarButtons(
|
||||
const std::vector<ThumbarHost::ThumbarButton>& buttons);
|
||||
#endif
|
||||
const std::vector<NativeWindow::ThumbarButton>& buttons);
|
||||
void SetMenu(v8::Isolate* isolate, v8::Local<v8::Value> menu);
|
||||
void SetAutoHideMenuBar(bool auto_hide);
|
||||
bool IsMenuBarAutoHide();
|
||||
|
|
|
@ -277,6 +277,11 @@ bool NativeWindow::HasModalDialog() {
|
|||
return has_dialog_attached_;
|
||||
}
|
||||
|
||||
bool NativeWindow::SetThumbarButtons(
|
||||
const std::vector<ThumbarButton>& buttons) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void NativeWindow::FocusOnWebView() {
|
||||
web_contents()->GetRenderViewHost()->Focus();
|
||||
}
|
||||
|
|
|
@ -23,10 +23,6 @@
|
|||
#include "ui/gfx/image/image.h"
|
||||
#include "ui/gfx/image/image_skia.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include "atom/browser/ui/win/thumbar_host.h"
|
||||
#endif
|
||||
|
||||
class SkRegion;
|
||||
|
||||
namespace base {
|
||||
|
@ -63,7 +59,15 @@ struct DraggableRegion;
|
|||
class NativeWindow : public content::WebContentsObserver,
|
||||
public brightray::InspectableWebContentsViewDelegate {
|
||||
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 {
|
||||
public:
|
||||
|
@ -148,10 +152,8 @@ class NativeWindow : public content::WebContentsObserver,
|
|||
const std::string& description) = 0;
|
||||
virtual void SetVisibleOnAllWorkspaces(bool visible) = 0;
|
||||
virtual bool IsVisibleOnAllWorkspaces() = 0;
|
||||
#if defined(OS_WIN)
|
||||
virtual bool SetThumbarButtons(
|
||||
const std::vector<ThumbarHost::ThumbarButton>& buttons) = 0;
|
||||
#endif
|
||||
const std::vector<ThumbarButton>& buttons);
|
||||
|
||||
virtual bool IsClosed() const { return is_closed_; }
|
||||
|
||||
|
|
|
@ -717,17 +717,17 @@ bool NativeWindowViews::IsVisibleOnAllWorkspaces() {
|
|||
return false;
|
||||
}
|
||||
|
||||
#if defined(OS_WIN)
|
||||
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_) {
|
||||
return atom_desktop_window_tree_host_win_->SetThumbarButtons(
|
||||
views::HWNDForNativeWindow(window_->GetNativeWindow()),
|
||||
buttons);
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
gfx::AcceleratedWidget NativeWindowViews::GetAcceleratedWidget() {
|
||||
return GetNativeWindow()->GetHost()->GetAcceleratedWidget();
|
||||
|
|
|
@ -82,10 +82,8 @@ class NativeWindowViews : public NativeWindow,
|
|||
bool IsMenuBarVisible() override;
|
||||
void SetVisibleOnAllWorkspaces(bool visible) override;
|
||||
bool IsVisibleOnAllWorkspaces() override;
|
||||
#if defined(OS_WIN)
|
||||
bool SetThumbarButtons(
|
||||
const std::vector<ThumbarHost::ThumbarButton>& buttons) override;
|
||||
#endif
|
||||
const std::vector<NativeWindow::ThumbarButton>& buttons) override;
|
||||
|
||||
gfx::AcceleratedWidget GetAcceleratedWidget();
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <shobjidl.h>
|
||||
|
||||
#include "atom/browser/native_window.h"
|
||||
#include "atom/browser/ui/win/thumbar_host.h"
|
||||
|
||||
namespace atom {
|
||||
|
@ -22,7 +23,7 @@ AtomDesktopWindowTreeHostWin::~AtomDesktopWindowTreeHostWin() {
|
|||
|
||||
bool AtomDesktopWindowTreeHostWin::SetThumbarButtons(
|
||||
HWND window,
|
||||
const std::vector<ThumbarHost::ThumbarButton>& buttons) {
|
||||
const std::vector<NativeWindow::ThumbarButton>& buttons) {
|
||||
if (!thumbar_host_.get()) {
|
||||
thumbar_host_.reset(new ThumbarHost(window));
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include <vector>
|
||||
|
||||
#include "atom/browser/native_window.h"
|
||||
#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"
|
||||
|
@ -24,7 +25,7 @@ class AtomDesktopWindowTreeHostWin : public views::DesktopWindowTreeHostWin {
|
|||
|
||||
bool SetThumbarButtons(
|
||||
HWND window,
|
||||
const std::vector<ThumbarHost::ThumbarButton>& buttons);
|
||||
const std::vector<NativeWindow::ThumbarButton>& buttons);
|
||||
|
||||
protected:
|
||||
bool PreHandleMSG(UINT message,
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
|
||||
#include <shobjidl.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "base/win/scoped_comptr.h"
|
||||
#include "base/win/win_util.h"
|
||||
#include "base/win/wrapped_window_proc.h"
|
||||
|
@ -64,7 +66,7 @@ ThumbarHost::~ThumbarHost() {
|
|||
}
|
||||
|
||||
bool ThumbarHost::SetThumbarButtons(
|
||||
const std::vector<ThumbarHost::ThumbarButton>& buttons) {
|
||||
const std::vector<atom::NativeWindow::ThumbarButton>& buttons) {
|
||||
if (buttons.size() > kMaxButtonsCount)
|
||||
return false;
|
||||
|
||||
|
@ -112,7 +114,7 @@ bool ThumbarHost::SetThumbarButtons(
|
|||
if (!is_initialized_) {
|
||||
is_initialized_ = true;
|
||||
is_success = taskbar->ThumbBarAddButtons(
|
||||
window_, kMaxButtonsCount, thumb_buttons) == S_OK;
|
||||
window_, buttons.size(), thumb_buttons) == S_OK;
|
||||
} else {
|
||||
is_success = taskbar->ThumbBarUpdateButtons(
|
||||
window_, kMaxButtonsCount, thumb_buttons) == S_OK;
|
||||
|
|
|
@ -8,35 +8,24 @@
|
|||
#include <windows.h>
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "base/callback.h"
|
||||
#include "ui/gfx/image/image.h"
|
||||
#include "atom/browser/native_window.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
class ThumbarHost {
|
||||
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);
|
||||
~ThumbarHost();
|
||||
|
||||
bool SetThumbarButtons(
|
||||
const std::vector<ThumbarHost::ThumbarButton>& buttons);
|
||||
const std::vector<NativeWindow::ThumbarButton>& buttons);
|
||||
bool HandleThumbarButtonEvent(int button_id);
|
||||
|
||||
private:
|
||||
using ThumbarButtonClickedCallbackMap = std::map<
|
||||
int, ThumbarButtonClickedCallback>;
|
||||
int, NativeWindow::ThumbarButtonClickedCallback>;
|
||||
ThumbarButtonClickedCallbackMap thumbar_button_clicked_callback_map_;
|
||||
|
||||
bool is_initialized_;
|
||||
|
|
Loading…
Reference in a new issue