From efd294d69d38b415977633f29e2304e1f3196dc5 Mon Sep 17 00:00:00 2001 From: deepak1556 Date: Wed, 8 Apr 2015 13:50:03 +0530 Subject: [PATCH] nativeImage: adding setTemplateImage method --- atom/common/api/atom_api_native_image.cc | 3 +++ atom/common/api/atom_api_native_image.h | 1 + atom/common/api/atom_api_native_image_mac.mm | 4 ++++ docs/api/native-image.md | 6 ++++++ 4 files changed, 14 insertions(+) diff --git a/atom/common/api/atom_api_native_image.cc b/atom/common/api/atom_api_native_image.cc index a57ff221a424..c59825c0b66d 100644 --- a/atom/common/api/atom_api_native_image.cc +++ b/atom/common/api/atom_api_native_image.cc @@ -138,6 +138,9 @@ mate::ObjectTemplateBuilder NativeImage::GetObjectTemplateBuilder( .SetMethod("toDataUrl", &NativeImage::ToDataURL) .SetMethod("isEmpty", &NativeImage::IsEmpty) .SetMethod("getSize", &NativeImage::GetSize) + #if defined(OS_MACOSX) + .SetMethod("setTemplateImage", &NativeImage::SetTemplateImage) + #endif .Build()); return mate::ObjectTemplateBuilder( diff --git a/atom/common/api/atom_api_native_image.h b/atom/common/api/atom_api_native_image.h index fab93efc7021..627ca9afc2a4 100644 --- a/atom/common/api/atom_api_native_image.h +++ b/atom/common/api/atom_api_native_image.h @@ -62,6 +62,7 @@ class NativeImage : public mate::Wrappable { #if defined(OS_MACOSX) // Mark the image as template image if possible. static void MakeTemplateImage(gfx::Image* image); + void SetTemplateImage(bool setAsTemplate); #endif v8::Handle ToPNG(v8::Isolate* isolate); diff --git a/atom/common/api/atom_api_native_image_mac.mm b/atom/common/api/atom_api_native_image_mac.mm index 67d16d2e820b..fb7c03cb93cd 100644 --- a/atom/common/api/atom_api_native_image_mac.mm +++ b/atom/common/api/atom_api_native_image_mac.mm @@ -15,6 +15,10 @@ void NativeImage::MakeTemplateImage(gfx::Image* image) { [image->AsNSImage() setTemplate:YES]; } +void NativeImage::SetTemplateImage(bool setAsTemplate) { + [image_.AsNSImage() setTemplate:setAsTemplate]; +} + } // namespace api } // namespace atom diff --git a/docs/api/native-image.md b/docs/api/native-image.md index de46ad1c4c4d..9e7b35420c31 100644 --- a/docs/api/native-image.md +++ b/docs/api/native-image.md @@ -131,3 +131,9 @@ Returns whether the image is empty. Returns the size of the image. [buffer]: https://iojs.org/api/buffer.html#buffer_class_buffer + +### NativeImage.setTemplateImage(option) + +* `option` Boolean + +To toggle a `NativeImage` as Template image on OSX