mirror of
https://github.com/greenshot/greenshot
synced 2025-07-16 10:03:44 -07:00
Fixes for allowing resizing text based containers, rotating still doesn't work.
This commit is contained in:
parent
91a75c7c18
commit
e801c95f84
2 changed files with 48 additions and 3 deletions
|
@ -41,6 +41,8 @@ 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();
|
||||||
|
@ -151,6 +153,26 @@ 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>
|
||||||
|
@ -172,8 +194,7 @@ namespace Greenshot.Drawing {
|
||||||
EllipseContainer.DrawEllipse(rect, graphics, rm, 0, Color.Transparent, fillColor, false);
|
EllipseContainer.DrawEllipse(rect, graphics, rm, 0, Color.Transparent, fillColor, false);
|
||||||
}
|
}
|
||||||
using (FontFamily fam = new FontFamily(FontFamily.GenericSansSerif.Name)) {
|
using (FontFamily fam = new FontFamily(FontFamily.GenericSansSerif.Name)) {
|
||||||
float factor = (((float)rect.Width / DefaultSize.Width) + ((float)rect.Height / DefaultSize.Height)) / 2;
|
using (Font _font = new Font(fam, fontSize, FontStyle.Bold, GraphicsUnit.Pixel)) {
|
||||||
using (Font _font = new Font(fam, 16 * factor, FontStyle.Bold, GraphicsUnit.Pixel)) {
|
|
||||||
TextContainer.DrawText(graphics, rect, 0, lineColor, false, _stringFormat, text, _font);
|
TextContainer.DrawText(graphics, rect, 0, lineColor, false, _stringFormat, text, _font);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -214,7 +214,31 @@ namespace Greenshot.Drawing {
|
||||||
_parent.KeysLocked = false;
|
_parent.KeysLocked = false;
|
||||||
_parent.Controls.Remove(_textBox);
|
_parent.Controls.Remove(_textBox);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <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;
|
||||||
|
|
||||||
|
float fontSize = GetFieldValueAsFloat(FieldType.FONT_SIZE);
|
||||||
|
fontSize *= factor;
|
||||||
|
SetFieldValue(FieldType.FONT_SIZE, fontSize);
|
||||||
|
|
||||||
|
fontInvalidated = true;
|
||||||
|
}
|
||||||
|
|
||||||
protected void UpdateFormat() {
|
protected void UpdateFormat() {
|
||||||
string fontFamily = GetFieldValueAsString(FieldType.FONT_FAMILY);
|
string fontFamily = GetFieldValueAsString(FieldType.FONT_FAMILY);
|
||||||
bool fontBold = GetFieldValueAsBool(FieldType.FONT_BOLD);
|
bool fontBold = GetFieldValueAsBool(FieldType.FONT_BOLD);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue