Skip to content

Commit

Permalink
New : add shortcut to modify width
Browse files Browse the repository at this point in the history
request from #92
  • Loading branch information
pubpub-zz committed May 11, 2021
1 parent 245ad92 commit 81d7bec
Show file tree
Hide file tree
Showing 9 changed files with 206 additions and 80 deletions.
3 changes: 3 additions & 0 deletions ppInk/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ Arrow= 15,1.85000002384186

FitToCurve = True

#increments for penwidth +/- shortcuts
PenWidth_Delta = 50

Default_Arrow = START

# 1.04 % should be about 20 pix ; will also change size of circles in tags and selection Size
Expand Down
2 changes: 2 additions & 0 deletions ppInk/hotkeys.ini
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ Hotkey_ClipArt1= Divide
Hotkey_ClipArt2= Multiply
Hotkey_ClipArt3= Subtract
Hotkey_Zoom= Z
Hotkey_PenWidth_Plus = None
Hotkey_PenWidth_Minus = None

# Hotkey for each pen
Pen0_Hotkey = D1
Expand Down
3 changes: 3 additions & 0 deletions ppInk/lang/en-us.txt
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ OptionsHotKeyAltAsOneCommand = "Process Alt as Temporary Command (Alt will be ig
OptionsHotkeysglobal = "Global hotkey (starts drawing, switches between mouse pointer and drawing)"
OptionsHotkeysEnableinpointer = "Enable all following hotkeys in mouse pointer mode (may cause a mess)"

OptionsHotkeysPenWidthPlus = "Pen Width +"
OptionsHotkeysPenWidthMinus = "Pen Width -"

VideoTab="Video"
OptNoVideo="No video recording"
OptObsRecord="OBS recording"
Expand Down
3 changes: 3 additions & 0 deletions ppInk/lang/fr.txt
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ OptionsHotKeyAltAsOneCommand = "Alt utilisé comme commande temporaire (Alt sera
OptionsHotkeysglobal = "Raccourci général (débuter un dessin, basculer entre le mode curseur de souris et le dessin)"
OptionsHotkeysEnableinpointer = "Activer tous les raccourcis en mode curseur de souris (peut poser problème)"

OptionsHotkeysPenWidthPlus = "Largeur Stylo +"
OptionsHotkeysPenWidthMinus = "Largeur Stylo -"

VideoTab="Video"
OptNoVideo="Pas d'enregistrement video"
OptObsRecord="Enregistrement video avec OBS Studio"
Expand Down
43 changes: 32 additions & 11 deletions src/FormCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1178,16 +1178,7 @@ private void IC_MouseWheel(object sender, CancelMouseEventArgs e)
}
else
{
Root.GlobalPenWidth += Root.PixelToHiMetric(e.Delta > 0 ? 2 : -2);
if (Root.GlobalPenWidth < 1)
Root.GlobalPenWidth = 1;
/*if (Root.GlobalPenWidth > 120)
Root.GlobalPenWidth = 120;
*/
//Console.WriteLine(Root.GlobalPenWidth);
IC.DefaultDrawingAttributes.Width = Root.GlobalPenWidth;
if (Root.CanvasCursor == 1)
SetPenTipCursor();
PenWidth_Change(Root.PixelToHiMetric(e.Delta > 0 ? 2 : -2));
return;
}
}
Expand Down Expand Up @@ -2932,7 +2923,10 @@ public void btStop_Click(object sender, EventArgs e)
bool LastClipArt1Status = false;
bool LastClipArt2Status = false;
bool LastClipArt3Status = false;
int SnappingPointerStep=0;

bool LastPenWidthPlus = false;
bool LastPenWidthMinus = false;
int SnappingPointerStep = 0;
DateTime SnappingPointerReset;

private void gpPenWidth_MouseDown(object sender, MouseEventArgs e)
Expand Down Expand Up @@ -3801,6 +3795,22 @@ private void tiSlide_Tick(object sender, EventArgs e)
btTool_Click(btClip3, null);
}
LastClipArt3Status = pressed;

pressed = (GetKeyState(Root.Hotkey_PenWidthPlus.Key) & 0x8000) == 0x8000;
if (pressed && !LastPenWidthPlus && Root.Hotkey_PenWidthPlus.ModifierMatch(control, alt, shift, win))
{
MouseTimeDown = DateTime.Now;
PenWidth_Change(Root.PenWidth_Delta);
}
LastPenWidthPlus = pressed;

pressed = (GetKeyState(Root.Hotkey_PenWidthMinus.Key) & 0x8000) == 0x8000;
if (pressed && !LastPenWidthMinus && Root.Hotkey_PenWidthMinus.ModifierMatch(control, alt, shift, win))
{
MouseTimeDown = DateTime.Now;
PenWidth_Change(-Root.PenWidth_Delta);
}
LastPenWidthMinus = pressed;
}

if (Root.Snapping < 0)
Expand All @@ -3810,6 +3820,17 @@ private void tiSlide_Tick(object sender, EventArgs e)

}

public void PenWidth_Change(int n)
{
Root.GlobalPenWidth += n;
if (Root.GlobalPenWidth < 1)
Root.GlobalPenWidth = 1;
IC.DefaultDrawingAttributes.Width = Root.GlobalPenWidth;
if (Root.CanvasCursor == 1)
SetPenTipCursor();
return;
}

private bool IsInsideVisibleScreen(int x, int y)
{
if (Root.WindowRect.Width > 0 && Root.WindowRect.Height > 0)
Expand Down
196 changes: 128 additions & 68 deletions src/FormOptions.Designer.cs

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions src/FormOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ private void FormOptions_Load(object sender, EventArgs e)
hiToolClipArt2.Hotkey = Root.Hotkey_ClipArt2;
hiToolClipArt3.Hotkey = Root.Hotkey_ClipArt3;
hiZoom.Hotkey = Root.Hotkey_Zoom;
hiPenWidthPlus.Hotkey = Root.Hotkey_PenWidthPlus;
hiPenWidthMinus.Hotkey = Root.Hotkey_PenWidthMinus;

WsUrlTxt.Text = Root.ObsUrl;
WsPwdTxt.Text = Root.ObsPwd;
Expand Down Expand Up @@ -385,6 +387,9 @@ private void FormOptions_LocalReload()
this.lbHkClipart3.Text = shortTxt(Root.Local.ButtonNameClipArt) + " 3";
this.lbHkZoom.Text = shortTxt(Root.Local.ButtonNameZoom);

this.lbHkPenWidthPlus.Text = Root.Local.OptionsHotkeysPenWidthPlus;
this.lbHkPenWidthMinus.Text = Root.Local.OptionsHotkeysPenWidthMinus;

this.lbGlobalHotkey.Text = Root.Local.OptionsHotkeysglobal;
this.cbAllowHotkeyInPointer.Text = Root.Local.OptionsHotkeysEnableinpointer;

Expand Down
3 changes: 3 additions & 0 deletions src/Local.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ public class Local
public string OptionsHotkeysglobal = "Global hotkey (start drawing, switch between mouse pointer and drawing)";
public string OptionsHotkeysEnableinpointer = "Enable all following hotkeys in mouse pointer mode (may cause a mess)";

public string OptionsHotkeysPenWidthPlus = "Pen Width +";
public string OptionsHotkeysPenWidthMinus = "Pen Width -";

public string VideoTab="Video";
public string OptNoVideo="No video recording";
public string OptObsRecord="OBS recording";
Expand Down
28 changes: 27 additions & 1 deletion src/Root.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@ public class Root
public Hotkey Hotkey_Global = new Hotkey();
public Hotkey[] Hotkey_Pens = new Hotkey[10];
public Hotkey Hotkey_FadingToggle = new Hotkey();

public Hotkey Hotkey_PenWidthPlus = new Hotkey();
public Hotkey Hotkey_PenWidthMinus = new Hotkey();

public Hotkey Hotkey_Eraser = new Hotkey();
public Hotkey Hotkey_InkVisible = new Hotkey();
public Hotkey Hotkey_Pointer = new Hotkey();
Expand Down Expand Up @@ -229,8 +233,9 @@ public class Root
public bool UponSubPanelUpdate = false;
public bool UponAllDrawingUpdate = false;
public bool MouseMovedUnderSnapshotDragging = false; // used to pause re-drawing when mouse is not moving during dragging to take a screenshot
public int PenWidth_Delta = 5;

public bool PanMode = false;
public bool PanMode = false;
public bool InkVisible = true;
public int MagneticRadius= MIN_MAGNETIC; // Magnet Radius; <=0 means off;
public int MinMagneticRadius() { return Math.Max(Math.Abs(MagneticRadius), MIN_MAGNETIC); }
Expand Down Expand Up @@ -1001,7 +1006,19 @@ public void ReadOptions(string file)
case "HOTKEY_ZOOM":
Hotkey_Zoom.Parse(sPara);
break;
case "HOTKEY_PENWIDTH_PLUS":
Hotkey_PenWidthPlus.Parse(sPara);
break;
case "HOTKEY_PENWIDTH_MINUS":
Hotkey_PenWidthMinus.Parse(sPara);
break;

case "PENWIDTH_DELTA":
if (int.TryParse(sPara, out tempi))
{
PenWidth_Delta=tempi;
}
break;
case "WHITE_TRAY_ICON":
if (sPara.ToUpper() == "TRUE" || sPara == "1" || sPara.ToUpper() == "ON")
WhiteTrayIcon = true;
Expand Down Expand Up @@ -1551,6 +1568,15 @@ public void SaveOptions(string file)
case "HOTKEY_ZOOM":
sPara = Hotkey_Zoom.ToStringInvariant();
break;
case "HOTKEY_PENWIDTH_PLUS":
sPara = Hotkey_PenWidthPlus.ToStringInvariant();
break;
case "HOTKEY_PENWIDTH_MINUS":
sPara = Hotkey_PenWidthMinus.ToStringInvariant();
break;
case "PENWIDTH_DELTA":
sPara = PenWidth_Delta.ToString();
break;

case "WHITE_TRAY_ICON":
if (WhiteTrayIcon)
Expand Down

0 comments on commit 81d7bec

Please sign in to comment.