Allow theme colors to use the sRGB color profile

This is enabled by adding the following to your theme:

    colorSpaceName = sRGB;

The default color space used for themes is “Apple Generic RGB” which is a bad choice for interoperability with other software (e.g. exporting a theme to CSS, creating theme colors in Photoshop, and similar).

Related to issue #768.
This commit is contained in:
Allan Odgaard
2013-02-18 15:34:32 +01:00
parent 08534e737f
commit d70ccc7cdf
2 changed files with 20 additions and 3 deletions

View File

@@ -185,7 +185,6 @@ static CGColorRef OakColorCreateCopySoften (CGColorPtr cgColor, CGFloat factor)
theme_t::shared_styles_t::shared_styles_t (bundles::item_ptr const& themeItem): _item(themeItem), _callback(*this)
{
_color_space = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
setup_styles();
bundles::add_callback(&_callback);
}
@@ -193,18 +192,33 @@ theme_t::shared_styles_t::shared_styles_t (bundles::item_ptr const& themeItem):
theme_t::shared_styles_t::~shared_styles_t ()
{
bundles::remove_callback(&_callback);
CGColorSpaceRelease(_color_space);
if(_color_space)
CGColorSpaceRelease(_color_space);
}
void theme_t::shared_styles_t::setup_styles ()
{
_styles.clear();
if(_color_space)
{
CGColorSpaceRelease(_color_space);
_color_space = NULL;
}
if(_item)
{
if(bundles::item_ptr newItem = bundles::lookup(_item->uuid()))
_item = newItem;
std::string colorSpaceName;
if(plist::get_key_path(_item->plist(), "colorSpaceName", colorSpaceName) && colorSpaceName == "sRGB")
{
if(_color_space)
CGColorSpaceRelease(_color_space);
_color_space = CGColorSpaceCreateWithName(kCGColorSpaceSRGB);
}
plist::array_t items;
if(plist::get_key_path(_item->plist(), "settings", items))
{
@@ -224,6 +238,9 @@ void theme_t::shared_styles_t::setup_styles ()
}
}
if(!_color_space)
_color_space = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
// =======================================
// = Find “global” foreground/background =
// =======================================

View File

@@ -121,7 +121,7 @@ private:
static decomposed_style_t parse_styles (plist::dictionary_t const& plist);
bundles::item_ptr _item;
CGColorSpaceRef _color_space;
CGColorSpaceRef _color_space = NULL;
std::vector<decomposed_style_t> _styles;
gutter_styles_t _gutter_styles;
CGColorPtr _foreground;