mirror of
https://github.com/electron/electron.git
synced 2026-05-02 03:00:22 -04:00
mac: Add support for template image
This commit is contained in:
@@ -8,10 +8,20 @@
|
||||
|
||||
#include "base/mac/foundation_util.h"
|
||||
#include "base/mac/scoped_nsobject.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
#include "ui/gfx/image/image.h"
|
||||
#include "ui/gfx/image/image_skia.h"
|
||||
|
||||
namespace {
|
||||
|
||||
bool IsTemplateImage(const std::string& path) {
|
||||
return (MatchPattern(path, "*Template.*") ||
|
||||
MatchPattern(path, "*Template@*x.*"));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace mate {
|
||||
|
||||
bool Converter<gfx::ImageSkia>::FromV8(v8::Isolate* isolate,
|
||||
@@ -41,6 +51,9 @@ bool Converter<gfx::Image>::FromV8(v8::Isolate* isolate,
|
||||
if (![image isValid])
|
||||
return false;
|
||||
|
||||
if (IsTemplateImage(path))
|
||||
[image setTemplate:YES];
|
||||
|
||||
*out = gfx::Image(image.release());
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user