2014-10-31 11:17:05 -07:00
|
|
|
// Copyright (c) 2014 GitHub, Inc.
|
2014-05-30 10:31:27 +08:00
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#ifndef ATOM_BROWSER_UI_TRAY_ICON_H_
|
|
|
|
#define ATOM_BROWSER_UI_TRAY_ICON_H_
|
|
|
|
|
|
|
|
#include <string>
|
2015-07-19 12:12:28 +08:00
|
|
|
#include <vector>
|
2014-05-30 10:31:27 +08:00
|
|
|
|
2016-07-02 11:47:40 +09:00
|
|
|
#include "atom/browser/ui/atom_menu_model.h"
|
2014-06-02 11:08:29 +08:00
|
|
|
#include "atom/browser/ui/tray_icon_observer.h"
|
|
|
|
#include "base/observer_list.h"
|
2015-05-04 11:43:05 +08:00
|
|
|
#include "ui/gfx/geometry/rect.h"
|
2014-05-30 10:31:27 +08:00
|
|
|
|
|
|
|
namespace atom {
|
|
|
|
|
|
|
|
class TrayIcon {
|
|
|
|
public:
|
|
|
|
static TrayIcon* Create();
|
|
|
|
|
2016-05-20 16:55:22 +09:00
|
|
|
#if defined(OS_WIN)
|
|
|
|
using ImageType = HICON;
|
|
|
|
#else
|
|
|
|
using ImageType = const gfx::Image&;
|
|
|
|
#endif
|
|
|
|
|
2014-05-30 23:57:54 +08:00
|
|
|
virtual ~TrayIcon();
|
|
|
|
|
2014-05-30 10:31:27 +08:00
|
|
|
// Sets the image associated with this status icon.
|
2016-05-20 16:55:22 +09:00
|
|
|
virtual void SetImage(ImageType image) = 0;
|
2014-05-30 10:31:27 +08:00
|
|
|
|
|
|
|
// Sets the image associated with this status icon when pressed.
|
2016-05-20 16:55:22 +09:00
|
|
|
virtual void SetPressedImage(ImageType image);
|
2014-05-30 10:31:27 +08:00
|
|
|
|
|
|
|
// Sets the hover text for this status icon. This is also used as the label
|
|
|
|
// for the menu item which is created as a replacement for the status icon
|
|
|
|
// click action on platforms that do not support custom click actions for the
|
|
|
|
// status icon (e.g. Ubuntu Unity).
|
|
|
|
virtual void SetToolTip(const std::string& tool_tip) = 0;
|
|
|
|
|
2014-09-09 19:33:58 +08:00
|
|
|
// Sets the title displayed aside of the status icon in the status bar. This
|
2016-06-18 15:26:26 +02:00
|
|
|
// only works on macOS.
|
2014-09-09 19:33:58 +08:00
|
|
|
virtual void SetTitle(const std::string& title);
|
|
|
|
|
2016-07-26 13:51:43 -07:00
|
|
|
// Sets the status icon highlight mode. This only works on macOS.
|
|
|
|
enum HighlightMode {
|
|
|
|
ALWAYS, // Always highlight the tray icon
|
|
|
|
NEVER, // Never highlight the tray icon
|
|
|
|
SELECTION // Highlight the tray icon when clicked or the menu is opened
|
|
|
|
};
|
|
|
|
virtual void SetHighlightMode(HighlightMode mode);
|
2014-09-09 19:39:39 +08:00
|
|
|
|
2014-11-28 18:30:43 +08:00
|
|
|
// Displays a notification balloon with the specified contents.
|
|
|
|
// Depending on the platform it might not appear by the icon tray.
|
2016-05-20 16:55:22 +09:00
|
|
|
virtual void DisplayBalloon(ImageType icon,
|
2014-11-28 18:30:43 +08:00
|
|
|
const base::string16& title,
|
|
|
|
const base::string16& contents);
|
|
|
|
|
2015-12-02 18:43:11 +08:00
|
|
|
// Popups the menu.
|
|
|
|
virtual void PopUpContextMenu(const gfx::Point& pos,
|
2016-07-02 11:47:40 +09:00
|
|
|
AtomMenuModel* menu_model);
|
2015-07-16 10:50:53 +08:00
|
|
|
|
2014-05-30 10:31:27 +08:00
|
|
|
// Set the context menu for this icon.
|
2016-07-02 11:47:40 +09:00
|
|
|
virtual void SetContextMenu(AtomMenuModel* menu_model) = 0;
|
2014-05-30 10:31:27 +08:00
|
|
|
|
2016-06-21 15:40:30 +09:00
|
|
|
// Returns the bounds of tray icon.
|
|
|
|
virtual gfx::Rect GetBounds();
|
|
|
|
|
2014-06-02 11:08:29 +08:00
|
|
|
void AddObserver(TrayIconObserver* obs) { observers_.AddObserver(obs); }
|
|
|
|
void RemoveObserver(TrayIconObserver* obs) { observers_.RemoveObserver(obs); }
|
2016-06-21 15:40:30 +09:00
|
|
|
|
2017-10-05 11:49:26 +09:00
|
|
|
void NotifyClicked(const gfx::Rect& = gfx::Rect(),
|
|
|
|
const gfx::Point& location = gfx::Point(),
|
|
|
|
int modifiers = 0);
|
2015-07-27 03:15:51 -07:00
|
|
|
void NotifyDoubleClicked(const gfx::Rect& = gfx::Rect(), int modifiers = 0);
|
2014-11-28 19:42:57 +08:00
|
|
|
void NotifyBalloonShow();
|
2014-11-28 18:50:31 +08:00
|
|
|
void NotifyBalloonClicked();
|
2014-11-28 19:42:57 +08:00
|
|
|
void NotifyBalloonClosed();
|
2015-07-27 03:15:51 -07:00
|
|
|
void NotifyRightClicked(const gfx::Rect& bounds = gfx::Rect(),
|
2015-07-29 12:01:27 +08:00
|
|
|
int modifiers = 0);
|
2015-11-10 10:02:50 -06:00
|
|
|
void NotifyDrop();
|
2015-10-18 00:32:13 -05:00
|
|
|
void NotifyDropFiles(const std::vector<std::string>& files);
|
2016-07-14 18:21:39 +01:00
|
|
|
void NotifyDropText(const std::string& text);
|
2015-11-05 19:02:24 -06:00
|
|
|
void NotifyDragEntered();
|
|
|
|
void NotifyDragExited();
|
2015-11-10 10:02:50 -06:00
|
|
|
void NotifyDragEnded();
|
2017-06-28 12:09:12 -07:00
|
|
|
void NotifyMouseEntered(const gfx::Point& location = gfx::Point(),
|
|
|
|
int modifiers = 0);
|
|
|
|
void NotifyMouseExited(const gfx::Point& location = gfx::Point(),
|
|
|
|
int modifiers = 0);
|
2017-08-26 14:04:58 -04:00
|
|
|
void NotifyMouseMoved(const gfx::Point& location = gfx::Point(),
|
|
|
|
int modifiers = 0);
|
2014-06-02 11:08:29 +08:00
|
|
|
|
2014-05-30 10:31:27 +08:00
|
|
|
protected:
|
|
|
|
TrayIcon();
|
|
|
|
|
|
|
|
private:
|
2015-09-02 15:16:49 +08:00
|
|
|
base::ObserverList<TrayIconObserver> observers_;
|
2014-06-02 11:08:29 +08:00
|
|
|
|
2014-05-30 10:31:27 +08:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(TrayIcon);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace atom
|
|
|
|
|
|
|
|
#endif // ATOM_BROWSER_UI_TRAY_ICON_H_
|