taskbar_host.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. // Copyright (c) 2015 GitHub, Inc.
  2. // Use of this source code is governed by the MIT license that can be
  3. // found in the LICENSE file.
  4. #ifndef ATOM_BROWSER_UI_WIN_TASKBAR_HOST_H_
  5. #define ATOM_BROWSER_UI_WIN_TASKBAR_HOST_H_
  6. #include <shobjidl.h>
  7. #include <map>
  8. #include <string>
  9. #include <vector>
  10. #include "atom/browser/native_window.h"
  11. #include "base/callback.h"
  12. #include "base/win/scoped_comptr.h"
  13. #include "ui/gfx/geometry/rect.h"
  14. #include "ui/gfx/image/image.h"
  15. namespace atom {
  16. class TaskbarHost {
  17. public:
  18. struct ThumbarButton {
  19. std::string tooltip;
  20. gfx::Image icon;
  21. std::vector<std::string> flags;
  22. base::Closure clicked_callback;
  23. };
  24. TaskbarHost();
  25. virtual ~TaskbarHost();
  26. // Add or update the buttons in thumbar.
  27. bool SetThumbarButtons(HWND window,
  28. const std::vector<ThumbarButton>& buttons);
  29. void RestoreThumbarButtons(HWND window);
  30. // Set the progress state in taskbar.
  31. bool SetProgressBar(HWND window,
  32. double value,
  33. const NativeWindow::ProgressState state);
  34. // Set the overlay icon in taskbar.
  35. bool SetOverlayIcon(HWND window,
  36. const gfx::Image& overlay,
  37. const std::string& text);
  38. // Set the region of the window to show as a thumbnail in taskbar.
  39. bool SetThumbnailClip(HWND window, const gfx::Rect& region);
  40. // Set the tooltip for the thumbnail in taskbar.
  41. bool SetThumbnailToolTip(HWND window, const std::string& tooltip);
  42. // Called by the window that there is a button in thumbar clicked.
  43. bool HandleThumbarButtonEvent(int button_id);
  44. private:
  45. // Initialize the taskbar object.
  46. bool InitializeTaskbar();
  47. using CallbackMap = std::map<int, base::Closure>;
  48. CallbackMap callback_map_;
  49. std::vector<ThumbarButton> last_buttons_;
  50. // The COM object of taskbar.
  51. base::win::ScopedComPtr<ITaskbarList3> taskbar_;
  52. // Whether we have already added the buttons to thumbar.
  53. bool thumbar_buttons_added_ = false;
  54. DISALLOW_COPY_AND_ASSIGN(TaskbarHost);
  55. };
  56. } // namespace atom
  57. #endif // ATOM_BROWSER_UI_WIN_TASKBAR_HOST_H_