2014-10-31 18:17:05 +00:00
|
|
|
// Copyright (c) 2014 GitHub, Inc.
|
2014-05-30 02:31:27 +00: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 04:12:28 +00:00
|
|
|
#include <vector>
|
2014-05-30 02:31:27 +00:00
|
|
|
|
2014-06-02 03:08:29 +00:00
|
|
|
#include "atom/browser/ui/tray_icon_observer.h"
|
|
|
|
#include "base/observer_list.h"
|
2014-05-30 02:31:27 +00:00
|
|
|
#include "ui/base/models/simple_menu_model.h"
|
2015-05-04 03:43:05 +00:00
|
|
|
#include "ui/gfx/geometry/rect.h"
|
2014-05-30 02:31:27 +00:00
|
|
|
|
|
|
|
namespace atom {
|
|
|
|
|
|
|
|
class TrayIcon {
|
|
|
|
public:
|
|
|
|
static TrayIcon* Create();
|
|
|
|
|
2014-05-30 15:57:54 +00:00
|
|
|
virtual ~TrayIcon();
|
|
|
|
|
2014-05-30 02:31:27 +00:00
|
|
|
// Sets the image associated with this status icon.
|
2015-01-03 02:43:56 +00:00
|
|
|
virtual void SetImage(const gfx::Image& image) = 0;
|
2014-05-30 02:31:27 +00:00
|
|
|
|
|
|
|
// Sets the image associated with this status icon when pressed.
|
2015-01-03 02:43:56 +00:00
|
|
|
virtual void SetPressedImage(const gfx::Image& image);
|
2014-05-30 02:31:27 +00: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 11:33:58 +00:00
|
|
|
// Sets the title displayed aside of the status icon in the status bar. This
|
|
|
|
// only works on OS X.
|
|
|
|
virtual void SetTitle(const std::string& title);
|
|
|
|
|
2014-09-09 11:39:39 +00:00
|
|
|
// Sets whether the status icon is highlighted when it is clicked. This only
|
|
|
|
// works on OS X.
|
|
|
|
virtual void SetHighlightMode(bool highlight);
|
|
|
|
|
2014-11-28 10:30:43 +00:00
|
|
|
// Displays a notification balloon with the specified contents.
|
|
|
|
// Depending on the platform it might not appear by the icon tray.
|
2015-01-03 02:43:56 +00:00
|
|
|
virtual void DisplayBalloon(const gfx::Image& icon,
|
2014-11-28 10:30:43 +00:00
|
|
|
const base::string16& title,
|
|
|
|
const base::string16& contents);
|
|
|
|
|
2015-08-10 05:00:15 +00:00
|
|
|
virtual void PopUpContextMenu(const gfx::Point& pos);
|
2015-07-16 02:50:53 +00:00
|
|
|
|
2014-05-30 02:31:27 +00:00
|
|
|
// Set the context menu for this icon.
|
2014-05-30 06:37:53 +00:00
|
|
|
virtual void SetContextMenu(ui::SimpleMenuModel* menu_model) = 0;
|
2014-05-30 02:31:27 +00:00
|
|
|
|
2014-06-02 03:08:29 +00:00
|
|
|
void AddObserver(TrayIconObserver* obs) { observers_.AddObserver(obs); }
|
|
|
|
void RemoveObserver(TrayIconObserver* obs) { observers_.RemoveObserver(obs); }
|
2015-07-27 10:15:51 +00:00
|
|
|
void NotifyClicked(const gfx::Rect& = gfx::Rect(), int modifiers = 0);
|
|
|
|
void NotifyDoubleClicked(const gfx::Rect& = gfx::Rect(), int modifiers = 0);
|
2014-11-28 11:42:57 +00:00
|
|
|
void NotifyBalloonShow();
|
2014-11-28 10:50:31 +00:00
|
|
|
void NotifyBalloonClicked();
|
2014-11-28 11:42:57 +00:00
|
|
|
void NotifyBalloonClosed();
|
2015-07-27 10:15:51 +00:00
|
|
|
void NotifyRightClicked(const gfx::Rect& bounds = gfx::Rect(),
|
2015-07-29 04:01:27 +00:00
|
|
|
int modifiers = 0);
|
2015-11-10 16:02:50 +00:00
|
|
|
void NotifyDrop();
|
2015-10-18 05:32:13 +00:00
|
|
|
void NotifyDropFiles(const std::vector<std::string>& files);
|
2015-11-06 01:02:24 +00:00
|
|
|
void NotifyDragEntered();
|
|
|
|
void NotifyDragExited();
|
2015-11-10 16:02:50 +00:00
|
|
|
void NotifyDragEnded();
|
2014-06-02 03:08:29 +00:00
|
|
|
|
2014-05-30 02:31:27 +00:00
|
|
|
protected:
|
|
|
|
TrayIcon();
|
|
|
|
|
|
|
|
private:
|
2015-09-02 07:16:49 +00:00
|
|
|
base::ObserverList<TrayIconObserver> observers_;
|
2014-06-02 03:08:29 +00:00
|
|
|
|
2014-05-30 02:31:27 +00:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(TrayIcon);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace atom
|
|
|
|
|
|
|
|
#endif // ATOM_BROWSER_UI_TRAY_ICON_H_
|