Skip to content

Commit 231e180

Browse files
committed
⬆️♻️ Use new FredEmmott::GUI combobox APIs to reduce repetition
1 parent a7110b4 commit 231e180

2 files changed

Lines changed: 14 additions & 30 deletions

File tree

src/main.cpp

Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -392,16 +392,18 @@ void ShowArtifacts() {
392392
}
393393

394394
void ShowLicenses() {
395-
enum class Products { Self, CompressedEmbed, WIL, FUI, Yoga };
396-
constexpr std::array ProductLabels {
397-
std::tuple {Products::Self, "OpenKneeboard Fresh Start"},
398-
std::tuple {Products::CompressedEmbed, "compressed-embed"},
399-
std::tuple {Products::FUI, "FredEmmott::GUI"},
400-
std::tuple {Products::WIL, "Windows Implementation Library"},
401-
std::tuple {Products::Yoga, "Yoga"},
395+
struct Product {
396+
std::string_view mName;
397+
std::string_view mLicense;
402398
};
403399
static const Licenses licenses {};
404-
static auto key {Products::Self};
400+
static const std::array Products {
401+
Product {"OpenKneeboard Fresh Start", licenses.SelfAsStringView()},
402+
Product {"Compressed-Embed", licenses.CompressedEmbedAsStringView()},
403+
Product {"FredEmmott::GUI", licenses.FUIAsStringView()},
404+
Product {"Windows Implementation Library", licenses.WILAsStringView()},
405+
Product {"Yoga", licenses.YogaAsStringView()},
406+
};
405407

406408
const auto layout
407409
= BeginVStackPanel().Styled(Style().FlexGrow(1).Gap(12)).Scoped();
@@ -419,33 +421,15 @@ void ShowLicenses() {
419421
.Body();
420422
}
421423

422-
ComboBox(&key, ProductLabels)
424+
static std::size_t selectedIndex {};
425+
ComboBox(&selectedIndex, Products, &Product::mName)
423426
.Styled(Style().AlignSelf(YGAlignStretch))
424427
.Caption("Component");
425428

426-
std::string_view license;
427-
switch (key) {
428-
case Products::Self:
429-
license = licenses.SelfAsStringView();
430-
break;
431-
case Products::CompressedEmbed:
432-
license = licenses.CompressedEmbedAsStringView();
433-
break;
434-
case Products::WIL:
435-
license = licenses.WILAsStringView();
436-
break;
437-
case Products::FUI:
438-
license = licenses.FUIAsStringView();
439-
break;
440-
case Products::Yoga:
441-
license = licenses.YogaAsStringView();
442-
break;
443-
}
444-
445429
const auto card = BeginCard().Scoped();
446430
const auto scroll
447431
= BeginVScrollView().Scoped().Styled(Style().Width(800).Height(600));
448-
TextBlock(license);
432+
TextBlock(Products.at(selectedIndex).mLicense);
449433
}
450434

451435
void ShowLicensesButton() {

vcpkg-configuration.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"registries": [
33
{
44
"kind": "git",
5-
"baseline": "ffb4f11a81bc92bce1cb52277f614469328997f9",
5+
"baseline": "c3a8703cf9b5b2aaf1004842ace2dd7417cb5b1e",
66
"repository": "https://github.com/fredemmott/vcpkg-registry",
77
"packages": [
88
"compressed-embed",

0 commit comments

Comments
 (0)