mirror of
https://github.com/greenshot/greenshot
synced 2025-08-20 13:33:27 -07:00
Improvement for #220, the size of the font is calculated according to the size of the counter
This commit is contained in:
parent
90d1e114e0
commit
80c262d47f
1 changed files with 9 additions and 30 deletions
|
@ -1,20 +1,20 @@
|
||||||
/*
|
/*
|
||||||
* Greenshot - a free and open source screenshot tool
|
* Greenshot - a free and open source screenshot tool
|
||||||
* Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom
|
* Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom
|
||||||
*
|
*
|
||||||
* For more information see: http://getgreenshot.org/
|
* For more information see: http://getgreenshot.org/
|
||||||
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
|
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 1 of the License, or
|
* the Free Software Foundation, either version 1 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
@ -40,9 +40,7 @@ namespace Greenshot.Drawing {
|
||||||
|
|
||||||
private readonly bool _drawAsRectangle = false;
|
private readonly bool _drawAsRectangle = false;
|
||||||
|
|
||||||
private float fontSize = 16;
|
public StepLabelContainer(Surface parent) : base(parent) {
|
||||||
|
|
||||||
public StepLabelContainer(Surface parent) : base(parent) {
|
|
||||||
parent.AddStepLabel(this);
|
parent.AddStepLabel(this);
|
||||||
InitContent();
|
InitContent();
|
||||||
Init();
|
Init();
|
||||||
|
@ -168,26 +166,6 @@ namespace Greenshot.Drawing {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Make sure the size of the font is scaled
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="matrix"></param>
|
|
||||||
public override void Transform(Matrix matrix) {
|
|
||||||
Rectangle rect = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);
|
|
||||||
int widthBefore = rect.Width;
|
|
||||||
int heightBefore = rect.Height;
|
|
||||||
|
|
||||||
// Transform this container
|
|
||||||
base.Transform(matrix);
|
|
||||||
rect = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);
|
|
||||||
|
|
||||||
int widthAfter = rect.Width;
|
|
||||||
int heightAfter = rect.Height;
|
|
||||||
float factor = ((float)widthAfter / widthBefore + (float)heightAfter / heightBefore) / 2;
|
|
||||||
|
|
||||||
fontSize *= factor;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Override the parent, calculate the label number, than draw
|
/// Override the parent, calculate the label number, than draw
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -209,6 +187,7 @@ namespace Greenshot.Drawing {
|
||||||
EllipseContainer.DrawEllipse(rect, graphics, rm, 0, Color.Transparent, fillColor, false);
|
EllipseContainer.DrawEllipse(rect, graphics, rm, 0, Color.Transparent, fillColor, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float fontSize = Math.Min(Width,Height) / 1.4f;
|
||||||
using FontFamily fam = new FontFamily(FontFamily.GenericSansSerif.Name);
|
using FontFamily fam = new FontFamily(FontFamily.GenericSansSerif.Name);
|
||||||
using Font font = new Font(fam, fontSize, FontStyle.Bold, GraphicsUnit.Pixel);
|
using Font font = new Font(fam, fontSize, FontStyle.Bold, GraphicsUnit.Pixel);
|
||||||
TextContainer.DrawText(graphics, rect, 0, lineColor, false, _stringFormat, text, font);
|
TextContainer.DrawText(graphics, rect, 0, lineColor, false, _stringFormat, text, font);
|
||||||
|
@ -219,9 +198,9 @@ namespace Greenshot.Drawing {
|
||||||
Color fillColor = GetFieldValueAsColor(FieldType.FILL_COLOR);
|
Color fillColor = GetFieldValueAsColor(FieldType.FILL_COLOR);
|
||||||
if (_drawAsRectangle) {
|
if (_drawAsRectangle) {
|
||||||
return RectangleContainer.RectangleClickableAt(rect, 0, fillColor, x, y);
|
return RectangleContainer.RectangleClickableAt(rect, 0, fillColor, x, y);
|
||||||
} else {
|
|
||||||
return EllipseContainer.EllipseClickableAt(rect, 0, fillColor, x, y);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
return EllipseContainer.EllipseClickableAt(rect, 0, fillColor, x, y);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue