Add ToRGBHex color helper
This commit is contained in:
parent
13f9a6c273
commit
9b0a32f62c
3 changed files with 12 additions and 5 deletions
|
@ -647,11 +647,7 @@ void WebContents::MediaStoppedPlaying(const MediaPlayerId& id) {
|
|||
}
|
||||
|
||||
void WebContents::DidChangeThemeColor(SkColor theme_color) {
|
||||
std::string hex_theme_color = base::StringPrintf("#%02X%02X%02X",
|
||||
SkColorGetR(theme_color),
|
||||
SkColorGetG(theme_color),
|
||||
SkColorGetB(theme_color));
|
||||
Emit("did-change-theme-color", hex_theme_color);
|
||||
Emit("did-change-theme-color", atom::ToRGBHex(theme_color));
|
||||
}
|
||||
|
||||
void WebContents::DocumentLoadedInFrame(
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
|
@ -45,4 +46,11 @@ SkColor ParseHexColor(const std::string& color_string) {
|
|||
return SkColorSetARGB(bytes[0], bytes[1], bytes[2], bytes[3]);
|
||||
}
|
||||
|
||||
std::string ToRGBHex(const SkColor color) {
|
||||
return base::StringPrintf("#%02X%02X%02X",
|
||||
SkColorGetR(color),
|
||||
SkColorGetG(color),
|
||||
SkColorGetB(color));
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
|
|
@ -14,6 +14,9 @@ namespace atom {
|
|||
// Parse hex color like "#FFF" or "#EFEFEF"
|
||||
SkColor ParseHexColor(const std::string& name);
|
||||
|
||||
// Convert color to RGB hex value like "#ABCDEF"
|
||||
std::string ToRGBHex(const SkColor color);
|
||||
|
||||
} // namespace atom
|
||||
|
||||
#endif // ATOM_COMMON_COLOR_UTIL_H_
|
||||
|
|
Loading…
Reference in a new issue