Load actual factory default, not saved style, when requested.

This commit is contained in:
EvilSpirit 2016-05-26 16:17:31 +06:00 committed by whitequark
parent 5791310bb1
commit 73d82a6347
2 changed files with 7 additions and 6 deletions

View File

@ -818,7 +818,7 @@ public:
static void CreateAllDefaultStyles(); static void CreateAllDefaultStyles();
static void CreateDefaultStyle(hStyle h); static void CreateDefaultStyle(hStyle h);
static void FillDefaultStyle(Style *s, const Default *d = NULL); static void FillDefaultStyle(Style *s, const Default *d = NULL, bool factory = false);
static void FreezeDefaultStyles(); static void FreezeDefaultStyles();
static void LoadFactoryDefaults(); static void LoadFactoryDefaults();

View File

@ -83,12 +83,13 @@ void Style::CreateDefaultStyle(hStyle h) {
SK.style.Add(&ns); SK.style.Add(&ns);
} }
void Style::FillDefaultStyle(Style *s, const Default *d) { void Style::FillDefaultStyle(Style *s, const Default *d, bool factory) {
if(d == NULL) d = &Defaults[0]; if(d == NULL) d = &Defaults[0];
s->color = CnfThawColor(d->color, CnfColor(d->cnfPrefix)); s->color = (factory) ? d->color : CnfThawColor(d->color, CnfColor(d->cnfPrefix));
s->width = CnfThawFloat((float)(d->width), CnfWidth(d->cnfPrefix)); s->width = (factory) ? d->width : CnfThawFloat((float)(d->width), CnfWidth(d->cnfPrefix));
s->widthAs = UnitsAs::PIXELS; s->widthAs = UnitsAs::PIXELS;
s->textHeight = CnfThawFloat(DEFAULT_TEXT_HEIGHT, CnfTextHeight(d->cnfPrefix)); s->textHeight = (factory) ? DEFAULT_TEXT_HEIGHT
: CnfThawFloat(DEFAULT_TEXT_HEIGHT, CnfTextHeight(d->cnfPrefix));
s->textHeightAs = UnitsAs::PIXELS; s->textHeightAs = UnitsAs::PIXELS;
s->textOrigin = TextOrigin::NONE; s->textOrigin = TextOrigin::NONE;
s->textAngle = 0; s->textAngle = 0;
@ -106,7 +107,7 @@ void Style::LoadFactoryDefaults() {
const Default *d; const Default *d;
for(d = &(Defaults[0]); d->h.v; d++) { for(d = &(Defaults[0]); d->h.v; d++) {
Style *s = Get(d->h); Style *s = Get(d->h);
FillDefaultStyle(s, d); FillDefaultStyle(s, d, /*factory=*/true);
} }
SS.backgroundColor = RGBi(0, 0, 0); SS.backgroundColor = RGBi(0, 0, 0);
SS.bgImage.pixmap.Clear(); SS.bgImage.pixmap.Clear();