diff --git a/program/MainWindow.cs b/program/MainWindow.cs index 7490331..b18bdc4 100644 --- a/program/MainWindow.cs +++ b/program/MainWindow.cs @@ -30,7 +30,14 @@ [UI] private Image ConnectionIcon = null; // was GtkIconView in the old glade [UI] private Label ConnectionAlertLabel = null; - [UI] private DrawingArea BatteryArea = null; + [UI] private DrawingArea BatteryArea = null; + + [UI] private Box BatteryBox = null; + [UI] private Label BatteryPercentLabel = null; + [UI] private Label ConnectionStatusLabel = null; + [UI] private Box StatusDot = null; + [UI] private RadioButton LangEnRadio = null; + private uint _retryTimerId; @@ -115,6 +122,13 @@ // LanguageSwitch.AddNotification("active", OnLanguageSwitchNotify); LanguageToggle.Toggled += OnLanguageToggled; + // icons drawn in code (no dependency on the icon theme) + SetModeIcon(Option1Button, ModeIcon.Kind.Stethoscope); + SetModeIcon(Option2Button, ModeIcon.Kind.BodyTarget); + SetModeIcon(Option3Button, ModeIcon.Kind.Chart); + SettingButton.Image = PlainIcon(ModeIcon.Kind.Cog, 32); + CloseButton.Image = PlainIcon(ModeIcon.Kind.Power, 30); + DeleteEvent += OnDeleteEvent; SizeAllocated += OnWindowSizeAllocated; @@ -170,6 +184,24 @@ }; _Language.Apply(LanguageToggle.Active); + // あ / A buttons drive the language directly (LanguageToggle is hidden now) + if (LangEnRadio != null) + { + LangEnRadio.Active = LanguageToggle.Active; // show the current language + LangEnRadio.Toggled += (s, e) => + { + bool english = LangEnRadio.Active; + Console.WriteLine("Language button -> " + (english ? "EN" : "JP")); + LanguageToggle.Active = english; // keeps the old toggle in sync + if (_Language.IsEnglish != english) + _Language.Apply(english); // switch even if the toggle didn't + }; + } + else + { + Console.WriteLine("LangEnRadio not found - is homepageallv9.glade loaded?"); + } + UpdateBattery(); _batteryTimerId = GLib.Timeout.Add(BatteryPollMs, OnBatteryTick); @@ -257,6 +289,13 @@ if (connected || AppConfig.DebugMode) StopAutoRetry(); else StartAutoRetry(); + + if (ConnectionStatusLabel != null) + ConnectionStatusLabel.Text = connected + ? (_Language.IsEnglish ? "Connected" : "接続中") + : (_Language.IsEnglish ? "Not connected" : "未接続"); + SetClass(ConnectionStatusLabel, "on", connected); + SetClass(StatusDot, "on", connected); if (ConnectionIcon == null) return; @@ -315,9 +354,9 @@ _battery = BatteryMonitor.Read(); - if (!_battery.Present) // desktop / dev machine — hide it entirely + if (!_battery.Present) // desktop / dev machine — hide it entirely { - BatteryArea.Visible = false; + if (BatteryBox != null) BatteryBox.Visible = false; else BatteryArea.Visible = false; return; } @@ -326,11 +365,13 @@ : "BatteryIcon.Discharging"; BatteryArea.Visible = true; + if (BatteryBox != null) BatteryBox.Visible = true; + if (BatteryPercentLabel != null) BatteryPercentLabel.Text = _battery.Percent + "%"; BatteryArea.TooltipText = _Language.Format(key, _battery.Percent); BatteryArea.QueueDraw(); } - private void OnBatteryDrawn(object o, DrawnArgs args) + private void OnBatteryDrawn(object o, DrawnArgs args) { DrawingArea area = (DrawingArea)o; Cairo.Context cr = args.Cr; @@ -385,42 +426,14 @@ cr.Restore(); } - // contents: optional charging bolt + the number - string text = _battery.Present - ? _battery.Percent.ToString(CultureInfo.InvariantCulture) - : "--"; - - cr.SelectFontFace("Sans", Cairo.FontSlant.Normal, Cairo.FontWeight.Bold); - cr.SetFontSize(bh * 0.60); - Cairo.TextExtents te = cr.TextExtents(text); - - double boltW = _battery.Charging ? bh * 0.36 : 0; - double boltG = _battery.Charging ? bh * 0.14 : 0; - double startX = bx + (bw - (boltW + boltG + te.Width)) / 2; - double tx = startX + boltW + boltG - te.XBearing; - double ty = by + (bh - te.Height) / 2 - te.YBearing; - - System.Action paint = () => + // The percentage is shown by BatteryPercentLabel now; only the + // charging bolt is drawn inside the battery. + if (_battery.Charging) { - if (_battery.Charging) - DrawBolt(cr, startX, by + bh * 0.16, boltW, bh * 0.68); - cr.MoveTo(tx, ty); - cr.ShowText(text); - }; - - cr.Save(); // over the fill -> light - cr.Rectangle(ix, 0, fillW, h); - cr.Clip(); - cr.SetSourceRGB(1, 1, 1); - paint(); - cr.Restore(); - - cr.Save(); // over the empty part -> theme fg - cr.Rectangle(ix + fillW, 0, w, h); - cr.Clip(); - cr.SetSourceRGBA(fg.Red, fg.Green, fg.Blue, fg.Alpha); - paint(); - cr.Restore(); + double boltHeight = bh * 0.68, boltWidth = bh * 0.36; + cr.SetSourceRGB(1, 1, 1); + DrawBolt(cr, bx + (bw - boltWidth) / 2, by + (bh - boltHeight) / 2, boltWidth, boltHeight); + } } private static void RoundedRect(Cairo.Context cr, double x, double y, @@ -741,5 +754,27 @@ catch { return false; } } + private static void SetModeIcon(Button b, ModeIcon.Kind kind) + { + var icon = new ModeIcon(kind, 96); + icon.Show(); + b.Image = icon; // Language still sets the label text. + // always-show-image / image-position are set in the glade + // (this GTK# version has no AlwaysShowImage property). + } + + private static Widget PlainIcon(ModeIcon.Kind kind, int size) + { + var icon = new ModeIcon(kind, size, false, 10, 1, 1, 1); // white, 10px gap + icon.Show(); + return icon; + } + + private static void SetClass(Widget w, string cls, bool on) + { + if (w == null) return; + if (on) w.StyleContext.AddClass(cls); else w.StyleContext.RemoveClass(cls); + } + } \ No newline at end of file diff --git a/program/ModeIcon.cs b/program/ModeIcon.cs new file mode 100644 index 0000000..7e11483 --- /dev/null +++ b/program/ModeIcon.cs @@ -0,0 +1,176 @@ +using System; +using Gtk; + +/// Line icons drawn with Cairo, so they never depend on the icon theme or +/// an SVG loader being installed. +/// +/// new ModeIcon(kind, 96) mode buttons: white icon on a +/// translucent rounded plate +/// new ModeIcon(kind, 32, false, 10, r, g, b) plain icon in any colour +/// (設定 / 終了 / 戻る / 再生) +public class ModeIcon : DrawingArea +{ + public enum Kind { Stethoscope, BodyTarget, Chart, Cog, Power, Back, Play } + + private readonly Kind _kind; + private readonly bool _plate; + private readonly int _gap; // space reserved between icon and label + private readonly double _r, _g, _b; // stroke colour + + /// Mode-button style: plate + white glyph + 28px gap. + public ModeIcon(Kind kind, int size) : this(kind, size, true, 28, 1, 1, 1) { } + + public ModeIcon(Kind kind, int size, bool plate, int gap, double r, double g, double b) + { + _kind = kind; _plate = plate; _gap = gap; + _r = r; _g = g; _b = b; + // GTK ignores CSS margins on a button's image, so the gap is part of the icon. + SetSizeRequest(size + gap, size); + Drawn += OnDrawn; + } + + private void OnDrawn(object o, DrawnArgs args) + { + var cr = args.Cr; + double w = AllocatedWidth - _gap, h = AllocatedHeight, s = Math.Min(w, h); + double x0 = 0, y0 = (h - s) / 2; + + double k; + if (_plate) + { + double r = s * 0.27; + cr.NewPath(); + cr.Arc(x0 + s - r, y0 + r, r, -Math.PI / 2, 0); + cr.Arc(x0 + s - r, y0 + s - r, r, 0, Math.PI / 2); + cr.Arc(x0 + r, y0 + s - r, r, Math.PI / 2, Math.PI); + cr.Arc(x0 + r, y0 + r, r, Math.PI, 3 * Math.PI / 2); + cr.ClosePath(); + cr.SetSourceRGBA(1, 1, 1, 0.18); + cr.Fill(); + k = s * 0.58 / 24.0; + } + else + { + k = s / 24.0; + } + + cr.Save(); + cr.Translate(x0 + (s - 24 * k) / 2, y0 + (s - 24 * k) / 2); + cr.Scale(k, k); + cr.LineWidth = _plate ? 1.8 : 2.2; + cr.LineCap = Cairo.LineCap.Round; + cr.LineJoin = Cairo.LineJoin.Round; + cr.SetSourceRGB(_r, _g, _b); + + switch (_kind) + { + case Kind.Stethoscope: Stethoscope(cr); break; + case Kind.BodyTarget: BodyTarget(cr); break; + case Kind.Chart: Chart(cr); break; + case Kind.Cog: Cog(cr); break; + case Kind.Power: Power(cr); break; + case Kind.Back: Back(cr); break; + case Kind.Play: Play(cr); break; + } + cr.Stroke(); + cr.Restore(); + + args.RetVal = true; + } + + // earpieces, binaurals, tubing, chest piece + private static void Stethoscope(Cairo.Context cr) + { + cr.MoveTo(4, 3); cr.LineTo(6, 3); + cr.MoveTo(14, 3); cr.LineTo(16, 3); + cr.MoveTo(5, 3); cr.LineTo(5, 8); + cr.ArcNegative(10, 8, 5, Math.PI, 0); // U-bend to (15,8) + cr.LineTo(15, 3); + cr.MoveTo(10, 13); cr.LineTo(10, 15.5); + cr.ArcNegative(15, 15.5, 5, Math.PI, 0); // tubing to (20,15.5) + cr.LineTo(20, 12.5); + cr.NewSubPath(); + cr.Arc(20, 10.5, 2, 0, 2 * Math.PI); // chest piece + } + + // torso with an auscultation target on the chest + private static void BodyTarget(Cairo.Context cr) + { + cr.MoveTo(9.5, 3.5); // neckline + cr.CurveTo(9.9, 4.7, 10.8, 5.4, 12, 5.4); + cr.CurveTo(13.2, 5.4, 14.1, 4.7, 14.5, 3.5); + cr.MoveTo(9.5, 3.5); // body outline + cr.LineTo(5.5, 5.3); cr.LineTo(3.5, 11); cr.LineTo(6.1, 12); + cr.LineTo(7, 9.5); cr.LineTo(7, 21); cr.LineTo(17, 21); + cr.LineTo(17, 9.5); cr.LineTo(17.9, 12); cr.LineTo(20.5, 11); + cr.LineTo(18.5, 5.3); cr.LineTo(14.5, 3.5); + cr.NewSubPath(); + cr.Arc(12, 13, 2, 0, 2 * Math.PI); // target + cr.MoveTo(12, 9.8); cr.LineTo(12, 10.8); + cr.MoveTo(12, 15.2); cr.LineTo(12, 16.2); + cr.MoveTo(8.8, 13); cr.LineTo(9.8, 13); + cr.MoveTo(14.2, 13); cr.LineTo(15.2, 13); + } + + // clipboard chart with a check and answer lines + private static void Chart(Cairo.Context cr) + { + cr.Rectangle(9, 3, 6, 3); // clip + cr.MoveTo(7, 4.5); cr.LineTo(6, 4.5); // board + cr.ArcNegative(6, 5.5, 1, -Math.PI / 2, -Math.PI); + cr.LineTo(5, 20); + cr.ArcNegative(6, 20, 1, Math.PI, Math.PI / 2); + cr.LineTo(18, 21); + cr.ArcNegative(18, 20, 1, Math.PI / 2, 0); + cr.LineTo(19, 5.5); + cr.ArcNegative(18, 5.5, 1, 0, -Math.PI / 2); + cr.LineTo(17, 4.5); + cr.MoveTo(8.5, 11); cr.LineTo(10.3, 12.8); cr.LineTo(14, 9); // check + cr.MoveTo(8.5, 16.5); cr.LineTo(15.5, 16.5); + cr.MoveTo(8.5, 19); cr.LineTo(13, 19); + } + + // cog wheel: 8 trapezoid teeth around a ring, hole in the middle + private static void Cog(Cairo.Context cr) + { + const int teeth = 8; + const double cx = 12, cy = 12, rOut = 10.5, rIn = 8; + double step = 2 * Math.PI / teeth; + double halfOut = step * 0.20, halfIn = step * 0.30; + + for (int i = 0; i < teeth; i++) + { + double a = i * step - Math.PI / 2; + double a1 = a - halfIn, a2 = a - halfOut, a3 = a + halfOut, a4 = a + halfIn; + if (i == 0) cr.MoveTo(cx + rIn * Math.Cos(a1), cy + rIn * Math.Sin(a1)); + else cr.LineTo(cx + rIn * Math.Cos(a1), cy + rIn * Math.Sin(a1)); + cr.LineTo(cx + rOut * Math.Cos(a2), cy + rOut * Math.Sin(a2)); + cr.LineTo(cx + rOut * Math.Cos(a3), cy + rOut * Math.Sin(a3)); + cr.LineTo(cx + rIn * Math.Cos(a4), cy + rIn * Math.Sin(a4)); + cr.Arc(cx, cy, rIn, a4, a + step - halfIn); // ring to the next tooth + } + cr.ClosePath(); + cr.NewSubPath(); + cr.Arc(cx, cy, 3.2, 0, 2 * Math.PI); + } + + // power symbol + private static void Power(Cairo.Context cr) + { + cr.Arc(12, 13, 8.5, -Math.PI / 2 + 0.75, 3 * Math.PI / 2 - 0.75); + cr.MoveTo(12, 2.5); cr.LineTo(12, 11.5); + } + + // ‹ chevron + private static void Back(Cairo.Context cr) + { + cr.MoveTo(15, 5); cr.LineTo(8, 12); cr.LineTo(15, 19); + } + + // ▶ outline + private static void Play(Cairo.Context cr) + { + cr.MoveTo(7, 4.5); cr.LineTo(19.5, 12); cr.LineTo(7, 19.5); + cr.ClosePath(); + } +} diff --git a/program/homepageallv8.glade b/program/homepageallv8.glade index ccfe141..f033ca9 100644 --- a/program/homepageallv8.glade +++ b/program/homepageallv8.glade @@ -4,6 +4,18 @@ + + True + False + emblem-system-symbolic + 32 + + + True + False + system-shutdown-symbolic + 30 + True False @@ -31,29 +43,65 @@ + SplashGrid True False 20 5 - 20 + + StatusCapsule True False horizontal - 12 + 14 end center True False 40 - 8 + 10 - + + LangSegment True False + 3 + True center - Language + + + LangJpRadio + あ + True + True + False + True + False + + + True + True + 0 + + + + + LangEnRadio + A + True + True + False + False + LangJpRadio + + + True + True + 1 + + False @@ -62,62 +110,168 @@ - - A / あ + + CapsuleDivider True - True - True - False - center + False + vertical + 10 + 10 False - False + True 1 - + True False - network-offline - 6 + horizontal + 8 center + + + StatusDot + 10 + 10 + True + False + center + + + False + False + 0 + + + + + ConnectionStatusLabel + True + False + center + 0.5 + 未接続 + + + False + False + 1 + + + + + + False + True + False + network-offline + + + False + False + 2 + + False - False + True 2 + True + True False horizontal - 4 - center + 8 + fill - - True - False - center - 12 - 70 - 34 - True + + CapsuleDivider + True + False + vertical + 6 + 10 + 10 + + + False + True + 0 + + + + + True + False + center + 34 + 18 + True + + + False + False + 1 + + + + + BatteryPercentLabel + True + False + center + 0.5 + --% + + + False + False + 2 + + False - False + True 3 + + + + False + True + False + Language False False - 3 + 4 + + + + + A / あ + False + True + True + True + False + + + False + False + 5 @@ -133,10 +287,13 @@ True True True + True + left 50 20 True True + 0 0 @@ -149,10 +306,13 @@ True True True + True + left 50 20 True True + 0 0 @@ -165,10 +325,13 @@ True True True + True + left 50 20 True True + 0 0 @@ -187,6 +350,9 @@ True 20 40 + SettingIcon + left + True 1 @@ -205,6 +371,9 @@ True 20 40 + CloseIcon + left + True 1 diff --git a/program/touch_friendly.css b/program/touch_friendly.css index 7e30042..c90c152 100644 --- a/program/touch_friendly.css +++ b/program/touch_friendly.css @@ -41,29 +41,122 @@ /* #ConditionNameLabel is styled in the SOUND PAGE section below. */ -/* ---------- splash / main menu ---------- */ +/* ══════════════════════════════════════════════════════════════════ + SPLASH / MAIN MENU — design "Final" (A1 buttons + status capsule) + ══════════════════════════════════════════════════════════════════ */ + +#SplashGrid { + background-color: rgba(239, 234, 224, 0.92); + padding-bottom: 20px; +} + +/* ── mode buttons: rounded green, icon (ModeIcon) + label ── */ #Option1Button, #Option2Button, #Option3Button { min-height: 95px; - background-color: #6A991A; + padding: 0 34px; + background-color: #5E8E1B; + background-image: none; + border-width: 0; + border-radius: 24px; + box-shadow: 0 6px 18px rgba(70, 105, 18, 0.28); + outline-style: none; } -#Option1Button label, #Option2Button label, #Option3Button label { font-size: 50px; } -#Option1Button:hover, #Option2Button:hover, #Option3Button:hover { background-color: #7BAE22; } -#Option1Button:active, #Option2Button:active, #Option3Button:active { background-color: #5A8315; } +#Option1Button label, #Option2Button label, #Option3Button label { + font-size: 50px; + font-weight: 900; + color: #FFFFFF; +} +#Option1Button:hover, #Option2Button:hover, #Option3Button:hover { background-color: #6A9C22; } +#Option1Button:active, #Option2Button:active, #Option3Button:active { background-color: #4F7A15; } -#SettingButton { min-height: 95px;min-width: 200px; background-color: #F97F00; } -#SettingButton label { font-size: 34px; } -#SettingButton:hover { background-color: #FF9020; } +/* modes locked until the device connects */ +#Option1Button:disabled, #Option2Button:disabled, #Option3Button:disabled { + background-color: #A9B39B; + box-shadow: none; +} +#Option1Button:disabled label, +#Option2Button:disabled label, +#Option3Button:disabled label { color: #F2F4EE; } + +/* ── 設定 / 終了 ── */ +#SettingButton, #CloseButton { + min-height: 95px; + min-width: 200px; + border-width: 0; + border-radius: 20px; + background-image: none; + outline-style: none; +} +#SettingButton label, #CloseButton label { font-size: 32px; font-weight: 900; color: #FFFFFF; } +#SettingButton image, #CloseButton image { color: #FFFFFF; margin-right: 10px; } + +#SettingButton { background-color: #F28A0A; box-shadow: 0 6px 16px rgba(242, 138, 10, 0.28); } +#SettingButton:hover { background-color: #FF9A24; } #SettingButton:active { background-color: #D96C00; } -#CloseButton { min-height: 95px;min-width: 200px; background-color: #808080; } -#CloseButton label { font-size: 34px; color: #ffffff; } -#CloseButton:hover { background-color: #909090; } -#CloseButton:active { background-color: #6E6E6E; } +#CloseButton { background-color: #6B7280; box-shadow: 0 6px 16px rgba(60, 66, 76, 0.25); } +#CloseButton:hover { background-color: #7B828F; } +#CloseButton:active { background-color: #575D69; } -#LanguageToggle { min-height: 46px; min-width: 80px; background-color: #ffffff; } -#LanguageToggle label { font-size: 20px; color: #1e1e1e; } -#LanguageToggle:checked { background-color: #0B3B6B; } -#LanguageToggle:checked label { color: #ffffff; } +/* ── status capsule (top-right) ── */ +#StatusCapsule { + background-color: #FFFFFF; + border: 1px solid #E2DDD2; + border-radius: 27px; + padding: 6px 6px 6px 18px; + box-shadow: 0 2px 8px rgba(30, 36, 48, 0.06); +} +#CapsuleDivider { background-color: #E2DDD2; min-width: 1px; } + +#BatteryArea { color: #4A505B; } /* battery outline (OnBatteryDrawn) */ +#BatteryPercentLabel { + font-family: 'Noto Sans JP', 'IPAPGothic', sans-serif; + font-size: 16px; + font-weight: 700; + color: #1E2430; +} + +#StatusDot { background-color: #D93025; border-radius: 5px; } +#StatusDot.on { background-color: #2E9E4F; } +#ConnectionStatusLabel { + font-family: 'Noto Sans JP', 'IPAPGothic', sans-serif; + font-size: 15px; + font-weight: 700; + color: #A3201B; +} +#ConnectionStatusLabel.on { color: #1E6B32; } + +/* あ / A segmented switch (drives the hidden LanguageToggle) */ +#LangSegment { background-color: #ECEEF1; border-radius: 22px; padding: 3px; } +#LangJpRadio, #LangEnRadio, +#LangJpRadio button, #LangEnRadio button { + min-height: 38px; + min-width: 50px; + padding: 0; + background-color: transparent; + background-image: none; + border-width: 0; + border-radius: 19px; + box-shadow: none; + outline-style: none; +} +#LangJpRadio label, #LangEnRadio label { font-size: 17px; font-weight: 500; color: #4A505B; } +#LangJpRadio:checked, #LangEnRadio:checked, +#LangJpRadio button:checked, #LangEnRadio button:checked { background-color: #0B3B6B; } +#LangJpRadio:checked label, #LangEnRadio:checked label { color: #FFFFFF; font-weight: 700; } + +/* ── connection alert (bottom centre) ── */ +#ConnectionAlertLabel { + font-family: 'Noto Sans JP', 'IPAPGothic', sans-serif; + font-size: 21px; + font-weight: 700; + color: #FFFFFF; + background-color: #C62828; + border-radius: 28px; + padding: 12px 30px; + margin: 8px 40px; + box-shadow: 0 6px 16px rgba(198, 40, 40, 0.28); +} /* ---------- back buttons ---------- */ /* MapBackButton and SoundBackButton are styled in their page sections @@ -427,25 +520,6 @@ /* the popup of any combo is a separate toplevel — keep it readable */ window.popup list row label { color: #111111; } -/* ---------- disabled states ---------- */ -/* splash: modes unavailable until the device connects */ -#Option1Button:disabled, #Option2Button:disabled, #Option3Button:disabled { - background-color: #A8AFA0; - border-color: rgba(0,0,0,0.25); -} -#Option1Button:disabled label, -#Option2Button:disabled label, -#Option3Button:disabled label { color: #EFEFEF; } - -#ConnectionAlertLabel { - font-family: 'Noto Sans JP', 'IPAPGothic', sans-serif; - font-size: 22px; - font-weight: 700; - color: #ffffff; - background-color: #C62828; - padding: 10px 24px; - margin: 8px 40px; -} /* #BatteryLabel { margin-left: 4px; } */ #BatteryLabel.battery-low { color: #c62828; font-weight: bold; }