#include "atom/common/native_mate_converters/string16_converter.h"
#include "native_mate/constructor.h"
#include "native_mate/dictionary.h"
+#include "ui/gfx/image/image.h"
#include "atom/common/node_includes.h"
namespace api {
-Tray::Tray(const gfx::ImageSkia& image)
+Tray::Tray(const gfx::Image& image)
: tray_icon_(TrayIcon::Create()) {
tray_icon_->SetImage(image);
tray_icon_->AddObserver(this);
}
// static
-mate::Wrappable* Tray::New(const gfx::ImageSkia& image) {
+mate::Wrappable* Tray::New(const gfx::Image& image) {
return new Tray(image);
}
tray_icon_.reset();
}
-void Tray::SetImage(mate::Arguments* args, const gfx::ImageSkia& image) {
+void Tray::SetImage(mate::Arguments* args, const gfx::Image& image) {
if (!CheckTrayLife(args))
return;
tray_icon_->SetImage(image);
}
-void Tray::SetPressedImage(mate::Arguments* args, const gfx::ImageSkia& image) {
+void Tray::SetPressedImage(mate::Arguments* args, const gfx::Image& image) {
if (!CheckTrayLife(args))
return;
tray_icon_->SetPressedImage(image);
if (!CheckTrayLife(args))
return;
- gfx::ImageSkia icon;
+ gfx::Image icon;
options.Get("icon", &icon);
base::string16 title, content;
if (!options.Get("title", &title) ||
#include "base/memory/scoped_ptr.h"
namespace gfx {
-class ImageSkia;
+class Image;
}
namespace mate {
class Tray : public mate::EventEmitter,
public TrayIconObserver {
public:
- static mate::Wrappable* New(const gfx::ImageSkia& image);
+ static mate::Wrappable* New(const gfx::Image& image);
static void BuildPrototype(v8::Isolate* isolate,
v8::Handle<v8::ObjectTemplate> prototype);
protected:
- explicit Tray(const gfx::ImageSkia& image);
+ explicit Tray(const gfx::Image& image);
virtual ~Tray();
// TrayIconObserver:
void OnBalloonClosed() override;
void Destroy();
- void SetImage(mate::Arguments* args, const gfx::ImageSkia& image);
- void SetPressedImage(mate::Arguments* args, const gfx::ImageSkia& image);
+ void SetImage(mate::Arguments* args, const gfx::Image& image);
+ void SetPressedImage(mate::Arguments* args, const gfx::Image& image);
void SetToolTip(mate::Arguments* args, const std::string& tool_tip);
void SetTitle(mate::Arguments* args, const std::string& title);
void SetHighlightMode(mate::Arguments* args, bool highlight);
TrayIcon::~TrayIcon() {
}
-void TrayIcon::SetPressedImage(const gfx::ImageSkia& image) {
+void TrayIcon::SetPressedImage(const gfx::Image& image) {
}
void TrayIcon::SetTitle(const std::string& title) {
void TrayIcon::SetHighlightMode(bool highlight) {
}
-void TrayIcon::DisplayBalloon(const gfx::ImageSkia& icon,
+void TrayIcon::DisplayBalloon(const gfx::Image& icon,
const base::string16& title,
const base::string16& contents) {
}
virtual ~TrayIcon();
// Sets the image associated with this status icon.
- virtual void SetImage(const gfx::ImageSkia& image) = 0;
+ virtual void SetImage(const gfx::Image& image) = 0;
// Sets the image associated with this status icon when pressed.
- virtual void SetPressedImage(const gfx::ImageSkia& image);
+ virtual void SetPressedImage(const gfx::Image& image);
// 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
// Displays a notification balloon with the specified contents.
// Depending on the platform it might not appear by the icon tray.
- virtual void DisplayBalloon(const gfx::ImageSkia& icon,
+ virtual void DisplayBalloon(const gfx::Image& icon,
const base::string16& title,
const base::string16& contents);
TrayIconCocoa();
virtual ~TrayIconCocoa();
- virtual void SetImage(const gfx::ImageSkia& image) OVERRIDE;
- virtual void SetPressedImage(const gfx::ImageSkia& image) OVERRIDE;
+ virtual void SetImage(const gfx::Image& image) OVERRIDE;
+ virtual void SetPressedImage(const gfx::Image& image) OVERRIDE;
virtual void SetToolTip(const std::string& tool_tip) OVERRIDE;
virtual void SetTitle(const std::string& title) OVERRIDE;
virtual void SetHighlightMode(bool highlight) OVERRIDE;
[[NSStatusBar systemStatusBar] removeStatusItem:item_];
}
-void TrayIconCocoa::SetImage(const gfx::ImageSkia& image) {
- if (!image.isNull()) {
- gfx::Image neutral(image);
- if (!neutral.IsEmpty())
- [item_ setImage:neutral.ToNSImage()];
- }
+void TrayIconCocoa::SetImage(const gfx::Image& image) {
+ if (!image.IsEmpty())
+ [item_ setImage:image.ToNSImage()];
}
-void TrayIconCocoa::SetPressedImage(const gfx::ImageSkia& image) {
- if (!image.isNull()) {
- gfx::Image neutral(image);
- if (!neutral.IsEmpty())
- [item_ setAlternateImage:neutral.ToNSImage()];
- }
+void TrayIconCocoa::SetPressedImage(const gfx::Image& image) {
+ if (!image.IsEmpty())
+ [item_ setAlternateImage:image.ToNSImage()];
}
void TrayIconCocoa::SetToolTip(const std::string& tool_tip) {
TrayIconGtk::~TrayIconGtk() {
}
-void TrayIconGtk::SetImage(const gfx::ImageSkia& image) {
+void TrayIconGtk::SetImage(const gfx::Image& image) {
if (icon_) {
- icon_->SetImage(image);
+ icon_->SetImage(image.AsImageSkia());
return;
}
virtual ~TrayIconGtk();
// TrayIcon:
- virtual void SetImage(const gfx::ImageSkia& image) OVERRIDE;
+ virtual void SetImage(const gfx::Image& image) OVERRIDE;
virtual void SetToolTip(const std::string& tool_tip) OVERRIDE;
virtual void SetContextMenu(ui::SimpleMenuModel* menu_model) OVERRIDE;
LOG(WARNING) << "Unable to re-create status tray icon.";
}
-void NotifyIcon::SetImage(const gfx::ImageSkia& image) {
+void NotifyIcon::SetImage(const gfx::Image& image) {
// Create the icon.
NOTIFYICONDATA icon_data;
InitIconData(&icon_data);
icon_data.uFlags = NIF_ICON;
- icon_.Set(IconUtil::CreateHICONFromSkBitmap(*image.bitmap()));
+ icon_.Set(IconUtil::CreateHICONFromSkBitmap(image.AsBitmap()));
icon_data.hIcon = icon_.Get();
BOOL result = Shell_NotifyIcon(NIM_MODIFY, &icon_data);
if (!result)
LOG(WARNING) << "Error setting status tray icon image";
}
-void NotifyIcon::SetPressedImage(const gfx::ImageSkia& image) {
+void NotifyIcon::SetPressedImage(const gfx::Image& image) {
// Ignore pressed images, since the standard on Windows is to not highlight
// pressed status icons.
}
LOG(WARNING) << "Unable to set tooltip for status tray icon";
}
-void NotifyIcon::DisplayBalloon(const gfx::ImageSkia& icon,
+void NotifyIcon::DisplayBalloon(const gfx::Image& icon,
const base::string16& title,
const base::string16& contents) {
NOTIFYICONDATA icon_data;
base::win::Version win_version = base::win::GetVersion();
if (!icon.isNull() && win_version != base::win::VERSION_PRE_XP) {
- balloon_icon_.Set(IconUtil::CreateHICONFromSkBitmap(*icon.bitmap()));
+ balloon_icon_.Set(IconUtil::CreateHICONFromSkBitmap(icon.AsBitmap()));
icon_data.hBalloonIcon = balloon_icon_.Get();
icon_data.dwInfoFlags = NIIF_USER | NIIF_LARGE_ICON;
}
UINT message_id() const { return message_id_; }
// Overridden from TrayIcon:
- void SetImage(const gfx::ImageSkia& image) override;
- void SetPressedImage(const gfx::ImageSkia& image) override;
+ void SetImage(const gfx::Image& image) override;
+ void SetPressedImage(const gfx::Image& image) override;
void SetToolTip(const std::string& tool_tip) override;
- void DisplayBalloon(const gfx::ImageSkia& icon,
+ void DisplayBalloon(const gfx::Image& icon,
const base::string16& title,
const base::string16& contents) override;
void SetContextMenu(ui::SimpleMenuModel* menu_model) override;