Add NativeImage.IsTemplateImage method
* Rename internal function that determines template image filename patterns * Add the new IsTemplateMethod
This commit is contained in:
parent
7ceca9f426
commit
9211109088
3 changed files with 11 additions and 2 deletions
|
@ -113,7 +113,7 @@ bool PopulateImageSkiaRepsFromPath(gfx::ImageSkia* image,
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(OS_MACOSX)
|
#if defined(OS_MACOSX)
|
||||||
bool IsTemplateImage(const base::FilePath& path) {
|
bool IsTemplateFilename(const base::FilePath& path) {
|
||||||
return (MatchPattern(path.value(), "*Template.*") ||
|
return (MatchPattern(path.value(), "*Template.*") ||
|
||||||
MatchPattern(path.value(), "*Template@*x.*"));
|
MatchPattern(path.value(), "*Template@*x.*"));
|
||||||
}
|
}
|
||||||
|
@ -139,6 +139,7 @@ mate::ObjectTemplateBuilder NativeImage::GetObjectTemplateBuilder(
|
||||||
.SetMethod("isEmpty", &NativeImage::IsEmpty)
|
.SetMethod("isEmpty", &NativeImage::IsEmpty)
|
||||||
.SetMethod("getSize", &NativeImage::GetSize)
|
.SetMethod("getSize", &NativeImage::GetSize)
|
||||||
.SetMethod("setTemplateImage", &NativeImage::SetTemplateImage)
|
.SetMethod("setTemplateImage", &NativeImage::SetTemplateImage)
|
||||||
|
.SetMethod("isTemplateImage", &NativeImage::IsTemplateImage)
|
||||||
.Build());
|
.Build());
|
||||||
|
|
||||||
return mate::ObjectTemplateBuilder(
|
return mate::ObjectTemplateBuilder(
|
||||||
|
@ -180,6 +181,8 @@ gfx::Size NativeImage::GetSize() {
|
||||||
#if !defined(OS_MACOSX)
|
#if !defined(OS_MACOSX)
|
||||||
void NativeImage::SetTemplateImage(bool setAsTemplate) {
|
void NativeImage::SetTemplateImage(bool setAsTemplate) {
|
||||||
}
|
}
|
||||||
|
bool NativeImage::IsTemplateImage() {
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// static
|
// static
|
||||||
|
@ -217,7 +220,7 @@ mate::Handle<NativeImage> NativeImage::CreateFromPath(
|
||||||
gfx::Image image(image_skia);
|
gfx::Image image(image_skia);
|
||||||
mate::Handle<NativeImage> handle = Create(isolate, image);
|
mate::Handle<NativeImage> handle = Create(isolate, image);
|
||||||
#if defined(OS_MACOSX)
|
#if defined(OS_MACOSX)
|
||||||
if (IsTemplateImage(path))
|
if (IsTemplateFilename(path))
|
||||||
handle->SetTemplateImage(true);
|
handle->SetTemplateImage(true);
|
||||||
#endif
|
#endif
|
||||||
return handle;
|
return handle;
|
||||||
|
|
|
@ -67,6 +67,8 @@ class NativeImage : public mate::Wrappable {
|
||||||
|
|
||||||
// Mark the image as template image.
|
// Mark the image as template image.
|
||||||
void SetTemplateImage(bool setAsTemplate);
|
void SetTemplateImage(bool setAsTemplate);
|
||||||
|
// Determine if the image is a template image.
|
||||||
|
bool IsTemplateImage();
|
||||||
|
|
||||||
gfx::Image image_;
|
gfx::Image image_;
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,10 @@ void NativeImage::SetTemplateImage(bool setAsTemplate) {
|
||||||
[image_.AsNSImage() setTemplate:setAsTemplate];
|
[image_.AsNSImage() setTemplate:setAsTemplate];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool NativeImage::IsTemplateImage() {
|
||||||
|
return [image_.AsNSImage() isTemplate];
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace api
|
} // namespace api
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|
Loading…
Reference in a new issue