2015-08-02 03:11:29 +00:00
|
|
|
// Copyright (c) 2015 GitHub, Inc.
|
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2015-08-06 02:30:22 +00:00
|
|
|
#ifndef ATOM_BROWSER_UI_WIN_TASKBAR_HOST_H_
|
|
|
|
#define ATOM_BROWSER_UI_WIN_TASKBAR_HOST_H_
|
2015-08-02 03:11:29 +00:00
|
|
|
|
2015-08-06 04:58:40 +00:00
|
|
|
#include <shobjidl.h>
|
2015-08-02 03:11:29 +00:00
|
|
|
|
|
|
|
#include <map>
|
2015-08-06 04:44:07 +00:00
|
|
|
#include <string>
|
2015-08-02 03:11:29 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2016-08-26 22:30:02 +00:00
|
|
|
#include "atom/browser/native_window.h"
|
2015-08-06 03:10:34 +00:00
|
|
|
#include "base/callback.h"
|
2015-08-06 04:58:40 +00:00
|
|
|
#include "base/win/scoped_comptr.h"
|
2016-07-14 20:27:16 +00:00
|
|
|
#include "ui/gfx/geometry/rect.h"
|
2015-08-06 03:10:34 +00:00
|
|
|
#include "ui/gfx/image/image.h"
|
2015-08-02 03:11:29 +00:00
|
|
|
|
|
|
|
namespace atom {
|
|
|
|
|
2015-08-06 02:30:22 +00:00
|
|
|
class TaskbarHost {
|
2015-08-02 03:11:29 +00:00
|
|
|
public:
|
2015-08-06 03:10:34 +00:00
|
|
|
struct ThumbarButton {
|
|
|
|
std::string tooltip;
|
|
|
|
gfx::Image icon;
|
|
|
|
std::vector<std::string> flags;
|
|
|
|
base::Closure clicked_callback;
|
|
|
|
};
|
|
|
|
|
|
|
|
TaskbarHost();
|
|
|
|
virtual ~TaskbarHost();
|
2015-08-02 03:11:29 +00:00
|
|
|
|
2015-08-06 04:54:00 +00:00
|
|
|
// Add or update the buttons in thumbar.
|
2015-08-02 03:11:29 +00:00
|
|
|
bool SetThumbarButtons(
|
2015-08-06 03:10:34 +00:00
|
|
|
HWND window, const std::vector<ThumbarButton>& buttons);
|
2015-08-06 04:44:07 +00:00
|
|
|
|
2016-08-12 15:55:42 +00:00
|
|
|
void RestoreThumbarButtons(HWND window);
|
|
|
|
|
2015-08-06 05:07:00 +00:00
|
|
|
// Set the progress state in taskbar.
|
2016-08-09 23:05:44 +00:00
|
|
|
bool SetProgressBar(
|
|
|
|
HWND window, double value, const NativeWindow::ProgressState state);
|
2015-08-06 04:54:00 +00:00
|
|
|
|
2015-08-06 05:07:00 +00:00
|
|
|
// Set the overlay icon in taskbar.
|
|
|
|
bool SetOverlayIcon(
|
|
|
|
HWND window, const gfx::Image& overlay, const std::string& text);
|
|
|
|
|
2016-07-14 20:27:16 +00:00
|
|
|
// Set the region of the window to show as a thumbnail in taskbar.
|
2016-08-07 17:23:42 +00:00
|
|
|
bool SetThumbnailClip(HWND window, const gfx::Rect& region);
|
|
|
|
|
|
|
|
// Set the tooltip for the thumbnail in taskbar.
|
|
|
|
bool SetThumbnailToolTip(HWND window, const std::string& tooltip);
|
2016-07-14 20:27:16 +00:00
|
|
|
|
2015-08-06 04:44:07 +00:00
|
|
|
// Called by the window that there is a button in thumbar clicked.
|
2015-08-02 03:11:29 +00:00
|
|
|
bool HandleThumbarButtonEvent(int button_id);
|
|
|
|
|
|
|
|
private:
|
2016-06-09 05:21:21 +00:00
|
|
|
// Initialize the taskbar object.
|
|
|
|
bool InitializeTaskbar();
|
2015-08-06 04:58:40 +00:00
|
|
|
|
2015-08-06 04:44:07 +00:00
|
|
|
using CallbackMap = std::map<int, base::Closure>;
|
|
|
|
CallbackMap callback_map_;
|
2015-08-02 03:11:29 +00:00
|
|
|
|
2016-08-12 15:55:42 +00:00
|
|
|
std::vector<ThumbarButton> last_buttons_;
|
|
|
|
|
2015-08-06 04:58:40 +00:00
|
|
|
// The COM object of taskbar.
|
|
|
|
base::win::ScopedComPtr<ITaskbarList3> taskbar_;
|
|
|
|
|
2015-08-06 04:44:07 +00:00
|
|
|
// Whether we have already added the buttons to thumbar.
|
|
|
|
bool thumbar_buttons_added_;
|
2015-08-02 03:11:29 +00:00
|
|
|
|
2015-08-06 02:30:22 +00:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(TaskbarHost);
|
2015-08-02 03:11:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace atom
|
|
|
|
|
2015-08-06 02:30:22 +00:00
|
|
|
#endif // ATOM_BROWSER_UI_WIN_TASKBAR_HOST_H_
|