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
|
@ -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…
Add table
Add a link
Reference in a new issue