From 73d82a6347a04b099b7d8b3fbca7ad55405e4fc5 Mon Sep 17 00:00:00 2001 From: EvilSpirit Date: Thu, 26 May 2016 16:17:31 +0600 Subject: [PATCH] Load actual factory default, not saved style, when requested. --- src/sketch.h | 2 +- src/style.cpp | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/sketch.h b/src/sketch.h index 5f8d81b..306ea2f 100644 --- a/src/sketch.h +++ b/src/sketch.h @@ -818,7 +818,7 @@ public: static void CreateAllDefaultStyles(); 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 LoadFactoryDefaults(); diff --git a/src/style.cpp b/src/style.cpp index b06de05..e3803ae 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -83,12 +83,13 @@ void Style::CreateDefaultStyle(hStyle h) { 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]; - s->color = CnfThawColor(d->color, CnfColor(d->cnfPrefix)); - s->width = CnfThawFloat((float)(d->width), CnfWidth(d->cnfPrefix)); + s->color = (factory) ? d->color : CnfThawColor(d->color, CnfColor(d->cnfPrefix)); + s->width = (factory) ? d->width : CnfThawFloat((float)(d->width), CnfWidth(d->cnfPrefix)); 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->textOrigin = TextOrigin::NONE; s->textAngle = 0; @@ -106,7 +107,7 @@ void Style::LoadFactoryDefaults() { const Default *d; for(d = &(Defaults[0]); d->h.v; d++) { Style *s = Get(d->h); - FillDefaultStyle(s, d); + FillDefaultStyle(s, d, /*factory=*/true); } SS.backgroundColor = RGBi(0, 0, 0); SS.bgImage.pixmap.Clear();