Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
606ae85781 |
+42
-17
@@ -295,6 +295,17 @@ const SVG_OTTER: &str = include_str!("../assets/icons/otter.svg");
|
|||||||
const SVG_HIVE: &str = include_str!("../assets/icons/hive.svg");
|
const SVG_HIVE: &str = include_str!("../assets/icons/hive.svg");
|
||||||
const SVG_BOLT: &str = include_str!("../assets/icons/bolt.svg");
|
const SVG_BOLT: &str = include_str!("../assets/icons/bolt.svg");
|
||||||
|
|
||||||
|
/// KPI card minimum widths. The count cards (Total/Hashing/...) are narrow; the
|
||||||
|
/// two wide cards (SHA-256 Hashrate, Est. power) need more room so their
|
||||||
|
/// icon + units-bearing value never clips (round 12 #2). The wide floor fits the
|
||||||
|
/// widest realistic value the card can show -- a ~20px icon + 5px gap + a value
|
||||||
|
/// text up to "118.0 PH" (~127px at 19pt bold) + the card's 16px side inset --
|
||||||
|
/// so the units ("kW"/"PH"/...) stay visible instead of being squeezed off; the
|
||||||
|
/// row collapses the wide cards entirely (see `on_resize`) rather than shrink
|
||||||
|
/// them below this and clip.
|
||||||
|
const KPI_MIN: i32 = 116;
|
||||||
|
const KPI_WIDE_MIN: i32 = 176;
|
||||||
|
|
||||||
/// Recolour an SVG to the KPI card's colour (round 11 #15). Some Font Awesome
|
/// Recolour an SVG to the KPI card's colour (round 11 #15). Some Font Awesome
|
||||||
/// exports use fill="currentColor" (replaced here); others omit fill entirely and
|
/// exports use fill="currentColor" (replaced here); others omit fill entirely and
|
||||||
/// default to black, so a root `fill` is also injected for shapes to inherit.
|
/// default to black, so a root `fill` is also injected for shapes to inherit.
|
||||||
@@ -560,7 +571,7 @@ pub fn build(frame: Widget) -> App {
|
|||||||
card.set_bg(pal.card_bg.0, pal.card_bg.1, pal.card_bg.2);
|
card.set_bg(pal.card_bg.0, pal.card_bg.1, pal.card_bg.2);
|
||||||
// Min-content floor (the widest label/value); cards grow equally past
|
// Min-content floor (the widest label/value); cards grow equally past
|
||||||
// this to fill the window (proportion 1 + EXPAND on add).
|
// this to fill the window (proportion 1 + EXPAND on add).
|
||||||
card.set_min_size(116, 62);
|
card.set_min_size(KPI_MIN, 62);
|
||||||
let cs = Widget::box_sizer(true);
|
let cs = Widget::box_sizer(true);
|
||||||
let value = Widget::static_text(card, "0");
|
let value = Widget::static_text(card, "0");
|
||||||
value.set_font_size(19);
|
value.set_font_size(19);
|
||||||
@@ -622,8 +633,13 @@ pub fn build(frame: Widget) -> App {
|
|||||||
// Total-hashrate value renders in the default (black) text colour, not accent
|
// Total-hashrate value renders in the default (black) text colour, not accent
|
||||||
// (round 12 #1); it still dims with focus like the other neutral cards.
|
// (round 12 #1); it still dims with focus like the other neutral cards.
|
||||||
let (card_hashrate, kpi_hashrate) = mk_card("SHA-256 Hashrate", ColorKind::Neutral, Some(SVG_HIVE));
|
let (card_hashrate, kpi_hashrate) = mk_card("SHA-256 Hashrate", ColorKind::Neutral, Some(SVG_HIVE));
|
||||||
let (_card_power, kpi_power) = mk_card("Est. power", ColorKind::Neutral, Some(SVG_BOLT));
|
let (card_power, kpi_power) = mk_card("Est. power", ColorKind::Neutral, Some(SVG_BOLT));
|
||||||
drop(mk_card);
|
drop(mk_card);
|
||||||
|
// The two wide cards carry a units-bearing value (icon + e.g. "685 TH" /
|
||||||
|
// "21.3 kW"); give them a larger min width so the value never clips, and
|
||||||
|
// collapse them before the row would squeeze them below it (round 12 #2).
|
||||||
|
card_hashrate.set_min_size(KPI_WIDE_MIN, 62);
|
||||||
|
card_power.set_min_size(KPI_WIDE_MIN, 62);
|
||||||
let _ = (card_hashing, card_slow, card_not, card_paused);
|
let _ = (card_hashing, card_slow, card_not, card_paused);
|
||||||
// The hashrate card is kpi_cards[5] in build order (Total, Hashing, Slow,
|
// The hashrate card is kpi_cards[5] in build order (Total, Hashing, Slow,
|
||||||
// Not, Paused, Hashrate, Power); its caption is retitled per algorithm.
|
// Not, Paused, Hashrate, Power); its caption is retitled per algorithm.
|
||||||
@@ -832,23 +848,32 @@ impl App {
|
|||||||
/// seven cards at their minimum width, the two wide cards are hidden so the
|
/// seven cards at their minimum width, the two wide cards are hidden so the
|
||||||
/// five miner-count cards fill the row; they return when there is room again.
|
/// five miner-count cards fill the row; they return when there is room again.
|
||||||
fn on_resize(&mut self, width: i32) {
|
fn on_resize(&mut self, width: i32) {
|
||||||
// Each card is a ~116px min + BORDER_ALL*2 (8px); the row itself is
|
// Each card occupies its min width + BORDER_ALL*2 (8px); the row itself is
|
||||||
// inset by the root border. Below the width needed for all seven, drop
|
// inset by the root border (~12px). Collapse the two wide cards below the
|
||||||
// the two wide cards.
|
// width where all seven fit at their mins, so the wide cards' units-bearing
|
||||||
const CARD_SLOT: i32 = 116 + 8;
|
// value never gets squeezed/clipped (round 12 #2) -- they drop out cleanly
|
||||||
let need_all = CARD_SLOT * 7 + 12;
|
// instead.
|
||||||
|
let need_all = 5 * (KPI_MIN + 8) + 2 * (KPI_WIDE_MIN + 8) + 12;
|
||||||
let want_collapsed = width < need_all;
|
let want_collapsed = width < need_all;
|
||||||
if want_collapsed == self.kpi_collapsed {
|
if want_collapsed != self.kpi_collapsed {
|
||||||
return;
|
self.kpi_collapsed = want_collapsed;
|
||||||
|
let show = !want_collapsed;
|
||||||
|
// kpi_cards[5] = Hashrate card, [6] = Est. power card (build order).
|
||||||
|
let hashrate_card = self.kpi_cards[5].0;
|
||||||
|
let power_card = self.kpi_cards[6].0;
|
||||||
|
self.kpi_row.sizer_show(hashrate_card, show);
|
||||||
|
self.kpi_row.sizer_show(power_card, show);
|
||||||
|
self.panel.layout();
|
||||||
|
}
|
||||||
|
// A nested wxPanel does not re-run its own sizer when the parent resizes
|
||||||
|
// it, so the value/label centring spacers keep the slot sizes they were
|
||||||
|
// given at the previous width. Re-layout each card here so the value
|
||||||
|
// (which may carry a units suffix like "kW"/"PH") stays centred and its
|
||||||
|
// full text is allocated -- otherwise the suffix reads as clipped when
|
||||||
|
// the row is squeezed (round 12 #2).
|
||||||
|
for (card, _, _, _) in &self.kpi_cards {
|
||||||
|
card.layout();
|
||||||
}
|
}
|
||||||
self.kpi_collapsed = want_collapsed;
|
|
||||||
let show = !want_collapsed;
|
|
||||||
// kpi_cards[5] = Hashrate card, [6] = Est. power card (build order).
|
|
||||||
let hashrate_card = self.kpi_cards[5].0;
|
|
||||||
let power_card = self.kpi_cards[6].0;
|
|
||||||
self.kpi_row.sizer_show(hashrate_card, show);
|
|
||||||
self.kpi_row.sizer_show(power_card, show);
|
|
||||||
self.panel.layout();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn rebuild_table(&mut self) {
|
pub fn rebuild_table(&mut self) {
|
||||||
|
|||||||
Reference in New Issue
Block a user