Allow changing text size for default styles.
This is especially useful for High-DPI displays on non-OS X.pull/4/head
parent
96344c85a6
commit
a0576e2a50
|
@ -10,21 +10,13 @@
|
||||||
|
|
||||||
void Constraint::LineDrawOrGetDistance(Vector a, Vector b) {
|
void Constraint::LineDrawOrGetDistance(Vector a, Vector b) {
|
||||||
if(dogd.drawing) {
|
if(dogd.drawing) {
|
||||||
// Draw comments in the specified style, but everything else in the
|
hStyle hs = disp.style;
|
||||||
// default style for constraints.
|
if(hs.v == 0) hs.v = Style::CONSTRAINT;
|
||||||
hStyle hs;
|
|
||||||
if(type == COMMENT && disp.style.v) {
|
|
||||||
hs = disp.style;
|
|
||||||
} else {
|
|
||||||
hs.v = Style::CONSTRAINT;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(dogd.sel) {
|
if(dogd.sel) {
|
||||||
dogd.sel->AddEdge(a, b, hs.v);
|
dogd.sel->AddEdge(a, b, hs.v);
|
||||||
} else {
|
} else {
|
||||||
// The only constraints with styles should be comments, so don't
|
if(Style::Width(hs) >= 3.0) {
|
||||||
// check otherwise, save looking up the styles constantly.
|
|
||||||
if(type == COMMENT && Style::Width(hs) >= 3.0) {
|
|
||||||
ssglFatLine(a, b, Style::Width(hs) / SS.GW.scale);
|
ssglFatLine(a, b, Style::Width(hs) / SS.GW.scale);
|
||||||
} else {
|
} else {
|
||||||
glBegin(GL_LINE_STRIP);
|
glBegin(GL_LINE_STRIP);
|
||||||
|
@ -85,12 +77,9 @@ std::string Constraint::Label(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Constraint::DoLabel(Vector ref, Vector *labelPos, Vector gr, Vector gu) {
|
void Constraint::DoLabel(Vector ref, Vector *labelPos, Vector gr, Vector gu) {
|
||||||
double th;
|
hStyle hs = disp.style;
|
||||||
if(type == COMMENT) {
|
if(hs.v == 0) hs.v = Style::CONSTRAINT;
|
||||||
th = Style::TextHeight(disp.style);
|
double th = Style::TextHeight(hs);
|
||||||
} else {
|
|
||||||
th = Style::DefaultTextHeight();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string s = Label();
|
std::string s = Label();
|
||||||
double swidth = ssglStrWidth(s, th),
|
double swidth = ssglStrWidth(s, th),
|
||||||
|
@ -159,13 +148,16 @@ void Constraint::DoProjectedPoint(Vector *r) {
|
||||||
// depending whether that extension was from A or from B.
|
// depending whether that extension was from A or from B.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
int Constraint::DoLineTrimmedAgainstBox(Vector ref, Vector a, Vector b) {
|
int Constraint::DoLineTrimmedAgainstBox(Vector ref, Vector a, Vector b) {
|
||||||
|
hStyle hs = disp.style;
|
||||||
|
if(hs.v == 0) hs.v = Style::CONSTRAINT;
|
||||||
|
double th = Style::TextHeight(hs);
|
||||||
Vector gu = SS.GW.projUp.WithMagnitude(1),
|
Vector gu = SS.GW.projUp.WithMagnitude(1),
|
||||||
gr = SS.GW.projRight.WithMagnitude(1);
|
gr = SS.GW.projRight.WithMagnitude(1);
|
||||||
|
|
||||||
double pixels = 1.0 / SS.GW.scale;
|
double pixels = 1.0 / SS.GW.scale;
|
||||||
std::string s = Label();
|
std::string s = Label();
|
||||||
double swidth = ssglStrWidth(s, Style::DefaultTextHeight()) + 4*pixels,
|
double swidth = ssglStrWidth(s, th) + 4*pixels,
|
||||||
sheight = ssglStrHeight(Style::DefaultTextHeight()) + 8*pixels;
|
sheight = ssglStrHeight(th) + 8*pixels;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
Vector n;
|
Vector n;
|
||||||
|
@ -1077,9 +1069,11 @@ s:
|
||||||
void Constraint::Draw(void) {
|
void Constraint::Draw(void) {
|
||||||
dogd.drawing = true;
|
dogd.drawing = true;
|
||||||
dogd.sel = NULL;
|
dogd.sel = NULL;
|
||||||
|
hStyle hs = disp.style;
|
||||||
|
if(hs.v == 0) hs.v = Style::CONSTRAINT;
|
||||||
|
|
||||||
ssglLineWidth(Style::Width(Style::CONSTRAINT));
|
ssglLineWidth(Style::Width(hs));
|
||||||
ssglColorRGB(Style::Color(Style::CONSTRAINT));
|
ssglColorRGB(Style::Color(hs));
|
||||||
|
|
||||||
DrawOrGetDistance(NULL);
|
DrawOrGetDistance(NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -787,6 +787,7 @@ public:
|
||||||
|
|
||||||
static std::string CnfColor(const std::string &prefix);
|
static std::string CnfColor(const std::string &prefix);
|
||||||
static std::string CnfWidth(const std::string &prefix);
|
static std::string CnfWidth(const std::string &prefix);
|
||||||
|
static std::string CnfTextHeight(const std::string &prefix);
|
||||||
static std::string CnfPrefixToName(const std::string &prefix);
|
static std::string CnfPrefixToName(const std::string &prefix);
|
||||||
|
|
||||||
static void CreateAllDefaultStyles(void);
|
static void CreateAllDefaultStyles(void);
|
||||||
|
|
|
@ -33,6 +33,9 @@ std::string Style::CnfColor(const std::string &prefix) {
|
||||||
std::string Style::CnfWidth(const std::string &prefix) {
|
std::string Style::CnfWidth(const std::string &prefix) {
|
||||||
return "Style_" + prefix + "_Width";
|
return "Style_" + prefix + "_Width";
|
||||||
}
|
}
|
||||||
|
std::string Style::CnfTextHeight(const std::string &prefix) {
|
||||||
|
return "Style_" + prefix + "_TextHeight";
|
||||||
|
}
|
||||||
|
|
||||||
std::string Style::CnfPrefixToName(const std::string &prefix) {
|
std::string Style::CnfPrefixToName(const std::string &prefix) {
|
||||||
std::string name = "#def-";
|
std::string name = "#def-";
|
||||||
|
@ -83,7 +86,7 @@ void Style::FillDefaultStyle(Style *s, const Default *d) {
|
||||||
s->color = CnfThawColor(d->color, CnfColor(d->cnfPrefix));
|
s->color = CnfThawColor(d->color, CnfColor(d->cnfPrefix));
|
||||||
s->width = CnfThawFloat((float)(d->width), CnfWidth(d->cnfPrefix));
|
s->width = CnfThawFloat((float)(d->width), CnfWidth(d->cnfPrefix));
|
||||||
s->widthAs = UNITS_AS_PIXELS;
|
s->widthAs = UNITS_AS_PIXELS;
|
||||||
s->textHeight = DEFAULT_TEXT_HEIGHT;
|
s->textHeight = CnfThawFloat(DEFAULT_TEXT_HEIGHT, CnfTextHeight(d->cnfPrefix));
|
||||||
s->textHeightAs = UNITS_AS_PIXELS;
|
s->textHeightAs = UNITS_AS_PIXELS;
|
||||||
s->textOrigin = 0;
|
s->textOrigin = 0;
|
||||||
s->textAngle = 0;
|
s->textAngle = 0;
|
||||||
|
@ -125,6 +128,7 @@ void Style::FreezeDefaultStyles(void) {
|
||||||
for(d = &(Defaults[0]); d->h.v; d++) {
|
for(d = &(Defaults[0]); d->h.v; d++) {
|
||||||
CnfFreezeColor(Color(d->h), CnfColor(d->cnfPrefix));
|
CnfFreezeColor(Color(d->h), CnfColor(d->cnfPrefix));
|
||||||
CnfFreezeFloat((float)Width(d->h), CnfWidth(d->cnfPrefix));
|
CnfFreezeFloat((float)Width(d->h), CnfWidth(d->cnfPrefix));
|
||||||
|
CnfFreezeFloat((float)TextHeight(d->h), CnfTextHeight(d->cnfPrefix));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -810,7 +814,7 @@ void TextWindow::ShowStyleInfo(void) {
|
||||||
if(s->h.v < Style::FIRST_CUSTOM) {
|
if(s->h.v < Style::FIRST_CUSTOM) {
|
||||||
Printf(false," %Ftin units of %Fdpixels%E");
|
Printf(false," %Ftin units of %Fdpixels%E");
|
||||||
} else {
|
} else {
|
||||||
Printf(false," %Ftin units of %Fd"
|
Printf(false,"%Ba %Ftin units of %Fd"
|
||||||
"%D%f%LW%s pixels%E "
|
"%D%f%LW%s pixels%E "
|
||||||
"%D%f%Lw%s %s",
|
"%D%f%Lw%s %s",
|
||||||
s->h.v, &ScreenChangeStyleYesNo,
|
s->h.v, &ScreenChangeStyleYesNo,
|
||||||
|
@ -877,19 +881,18 @@ void TextWindow::ShowStyleInfo(void) {
|
||||||
|
|
||||||
// The text height, and its units
|
// The text height, and its units
|
||||||
Printf(false, "");
|
Printf(false, "");
|
||||||
Printf(false, "%Ft text comment style%E");
|
Printf(false, "%Ft text style%E");
|
||||||
|
|
||||||
const char *chng = (s->h.v < Style::FIRST_CUSTOM) ? "" : "[change]";
|
|
||||||
if(s->textHeightAs == Style::UNITS_AS_PIXELS) {
|
if(s->textHeightAs == Style::UNITS_AS_PIXELS) {
|
||||||
Printf(false, "%Ba %Ftheight %E%@ %D%f%Lt%Fl%s%E",
|
Printf(false, "%Ba %Ftheight %E%@ %D%f%Lt%Fl%s%E",
|
||||||
s->textHeight,
|
s->textHeight,
|
||||||
s->h.v, &ScreenChangeStyleMetric,
|
s->h.v, &ScreenChangeStyleMetric,
|
||||||
chng);
|
"[change]");
|
||||||
} else {
|
} else {
|
||||||
Printf(false, "%Ba %Ftheight %E%s %D%f%Lt%Fl%s%E",
|
Printf(false, "%Ba %Ftheight %E%s %D%f%Lt%Fl%s%E",
|
||||||
SS.MmToString(s->textHeight).c_str(),
|
SS.MmToString(s->textHeight).c_str(),
|
||||||
s->h.v, &ScreenChangeStyleMetric,
|
s->h.v, &ScreenChangeStyleMetric,
|
||||||
chng);
|
"[change]");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool textHeightpx = (s->textHeightAs == Style::UNITS_AS_PIXELS);
|
bool textHeightpx = (s->textHeightAs == Style::UNITS_AS_PIXELS);
|
||||||
|
|
Loading…
Reference in New Issue