Skip to content

Commit 15964d3

Browse files
author
Delta-Kronecker
committed
ui: dynamic centered layout, reserve update banner slot only when shown, make banner clickable
1 parent cf20421 commit 15964d3

1 file changed

Lines changed: 40 additions & 10 deletions

File tree

scripts/TorJetUi.cs

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -416,19 +416,35 @@ private void LayoutPass()
416416
rcMin = new Rectangle(w - 78, 0, 38, 36);
417417

418418
int cx = w / 2;
419-
rcPower = new Rectangle(cx - 52, 88, 104, 104);
419+
bool showProxy = !autoProxyEnabled;
420+
bool showUpd = showUpdateBanner && updateVersion.Length > 0;
420421

421-
int yBelowRing = 204;
422-
if (autoProxyEnabled)
423-
rcProxy = new Rectangle(0, 0, 0, 0);
422+
// vertical flow: ring -> connect -> proxy? -> settings -> update?
423+
// connect text is drawn at rcPower.Bottom + 8 with height 22.
424+
int total = 104 + 30 + 24; // ring + connect region + gap
425+
if (showProxy) total += 42 + 14; // proxy row + gap
426+
total += 38; // settings row
427+
if (showUpd) total += 14 + 38; // gap + update banner row
428+
429+
int y = 78 + Math.Max(0, (ClientSize.Height - 24 - 78 - total) / 2);
430+
rcPower = new Rectangle(cx - 52, y, 104, 104);
431+
y += 104 + 30 + 24;
432+
if (showProxy)
433+
{
434+
rcProxy = new Rectangle(24, y, w - 48, 42);
435+
y += 42 + 14;
436+
}
424437
else
438+
rcProxy = new Rectangle(0, 0, 0, 0);
439+
rcSettings = new Rectangle(24, y, w - 48, 38);
440+
y += 38;
441+
if (showUpd)
425442
{
426-
rcProxy = new Rectangle(24, yBelowRing, w - 48, 42);
427-
yBelowRing += 50;
443+
y += 14;
444+
rcUpdateBtn = new Rectangle(24, y, w - 48, 38);
428445
}
429-
rcSettings = new Rectangle(24, yBelowRing, w - 48, 38);
430-
yBelowRing += 44;
431-
rcUpdateBtn = new Rectangle(24, yBelowRing, w - 48, 38);
446+
else
447+
rcUpdateBtn = new Rectangle(0, 0, 0, 0);
432448

433449
int ry = 78 - settingsScrollY;
434450
int rowCount = SettingLabels.Length;
@@ -567,7 +583,7 @@ private void PaintMain(Graphics g)
567583
string stateTxt = StateText();
568584
Color stateCol = StateColor();
569585
Theme.DrawTextShadow(g, stateTxt, Theme.Big(),
570-
new Rectangle(0, 46, ClientSize.Width, 36), stateCol,
586+
new Rectangle(0, 58, ClientSize.Width, 36), stateCol,
571587
Color.FromArgb(60, 0, 0, 0),
572588
TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter,
573589
1, 2);
@@ -1016,6 +1032,7 @@ private void OnMouseDownAll(object s, MouseEventArgs e)
10161032
case 5: OnConnectButton(); break;
10171033
case 20: ApplyProxyToggle(!ProxyIsOurs()); break;
10181034
case 30: page = Page.Settings; settingsScrollY = 0; CancelEdit(); LayoutPass(); Invalidate(); break;
1035+
case 50: OpenReleases(); break;
10191036
case 40: page = Page.Main; CancelEdit(); LayoutPass(); Invalidate(); break;
10201037
default:
10211038
if (page != Page.Settings || h < 100) break;
@@ -1119,6 +1136,8 @@ private int HitTest(Point p)
11191136
{
11201137
if (!autoProxyEnabled && rcProxy.Contains(p)) return 20;
11211138
if (rcSettings.Contains(p)) return 30;
1139+
if (showUpdateBanner && updateVersion.Length > 0 &&
1140+
rcUpdateBtn.Contains(p)) return 50;
11221141
}
11231142
else
11241143
{
@@ -1223,6 +1242,17 @@ private void Run(string file, string args)
12231242
catch { }
12241243
}
12251244

1245+
private void OpenReleases()
1246+
{
1247+
try
1248+
{
1249+
Process.Start(new ProcessStartInfo(
1250+
"https://github.com/Delta-Kronecker/TorJet/releases")
1251+
{ UseShellExecute = true });
1252+
}
1253+
catch { }
1254+
}
1255+
12261256
private void FlashMessage(string msg)
12271257
{
12281258
errorMsg = msg;

0 commit comments

Comments
 (0)