Merge pull request #1383 from deepak1556/nativeimage_patch

nativeImage: adding setTemplateImage method
This commit is contained in:
Cheng Zhao 2015-04-13 11:47:58 +08:00
commit f11988a354
4 changed files with 14 additions and 0 deletions

View file

@ -138,6 +138,9 @@ mate::ObjectTemplateBuilder NativeImage::GetObjectTemplateBuilder(
.SetMethod("toDataUrl", &NativeImage::ToDataURL) .SetMethod("toDataUrl", &NativeImage::ToDataURL)
.SetMethod("isEmpty", &NativeImage::IsEmpty) .SetMethod("isEmpty", &NativeImage::IsEmpty)
.SetMethod("getSize", &NativeImage::GetSize) .SetMethod("getSize", &NativeImage::GetSize)
#if defined(OS_MACOSX)
.SetMethod("setTemplateImage", &NativeImage::SetTemplateImage)
#endif
.Build()); .Build());
return mate::ObjectTemplateBuilder( return mate::ObjectTemplateBuilder(

View file

@ -62,6 +62,7 @@ class NativeImage : public mate::Wrappable {
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
// Mark the image as template image if possible. // Mark the image as template image if possible.
static void MakeTemplateImage(gfx::Image* image); static void MakeTemplateImage(gfx::Image* image);
void SetTemplateImage(bool setAsTemplate);
#endif #endif
v8::Handle<v8::Value> ToPNG(v8::Isolate* isolate); v8::Handle<v8::Value> ToPNG(v8::Isolate* isolate);

View file

@ -15,6 +15,10 @@ void NativeImage::MakeTemplateImage(gfx::Image* image) {
[image->AsNSImage() setTemplate:YES]; [image->AsNSImage() setTemplate:YES];
} }
void NativeImage::SetTemplateImage(bool setAsTemplate) {
[image_.AsNSImage() setTemplate:setAsTemplate];
}
} // namespace api } // namespace api
} // namespace atom } // namespace atom

View file

@ -131,3 +131,9 @@ Returns whether the image is empty.
Returns the size of the image. Returns the size of the image.
[buffer]: https://iojs.org/api/buffer.html#buffer_class_buffer [buffer]: https://iojs.org/api/buffer.html#buffer_class_buffer
### NativeImage.setTemplateImage(option)
* `option` Boolean
To toggle a `NativeImage` as Template image on OSX