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