Convert to mate::Handle<NativeImage> instead of gfx::Image

This commit is contained in:
Cheng Zhao 2016-05-20 16:14:40 +09:00
parent 7c34d8333c
commit adfd99f5f0
6 changed files with 80 additions and 31 deletions

View file

@ -11,6 +11,7 @@
#include "atom/browser/api/trackable_object.h"
#include "atom/browser/ui/tray_icon_observer.h"
#include "base/memory/scoped_ptr.h"
#include "native_mate/handle.h"
namespace gfx {
class Image;
@ -28,18 +29,19 @@ class TrayIcon;
namespace api {
class Menu;
class NativeImage;
class Tray : public mate::TrackableObject<Tray>,
public TrayIconObserver {
public:
static mate::WrappableBase* New(
v8::Isolate* isolate, const gfx::Image& image);
v8::Isolate* isolate, mate::Handle<NativeImage> image);
static void BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::ObjectTemplate> prototype);
protected:
Tray(v8::Isolate* isolate, const gfx::Image& image);
Tray(v8::Isolate* isolate, mate::Handle<NativeImage> image);
~Tray() override;
// TrayIconObserver:
@ -55,18 +57,20 @@ class Tray : public mate::TrackableObject<Tray>,
void OnDragExited() override;
void OnDragEnded() override;
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);
void SetImage(v8::Isolate* isolate, mate::Handle<NativeImage> image);
void SetPressedImage(v8::Isolate* isolate, mate::Handle<NativeImage> image);
void SetToolTip(const std::string& tool_tip);
void SetTitle(const std::string& title);
void SetHighlightMode(bool highlight);
void DisplayBalloon(mate::Arguments* args, const mate::Dictionary& options);
void PopUpContextMenu(mate::Arguments* args);
void SetContextMenu(mate::Arguments* args, Menu* menu);
void SetContextMenu(Menu* menu);
private:
v8::Local<v8::Object> ModifiersToObject(v8::Isolate* isolate, int modifiers);
v8::Global<v8::Object> image_;
v8::Global<v8::Object> pressed_image_;
scoped_ptr<TrayIcon> tray_icon_;
DISALLOW_COPY_AND_ASSIGN(Tray);