mirror of
https://github.com/greenshot/greenshot
synced 2025-08-19 21:13:23 -07:00
Improved the drawing of the speechbubble, now one can resize it "the wrong way" and it is still drawn correctly. Made the counting labels to appear directly centered to the mouse, this simplifies placing them. Also removed the possibility to resize them. Fixed a bug where the tool-buttons were not being disabled, if another tool is selected or ESC is pressed.
This commit is contained in:
parent
0e3f5d1cbb
commit
db8b2cb2c5
4 changed files with 30 additions and 17 deletions
|
@ -559,7 +559,7 @@ namespace Greenshot.Drawing {
|
||||||
ResumeLayout();
|
ResumeLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void HideGrippers() {
|
public virtual void HideGrippers() {
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
if (_grippers != null) {
|
if (_grippers != null) {
|
||||||
for (int i = 0; i < _grippers.Length; i++) {
|
for (int i = 0; i < _grippers.Length; i++) {
|
||||||
|
|
|
@ -43,7 +43,7 @@ namespace Greenshot.Drawing {
|
||||||
/// We set our own field values
|
/// We set our own field values
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected override void InitializeFields() {
|
protected override void InitializeFields() {
|
||||||
AddField(GetType(), FieldType.LINE_THICKNESS, 0);
|
AddField(GetType(), FieldType.LINE_THICKNESS, 2);
|
||||||
AddField(GetType(), FieldType.LINE_COLOR, Color.Blue);
|
AddField(GetType(), FieldType.LINE_COLOR, Color.Blue);
|
||||||
AddField(GetType(), FieldType.SHADOW, false);
|
AddField(GetType(), FieldType.SHADOW, false);
|
||||||
AddField(GetType(), FieldType.FONT_ITALIC, false);
|
AddField(GetType(), FieldType.FONT_ITALIC, false);
|
||||||
|
@ -68,7 +68,7 @@ namespace Greenshot.Drawing {
|
||||||
if (TargetGripper == null) {
|
if (TargetGripper == null) {
|
||||||
InitTargetGripper(Color.Green, new Point(mouseX, mouseY));
|
InitTargetGripper(Color.Green, new Point(mouseX, mouseY));
|
||||||
}
|
}
|
||||||
return base.HandleMouseDown(mouseX, mouseY);
|
return base.HandleMouseDown(mouseX + 20, mouseY + 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Rectangle DrawingBounds {
|
public override Rectangle DrawingBounds {
|
||||||
|
@ -93,9 +93,9 @@ namespace Greenshot.Drawing {
|
||||||
bool lineVisible = (lineThickness > 0 && Colors.IsVisible(lineColor));
|
bool lineVisible = (lineThickness > 0 && Colors.IsVisible(lineColor));
|
||||||
Rectangle rect = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);
|
Rectangle rect = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);
|
||||||
|
|
||||||
int tailAngle = 90 + (int)GeometryHelper.Angle2D(Left + (Width / 2), Top + (Height / 2), TargetGripper.Left, TargetGripper.Top);
|
int tailAngle = 90 + (int)GeometryHelper.Angle2D(rect.Left + (rect.Width / 2), rect.Top + (rect.Height / 2), TargetGripper.Left, TargetGripper.Top);
|
||||||
int tailLength = GeometryHelper.Distance2D(Left + (Width / 2), Top + (Height / 2), TargetGripper.Left, TargetGripper.Top);
|
int tailLength = GeometryHelper.Distance2D(rect.Left + (rect.Width / 2), rect.Top + (rect.Height / 2), TargetGripper.Left, TargetGripper.Top);
|
||||||
int tailWidth = (Math.Abs(Width) + Math.Abs(Height)) / 20;
|
int tailWidth = (Math.Abs(rect.Width) + Math.Abs(rect.Height)) / 20;
|
||||||
|
|
||||||
GraphicsPath bubble = new GraphicsPath();
|
GraphicsPath bubble = new GraphicsPath();
|
||||||
int CornerRadius = 30;
|
int CornerRadius = 30;
|
||||||
|
@ -118,9 +118,9 @@ namespace Greenshot.Drawing {
|
||||||
GraphicsState state = graphics.Save();
|
GraphicsState state = graphics.Save();
|
||||||
// draw the tail border where the bubble is not visible
|
// draw the tail border where the bubble is not visible
|
||||||
using (Region clipRegion = new Region(bubble)) {
|
using (Region clipRegion = new Region(bubble)) {
|
||||||
clipRegion.Translate(Left, Top);
|
clipRegion.Translate(rect.Left, rect.Top);
|
||||||
graphics.SetClip(clipRegion, CombineMode.Exclude);
|
graphics.SetClip(clipRegion, CombineMode.Exclude);
|
||||||
graphics.TranslateTransform(Left + (Width / 2), Top + (Height / 2));
|
graphics.TranslateTransform(rect.Left + (rect.Width / 2), rect.Top + (rect.Height / 2));
|
||||||
graphics.RotateTransform(tailAngle);
|
graphics.RotateTransform(tailAngle);
|
||||||
using (Pen pen = new Pen(lineColor, lineThickness)) {
|
using (Pen pen = new Pen(lineColor, lineThickness)) {
|
||||||
graphics.DrawPath(pen, tail);
|
graphics.DrawPath(pen, tail);
|
||||||
|
@ -132,7 +132,7 @@ namespace Greenshot.Drawing {
|
||||||
if (Colors.IsVisible(fillColor)) {
|
if (Colors.IsVisible(fillColor)) {
|
||||||
//draw the bubbleshape
|
//draw the bubbleshape
|
||||||
state = graphics.Save();
|
state = graphics.Save();
|
||||||
graphics.TranslateTransform(Left, Top);
|
graphics.TranslateTransform(rect.Left, rect.Top);
|
||||||
using (Brush brush = new SolidBrush(fillColor)) {
|
using (Brush brush = new SolidBrush(fillColor)) {
|
||||||
graphics.FillPath(brush, bubble);
|
graphics.FillPath(brush, bubble);
|
||||||
}
|
}
|
||||||
|
@ -147,11 +147,11 @@ namespace Greenshot.Drawing {
|
||||||
Matrix transformMatrix = new Matrix();
|
Matrix transformMatrix = new Matrix();
|
||||||
transformMatrix.Rotate(tailAngle);
|
transformMatrix.Rotate(tailAngle);
|
||||||
clipRegion.Transform(transformMatrix);
|
clipRegion.Transform(transformMatrix);
|
||||||
clipRegion.Translate(Left + (Width / 2), Top + (Height / 2));
|
clipRegion.Translate(rect.Left + (rect.Width / 2), rect.Top + (rect.Height / 2));
|
||||||
graphics.SetClip(clipRegion, CombineMode.Exclude);
|
graphics.SetClip(clipRegion, CombineMode.Exclude);
|
||||||
graphics.TranslateTransform(Left, Top);
|
graphics.TranslateTransform(rect.Left, rect.Top);
|
||||||
using (Pen pen = new Pen(lineColor, lineThickness)) {
|
using (Pen pen = new Pen(lineColor, lineThickness)) {
|
||||||
pen.EndCap = pen.StartCap = LineCap.Round;
|
//pen.EndCap = pen.StartCap = LineCap.Round;
|
||||||
graphics.DrawPath(pen, bubble);
|
graphics.DrawPath(pen, bubble);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -161,7 +161,7 @@ namespace Greenshot.Drawing {
|
||||||
if (Colors.IsVisible(fillColor)) {
|
if (Colors.IsVisible(fillColor)) {
|
||||||
// Draw the tail border
|
// Draw the tail border
|
||||||
state = graphics.Save();
|
state = graphics.Save();
|
||||||
graphics.TranslateTransform(Left + (Width / 2), Top + (Height / 2));
|
graphics.TranslateTransform(rect.Left + (rect.Width / 2), rect.Top + (rect.Height / 2));
|
||||||
graphics.RotateTransform(tailAngle);
|
graphics.RotateTransform(tailAngle);
|
||||||
using (Brush brush = new SolidBrush(fillColor)) {
|
using (Brush brush = new SolidBrush(fillColor)) {
|
||||||
graphics.FillPath(brush, tail);
|
graphics.FillPath(brush, tail);
|
||||||
|
|
|
@ -48,20 +48,33 @@ namespace Greenshot.Drawing {
|
||||||
InitContent();
|
InitContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void ShowGrippers() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void HideGrippers() {
|
||||||
|
}
|
||||||
|
|
||||||
public override bool InitContent() {
|
public override bool InitContent() {
|
||||||
_defaultEditMode = EditStatus.IDLE;
|
_defaultEditMode = EditStatus.IDLE;
|
||||||
_stringFormat.Alignment = StringAlignment.Center;
|
_stringFormat.Alignment = StringAlignment.Center;
|
||||||
_stringFormat.LineAlignment = StringAlignment.Center;
|
_stringFormat.LineAlignment = StringAlignment.Center;
|
||||||
|
|
||||||
// Set defaults
|
// Set defaults
|
||||||
Width = 40;
|
Width = 30;
|
||||||
Height = 40;
|
Height = 30;
|
||||||
using (FontFamily fam = new FontFamily(FontFamily.GenericSansSerif.Name)) {
|
using (FontFamily fam = new FontFamily(FontFamily.GenericSansSerif.Name)) {
|
||||||
_font = new Font(fam, 18, FontStyle.Regular, GraphicsUnit.Pixel);
|
_font = new Font(fam, 14, FontStyle.Regular, GraphicsUnit.Pixel);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This makes it possible for the label to be placed exactly in the middle of the pointer.
|
||||||
|
/// </summary>
|
||||||
|
public override bool HandleMouseDown(int mouseX, int mouseY) {
|
||||||
|
return base.HandleMouseDown(mouseX - (Width / 2), mouseY - (Height / 2));
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// We set our own field values
|
/// We set our own field values
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -176,7 +176,7 @@ namespace Greenshot {
|
||||||
obfuscateModeButton.DropDownItemClicked += FilterPresetDropDownItemClicked;
|
obfuscateModeButton.DropDownItemClicked += FilterPresetDropDownItemClicked;
|
||||||
highlightModeButton.DropDownItemClicked += FilterPresetDropDownItemClicked;
|
highlightModeButton.DropDownItemClicked += FilterPresetDropDownItemClicked;
|
||||||
|
|
||||||
toolbarButtons = new[] { btnCursor, btnRect, btnEllipse, btnText, btnLine, btnArrow, btnFreehand, btnHighlight, btnObfuscate, btnCrop };
|
toolbarButtons = new[] { btnCursor, btnRect, btnEllipse, btnText, btnLine, btnArrow, btnFreehand, btnHighlight, btnObfuscate, btnCrop, btnStepLabel, btnSpeechBubble };
|
||||||
//toolbarDropDownButtons = new ToolStripDropDownButton[]{btnBlur, btnPixeliate, btnTextHighlighter, btnAreaHighlighter, btnMagnifier};
|
//toolbarDropDownButtons = new ToolStripDropDownButton[]{btnBlur, btnPixeliate, btnTextHighlighter, btnAreaHighlighter, btnMagnifier};
|
||||||
|
|
||||||
pluginToolStripMenuItem.Visible = pluginToolStripMenuItem.DropDownItems.Count > 0;
|
pluginToolStripMenuItem.Visible = pluginToolStripMenuItem.DropDownItems.Count > 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue