From 15318a4c9d050feba9c2f01363aa1915829f69ff Mon Sep 17 00:00:00 2001
From: Michael Lu <38804680+Yamazaki93@users.noreply.github.com>
Date: Mon, 13 Feb 2023 20:59:47 -0800
Subject: [PATCH 01/14] Initial setup of checklist infrastructure and test
drawing on MFD
---
B78XH/B78XH.vcxproj | 11 ++++-
B78XH/B78XH.vcxproj.filters | 33 +++++++++++++++
B78XH/CheckListItem.h | 59 +++++++++++++++++++++++++++
B78XH/CheckListLine.cpp | 13 ++++++
B78XH/CheckListLine.h | 25 ++++++++++++
B78XH/CheckListLineStateIndicator.cpp | 22 ++++++++++
B78XH/CheckListLineStateIndicator.h | 21 ++++++++++
B78XH/MFDCHKLControl.cpp | 16 ++++++++
B78XH/MFDCHKLControl.h | 16 ++++++++
B78XH/MFDPanelResolver.h | 7 ++--
B78XH/MFDSYSControl.cpp | 11 -----
B78XH/MFDSYSControl.h | 10 -----
12 files changed, 219 insertions(+), 25 deletions(-)
create mode 100644 B78XH/CheckListItem.h
create mode 100644 B78XH/CheckListLine.cpp
create mode 100644 B78XH/CheckListLine.h
create mode 100644 B78XH/CheckListLineStateIndicator.cpp
create mode 100644 B78XH/CheckListLineStateIndicator.h
create mode 100644 B78XH/MFDCHKLControl.cpp
create mode 100644 B78XH/MFDCHKLControl.h
diff --git a/B78XH/B78XH.vcxproj b/B78XH/B78XH.vcxproj
index 963b842..b42a8fe 100644
--- a/B78XH/B78XH.vcxproj
+++ b/B78XH/B78XH.vcxproj
@@ -51,7 +51,7 @@
true
.wasm
$(MSFS_IncludePath);$(CPP_EXTERNALS)\include\NANOVG;
- ..\..\..\..\WebstormProjects\B78XH-INTERIOR\SimObjects\Airplanes\Asobo_B787_10\panel
+ ..\..\B78XH\SimObjects\Airplanes\Heavy-Division-B78XH-mod\panel
false
@@ -153,6 +153,10 @@
+
+
+
+
@@ -371,6 +375,11 @@
+
+
+
+
+
diff --git a/B78XH/B78XH.vcxproj.filters b/B78XH/B78XH.vcxproj.filters
index 6ca7e02..9f3eb4a 100644
--- a/B78XH/B78XH.vcxproj.filters
+++ b/B78XH/B78XH.vcxproj.filters
@@ -613,6 +613,18 @@
Source Files\Controls\Controls\MFD\ND
+
+ Source Files\Controls\Controls\MFD\CheckList
+
+
+ Source Files\Controls\Controls\MFD\CheckList\CheckListBasics
+
+
+ Source Files\Controls\Controls\MFD\CheckList\CheckListBasics
+
+
+ Source Files\Controls\Controls\MFD\CheckList\CheckListBasics
+
@@ -1332,6 +1344,21 @@
Source Files\Controls\Controls\MFD\ND
+
+ Source Files\Controls\Controls\MFD\CheckList
+
+
+ Source Files\Controls\Controls\MFD\CheckList\CheckListBasics
+
+
+ Source Files\Controls\Controls\MFD\CheckList\CheckListBasics
+
+
+ Source Files\Controls\Controls\MFD\CheckList\CheckListBasics
+
+
+ Source Files\Controls\Controls\MFD\CheckList\CheckListBasics
+
@@ -1652,6 +1679,12 @@
{983f63d5-9b41-4db6-a45a-80ca39311e9c}
+
+ {41a37572-c463-484a-bf96-160e9f8155a2}
+
+
+ {1b4f3874-894c-4757-b210-c6ef873b9b07}
+
diff --git a/B78XH/CheckListItem.h b/B78XH/CheckListItem.h
new file mode 100644
index 0000000..0fccd51
--- /dev/null
+++ b/B78XH/CheckListItem.h
@@ -0,0 +1,59 @@
+#pragma once
+#include "Control.h"
+#include "Tools/Tools.h"
+
+/**
+* \brief An abstract representation of an "item" on the checklist. An Item simply has a "CHECKLIST_ITEM_STATE"
+ */
+class CheckListItem : public Control {
+ public:
+ enum class CHECKLIST_ITEM_STATE {
+ OPEN,
+ COMPLETED,
+ OVERRIDDEN
+ };
+
+ CheckListItem(const string& name)
+ : Control(name),
+ currentState_(CHECKLIST_ITEM_STATE::OPEN) {
+ }
+
+ /**
+ * \brief Sets the item to the desired state.
+ */
+ auto setCurrentState(CHECKLIST_ITEM_STATE state) -> void;
+ /**
+ * \brief Gets the current state of the item.
+ */
+ auto getCurrentState() const -> CHECKLIST_ITEM_STATE;
+
+ protected:
+ /**
+ * \brief Checks if the item is being hovered by the cursor.
+ * \return true if in focus, false otherwise
+ */
+ auto isInFocus() -> bool;
+ /**
+ * \brief Gets the color corresponding to the current state.
+ * \return Desired color.
+ */
+ auto getItemStateColor() const -> NVGcolor;
+ /**
+ * \brief Draws a magenta border around the item
+ */
+ auto drawBorder() -> void;
+
+ private:
+ /**
+ * \brief The item's current state.
+ */
+ CHECKLIST_ITEM_STATE currentState_;
+ /**
+ * \brief The item's bound in absolute space. Order is LRTB.
+ */
+ float bounds_[4] = {0, 0, 0, 0};
+ /**
+ * \brief Updates bounds_ with the current absolute position.
+ */
+ auto calculateBounds() -> void;
+};
diff --git a/B78XH/CheckListLine.cpp b/B78XH/CheckListLine.cpp
new file mode 100644
index 0000000..1487e71
--- /dev/null
+++ b/B78XH/CheckListLine.cpp
@@ -0,0 +1,13 @@
+#include "CheckListLine.h"
+
+void CheckListLine::prepareControls() {
+ CheckListItem::prepareControls();
+
+ add(std::make_shared("STATE_INDICATOR", this));
+}
+
+void CheckListLine::setupControls() {
+ CheckListItem::setupControls();
+
+ getControl("STATE_INDICATOR")->position.setPosition(CheckListDimensions::LINE_MARGIN, CheckListDimensions::LINE_MARGIN, CheckListDimensions::INNER_LINE_END_Y, CheckListDimensions::INNER_LINE_END_Y);
+}
diff --git a/B78XH/CheckListLine.h b/B78XH/CheckListLine.h
new file mode 100644
index 0000000..ac7256c
--- /dev/null
+++ b/B78XH/CheckListLine.h
@@ -0,0 +1,25 @@
+#pragma once
+
+#include "CheckListItem.h"
+#include "CheckListLineStateIndicator.h"
+
+/**
+ * \brief A line in the check list. This typically consists of 1 "LineStateIndicator" and several "CheckListItem"
+ */
+class CheckListLine : public CheckListItem {
+ public:
+ enum class CHECKLIST_LINE_TYPE {
+ OPEN_LOOP,
+ CLOSED_LOOP
+ };
+
+ CheckListLine(const string& name, const CHECKLIST_LINE_TYPE line_type)
+ : CheckListItem(name),
+ line_type(line_type) {
+ }
+
+ const CHECKLIST_LINE_TYPE line_type;
+
+ auto prepareControls() -> void override;
+ auto setupControls() -> void override;
+};
diff --git a/B78XH/CheckListLineStateIndicator.cpp b/B78XH/CheckListLineStateIndicator.cpp
new file mode 100644
index 0000000..a5e06ae
--- /dev/null
+++ b/B78XH/CheckListLineStateIndicator.cpp
@@ -0,0 +1,22 @@
+#include "CheckListLineStateIndicator.h"
+#include "CheckListLine.h"
+
+void CheckListLineStateIndicator::render() {
+ CheckListItem::render();
+
+ if (line_->line_type == CheckListLine::CHECKLIST_LINE_TYPE::OPEN_LOOP) {
+ }
+ else {
+ // green check, testing
+ nvgStrokeColor(getContext(), Tools::Colors::green);
+ nvgStrokeWidth(getContext(), 3);
+ nvgBeginPath(getContext());
+ {
+ nvgMoveTo(getContext(), CheckListDimensions::LINE_MARGIN, CheckListDimensions::ONE_FORTH_INNER_LINE_HEIGHT * 3);
+ nvgLineTo(getContext(), CheckListDimensions::LINE_MARGIN + CheckListDimensions::ONE_FORTH_INNER_LINE_HEIGHT, CheckListDimensions::INNER_LINE_END_Y);
+ nvgLineTo(getContext(), CheckListDimensions::LINE_MARGIN + CheckListDimensions::ONE_FORTH_INNER_LINE_HEIGHT * 3, CheckListDimensions::LINE_MARGIN);
+ nvgStroke(getContext());
+ }
+ nvgClosePath(getContext());
+ }
+}
diff --git a/B78XH/CheckListLineStateIndicator.h b/B78XH/CheckListLineStateIndicator.h
new file mode 100644
index 0000000..d735dd9
--- /dev/null
+++ b/B78XH/CheckListLineStateIndicator.h
@@ -0,0 +1,21 @@
+#pragma once
+#include "CheckListItem.h"
+#include "CheckListDimensions.h"
+
+class CheckListLine;
+
+/**
+ * \brief The main state indicator of a "line" in a checklist. This is typically the "checkbox"/"checkmark". Internal, Owned by "CheckListLine"
+ */
+class CheckListLineStateIndicator : public CheckListItem {
+ public:
+ CheckListLineStateIndicator(const string& name, const CheckListLine* parentLine)
+ : CheckListItem(name),
+ line_(parentLine){
+ }
+
+ auto render() -> void override;
+
+ private:
+ const CheckListLine* line_; // weak_ptr here?
+};
diff --git a/B78XH/MFDCHKLControl.cpp b/B78XH/MFDCHKLControl.cpp
new file mode 100644
index 0000000..4ba8cdb
--- /dev/null
+++ b/B78XH/MFDCHKLControl.cpp
@@ -0,0 +1,16 @@
+#include "MFDCHKLControl.h"
+
+auto MFDCHKLControl::render() -> void {
+ MFDBaseControl::render();
+}
+
+void MFDCHKLControl::prepareControls() {
+ MFDBaseControl::prepareControls();
+
+ add(std::make_shared("TEST_LINE", CheckListLine::CHECKLIST_LINE_TYPE::CLOSED_LOOP));
+}
+
+void MFDCHKLControl::setupControls() {
+ MFDBaseControl::setupControls();
+ getControl("TEST_LINE")->position.setPosition(0, 0, CheckListDimensions::TOTAL_LINE_WIDTH, CheckListDimensions::TOTAL_LINE_HEIGHT);
+}
diff --git a/B78XH/MFDCHKLControl.h b/B78XH/MFDCHKLControl.h
new file mode 100644
index 0000000..84da28b
--- /dev/null
+++ b/B78XH/MFDCHKLControl.h
@@ -0,0 +1,16 @@
+#pragma once
+#include "MFDBaseControl.h"
+#include "CheckListLine.h"
+#include "CheckListDimensions.h"
+
+class MFDCHKLControl : public MFDBaseControl {
+public:
+ explicit MFDCHKLControl(const string& name)
+ : MFDBaseControl(name) {
+ ident_ = CONTROL_IDENT::CHKL;
+ }
+
+ auto render() -> void override;
+ auto prepareControls() -> void override;
+ auto setupControls() -> void override;
+};
diff --git a/B78XH/MFDPanelResolver.h b/B78XH/MFDPanelResolver.h
index e71cf66..d684276 100644
--- a/B78XH/MFDPanelResolver.h
+++ b/B78XH/MFDPanelResolver.h
@@ -6,6 +6,7 @@
#include "MFDEmptyControl.h"
#include "MFDNDControl.h"
#include "MFDSYSControl.h"
+#include "MFDCHKLControl.h"
class MFDPanelResolver {
public:
@@ -70,7 +71,7 @@ class MFDPanelResolver {
std::array, 6> mfdOnePanels{
std::make_shared("MFDEmptyControl"),
std::make_shared("MFDEmptyControl"),
- std::make_shared("MFDEmptyControl"),
+ std::make_shared("MFDCHKLControl"),
std::make_shared("MFDEmptyControl"),
std::make_shared("MFDEmptyControl"),
std::make_shared("MFDEmptyControl")
@@ -79,7 +80,7 @@ class MFDPanelResolver {
std::array, 6> mfdTwoPanels{
std::make_shared("MFDEmptyControl"),
std::make_shared("MFDEmptyControl"),
- std::make_shared("MFDEmptyControl"),
+ std::make_shared("MFDCHKLControl"),
std::make_shared("MFDEmptyControl"),
std::make_shared("MFDEmptyControl"),
std::make_shared("MFDEmptyControl")
@@ -88,7 +89,7 @@ class MFDPanelResolver {
std::array, 6> mfdThreePanels{
std::make_shared("MFDEmptyControl"),
std::make_shared("MFDEmptyControl"),
- std::make_shared("MFDEmptyControl"),
+ std::make_shared("MFDCHKLControl"),
std::make_shared("MFDEmptyControl"),
std::make_shared("MFDEmptyControl"),
std::make_shared("MFDEmptyControl")
diff --git a/B78XH/MFDSYSControl.cpp b/B78XH/MFDSYSControl.cpp
index 344e01d..c40c1dc 100644
--- a/B78XH/MFDSYSControl.cpp
+++ b/B78XH/MFDSYSControl.cpp
@@ -24,17 +24,6 @@ auto MFDINFOControl::render() -> void {
nvgClosePath(getContext());
}
-auto MFDCHKLControl::render() -> void {
- MFDBaseControl::render();
- nvgBeginPath(getContext());
- {
- nvgFillColor(getContext(), nvgRGB(0, 0, 255));
- nvgRect(getContext(), 0, 0, 200, 200);
- nvgFill(getContext());
- }
- nvgClosePath(getContext());
-}
-
auto MFDCOMMControl::render() -> void {
MFDBaseControl::render();
nvgBeginPath(getContext());
diff --git a/B78XH/MFDSYSControl.h b/B78XH/MFDSYSControl.h
index 5814342..5b61ab2 100644
--- a/B78XH/MFDSYSControl.h
+++ b/B78XH/MFDSYSControl.h
@@ -21,16 +21,6 @@ class MFDINFOControl : public MFDBaseControl {
auto render() -> void override;
};
-class MFDCHKLControl : public MFDBaseControl {
- public:
- explicit MFDCHKLControl(const string& name)
- : MFDBaseControl(name) {
- ident_ = CONTROL_IDENT::TEST3;
- }
-
- auto render() -> void override;
-};
-
class MFDCOMMControl : public MFDBaseControl {
public:
explicit MFDCOMMControl(const string& name)
From 16b49d4dad93db3d0b17baa93b5debce73157bbe Mon Sep 17 00:00:00 2001
From: Michael Lu <38804680+Yamazaki93@users.noreply.github.com>
Date: Mon, 13 Feb 2023 21:18:54 -0800
Subject: [PATCH 02/14] Add missing dimension/item files
---
B78XH/B78XH.vcxproj.filters | 6 ++--
B78XH/CheckListDimensions.h | 12 +++++++
B78XH/CheckListItem.cpp | 50 +++++++++++++++++++++++++++
B78XH/CheckListLine.cpp | 2 +-
B78XH/CheckListLineStateIndicator.cpp | 6 ++--
B78XH/MFDCHKLControl.cpp | 2 +-
6 files changed, 70 insertions(+), 8 deletions(-)
create mode 100644 B78XH/CheckListDimensions.h
create mode 100644 B78XH/CheckListItem.cpp
diff --git a/B78XH/B78XH.vcxproj.filters b/B78XH/B78XH.vcxproj.filters
index 9f3eb4a..9124c4a 100644
--- a/B78XH/B78XH.vcxproj.filters
+++ b/B78XH/B78XH.vcxproj.filters
@@ -616,15 +616,15 @@
Source Files\Controls\Controls\MFD\CheckList
-
- Source Files\Controls\Controls\MFD\CheckList\CheckListBasics
-
Source Files\Controls\Controls\MFD\CheckList\CheckListBasics
Source Files\Controls\Controls\MFD\CheckList\CheckListBasics
+
+ Source Files\Controls\Controls\MFD\CheckList\CheckListBasics
+
diff --git a/B78XH/CheckListDimensions.h b/B78XH/CheckListDimensions.h
new file mode 100644
index 0000000..681e704
--- /dev/null
+++ b/B78XH/CheckListDimensions.h
@@ -0,0 +1,12 @@
+#pragma once
+
+class CheckListDimensions {
+ public:
+ static constexpr float TOTAL_HEIGHT = 50;
+ static constexpr float TOTAL_WIDTH = 700; // should match half MFD width
+ static constexpr float MARGIN = 5;
+ static constexpr float INNER_HEIGHT = TOTAL_HEIGHT - 2 * MARGIN;
+ static constexpr float ONE_FORTH_INNER_HEIGHT = INNER_HEIGHT / 4;
+ static constexpr float INNER_Y_END = TOTAL_HEIGHT - MARGIN;
+
+};
diff --git a/B78XH/CheckListItem.cpp b/B78XH/CheckListItem.cpp
new file mode 100644
index 0000000..b25d517
--- /dev/null
+++ b/B78XH/CheckListItem.cpp
@@ -0,0 +1,50 @@
+#include "CheckListItem.h"
+
+auto CheckListItem::setCurrentState(CHECKLIST_ITEM_STATE state) -> void {
+ currentState_ = state;
+}
+
+auto CheckListItem::getCurrentState() const -> CHECKLIST_ITEM_STATE {
+ return currentState_;
+}
+
+auto CheckListItem::isInFocus() -> bool {
+ calculateBounds();
+ if (mouseMove_.x >= bounds_[0] &&
+ mouseMove_.x <= bounds_[1] &&
+ mouseMove_.y >= bounds_[2] &&
+ mouseMove_.y < bounds_[3]) {
+ return true;
+ }
+ return false;
+}
+
+auto CheckListItem::getItemStateColor() const -> NVGcolor {
+ switch (currentState_) {
+ case CHECKLIST_ITEM_STATE::OPEN: return Tools::Colors::white;
+ case CHECKLIST_ITEM_STATE::COMPLETED: return Tools::Colors::green;
+ case CHECKLIST_ITEM_STATE::OVERRIDDEN: return Tools::Colors::cyan;
+ default: return Tools::Colors::white;
+ }
+}
+
+auto CheckListItem::drawBorder() -> void {
+ nvgStrokeColor(getContext(), Tools::Colors::magenta);
+ nvgStrokeWidth(getContext(), 5.0f);
+ nvgBeginPath(getContext());
+ {
+ nvgMoveTo(getContext(), 0, 0);
+ nvgLineTo(getContext(), position.width, 0);
+ nvgLineTo(getContext(), position.width, position.height);
+ nvgLineTo(getContext(), 0, position.height);
+ nvgStroke(getContext());
+ }
+ nvgClosePath(getContext());
+}
+
+auto CheckListItem::calculateBounds() -> void {
+ bounds_[0] = absolutePosition.left;
+ bounds_[1] = absolutePosition.left + position.width;
+ bounds_[2] = absolutePosition.top;
+ bounds_[3] = absolutePosition.top + position.height;
+}
diff --git a/B78XH/CheckListLine.cpp b/B78XH/CheckListLine.cpp
index 1487e71..2df2835 100644
--- a/B78XH/CheckListLine.cpp
+++ b/B78XH/CheckListLine.cpp
@@ -9,5 +9,5 @@ void CheckListLine::prepareControls() {
void CheckListLine::setupControls() {
CheckListItem::setupControls();
- getControl("STATE_INDICATOR")->position.setPosition(CheckListDimensions::LINE_MARGIN, CheckListDimensions::LINE_MARGIN, CheckListDimensions::INNER_LINE_END_Y, CheckListDimensions::INNER_LINE_END_Y);
+ getControl("STATE_INDICATOR")->position.setPosition(CheckListDimensions::MARGIN, CheckListDimensions::MARGIN, CheckListDimensions::INNER_Y_END, CheckListDimensions::INNER_Y_END);
}
diff --git a/B78XH/CheckListLineStateIndicator.cpp b/B78XH/CheckListLineStateIndicator.cpp
index a5e06ae..e8c4b7a 100644
--- a/B78XH/CheckListLineStateIndicator.cpp
+++ b/B78XH/CheckListLineStateIndicator.cpp
@@ -12,9 +12,9 @@ void CheckListLineStateIndicator::render() {
nvgStrokeWidth(getContext(), 3);
nvgBeginPath(getContext());
{
- nvgMoveTo(getContext(), CheckListDimensions::LINE_MARGIN, CheckListDimensions::ONE_FORTH_INNER_LINE_HEIGHT * 3);
- nvgLineTo(getContext(), CheckListDimensions::LINE_MARGIN + CheckListDimensions::ONE_FORTH_INNER_LINE_HEIGHT, CheckListDimensions::INNER_LINE_END_Y);
- nvgLineTo(getContext(), CheckListDimensions::LINE_MARGIN + CheckListDimensions::ONE_FORTH_INNER_LINE_HEIGHT * 3, CheckListDimensions::LINE_MARGIN);
+ nvgMoveTo(getContext(), CheckListDimensions::MARGIN, CheckListDimensions::ONE_FORTH_INNER_HEIGHT * 3);
+ nvgLineTo(getContext(), CheckListDimensions::MARGIN + CheckListDimensions::ONE_FORTH_INNER_HEIGHT, CheckListDimensions::INNER_Y_END);
+ nvgLineTo(getContext(), CheckListDimensions::MARGIN + CheckListDimensions::ONE_FORTH_INNER_HEIGHT * 3, CheckListDimensions::MARGIN);
nvgStroke(getContext());
}
nvgClosePath(getContext());
diff --git a/B78XH/MFDCHKLControl.cpp b/B78XH/MFDCHKLControl.cpp
index 4ba8cdb..b446b76 100644
--- a/B78XH/MFDCHKLControl.cpp
+++ b/B78XH/MFDCHKLControl.cpp
@@ -12,5 +12,5 @@ void MFDCHKLControl::prepareControls() {
void MFDCHKLControl::setupControls() {
MFDBaseControl::setupControls();
- getControl("TEST_LINE")->position.setPosition(0, 0, CheckListDimensions::TOTAL_LINE_WIDTH, CheckListDimensions::TOTAL_LINE_HEIGHT);
+ getControl("TEST_LINE")->position.setPosition(0, 0, CheckListDimensions::TOTAL_WIDTH, CheckListDimensions::TOTAL_HEIGHT);
}
From fd44a29467fbe764ef0cbcb92295257a08041456 Mon Sep 17 00:00:00 2001
From: Michael Lu <38804680+Yamazaki93@users.noreply.github.com>
Date: Mon, 13 Feb 2023 23:50:17 -0800
Subject: [PATCH 03/14] Open loop indicator, border and checkmark
---
B78XH/CheckListDimensions.h | 11 +--
B78XH/CheckListItem.cpp | 14 ++--
B78XH/CheckListItem.h | 1 +
B78XH/CheckListLine.cpp | 7 ++
B78XH/CheckListLine.h | 3 +-
B78XH/CheckListLineStateIndicator.cpp | 103 ++++++++++++++++++++++----
B78XH/CheckListLineStateIndicator.h | 3 +
B78XH/MFDCHKLControl.cpp | 4 +-
8 files changed, 120 insertions(+), 26 deletions(-)
diff --git a/B78XH/CheckListDimensions.h b/B78XH/CheckListDimensions.h
index 681e704..59f57b8 100644
--- a/B78XH/CheckListDimensions.h
+++ b/B78XH/CheckListDimensions.h
@@ -2,11 +2,12 @@
class CheckListDimensions {
public:
- static constexpr float TOTAL_HEIGHT = 50;
+ static constexpr float TOTAL_LINE_HEIGHT = 70;
static constexpr float TOTAL_WIDTH = 700; // should match half MFD width
- static constexpr float MARGIN = 5;
- static constexpr float INNER_HEIGHT = TOTAL_HEIGHT - 2 * MARGIN;
+ static constexpr float MARGIN = 8;
+ static constexpr float BORDER_WIDTH = 5;
+ static constexpr float INNER_START = MARGIN + BORDER_WIDTH / 2;
+ static constexpr float INNER_HEIGHT = TOTAL_LINE_HEIGHT - 2 * INNER_START;
static constexpr float ONE_FORTH_INNER_HEIGHT = INNER_HEIGHT / 4;
- static constexpr float INNER_Y_END = TOTAL_HEIGHT - MARGIN;
-
+ static constexpr float INNER_Y_END = TOTAL_LINE_HEIGHT - INNER_START;
};
diff --git a/B78XH/CheckListItem.cpp b/B78XH/CheckListItem.cpp
index b25d517..7125738 100644
--- a/B78XH/CheckListItem.cpp
+++ b/B78XH/CheckListItem.cpp
@@ -30,13 +30,17 @@ auto CheckListItem::getItemStateColor() const -> NVGcolor {
auto CheckListItem::drawBorder() -> void {
nvgStrokeColor(getContext(), Tools::Colors::magenta);
- nvgStrokeWidth(getContext(), 5.0f);
+ nvgStrokeWidth(getContext(), CheckListDimensions::BORDER_WIDTH);
nvgBeginPath(getContext());
{
- nvgMoveTo(getContext(), 0, 0);
- nvgLineTo(getContext(), position.width, 0);
- nvgLineTo(getContext(), position.width, position.height);
- nvgLineTo(getContext(), 0, position.height);
+ nvgMoveTo(getContext(), CheckListDimensions::BORDER_WIDTH / 2, CheckListDimensions::BORDER_WIDTH / 2);
+ nvgLineTo(getContext(), position.width - CheckListDimensions::BORDER_WIDTH / 2,
+ CheckListDimensions::BORDER_WIDTH / 2);
+ nvgLineTo(getContext(), position.width - CheckListDimensions::BORDER_WIDTH / 2,
+ position.height - CheckListDimensions::BORDER_WIDTH / 2);
+ nvgLineTo(getContext(), CheckListDimensions::BORDER_WIDTH / 2,
+ position.height - CheckListDimensions::BORDER_WIDTH / 2);
+ nvgLineTo(getContext(), CheckListDimensions::BORDER_WIDTH / 2, CheckListDimensions::BORDER_WIDTH / 2);
nvgStroke(getContext());
}
nvgClosePath(getContext());
diff --git a/B78XH/CheckListItem.h b/B78XH/CheckListItem.h
index 0fccd51..93a5828 100644
--- a/B78XH/CheckListItem.h
+++ b/B78XH/CheckListItem.h
@@ -1,6 +1,7 @@
#pragma once
#include "Control.h"
#include "Tools/Tools.h"
+#include "CheckListDimensions.h"
/**
* \brief An abstract representation of an "item" on the checklist. An Item simply has a "CHECKLIST_ITEM_STATE"
diff --git a/B78XH/CheckListLine.cpp b/B78XH/CheckListLine.cpp
index 2df2835..8ea8cd1 100644
--- a/B78XH/CheckListLine.cpp
+++ b/B78XH/CheckListLine.cpp
@@ -1,5 +1,12 @@
#include "CheckListLine.h"
+void CheckListLine::render() {
+ CheckListItem::render();
+ if(isInFocus()) {
+ drawBorder();
+ }
+}
+
void CheckListLine::prepareControls() {
CheckListItem::prepareControls();
diff --git a/B78XH/CheckListLine.h b/B78XH/CheckListLine.h
index ac7256c..4e54c6a 100644
--- a/B78XH/CheckListLine.h
+++ b/B78XH/CheckListLine.h
@@ -19,7 +19,8 @@ class CheckListLine : public CheckListItem {
}
const CHECKLIST_LINE_TYPE line_type;
-
+
+ auto render() -> void override;
auto prepareControls() -> void override;
auto setupControls() -> void override;
};
diff --git a/B78XH/CheckListLineStateIndicator.cpp b/B78XH/CheckListLineStateIndicator.cpp
index e8c4b7a..7167546 100644
--- a/B78XH/CheckListLineStateIndicator.cpp
+++ b/B78XH/CheckListLineStateIndicator.cpp
@@ -1,22 +1,99 @@
#include "CheckListLineStateIndicator.h"
#include "CheckListLine.h"
+void CheckListLineStateIndicator::drawOpenLoopIndicator() {
+ constexpr auto left = 0;
+ constexpr auto top = 0;
+ const auto width = getRelativePosition().getWidth();
+ const auto height = getRelativePosition().getHeight();
+ // open loop indicator
+ nvgFillColor(getContext(), Tools::Colors::cduButtonGray);
+ nvgBeginPath(getContext());
+ {
+ nvgRect(getContext(), 0, 0, width, height);
+ nvgFill(getContext());
+ }
+ nvgClosePath(getContext());
+
+ // top
+ nvgFillColor(getContext(), Tools::Colors::cduButtonBorderTopGray);
+ nvgBeginPath(getContext());
+ {
+ nvgMoveTo(getContext(), left, top);
+ nvgLineTo(getContext(), (left + width), top);
+ nvgLineTo(getContext(), (left + width - CheckListDimensions::BORDER_WIDTH),
+ (top + CheckListDimensions::BORDER_WIDTH));
+ nvgLineTo(getContext(), (left + CheckListDimensions::BORDER_WIDTH), (top + CheckListDimensions::BORDER_WIDTH));
+ nvgLineTo(getContext(), left, top);
+ }
+ nvgClosePath(getContext());
+ nvgFill(getContext());
+
+ // right
+ nvgFillColor(getContext(), Tools::Colors::cduButtonBorderRightGray);
+ nvgBeginPath(getContext());
+ {
+ nvgMoveTo(getContext(), (left + width), top);
+ nvgLineTo(getContext(), (left + width), (top + height) + 1);
+ nvgLineTo(getContext(), (left + width - CheckListDimensions::BORDER_WIDTH),
+ (top + height - CheckListDimensions::BORDER_WIDTH) + 1);
+ nvgLineTo(getContext(), (left + width - CheckListDimensions::BORDER_WIDTH),
+ (top + CheckListDimensions::BORDER_WIDTH));
+ nvgLineTo(getContext(), (left + width), (top));
+ }
+ nvgClosePath(getContext());
+ nvgFill(getContext());
+
+ // bottom
+ nvgFillColor(getContext(), Tools::Colors::cduButtonBorderBottomGray);
+ nvgBeginPath(getContext());
+ {
+ nvgMoveTo(getContext(), left, (top + height));
+ nvgLineTo(getContext(), (left + width), (top + height));
+ nvgLineTo(getContext(), (left + width - CheckListDimensions::BORDER_WIDTH),
+ (top + height - CheckListDimensions::BORDER_WIDTH));
+ nvgLineTo(getContext(), (left + CheckListDimensions::BORDER_WIDTH),
+ (top + height - CheckListDimensions::BORDER_WIDTH));
+ nvgLineTo(getContext(), (left), (top + height));
+ }
+ nvgClosePath(getContext());
+ nvgFill(getContext());
+
+ // left
+ nvgFillColor(getContext(), Tools::Colors::cduButtonBorderLeftGray);
+ nvgBeginPath(getContext());
+ {
+ nvgMoveTo(getContext(), left, top);
+ nvgLineTo(getContext(), (left + CheckListDimensions::BORDER_WIDTH), (top + CheckListDimensions::BORDER_WIDTH));
+ nvgLineTo(getContext(), (left + CheckListDimensions::BORDER_WIDTH),
+ (top + height - CheckListDimensions::BORDER_WIDTH));
+ nvgLineTo(getContext(), (left), (top + height));
+ nvgLineTo(getContext(), (left), (top));
+ }
+ nvgClosePath(getContext());
+ nvgFill(getContext());
+}
+
+void CheckListLineStateIndicator::drawCheckMark() {
+ nvgStrokeColor(getContext(), Tools::Colors::green);
+ nvgStrokeWidth(getContext(), 3);
+ nvgBeginPath(getContext());
+ {
+ nvgMoveTo(getContext(), CheckListDimensions::BORDER_WIDTH, 25);
+ nvgLineTo(getContext(), CheckListDimensions::BORDER_WIDTH + 15,
+ position.height - CheckListDimensions::BORDER_WIDTH);
+ nvgLineTo(getContext(), position.width - CheckListDimensions::BORDER_WIDTH, CheckListDimensions::BORDER_WIDTH);
+ nvgStroke(getContext());
+ }
+ nvgClosePath(getContext());
+}
+
void CheckListLineStateIndicator::render() {
CheckListItem::render();
if (line_->line_type == CheckListLine::CHECKLIST_LINE_TYPE::OPEN_LOOP) {
+ drawOpenLoopIndicator();
}
- else {
- // green check, testing
- nvgStrokeColor(getContext(), Tools::Colors::green);
- nvgStrokeWidth(getContext(), 3);
- nvgBeginPath(getContext());
- {
- nvgMoveTo(getContext(), CheckListDimensions::MARGIN, CheckListDimensions::ONE_FORTH_INNER_HEIGHT * 3);
- nvgLineTo(getContext(), CheckListDimensions::MARGIN + CheckListDimensions::ONE_FORTH_INNER_HEIGHT, CheckListDimensions::INNER_Y_END);
- nvgLineTo(getContext(), CheckListDimensions::MARGIN + CheckListDimensions::ONE_FORTH_INNER_HEIGHT * 3, CheckListDimensions::MARGIN);
- nvgStroke(getContext());
- }
- nvgClosePath(getContext());
- }
+ // green check, testing
+ drawCheckMark();
}
diff --git a/B78XH/CheckListLineStateIndicator.h b/B78XH/CheckListLineStateIndicator.h
index d735dd9..017e1a3 100644
--- a/B78XH/CheckListLineStateIndicator.h
+++ b/B78XH/CheckListLineStateIndicator.h
@@ -18,4 +18,7 @@ class CheckListLineStateIndicator : public CheckListItem {
private:
const CheckListLine* line_; // weak_ptr here?
+
+ auto drawOpenLoopIndicator() -> void;
+ auto drawCheckMark() -> void;
};
diff --git a/B78XH/MFDCHKLControl.cpp b/B78XH/MFDCHKLControl.cpp
index b446b76..6ae121f 100644
--- a/B78XH/MFDCHKLControl.cpp
+++ b/B78XH/MFDCHKLControl.cpp
@@ -7,10 +7,10 @@ auto MFDCHKLControl::render() -> void {
void MFDCHKLControl::prepareControls() {
MFDBaseControl::prepareControls();
- add(std::make_shared("TEST_LINE", CheckListLine::CHECKLIST_LINE_TYPE::CLOSED_LOOP));
+ add(std::make_shared("TEST_LINE", CheckListLine::CHECKLIST_LINE_TYPE::OPEN_LOOP));
}
void MFDCHKLControl::setupControls() {
MFDBaseControl::setupControls();
- getControl("TEST_LINE")->position.setPosition(0, 0, CheckListDimensions::TOTAL_WIDTH, CheckListDimensions::TOTAL_HEIGHT);
+ getControl("TEST_LINE")->position.setPosition(0, 0, CheckListDimensions::TOTAL_WIDTH, CheckListDimensions::TOTAL_LINE_HEIGHT);
}
From bab9b0cbd4b1bf898cd54f0440a681ef64643771 Mon Sep 17 00:00:00 2001
From: Michael Lu <38804680+Yamazaki93@users.noreply.github.com>
Date: Tue, 14 Feb 2023 03:15:19 -0800
Subject: [PATCH 04/14] LineStateIndicator renders line state based on line
type
---
B78XH/CheckListLineStateIndicator.cpp | 40 ++++++++++++++++++---------
B78XH/CheckListLineStateIndicator.h | 4 +--
B78XH/MFDCHKLControl.cpp | 17 ++++++++----
3 files changed, 41 insertions(+), 20 deletions(-)
diff --git a/B78XH/CheckListLineStateIndicator.cpp b/B78XH/CheckListLineStateIndicator.cpp
index 7167546..7c5d058 100644
--- a/B78XH/CheckListLineStateIndicator.cpp
+++ b/B78XH/CheckListLineStateIndicator.cpp
@@ -6,6 +6,18 @@ void CheckListLineStateIndicator::drawOpenLoopIndicator() {
constexpr auto top = 0;
const auto width = getRelativePosition().getWidth();
const auto height = getRelativePosition().getHeight();
+ const auto topGray = line_->getCurrentState() == CheckListItem::CHECKLIST_ITEM_STATE::COMPLETED
+ ? Tools::Colors::cduButtonBorderBottomGray
+ : Tools::Colors::cduButtonBorderTopGray;
+ const auto bottomGray = line_->getCurrentState() == CheckListItem::CHECKLIST_ITEM_STATE::COMPLETED
+ ? Tools::Colors::cduButtonBorderTopGray
+ : Tools::Colors::cduButtonBorderBottomGray;
+ const auto leftGray = line_->getCurrentState() == CheckListItem::CHECKLIST_ITEM_STATE::COMPLETED
+ ? Tools::Colors::cduButtonBorderRightGray
+ : Tools::Colors::cduButtonBorderLeftGray;
+ const auto rightGray = line_->getCurrentState() == CheckListItem::CHECKLIST_ITEM_STATE::COMPLETED
+ ? Tools::Colors::cduButtonBorderLeftGray
+ : Tools::Colors::cduButtonBorderRightGray;
// open loop indicator
nvgFillColor(getContext(), Tools::Colors::cduButtonGray);
nvgBeginPath(getContext());
@@ -14,9 +26,9 @@ void CheckListLineStateIndicator::drawOpenLoopIndicator() {
nvgFill(getContext());
}
nvgClosePath(getContext());
-
+
// top
- nvgFillColor(getContext(), Tools::Colors::cduButtonBorderTopGray);
+ nvgFillColor(getContext(), topGray);
nvgBeginPath(getContext());
{
nvgMoveTo(getContext(), left, top);
@@ -30,7 +42,7 @@ void CheckListLineStateIndicator::drawOpenLoopIndicator() {
nvgFill(getContext());
// right
- nvgFillColor(getContext(), Tools::Colors::cduButtonBorderRightGray);
+ nvgFillColor(getContext(), rightGray);
nvgBeginPath(getContext());
{
nvgMoveTo(getContext(), (left + width), top);
@@ -45,7 +57,7 @@ void CheckListLineStateIndicator::drawOpenLoopIndicator() {
nvgFill(getContext());
// bottom
- nvgFillColor(getContext(), Tools::Colors::cduButtonBorderBottomGray);
+ nvgFillColor(getContext(), bottomGray);
nvgBeginPath(getContext());
{
nvgMoveTo(getContext(), left, (top + height));
@@ -60,7 +72,7 @@ void CheckListLineStateIndicator::drawOpenLoopIndicator() {
nvgFill(getContext());
// left
- nvgFillColor(getContext(), Tools::Colors::cduButtonBorderLeftGray);
+ nvgFillColor(getContext(), leftGray);
nvgBeginPath(getContext());
{
nvgMoveTo(getContext(), left, top);
@@ -76,24 +88,26 @@ void CheckListLineStateIndicator::drawOpenLoopIndicator() {
void CheckListLineStateIndicator::drawCheckMark() {
nvgStrokeColor(getContext(), Tools::Colors::green);
- nvgStrokeWidth(getContext(), 3);
+ nvgStrokeWidth(getContext(), 4);
nvgBeginPath(getContext());
{
- nvgMoveTo(getContext(), CheckListDimensions::BORDER_WIDTH, 25);
- nvgLineTo(getContext(), CheckListDimensions::BORDER_WIDTH + 15,
- position.height - CheckListDimensions::BORDER_WIDTH);
- nvgLineTo(getContext(), position.width - CheckListDimensions::BORDER_WIDTH, CheckListDimensions::BORDER_WIDTH);
+ constexpr float sideOffset = 10;
+ nvgMoveTo(getContext(), sideOffset, 30);
+ nvgLineTo(getContext(), sideOffset+ 12,
+ position.height - sideOffset);
+ nvgLineTo(getContext(), position.width - sideOffset, sideOffset);
nvgStroke(getContext());
}
nvgClosePath(getContext());
}
void CheckListLineStateIndicator::render() {
- CheckListItem::render();
+ Control::render();
if (line_->line_type == CheckListLine::CHECKLIST_LINE_TYPE::OPEN_LOOP) {
drawOpenLoopIndicator();
}
- // green check, testing
- drawCheckMark();
+ if (line_->getCurrentState() == CheckListItem::CHECKLIST_ITEM_STATE::COMPLETED) {
+ drawCheckMark();
+ }
}
diff --git a/B78XH/CheckListLineStateIndicator.h b/B78XH/CheckListLineStateIndicator.h
index 017e1a3..b23f4d9 100644
--- a/B78XH/CheckListLineStateIndicator.h
+++ b/B78XH/CheckListLineStateIndicator.h
@@ -7,10 +7,10 @@ class CheckListLine;
/**
* \brief The main state indicator of a "line" in a checklist. This is typically the "checkbox"/"checkmark". Internal, Owned by "CheckListLine"
*/
-class CheckListLineStateIndicator : public CheckListItem {
+class CheckListLineStateIndicator : public Control {
public:
CheckListLineStateIndicator(const string& name, const CheckListLine* parentLine)
- : CheckListItem(name),
+ : Control(name),
line_(parentLine){
}
diff --git a/B78XH/MFDCHKLControl.cpp b/B78XH/MFDCHKLControl.cpp
index 6ae121f..1fc00de 100644
--- a/B78XH/MFDCHKLControl.cpp
+++ b/B78XH/MFDCHKLControl.cpp
@@ -1,16 +1,23 @@
#include "MFDCHKLControl.h"
auto MFDCHKLControl::render() -> void {
- MFDBaseControl::render();
+ MFDBaseControl::render();
}
void MFDCHKLControl::prepareControls() {
- MFDBaseControl::prepareControls();
+ MFDBaseControl::prepareControls();
- add(std::make_shared("TEST_LINE", CheckListLine::CHECKLIST_LINE_TYPE::OPEN_LOOP));
+ add(std::make_shared("TEST_LINE", CheckListLine::CHECKLIST_LINE_TYPE::OPEN_LOOP));
+ const auto l2 = std::make_shared("TEST_LINE_2", CheckListLine::CHECKLIST_LINE_TYPE::OPEN_LOOP);
+ l2->setCurrentState(CheckListItem::CHECKLIST_ITEM_STATE::COMPLETED);
+ add(l2);
}
void MFDCHKLControl::setupControls() {
- MFDBaseControl::setupControls();
- getControl("TEST_LINE")->position.setPosition(0, 0, CheckListDimensions::TOTAL_WIDTH, CheckListDimensions::TOTAL_LINE_HEIGHT);
+ MFDBaseControl::setupControls();
+ getControl("TEST_LINE")->position.setPosition(0, 0, CheckListDimensions::TOTAL_WIDTH,
+ CheckListDimensions::TOTAL_LINE_HEIGHT);
+ getControl("TEST_LINE_2")->position.setPosition(0, CheckListDimensions::TOTAL_LINE_HEIGHT,
+ CheckListDimensions::TOTAL_WIDTH,
+ CheckListDimensions::TOTAL_LINE_HEIGHT * 2);
}
From 403e43c4486328e4eb4b76b84d0d81078a53a10a Mon Sep 17 00:00:00 2001
From: Michael Lu <38804680+Yamazaki93@users.noreply.github.com>
Date: Tue, 14 Feb 2023 23:43:20 -0800
Subject: [PATCH 05/14] Add current item indicator
---
B78XH/CheckListLine.cpp | 38 +++++++++++++++++++++++++++++++++++---
B78XH/CheckListLine.h | 10 +++++++++-
B78XH/MFDCHKLControl.cpp | 1 +
3 files changed, 45 insertions(+), 4 deletions(-)
diff --git a/B78XH/CheckListLine.cpp b/B78XH/CheckListLine.cpp
index 8ea8cd1..effa30d 100644
--- a/B78XH/CheckListLine.cpp
+++ b/B78XH/CheckListLine.cpp
@@ -1,20 +1,52 @@
#include "CheckListLine.h"
+auto CheckListLine::setIsCurrent(bool current) -> void {
+ isCurrent_ = current;
+}
+
+auto CheckListLine::getIsCurrent() const -> bool {
+ return isCurrent_;
+}
+
void CheckListLine::render() {
CheckListItem::render();
- if(isInFocus()) {
+ if (isInFocus()) {
drawBorder();
}
+ if(isCurrent_) {
+ drawIsCurrentBorder();
+ }
}
void CheckListLine::prepareControls() {
CheckListItem::prepareControls();
- add(std::make_shared("STATE_INDICATOR", this));
+ stateIndicator_ = std::make_shared("STATE_INDICATOR", this);
+ add(stateIndicator_);
}
void CheckListLine::setupControls() {
CheckListItem::setupControls();
- getControl("STATE_INDICATOR")->position.setPosition(CheckListDimensions::MARGIN, CheckListDimensions::MARGIN, CheckListDimensions::INNER_Y_END, CheckListDimensions::INNER_Y_END);
+ stateIndicator_->position.setPosition(CheckListDimensions::MARGIN, CheckListDimensions::MARGIN,
+ CheckListDimensions::INNER_Y_END, CheckListDimensions::INNER_Y_END);
+}
+
+auto CheckListLine::drawIsCurrentBorder() -> void {
+ const float xStart = CheckListDimensions::INNER_Y_END + CheckListDimensions::MARGIN;
+ const float xEnd = position.width - CheckListDimensions::BORDER_WIDTH - CheckListDimensions::MARGIN;
+ const float yStart = CheckListDimensions::BORDER_WIDTH / 2 + CheckListDimensions::MARGIN;
+ const float yEnd = position.height - CheckListDimensions::BORDER_WIDTH - CheckListDimensions::MARGIN;
+ nvgStrokeColor(getContext(), Tools::Colors::white);
+ nvgStrokeWidth(getContext(), CheckListDimensions::BORDER_WIDTH);
+ nvgBeginPath(getContext());
+ {
+ nvgMoveTo(getContext(), xStart, yStart);
+ nvgLineTo(getContext(), xStart, yEnd);
+ nvgLineTo(getContext(), xEnd, yEnd);
+ nvgLineTo(getContext(), xEnd, yStart);
+ nvgLineTo(getContext(), xStart, yStart);
+ nvgStroke(getContext());
+ }
+ nvgClosePath(getContext());
}
diff --git a/B78XH/CheckListLine.h b/B78XH/CheckListLine.h
index 4e54c6a..fc6a7bc 100644
--- a/B78XH/CheckListLine.h
+++ b/B78XH/CheckListLine.h
@@ -15,12 +15,20 @@ class CheckListLine : public CheckListItem {
CheckListLine(const string& name, const CHECKLIST_LINE_TYPE line_type)
: CheckListItem(name),
- line_type(line_type) {
+ line_type(line_type), isCurrent_(false) {
}
const CHECKLIST_LINE_TYPE line_type;
+ auto setIsCurrent(bool current) -> void;
+ auto getIsCurrent() const -> bool;
auto render() -> void override;
auto prepareControls() -> void override;
auto setupControls() -> void override;
+
+ private:
+ std::shared_ptr stateIndicator_;
+ bool isCurrent_;
+
+ auto drawIsCurrentBorder() -> void;
};
diff --git a/B78XH/MFDCHKLControl.cpp b/B78XH/MFDCHKLControl.cpp
index 1fc00de..04e379e 100644
--- a/B78XH/MFDCHKLControl.cpp
+++ b/B78XH/MFDCHKLControl.cpp
@@ -10,6 +10,7 @@ void MFDCHKLControl::prepareControls() {
add(std::make_shared("TEST_LINE", CheckListLine::CHECKLIST_LINE_TYPE::OPEN_LOOP));
const auto l2 = std::make_shared("TEST_LINE_2", CheckListLine::CHECKLIST_LINE_TYPE::OPEN_LOOP);
l2->setCurrentState(CheckListItem::CHECKLIST_ITEM_STATE::COMPLETED);
+ l2->setIsCurrent(true);
add(l2);
}
From 67e5291d9d0f290c0704a40de6b0e4f434439e00 Mon Sep 17 00:00:00 2001
From: Michael Lu <38804680+Yamazaki93@users.noreply.github.com>
Date: Wed, 15 Feb 2023 03:24:55 -0800
Subject: [PATCH 06/14] Add title button placeholders
---
B78XH/B78XH.vcxproj | 2 +
B78XH/B78XH.vcxproj.filters | 6 ++
B78XH/CheckListButton.cpp | 97 +++++++++++++++++++++++++++
B78XH/CheckListButton.h | 21 ++++++
B78XH/CheckListItem.cpp | 11 +++
B78XH/CheckListItem.h | 5 ++
B78XH/CheckListLineStateIndicator.cpp | 46 ++++++-------
B78XH/MFDCHKLControl.cpp | 18 +++--
B78XH/MFDCHKLControl.h | 22 +++---
9 files changed, 193 insertions(+), 35 deletions(-)
create mode 100644 B78XH/CheckListButton.cpp
create mode 100644 B78XH/CheckListButton.h
diff --git a/B78XH/B78XH.vcxproj b/B78XH/B78XH.vcxproj
index b42a8fe..5874d2e 100644
--- a/B78XH/B78XH.vcxproj
+++ b/B78XH/B78XH.vcxproj
@@ -153,6 +153,7 @@
+
@@ -375,6 +376,7 @@
+
diff --git a/B78XH/B78XH.vcxproj.filters b/B78XH/B78XH.vcxproj.filters
index 9124c4a..91c0c61 100644
--- a/B78XH/B78XH.vcxproj.filters
+++ b/B78XH/B78XH.vcxproj.filters
@@ -625,6 +625,9 @@
Source Files\Controls\Controls\MFD\CheckList\CheckListBasics
+
+ Source Files\Controls\Controls\MFD\CheckList\CheckListBasics
+
@@ -1359,6 +1362,9 @@
Source Files\Controls\Controls\MFD\CheckList\CheckListBasics
+
+ Source Files\Controls\Controls\MFD\CheckList\CheckListBasics
+
diff --git a/B78XH/CheckListButton.cpp b/B78XH/CheckListButton.cpp
new file mode 100644
index 0000000..74adc43
--- /dev/null
+++ b/B78XH/CheckListButton.cpp
@@ -0,0 +1,97 @@
+#include "CheckListButton.h"
+
+void CheckListButton::render() {
+ Control::render();
+ drawButtonBorder();
+
+ nvgFontFace(getContext(), "heavy-fmc");
+ nvgFontSize(getContext(), 24.0f);
+ nvgFillColor(getContext(), Tools::Colors::white);
+ nvgTextAlign(getContext(), NVG_ALIGN_CENTER | NVG_ALIGN_MIDDLE);
+ nvgBeginPath(getContext());
+ {
+ nvgText(getContext(), position.width / 2, position.height / 2, displayText_.c_str(), nullptr);
+ nvgFill(getContext());
+ }
+ nvgClosePath(getContext());
+
+ if (shouldTriggerEvent()) {
+ Console::log("Checklist button triggered {}", displayText_.c_str());
+ if(invoke_ != nullptr) {
+ invoke_();
+ }
+ }
+}
+
+auto CheckListButton::drawButtonBorder() -> void {
+ constexpr auto left = 0;
+ constexpr auto top = 0;
+ const auto width = getRelativePosition().getWidth();
+ const auto height = getRelativePosition().getHeight();
+ // open loop indicator
+ nvgFillColor(getContext(), Tools::Colors::cduButtonGray);
+ nvgBeginPath(getContext());
+ {
+ nvgRect(getContext(), 0, 0, width, height);
+ nvgFill(getContext());
+ }
+ nvgClosePath(getContext());
+
+ // top
+ nvgFillColor(getContext(), Tools::Colors::cduButtonBorderTopGray);
+ nvgBeginPath(getContext());
+ {
+ nvgMoveTo(getContext(), left, top);
+ nvgLineTo(getContext(), left + width, top);
+ nvgLineTo(getContext(), left + width - CheckListDimensions::BORDER_WIDTH,
+ top + CheckListDimensions::BORDER_WIDTH);
+ nvgLineTo(getContext(), left + CheckListDimensions::BORDER_WIDTH, top + CheckListDimensions::BORDER_WIDTH);
+ nvgLineTo(getContext(), left, top);
+ }
+ nvgClosePath(getContext());
+ nvgFill(getContext());
+
+ // right
+ nvgFillColor(getContext(), Tools::Colors::cduButtonBorderRightGray);
+ nvgBeginPath(getContext());
+ {
+ nvgMoveTo(getContext(), left + width, top);
+ nvgLineTo(getContext(), left + width, top + height + 1);
+ nvgLineTo(getContext(), left + width - CheckListDimensions::BORDER_WIDTH,
+ top + height - CheckListDimensions::BORDER_WIDTH + 1);
+ nvgLineTo(getContext(), left + width - CheckListDimensions::BORDER_WIDTH,
+ top + CheckListDimensions::BORDER_WIDTH);
+ nvgLineTo(getContext(), left + width, top);
+ }
+ nvgClosePath(getContext());
+ nvgFill(getContext());
+
+ // bottom
+ nvgFillColor(getContext(), Tools::Colors::cduButtonBorderBottomGray);
+ nvgBeginPath(getContext());
+ {
+ nvgMoveTo(getContext(), left, top + height);
+ nvgLineTo(getContext(), left + width, top + height);
+ nvgLineTo(getContext(), left + width - CheckListDimensions::BORDER_WIDTH,
+ top + height - CheckListDimensions::BORDER_WIDTH);
+ nvgLineTo(getContext(), left + CheckListDimensions::BORDER_WIDTH,
+ top + height - CheckListDimensions::BORDER_WIDTH);
+ nvgLineTo(getContext(), left, top + height);
+ }
+ nvgClosePath(getContext());
+ nvgFill(getContext());
+
+ // left
+ nvgFillColor(getContext(), Tools::Colors::cduButtonBorderLeftGray);
+ nvgBeginPath(getContext());
+ {
+ nvgMoveTo(getContext(), left, top);
+ nvgLineTo(getContext(), left + CheckListDimensions::BORDER_WIDTH, top + CheckListDimensions::BORDER_WIDTH);
+ nvgLineTo(getContext(), left + CheckListDimensions::BORDER_WIDTH,
+ top + height - CheckListDimensions::BORDER_WIDTH);
+ nvgLineTo(getContext(), left, top + height);
+ nvgLineTo(getContext(), left, top);
+ }
+ nvgClosePath(getContext());
+ nvgFill(getContext());
+}
diff --git a/B78XH/CheckListButton.h b/B78XH/CheckListButton.h
new file mode 100644
index 0000000..22dc7f5
--- /dev/null
+++ b/B78XH/CheckListButton.h
@@ -0,0 +1,21 @@
+#pragma once
+#include
+#include "CheckListItem.h"
+#include "Control.h"
+#include "Tools/Console.h"
+
+class CheckListButton : public CheckListItem {
+ public:
+ CheckListButton(const string& name, const std::function& invoke, const string& displayText)
+ : CheckListItem(name),
+ invoke_(invoke), displayText_(displayText) {
+ }
+
+ auto render() -> void override;
+
+ private:
+ const std::function invoke_;
+ const string displayText_;
+
+ auto drawButtonBorder() -> void;
+};
diff --git a/B78XH/CheckListItem.cpp b/B78XH/CheckListItem.cpp
index 7125738..6771cda 100644
--- a/B78XH/CheckListItem.cpp
+++ b/B78XH/CheckListItem.cpp
@@ -19,6 +19,17 @@ auto CheckListItem::isInFocus() -> bool {
return false;
}
+auto CheckListItem::shouldTriggerEvent() -> bool {
+ calculateBounds();
+ if (mouseClick_.x >= bounds_[0] &&
+ mouseClick_.x <= bounds_[1] &&
+ mouseClick_.y >= bounds_[2] &&
+ mouseClick_.y <= bounds_[3]) {
+ return true;
+ }
+ return false;
+}
+
auto CheckListItem::getItemStateColor() const -> NVGcolor {
switch (currentState_) {
case CHECKLIST_ITEM_STATE::OPEN: return Tools::Colors::white;
diff --git a/B78XH/CheckListItem.h b/B78XH/CheckListItem.h
index 93a5828..cdaf874 100644
--- a/B78XH/CheckListItem.h
+++ b/B78XH/CheckListItem.h
@@ -34,6 +34,11 @@ class CheckListItem : public Control {
* \return true if in focus, false otherwise
*/
auto isInFocus() -> bool;
+ /**
+ * \brief Checks if mouse is clicking on this item
+ * \return true if mouse is clicking, false otherwise
+ */
+ auto shouldTriggerEvent() -> bool;
/**
* \brief Gets the color corresponding to the current state.
* \return Desired color.
diff --git a/B78XH/CheckListLineStateIndicator.cpp b/B78XH/CheckListLineStateIndicator.cpp
index 7c5d058..59af5eb 100644
--- a/B78XH/CheckListLineStateIndicator.cpp
+++ b/B78XH/CheckListLineStateIndicator.cpp
@@ -32,10 +32,10 @@ void CheckListLineStateIndicator::drawOpenLoopIndicator() {
nvgBeginPath(getContext());
{
nvgMoveTo(getContext(), left, top);
- nvgLineTo(getContext(), (left + width), top);
- nvgLineTo(getContext(), (left + width - CheckListDimensions::BORDER_WIDTH),
- (top + CheckListDimensions::BORDER_WIDTH));
- nvgLineTo(getContext(), (left + CheckListDimensions::BORDER_WIDTH), (top + CheckListDimensions::BORDER_WIDTH));
+ nvgLineTo(getContext(), left + width, top);
+ nvgLineTo(getContext(), left + width - CheckListDimensions::BORDER_WIDTH,
+ top + CheckListDimensions::BORDER_WIDTH);
+ nvgLineTo(getContext(), left + CheckListDimensions::BORDER_WIDTH, top + CheckListDimensions::BORDER_WIDTH);
nvgLineTo(getContext(), left, top);
}
nvgClosePath(getContext());
@@ -45,13 +45,13 @@ void CheckListLineStateIndicator::drawOpenLoopIndicator() {
nvgFillColor(getContext(), rightGray);
nvgBeginPath(getContext());
{
- nvgMoveTo(getContext(), (left + width), top);
- nvgLineTo(getContext(), (left + width), (top + height) + 1);
- nvgLineTo(getContext(), (left + width - CheckListDimensions::BORDER_WIDTH),
- (top + height - CheckListDimensions::BORDER_WIDTH) + 1);
- nvgLineTo(getContext(), (left + width - CheckListDimensions::BORDER_WIDTH),
- (top + CheckListDimensions::BORDER_WIDTH));
- nvgLineTo(getContext(), (left + width), (top));
+ nvgMoveTo(getContext(), left + width, top);
+ nvgLineTo(getContext(), left + width, top + height + 1);
+ nvgLineTo(getContext(), left + width - CheckListDimensions::BORDER_WIDTH,
+ top + height - CheckListDimensions::BORDER_WIDTH + 1);
+ nvgLineTo(getContext(), left + width - CheckListDimensions::BORDER_WIDTH,
+ top + CheckListDimensions::BORDER_WIDTH);
+ nvgLineTo(getContext(), left + width, top);
}
nvgClosePath(getContext());
nvgFill(getContext());
@@ -60,13 +60,13 @@ void CheckListLineStateIndicator::drawOpenLoopIndicator() {
nvgFillColor(getContext(), bottomGray);
nvgBeginPath(getContext());
{
- nvgMoveTo(getContext(), left, (top + height));
- nvgLineTo(getContext(), (left + width), (top + height));
- nvgLineTo(getContext(), (left + width - CheckListDimensions::BORDER_WIDTH),
- (top + height - CheckListDimensions::BORDER_WIDTH));
- nvgLineTo(getContext(), (left + CheckListDimensions::BORDER_WIDTH),
- (top + height - CheckListDimensions::BORDER_WIDTH));
- nvgLineTo(getContext(), (left), (top + height));
+ nvgMoveTo(getContext(), left, top + height);
+ nvgLineTo(getContext(), left + width, top + height);
+ nvgLineTo(getContext(), left + width - CheckListDimensions::BORDER_WIDTH,
+ top + height - CheckListDimensions::BORDER_WIDTH);
+ nvgLineTo(getContext(), left + CheckListDimensions::BORDER_WIDTH,
+ top + height - CheckListDimensions::BORDER_WIDTH);
+ nvgLineTo(getContext(), left, top + height);
}
nvgClosePath(getContext());
nvgFill(getContext());
@@ -76,11 +76,11 @@ void CheckListLineStateIndicator::drawOpenLoopIndicator() {
nvgBeginPath(getContext());
{
nvgMoveTo(getContext(), left, top);
- nvgLineTo(getContext(), (left + CheckListDimensions::BORDER_WIDTH), (top + CheckListDimensions::BORDER_WIDTH));
- nvgLineTo(getContext(), (left + CheckListDimensions::BORDER_WIDTH),
- (top + height - CheckListDimensions::BORDER_WIDTH));
- nvgLineTo(getContext(), (left), (top + height));
- nvgLineTo(getContext(), (left), (top));
+ nvgLineTo(getContext(), left + CheckListDimensions::BORDER_WIDTH, top + CheckListDimensions::BORDER_WIDTH);
+ nvgLineTo(getContext(), left + CheckListDimensions::BORDER_WIDTH,
+ top + height - CheckListDimensions::BORDER_WIDTH);
+ nvgLineTo(getContext(), left, top + height);
+ nvgLineTo(getContext(), left, top);
}
nvgClosePath(getContext());
nvgFill(getContext());
diff --git a/B78XH/MFDCHKLControl.cpp b/B78XH/MFDCHKLControl.cpp
index 04e379e..082cfb5 100644
--- a/B78XH/MFDCHKLControl.cpp
+++ b/B78XH/MFDCHKLControl.cpp
@@ -7,6 +7,13 @@ auto MFDCHKLControl::render() -> void {
void MFDCHKLControl::prepareControls() {
MFDBaseControl::prepareControls();
+ normalMenuButton_ = std::make_shared("NORMAL_MENU", nullptr, "NORMAL MENU");
+ add(normalMenuButton_);
+ resetsButton_ = std::make_shared("RESETS", nullptr, "RESETS");
+ add(resetsButton_);
+ nonNormalMenuButton_ = std::make_shared("NON_NORMAL_MENU", nullptr, "NON-NORMAL MENU");
+ add(nonNormalMenuButton_);
+
add(std::make_shared("TEST_LINE", CheckListLine::CHECKLIST_LINE_TYPE::OPEN_LOOP));
const auto l2 = std::make_shared("TEST_LINE_2", CheckListLine::CHECKLIST_LINE_TYPE::OPEN_LOOP);
l2->setCurrentState(CheckListItem::CHECKLIST_ITEM_STATE::COMPLETED);
@@ -16,9 +23,12 @@ void MFDCHKLControl::prepareControls() {
void MFDCHKLControl::setupControls() {
MFDBaseControl::setupControls();
- getControl("TEST_LINE")->position.setPosition(0, 0, CheckListDimensions::TOTAL_WIDTH,
- CheckListDimensions::TOTAL_LINE_HEIGHT);
- getControl("TEST_LINE_2")->position.setPosition(0, CheckListDimensions::TOTAL_LINE_HEIGHT,
- CheckListDimensions::TOTAL_WIDTH,
+ normalMenuButton_->position.setPosition(0, 0, 220, CheckListDimensions::TOTAL_LINE_HEIGHT);
+ resetsButton_->position.setPosition(220, 0, 390, CheckListDimensions::TOTAL_LINE_HEIGHT);
+ nonNormalMenuButton_->position.setPosition(390, 0, CheckListDimensions::TOTAL_WIDTH, CheckListDimensions::TOTAL_LINE_HEIGHT);
+ getControl("TEST_LINE")->position.setPosition(0, CheckListDimensions::TOTAL_LINE_HEIGHT, CheckListDimensions::TOTAL_WIDTH,
CheckListDimensions::TOTAL_LINE_HEIGHT * 2);
+ getControl("TEST_LINE_2")->position.setPosition(0, CheckListDimensions::TOTAL_LINE_HEIGHT * 2,
+ CheckListDimensions::TOTAL_WIDTH,
+ CheckListDimensions::TOTAL_LINE_HEIGHT * 3);
}
diff --git a/B78XH/MFDCHKLControl.h b/B78XH/MFDCHKLControl.h
index 84da28b..0887145 100644
--- a/B78XH/MFDCHKLControl.h
+++ b/B78XH/MFDCHKLControl.h
@@ -1,16 +1,22 @@
#pragma once
#include "MFDBaseControl.h"
#include "CheckListLine.h"
+#include "CheckListButton.h"
#include "CheckListDimensions.h"
class MFDCHKLControl : public MFDBaseControl {
-public:
- explicit MFDCHKLControl(const string& name)
- : MFDBaseControl(name) {
- ident_ = CONTROL_IDENT::CHKL;
- }
+ public:
+ explicit MFDCHKLControl(const string& name)
+ : MFDBaseControl(name) {
+ ident_ = CONTROL_IDENT::CHKL;
+ }
- auto render() -> void override;
- auto prepareControls() -> void override;
- auto setupControls() -> void override;
+ auto render() -> void override;
+ auto prepareControls() -> void override;
+ auto setupControls() -> void override;
+
+ private:
+ std::shared_ptr normalMenuButton_;
+ std::shared_ptr resetsButton_;
+ std::shared_ptr nonNormalMenuButton_;
};
From 9b2cc21ad1eecf335fc4c88a46f20ce28baaba90 Mon Sep 17 00:00:00 2001
From: Michael Lu <38804680+Yamazaki93@users.noreply.github.com>
Date: Wed, 15 Feb 2023 18:34:16 -0800
Subject: [PATCH 07/14] Add title and single line item
---
B78XH/B78XH.vcxproj | 4 ++++
B78XH/B78XH.vcxproj.filters | 12 ++++++++++
B78XH/CheckListButton.h | 3 +++
B78XH/CheckListDimensions.h | 7 +++---
B78XH/CheckListLineSingle.cpp | 17 ++++++++++++++
B78XH/CheckListLineSingle.h | 18 +++++++++++++++
B78XH/CheckListTitle.cpp | 43 +++++++++++++++++++++++++++++++++++
B78XH/CheckListTitle.h | 27 ++++++++++++++++++++++
B78XH/MFDCHKLControl.cpp | 27 ++++++++++++++--------
B78XH/MFDCHKLControl.h | 1 +
10 files changed, 147 insertions(+), 12 deletions(-)
create mode 100644 B78XH/CheckListLineSingle.cpp
create mode 100644 B78XH/CheckListLineSingle.h
create mode 100644 B78XH/CheckListTitle.cpp
create mode 100644 B78XH/CheckListTitle.h
diff --git a/B78XH/B78XH.vcxproj b/B78XH/B78XH.vcxproj
index 5874d2e..fcc571c 100644
--- a/B78XH/B78XH.vcxproj
+++ b/B78XH/B78XH.vcxproj
@@ -156,7 +156,9 @@
+
+
@@ -380,7 +382,9 @@
+
+
diff --git a/B78XH/B78XH.vcxproj.filters b/B78XH/B78XH.vcxproj.filters
index 91c0c61..f6d6fd6 100644
--- a/B78XH/B78XH.vcxproj.filters
+++ b/B78XH/B78XH.vcxproj.filters
@@ -628,6 +628,12 @@
Source Files\Controls\Controls\MFD\CheckList\CheckListBasics
+
+ Source Files\Controls\Controls\MFD\CheckList\CheckListBasics
+
+
+ Source Files\Controls\Controls\MFD\CheckList\CheckListBasics
+
@@ -1365,6 +1371,12 @@
Source Files\Controls\Controls\MFD\CheckList\CheckListBasics
+
+ Source Files\Controls\Controls\MFD\CheckList\CheckListBasics
+
+
+ Source Files\Controls\Controls\MFD\CheckList\CheckListBasics
+
diff --git a/B78XH/CheckListButton.h b/B78XH/CheckListButton.h
index 22dc7f5..1b19fc0 100644
--- a/B78XH/CheckListButton.h
+++ b/B78XH/CheckListButton.h
@@ -4,6 +4,9 @@
#include "Control.h"
#include "Tools/Console.h"
+/**
+ * \brief A clickable button on the checklist. This mostly shows up at the header/footer and in the menus
+ */
class CheckListButton : public CheckListItem {
public:
CheckListButton(const string& name, const std::function& invoke, const string& displayText)
diff --git a/B78XH/CheckListDimensions.h b/B78XH/CheckListDimensions.h
index 59f57b8..458dad6 100644
--- a/B78XH/CheckListDimensions.h
+++ b/B78XH/CheckListDimensions.h
@@ -6,8 +6,9 @@ class CheckListDimensions {
static constexpr float TOTAL_WIDTH = 700; // should match half MFD width
static constexpr float MARGIN = 8;
static constexpr float BORDER_WIDTH = 5;
- static constexpr float INNER_START = MARGIN + BORDER_WIDTH / 2;
- static constexpr float INNER_HEIGHT = TOTAL_LINE_HEIGHT - 2 * INNER_START;
+ static constexpr float INNER_Y_START = MARGIN + BORDER_WIDTH / 2;
+ static constexpr float INNER_HEIGHT = TOTAL_LINE_HEIGHT - 2 * INNER_Y_START;
static constexpr float ONE_FORTH_INNER_HEIGHT = INNER_HEIGHT / 4;
- static constexpr float INNER_Y_END = TOTAL_LINE_HEIGHT - INNER_START;
+ static constexpr float INNER_Y_END = TOTAL_LINE_HEIGHT - INNER_Y_START;
+ static constexpr float INNER_TEXT_X_START = INNER_Y_END + 2 * MARGIN + BORDER_WIDTH / 2;
};
diff --git a/B78XH/CheckListLineSingle.cpp b/B78XH/CheckListLineSingle.cpp
new file mode 100644
index 0000000..62c6e98
--- /dev/null
+++ b/B78XH/CheckListLineSingle.cpp
@@ -0,0 +1,17 @@
+#include "CheckListLineSingle.h"
+
+void CheckListLineSingle::render() {
+ CheckListLine::render();
+
+ nvgFillColor(getContext(), getItemStateColor());
+ nvgFontFace(getContext(), "roboto");
+ nvgFontSize(getContext(), 38.0f);
+ nvgTextAlign(getContext(), NVG_ALIGN_MIDDLE | NVG_ALIGN_LEFT);
+ nvgBeginPath(getContext());
+ {
+ nvgText(getContext(), CheckListDimensions::INNER_TEXT_X_START, position.height / 2, textDisplayed_.c_str(),
+ nullptr);
+ }
+ nvgClosePath(getContext());
+ nvgFill(getContext());
+}
diff --git a/B78XH/CheckListLineSingle.h b/B78XH/CheckListLineSingle.h
new file mode 100644
index 0000000..16ee9eb
--- /dev/null
+++ b/B78XH/CheckListLineSingle.h
@@ -0,0 +1,18 @@
+#pragma once
+#include "CheckListLine.h"
+
+/**
+ * \brief Specialized to render a checklist line that's just "single line".
+ * This is so common that it deserves it's own class.
+ */
+class CheckListLineSingle : public CheckListLine {
+ public:
+ CheckListLineSingle(const string& name, CHECKLIST_LINE_TYPE line_type, const string& textDisplayed)
+ : CheckListLine(name, line_type),
+ textDisplayed_(textDisplayed){
+ }
+
+ auto render() -> void override;
+ private:
+ const string textDisplayed_;
+};
diff --git a/B78XH/CheckListTitle.cpp b/B78XH/CheckListTitle.cpp
new file mode 100644
index 0000000..3afb872
--- /dev/null
+++ b/B78XH/CheckListTitle.cpp
@@ -0,0 +1,43 @@
+#include "CheckListTitle.h"
+
+void CheckListTitle::render() {
+ Control::render();
+
+ constexpr float triangleSize = 24;
+ constexpr float halfTriangleSize = triangleSize / 2;
+ const float halfHeight = position.height / 2;
+ const float halfWidth = position.width / 2;
+ nvgFontFace(getContext(), "heavy-fmc");
+ nvgFontSize(getContext(), 28.0f);
+ nvgFillColor(getContext(), type_ == TITLE_TYPE::NON_NORMAL_CHECKLIST ? Tools::Colors::amber : Tools::Colors::white);
+ nvgTextAlign(getContext(), NVG_ALIGN_CENTER | NVG_ALIGN_MIDDLE);
+ nvgBeginPath(getContext());
+ {
+ nvgText(getContext(), halfWidth, halfHeight, titleText_.c_str(), nullptr);
+ nvgFill(getContext());
+ }
+ nvgClosePath(getContext());
+ if(type_ != TITLE_TYPE::MENU) {
+ // draw front triangle
+ nvgBeginPath(getContext());
+ {
+ nvgMoveTo(getContext(), 0, halfHeight - halfTriangleSize);
+ nvgLineTo(getContext(), triangleSize, halfHeight);
+ nvgLineTo(getContext(), 0, halfHeight + halfTriangleSize);
+ nvgLineTo(getContext(), 0, halfHeight - halfTriangleSize);
+ nvgFill(getContext());
+ }
+ nvgClosePath(getContext());
+
+ // draw end triangle
+ nvgBeginPath(getContext());
+ {
+ nvgMoveTo(getContext(), position.width, halfHeight - halfTriangleSize);
+ nvgLineTo(getContext(), position.width - triangleSize, halfHeight);
+ nvgLineTo(getContext(), position.width, halfHeight + halfTriangleSize);
+ nvgLineTo(getContext(), position.width, halfHeight - halfTriangleSize);
+ nvgFill(getContext());
+ }
+ nvgClosePath(getContext());
+ }
+}
diff --git a/B78XH/CheckListTitle.h b/B78XH/CheckListTitle.h
new file mode 100644
index 0000000..a9ede34
--- /dev/null
+++ b/B78XH/CheckListTitle.h
@@ -0,0 +1,27 @@
+#pragma once
+#include "Control.h"
+#include "Tools/Tools.h"
+
+/**
+ * \brief The title line displayed in the electronic checklist.
+ * This can show title for both checklists and menus, with the difference is the checklist one shows 2 "triangles" enclosing the title text
+ */
+class CheckListTitle : public Control {
+ public:
+ enum class TITLE_TYPE {
+ NORMAL_CHECKLIST,
+ NON_NORMAL_CHECKLIST,
+ MENU,
+ };
+
+ CheckListTitle(const string& name, const TITLE_TYPE type, const string& titleText)
+ : Control(name),
+ titleText_(titleText), type_(type) {
+ }
+
+ auto render() -> void override;
+
+ private:
+ const string titleText_;
+ const TITLE_TYPE type_;
+};
diff --git a/B78XH/MFDCHKLControl.cpp b/B78XH/MFDCHKLControl.cpp
index 082cfb5..a58771b 100644
--- a/B78XH/MFDCHKLControl.cpp
+++ b/B78XH/MFDCHKLControl.cpp
@@ -1,5 +1,7 @@
#include "MFDCHKLControl.h"
+#include "CheckListLineSingle.h"
+
auto MFDCHKLControl::render() -> void {
MFDBaseControl::render();
}
@@ -13,22 +15,29 @@ void MFDCHKLControl::prepareControls() {
add(resetsButton_);
nonNormalMenuButton_ = std::make_shared("NON_NORMAL_MENU", nullptr, "NON-NORMAL MENU");
add(nonNormalMenuButton_);
-
- add(std::make_shared("TEST_LINE", CheckListLine::CHECKLIST_LINE_TYPE::OPEN_LOOP));
+
+ add(std::make_shared("TEST_TITLE", CheckListTitle::TITLE_TYPE::NORMAL_CHECKLIST, "PREFLIGHT"));
+ const auto l1 = std::make_shared("TEST_LINE", CheckListLine::CHECKLIST_LINE_TYPE::OPEN_LOOP, "Oxygen . . . . . . . . . . . . . . . . . . . . . . Tested,100%");
+ l1->setCurrentState(CheckListItem::CHECKLIST_ITEM_STATE::COMPLETED);
+ l1->setIsCurrent(true);
+ add(l1);
const auto l2 = std::make_shared("TEST_LINE_2", CheckListLine::CHECKLIST_LINE_TYPE::OPEN_LOOP);
l2->setCurrentState(CheckListItem::CHECKLIST_ITEM_STATE::COMPLETED);
- l2->setIsCurrent(true);
add(l2);
}
void MFDCHKLControl::setupControls() {
MFDBaseControl::setupControls();
- normalMenuButton_->position.setPosition(0, 0, 220, CheckListDimensions::TOTAL_LINE_HEIGHT);
- resetsButton_->position.setPosition(220, 0, 390, CheckListDimensions::TOTAL_LINE_HEIGHT);
- nonNormalMenuButton_->position.setPosition(390, 0, CheckListDimensions::TOTAL_WIDTH, CheckListDimensions::TOTAL_LINE_HEIGHT);
- getControl("TEST_LINE")->position.setPosition(0, CheckListDimensions::TOTAL_LINE_HEIGHT, CheckListDimensions::TOTAL_WIDTH,
- CheckListDimensions::TOTAL_LINE_HEIGHT * 2);
- getControl("TEST_LINE_2")->position.setPosition(0, CheckListDimensions::TOTAL_LINE_HEIGHT * 2,
+ normalMenuButton_->position.setPosition(0, 0, 215, CheckListDimensions::TOTAL_LINE_HEIGHT);
+ resetsButton_->position.setPosition(225, 0, 385, CheckListDimensions::TOTAL_LINE_HEIGHT);
+ nonNormalMenuButton_->position.setPosition(395, 0, CheckListDimensions::TOTAL_WIDTH,
+ CheckListDimensions::TOTAL_LINE_HEIGHT);
+ getControl("TEST_TITLE")->position.setPosition(200, CheckListDimensions::TOTAL_LINE_HEIGHT, 500,
+ CheckListDimensions::TOTAL_LINE_HEIGHT * 2);
+ getControl("TEST_LINE")->position.setPosition(0, CheckListDimensions::TOTAL_LINE_HEIGHT * 2,
CheckListDimensions::TOTAL_WIDTH,
CheckListDimensions::TOTAL_LINE_HEIGHT * 3);
+ getControl("TEST_LINE_2")->position.setPosition(0, CheckListDimensions::TOTAL_LINE_HEIGHT * 3,
+ CheckListDimensions::TOTAL_WIDTH,
+ CheckListDimensions::TOTAL_LINE_HEIGHT * 4);
}
diff --git a/B78XH/MFDCHKLControl.h b/B78XH/MFDCHKLControl.h
index 0887145..1e177b8 100644
--- a/B78XH/MFDCHKLControl.h
+++ b/B78XH/MFDCHKLControl.h
@@ -1,6 +1,7 @@
#pragma once
#include "MFDBaseControl.h"
#include "CheckListLine.h"
+#include "CheckListTitle.h"
#include "CheckListButton.h"
#include "CheckListDimensions.h"
From a0f707e7675cbe3da5a719f0be0cf0d8d7c0d17e Mon Sep 17 00:00:00 2001
From: Michael Lu <38804680+Yamazaki93@users.noreply.github.com>
Date: Thu, 16 Feb 2023 23:24:51 -0800
Subject: [PATCH 08/14] Add base checklist
---
B78XH/B78XH.vcxproj | 2 ++
B78XH/B78XH.vcxproj.filters | 6 ++++
B78XH/CheckList.cpp | 56 +++++++++++++++++++++++++++++++++++++
B78XH/CheckList.h | 44 +++++++++++++++++++++++++++++
B78XH/MFDCHKLControl.cpp | 11 +++++---
B78XH/MFDCHKLControl.h | 8 ++++--
6 files changed, 120 insertions(+), 7 deletions(-)
create mode 100644 B78XH/CheckList.cpp
create mode 100644 B78XH/CheckList.h
diff --git a/B78XH/B78XH.vcxproj b/B78XH/B78XH.vcxproj
index fcc571c..317b858 100644
--- a/B78XH/B78XH.vcxproj
+++ b/B78XH/B78XH.vcxproj
@@ -153,6 +153,7 @@
+
@@ -378,6 +379,7 @@
+
diff --git a/B78XH/B78XH.vcxproj.filters b/B78XH/B78XH.vcxproj.filters
index f6d6fd6..b2dbb97 100644
--- a/B78XH/B78XH.vcxproj.filters
+++ b/B78XH/B78XH.vcxproj.filters
@@ -634,6 +634,9 @@
Source Files\Controls\Controls\MFD\CheckList\CheckListBasics
+
+ Source Files\Controls\Controls\MFD\CheckList\CheckListBasics
+
@@ -1377,6 +1380,9 @@
Source Files\Controls\Controls\MFD\CheckList\CheckListBasics
+
+ Source Files\Controls\Controls\MFD\CheckList\CheckListBasics
+
diff --git a/B78XH/CheckList.cpp b/B78XH/CheckList.cpp
new file mode 100644
index 0000000..13e40f1
--- /dev/null
+++ b/B78XH/CheckList.cpp
@@ -0,0 +1,56 @@
+#include "CheckList.h"
+
+void CheckList::setupControls() {
+ CheckListItem::setupControls();
+ addOnBeforeRender([this](BaseControl&) -> bool {
+ serviceChecklistUpdateLoop();
+ return true;
+ });
+}
+
+auto CheckList::checkChecklistCompleted() -> void {
+ if (getCurrentState() == CHECKLIST_ITEM_STATE::OVERRIDDEN) {
+ return; // overridden checklist must be explicitly cleared
+ }
+ for (const std::shared_ptr l : lines_) {
+ if (l->getCurrentState() == CHECKLIST_ITEM_STATE::OPEN) {
+ setCurrentState(CHECKLIST_ITEM_STATE::OPEN);
+ break;
+ }
+ }
+}
+
+auto CheckList::advanceCurrentLine() -> void {
+ if (currentLine_ >= lines_.size()) {
+ return;
+ }
+ const std::shared_ptr currentLine = lines_.at(currentLine_);
+ currentLine->setIsCurrent(false);
+ currentLine++;
+ if (currentLine_ >= lines_.size()) {
+ return;
+ }
+ const std::shared_ptr nextLine = lines_.at(currentLine_);
+ nextLine->setIsCurrent(true);
+}
+
+auto CheckList::resetChecklist() -> void {
+ for (const std::shared_ptr l : lines_) {
+ l->setCurrentState(CHECKLIST_ITEM_STATE::OPEN);
+ }
+ setCurrentState(CHECKLIST_ITEM_STATE::OPEN);
+}
+
+auto CheckList::checkClosedLoopItems() -> void {
+}
+
+auto CheckList::serviceChecklistUpdateLoop() -> void {
+ checkClosedLoopItems();
+ if(currentLine_ >= lines_.size()) {
+ return;
+ }
+ const std::shared_ptr currentLine = lines_.at(currentLine_);
+ if (currentLine->getCurrentState() != CHECKLIST_ITEM_STATE::OPEN) {
+ advanceCurrentLine();
+ }
+}
diff --git a/B78XH/CheckList.h b/B78XH/CheckList.h
new file mode 100644
index 0000000..69a2077
--- /dev/null
+++ b/B78XH/CheckList.h
@@ -0,0 +1,44 @@
+#pragma once
+#include "CheckListItem.h"
+#include "CheckListLine.h"
+
+class CheckList : public CheckListItem {
+ public:
+ CheckList(const string& name)
+ : CheckListItem(name),
+ currentLine_(0) {
+ }
+
+ auto setupControls() -> void override;
+
+ protected:
+ /**
+ * \brief These lines have operational effects and counts towards the checklists overall completeness
+ */
+ const std::vector> lines_;
+
+ /**
+ * \brief Evaluates the entire checklists status. This does not care about overridden checklist.
+ */
+ auto checkChecklistCompleted() -> void;
+ /**
+ * \brief Advances the current line pointer. This does not change the checklist's status.
+ */
+ auto advanceCurrentLine() -> void;
+ /**
+ * \brief Resets all checklist lines
+ */
+ auto resetChecklist() -> void;
+ /**
+ * \brief Used to check all closed loop items and set their completeness state.
+ */
+ virtual auto checkClosedLoopItems() -> void;
+
+ private:
+ int currentLine_;
+
+ /**
+ * \brief Invoked periodically to check the checklist
+ */
+ auto serviceChecklistUpdateLoop() -> void;
+};
diff --git a/B78XH/MFDCHKLControl.cpp b/B78XH/MFDCHKLControl.cpp
index a58771b..9a1d21c 100644
--- a/B78XH/MFDCHKLControl.cpp
+++ b/B78XH/MFDCHKLControl.cpp
@@ -9,15 +9,15 @@ auto MFDCHKLControl::render() -> void {
void MFDCHKLControl::prepareControls() {
MFDBaseControl::prepareControls();
- normalMenuButton_ = std::make_shared("NORMAL_MENU", nullptr, "NORMAL MENU");
add(normalMenuButton_);
- resetsButton_ = std::make_shared("RESETS", nullptr, "RESETS");
add(resetsButton_);
- nonNormalMenuButton_ = std::make_shared("NON_NORMAL_MENU", nullptr, "NON-NORMAL MENU");
add(nonNormalMenuButton_);
+ add(normalButton_);
+ // TODO: Remove
add(std::make_shared("TEST_TITLE", CheckListTitle::TITLE_TYPE::NORMAL_CHECKLIST, "PREFLIGHT"));
- const auto l1 = std::make_shared("TEST_LINE", CheckListLine::CHECKLIST_LINE_TYPE::OPEN_LOOP, "Oxygen . . . . . . . . . . . . . . . . . . . . . . Tested,100%");
+ const auto l1 = std::make_shared("TEST_LINE", CheckListLine::CHECKLIST_LINE_TYPE::OPEN_LOOP,
+ "Oxygen . . . . . . . . . . . . . . . . . . . . . . Tested,100%");
l1->setCurrentState(CheckListItem::CHECKLIST_ITEM_STATE::COMPLETED);
l1->setIsCurrent(true);
add(l1);
@@ -32,6 +32,9 @@ void MFDCHKLControl::setupControls() {
resetsButton_->position.setPosition(225, 0, 385, CheckListDimensions::TOTAL_LINE_HEIGHT);
nonNormalMenuButton_->position.setPosition(395, 0, CheckListDimensions::TOTAL_WIDTH,
CheckListDimensions::TOTAL_LINE_HEIGHT);
+ normalButton_->position.setPosition(0, position.height - CheckListDimensions::TOTAL_LINE_HEIGHT, 150,
+ position.height);
+ // TODO: Remove
getControl("TEST_TITLE")->position.setPosition(200, CheckListDimensions::TOTAL_LINE_HEIGHT, 500,
CheckListDimensions::TOTAL_LINE_HEIGHT * 2);
getControl("TEST_LINE")->position.setPosition(0, CheckListDimensions::TOTAL_LINE_HEIGHT * 2,
diff --git a/B78XH/MFDCHKLControl.h b/B78XH/MFDCHKLControl.h
index 1e177b8..ad38de6 100644
--- a/B78XH/MFDCHKLControl.h
+++ b/B78XH/MFDCHKLControl.h
@@ -17,7 +17,9 @@ class MFDCHKLControl : public MFDBaseControl {
auto setupControls() -> void override;
private:
- std::shared_ptr normalMenuButton_;
- std::shared_ptr resetsButton_;
- std::shared_ptr nonNormalMenuButton_;
+ std::shared_ptr normalMenuButton_ = std::make_shared("NORMAL_MENU", nullptr, "NORMAL MENU");
+ std::shared_ptr resetsButton_ = std::make_shared("RESETS", nullptr, "RESETS");
+ std::shared_ptr nonNormalMenuButton_ = std::make_shared("NON_NORMAL_MENU", nullptr, "NON-NORMAL MENU");
+
+ std::shared_ptr normalButton_ = std::make_shared("NORMAL", nullptr, "NORMAL");
};
From 6d7c74d8602dbf63c7493878f986508814a45752 Mon Sep 17 00:00:00 2001
From: Michael Lu <38804680+Yamazaki93@users.noreply.github.com>
Date: Wed, 22 Feb 2023 00:20:32 -0800
Subject: [PATCH 09/14] Consolidate duplicated button drawing logics
---
B78XH/CheckList.cpp | 2 +-
B78XH/CheckListButton.cpp | 79 ++------------------------
B78XH/CheckListButton.h | 2 -
B78XH/CheckListItem.cpp | 76 ++++++++++++++++++++++++-
B78XH/CheckListItem.h | 15 ++++-
B78XH/CheckListLineStateIndicator.cpp | 82 ++-------------------------
B78XH/CheckListLineStateIndicator.h | 4 +-
7 files changed, 101 insertions(+), 159 deletions(-)
diff --git a/B78XH/CheckList.cpp b/B78XH/CheckList.cpp
index 13e40f1..a577f57 100644
--- a/B78XH/CheckList.cpp
+++ b/B78XH/CheckList.cpp
@@ -26,7 +26,7 @@ auto CheckList::advanceCurrentLine() -> void {
}
const std::shared_ptr currentLine = lines_.at(currentLine_);
currentLine->setIsCurrent(false);
- currentLine++;
+ currentLine_++;
if (currentLine_ >= lines_.size()) {
return;
}
diff --git a/B78XH/CheckListButton.cpp b/B78XH/CheckListButton.cpp
index 74adc43..5c18485 100644
--- a/B78XH/CheckListButton.cpp
+++ b/B78XH/CheckListButton.cpp
@@ -2,7 +2,11 @@
void CheckListButton::render() {
Control::render();
- drawButtonBorder();
+ drawButtonBorder(Tools::Colors::cduButtonGray,
+ Tools::Colors::cduButtonBorderTopGray,
+ Tools::Colors::cduButtonBorderRightGray,
+ Tools::Colors::cduButtonBorderBottomGray,
+ Tools::Colors::cduButtonBorderLeftGray);
nvgFontFace(getContext(), "heavy-fmc");
nvgFontSize(getContext(), 24.0f);
@@ -22,76 +26,3 @@ void CheckListButton::render() {
}
}
}
-
-auto CheckListButton::drawButtonBorder() -> void {
- constexpr auto left = 0;
- constexpr auto top = 0;
- const auto width = getRelativePosition().getWidth();
- const auto height = getRelativePosition().getHeight();
- // open loop indicator
- nvgFillColor(getContext(), Tools::Colors::cduButtonGray);
- nvgBeginPath(getContext());
- {
- nvgRect(getContext(), 0, 0, width, height);
- nvgFill(getContext());
- }
- nvgClosePath(getContext());
-
- // top
- nvgFillColor(getContext(), Tools::Colors::cduButtonBorderTopGray);
- nvgBeginPath(getContext());
- {
- nvgMoveTo(getContext(), left, top);
- nvgLineTo(getContext(), left + width, top);
- nvgLineTo(getContext(), left + width - CheckListDimensions::BORDER_WIDTH,
- top + CheckListDimensions::BORDER_WIDTH);
- nvgLineTo(getContext(), left + CheckListDimensions::BORDER_WIDTH, top + CheckListDimensions::BORDER_WIDTH);
- nvgLineTo(getContext(), left, top);
- }
- nvgClosePath(getContext());
- nvgFill(getContext());
-
- // right
- nvgFillColor(getContext(), Tools::Colors::cduButtonBorderRightGray);
- nvgBeginPath(getContext());
- {
- nvgMoveTo(getContext(), left + width, top);
- nvgLineTo(getContext(), left + width, top + height + 1);
- nvgLineTo(getContext(), left + width - CheckListDimensions::BORDER_WIDTH,
- top + height - CheckListDimensions::BORDER_WIDTH + 1);
- nvgLineTo(getContext(), left + width - CheckListDimensions::BORDER_WIDTH,
- top + CheckListDimensions::BORDER_WIDTH);
- nvgLineTo(getContext(), left + width, top);
- }
- nvgClosePath(getContext());
- nvgFill(getContext());
-
- // bottom
- nvgFillColor(getContext(), Tools::Colors::cduButtonBorderBottomGray);
- nvgBeginPath(getContext());
- {
- nvgMoveTo(getContext(), left, top + height);
- nvgLineTo(getContext(), left + width, top + height);
- nvgLineTo(getContext(), left + width - CheckListDimensions::BORDER_WIDTH,
- top + height - CheckListDimensions::BORDER_WIDTH);
- nvgLineTo(getContext(), left + CheckListDimensions::BORDER_WIDTH,
- top + height - CheckListDimensions::BORDER_WIDTH);
- nvgLineTo(getContext(), left, top + height);
- }
- nvgClosePath(getContext());
- nvgFill(getContext());
-
- // left
- nvgFillColor(getContext(), Tools::Colors::cduButtonBorderLeftGray);
- nvgBeginPath(getContext());
- {
- nvgMoveTo(getContext(), left, top);
- nvgLineTo(getContext(), left + CheckListDimensions::BORDER_WIDTH, top + CheckListDimensions::BORDER_WIDTH);
- nvgLineTo(getContext(), left + CheckListDimensions::BORDER_WIDTH,
- top + height - CheckListDimensions::BORDER_WIDTH);
- nvgLineTo(getContext(), left, top + height);
- nvgLineTo(getContext(), left, top);
- }
- nvgClosePath(getContext());
- nvgFill(getContext());
-}
diff --git a/B78XH/CheckListButton.h b/B78XH/CheckListButton.h
index 1b19fc0..2678dc4 100644
--- a/B78XH/CheckListButton.h
+++ b/B78XH/CheckListButton.h
@@ -19,6 +19,4 @@ class CheckListButton : public CheckListItem {
private:
const std::function invoke_;
const string displayText_;
-
- auto drawButtonBorder() -> void;
};
diff --git a/B78XH/CheckListItem.cpp b/B78XH/CheckListItem.cpp
index 6771cda..3d4583d 100644
--- a/B78XH/CheckListItem.cpp
+++ b/B78XH/CheckListItem.cpp
@@ -1,6 +1,6 @@
#include "CheckListItem.h"
-auto CheckListItem::setCurrentState(CHECKLIST_ITEM_STATE state) -> void {
+auto CheckListItem::setCurrentState(const CHECKLIST_ITEM_STATE state) -> void {
currentState_ = state;
}
@@ -57,6 +57,80 @@ auto CheckListItem::drawBorder() -> void {
nvgClosePath(getContext());
}
+auto CheckListItem::drawButtonBorder(const NVGcolor background, const NVGcolor top, const NVGcolor right, const NVGcolor bottom,
+ const NVGcolor left) -> void {
+ constexpr auto leftPos = 0;
+ constexpr auto topPos = 0;
+ const auto width = getRelativePosition().getWidth();
+ const auto height = getRelativePosition().getHeight();
+
+ nvgFillColor(getContext(), background);
+ nvgBeginPath(getContext());
+ {
+ nvgRect(getContext(), 0, 0, width, height);
+ nvgFill(getContext());
+ }
+ nvgClosePath(getContext());
+
+ // top
+ nvgFillColor(getContext(), top);
+ nvgBeginPath(getContext());
+ {
+ nvgMoveTo(getContext(), leftPos, topPos);
+ nvgLineTo(getContext(), leftPos + width, topPos);
+ nvgLineTo(getContext(), leftPos + width - CheckListDimensions::BORDER_WIDTH,
+ topPos + CheckListDimensions::BORDER_WIDTH);
+ nvgLineTo(getContext(), leftPos + CheckListDimensions::BORDER_WIDTH, topPos + CheckListDimensions::BORDER_WIDTH);
+ nvgLineTo(getContext(), leftPos, topPos);
+ }
+ nvgClosePath(getContext());
+ nvgFill(getContext());
+
+ // right
+ nvgFillColor(getContext(), right);
+ nvgBeginPath(getContext());
+ {
+ nvgMoveTo(getContext(), leftPos + width, topPos);
+ nvgLineTo(getContext(), leftPos + width, topPos + height + 1);
+ nvgLineTo(getContext(), leftPos + width - CheckListDimensions::BORDER_WIDTH,
+ topPos + height - CheckListDimensions::BORDER_WIDTH + 1);
+ nvgLineTo(getContext(), leftPos + width - CheckListDimensions::BORDER_WIDTH,
+ topPos + CheckListDimensions::BORDER_WIDTH);
+ nvgLineTo(getContext(), leftPos + width, topPos);
+ }
+ nvgClosePath(getContext());
+ nvgFill(getContext());
+
+ // bottom
+ nvgFillColor(getContext(), bottom);
+ nvgBeginPath(getContext());
+ {
+ nvgMoveTo(getContext(), leftPos, topPos + height);
+ nvgLineTo(getContext(), leftPos + width, topPos + height);
+ nvgLineTo(getContext(), leftPos + width - CheckListDimensions::BORDER_WIDTH,
+ topPos + height - CheckListDimensions::BORDER_WIDTH);
+ nvgLineTo(getContext(), leftPos + CheckListDimensions::BORDER_WIDTH,
+ topPos + height - CheckListDimensions::BORDER_WIDTH);
+ nvgLineTo(getContext(), leftPos, topPos + height);
+ }
+ nvgClosePath(getContext());
+ nvgFill(getContext());
+
+ // left
+ nvgFillColor(getContext(), left);
+ nvgBeginPath(getContext());
+ {
+ nvgMoveTo(getContext(), leftPos, topPos);
+ nvgLineTo(getContext(), leftPos + CheckListDimensions::BORDER_WIDTH, topPos + CheckListDimensions::BORDER_WIDTH);
+ nvgLineTo(getContext(), leftPos + CheckListDimensions::BORDER_WIDTH,
+ topPos + height - CheckListDimensions::BORDER_WIDTH);
+ nvgLineTo(getContext(), leftPos, topPos + height);
+ nvgLineTo(getContext(), leftPos, topPos);
+ }
+ nvgClosePath(getContext());
+ nvgFill(getContext());
+}
+
auto CheckListItem::calculateBounds() -> void {
bounds_[0] = absolutePosition.left;
bounds_[1] = absolutePosition.left + position.width;
diff --git a/B78XH/CheckListItem.h b/B78XH/CheckListItem.h
index cdaf874..71185e1 100644
--- a/B78XH/CheckListItem.h
+++ b/B78XH/CheckListItem.h
@@ -4,7 +4,7 @@
#include "CheckListDimensions.h"
/**
-* \brief An abstract representation of an "item" on the checklist. An Item simply has a "CHECKLIST_ITEM_STATE"
+* \brief An abstract representation of an "item" on the checklist. An Item simply has a "CHECKLIST_ITEM_STATE" and utility UI functions.
*/
class CheckListItem : public Control {
public:
@@ -41,14 +41,23 @@ class CheckListItem : public Control {
auto shouldTriggerEvent() -> bool;
/**
* \brief Gets the color corresponding to the current state.
- * \return Desired color.
*/
auto getItemStateColor() const -> NVGcolor;
/**
- * \brief Draws a magenta border around the item
+ * \brief Draws a magenta border around the item.
*/
auto drawBorder() -> void;
+ /**
+ * \brief Draws a button-like boarder around the item.
+ * \param background Background fill color.
+ * \param top Top boarder color.
+ * \param right Right boarder color.
+ * \param bottom Bottom boarder color.
+ * \param left Left boarder color.
+ */
+ auto drawButtonBorder(NVGcolor background, NVGcolor top, NVGcolor right, NVGcolor bottom, NVGcolor left) -> void;
+
private:
/**
* \brief The item's current state.
diff --git a/B78XH/CheckListLineStateIndicator.cpp b/B78XH/CheckListLineStateIndicator.cpp
index 59af5eb..782678a 100644
--- a/B78XH/CheckListLineStateIndicator.cpp
+++ b/B78XH/CheckListLineStateIndicator.cpp
@@ -1,89 +1,19 @@
-#include "CheckListLineStateIndicator.h"
#include "CheckListLine.h"
void CheckListLineStateIndicator::drawOpenLoopIndicator() {
- constexpr auto left = 0;
- constexpr auto top = 0;
- const auto width = getRelativePosition().getWidth();
- const auto height = getRelativePosition().getHeight();
- const auto topGray = line_->getCurrentState() == CheckListItem::CHECKLIST_ITEM_STATE::COMPLETED
+ const auto topGray = line_->getCurrentState() == CHECKLIST_ITEM_STATE::COMPLETED
? Tools::Colors::cduButtonBorderBottomGray
: Tools::Colors::cduButtonBorderTopGray;
- const auto bottomGray = line_->getCurrentState() == CheckListItem::CHECKLIST_ITEM_STATE::COMPLETED
+ const auto bottomGray = line_->getCurrentState() == CHECKLIST_ITEM_STATE::COMPLETED
? Tools::Colors::cduButtonBorderTopGray
: Tools::Colors::cduButtonBorderBottomGray;
- const auto leftGray = line_->getCurrentState() == CheckListItem::CHECKLIST_ITEM_STATE::COMPLETED
+ const auto leftGray = line_->getCurrentState() == CHECKLIST_ITEM_STATE::COMPLETED
? Tools::Colors::cduButtonBorderRightGray
: Tools::Colors::cduButtonBorderLeftGray;
- const auto rightGray = line_->getCurrentState() == CheckListItem::CHECKLIST_ITEM_STATE::COMPLETED
+ const auto rightGray = line_->getCurrentState() == CHECKLIST_ITEM_STATE::COMPLETED
? Tools::Colors::cduButtonBorderLeftGray
: Tools::Colors::cduButtonBorderRightGray;
- // open loop indicator
- nvgFillColor(getContext(), Tools::Colors::cduButtonGray);
- nvgBeginPath(getContext());
- {
- nvgRect(getContext(), 0, 0, width, height);
- nvgFill(getContext());
- }
- nvgClosePath(getContext());
-
- // top
- nvgFillColor(getContext(), topGray);
- nvgBeginPath(getContext());
- {
- nvgMoveTo(getContext(), left, top);
- nvgLineTo(getContext(), left + width, top);
- nvgLineTo(getContext(), left + width - CheckListDimensions::BORDER_WIDTH,
- top + CheckListDimensions::BORDER_WIDTH);
- nvgLineTo(getContext(), left + CheckListDimensions::BORDER_WIDTH, top + CheckListDimensions::BORDER_WIDTH);
- nvgLineTo(getContext(), left, top);
- }
- nvgClosePath(getContext());
- nvgFill(getContext());
-
- // right
- nvgFillColor(getContext(), rightGray);
- nvgBeginPath(getContext());
- {
- nvgMoveTo(getContext(), left + width, top);
- nvgLineTo(getContext(), left + width, top + height + 1);
- nvgLineTo(getContext(), left + width - CheckListDimensions::BORDER_WIDTH,
- top + height - CheckListDimensions::BORDER_WIDTH + 1);
- nvgLineTo(getContext(), left + width - CheckListDimensions::BORDER_WIDTH,
- top + CheckListDimensions::BORDER_WIDTH);
- nvgLineTo(getContext(), left + width, top);
- }
- nvgClosePath(getContext());
- nvgFill(getContext());
-
- // bottom
- nvgFillColor(getContext(), bottomGray);
- nvgBeginPath(getContext());
- {
- nvgMoveTo(getContext(), left, top + height);
- nvgLineTo(getContext(), left + width, top + height);
- nvgLineTo(getContext(), left + width - CheckListDimensions::BORDER_WIDTH,
- top + height - CheckListDimensions::BORDER_WIDTH);
- nvgLineTo(getContext(), left + CheckListDimensions::BORDER_WIDTH,
- top + height - CheckListDimensions::BORDER_WIDTH);
- nvgLineTo(getContext(), left, top + height);
- }
- nvgClosePath(getContext());
- nvgFill(getContext());
-
- // left
- nvgFillColor(getContext(), leftGray);
- nvgBeginPath(getContext());
- {
- nvgMoveTo(getContext(), left, top);
- nvgLineTo(getContext(), left + CheckListDimensions::BORDER_WIDTH, top + CheckListDimensions::BORDER_WIDTH);
- nvgLineTo(getContext(), left + CheckListDimensions::BORDER_WIDTH,
- top + height - CheckListDimensions::BORDER_WIDTH);
- nvgLineTo(getContext(), left, top + height);
- nvgLineTo(getContext(), left, top);
- }
- nvgClosePath(getContext());
- nvgFill(getContext());
+ drawButtonBorder(Tools::Colors::cduButtonGray, topGray, rightGray, bottomGray, leftGray);
}
void CheckListLineStateIndicator::drawCheckMark() {
@@ -102,7 +32,7 @@ void CheckListLineStateIndicator::drawCheckMark() {
}
void CheckListLineStateIndicator::render() {
- Control::render();
+ CheckListItem::render();
if (line_->line_type == CheckListLine::CHECKLIST_LINE_TYPE::OPEN_LOOP) {
drawOpenLoopIndicator();
diff --git a/B78XH/CheckListLineStateIndicator.h b/B78XH/CheckListLineStateIndicator.h
index b23f4d9..017e1a3 100644
--- a/B78XH/CheckListLineStateIndicator.h
+++ b/B78XH/CheckListLineStateIndicator.h
@@ -7,10 +7,10 @@ class CheckListLine;
/**
* \brief The main state indicator of a "line" in a checklist. This is typically the "checkbox"/"checkmark". Internal, Owned by "CheckListLine"
*/
-class CheckListLineStateIndicator : public Control {
+class CheckListLineStateIndicator : public CheckListItem {
public:
CheckListLineStateIndicator(const string& name, const CheckListLine* parentLine)
- : Control(name),
+ : CheckListItem(name),
line_(parentLine){
}
From e624a23225df27fd417b1c34a60b9b917fa397c3 Mon Sep 17 00:00:00 2001
From: Michael Lu <38804680+Yamazaki93@users.noreply.github.com>
Date: Fri, 24 Feb 2023 01:37:18 -0800
Subject: [PATCH 10/14] Basic checklist layout and WIP test preflight
---
B78XH/B78XH.vcxproj | 2 ++
B78XH/B78XH.vcxproj.filters | 9 +++++++++
B78XH/CheckList.cpp | 14 +++++++++++++-
B78XH/CheckList.h | 16 ++++++++++++----
B78XH/CheckListLine.cpp | 2 --
B78XH/CheckListLine.h | 2 +-
B78XH/MFDCHKLControl.cpp | 26 ++++----------------------
B78XH/MFDCHKLControl.h | 5 ++++-
B78XH/PreFlightCheckList.cpp | 1 +
B78XH/PreFlightCheckList.h | 12 ++++++++++++
10 files changed, 58 insertions(+), 31 deletions(-)
create mode 100644 B78XH/PreFlightCheckList.cpp
create mode 100644 B78XH/PreFlightCheckList.h
diff --git a/B78XH/B78XH.vcxproj b/B78XH/B78XH.vcxproj
index 317b858..d32ab69 100644
--- a/B78XH/B78XH.vcxproj
+++ b/B78XH/B78XH.vcxproj
@@ -266,6 +266,7 @@
+
@@ -488,6 +489,7 @@
+
diff --git a/B78XH/B78XH.vcxproj.filters b/B78XH/B78XH.vcxproj.filters
index b2dbb97..499b2cd 100644
--- a/B78XH/B78XH.vcxproj.filters
+++ b/B78XH/B78XH.vcxproj.filters
@@ -637,6 +637,9 @@
Source Files\Controls\Controls\MFD\CheckList\CheckListBasics
+
+ Source Files\Controls\Controls\MFD\CheckList\CheckLists
+
@@ -1383,6 +1386,9 @@
Source Files\Controls\Controls\MFD\CheckList\CheckListBasics
+
+ Source Files\Controls\Controls\MFD\CheckList\CheckLists
+
@@ -1709,6 +1715,9 @@
{1b4f3874-894c-4757-b210-c6ef873b9b07}
+
+ {39e6dbd1-ca13-4115-a6a3-f07a70a71a11}
+
diff --git a/B78XH/CheckList.cpp b/B78XH/CheckList.cpp
index a577f57..3804e87 100644
--- a/B78XH/CheckList.cpp
+++ b/B78XH/CheckList.cpp
@@ -6,6 +6,18 @@ void CheckList::setupControls() {
serviceChecklistUpdateLoop();
return true;
});
+ setupChecklistLayout();
+}
+
+auto CheckList::setupChecklistLayout() -> void {
+ title_->position.setPosition(200, CheckListDimensions::TOTAL_LINE_HEIGHT, 500,
+ CheckListDimensions::TOTAL_LINE_HEIGHT * 2);
+ for (auto i = 0; i < lines_.size(); i++) {
+ const std::shared_ptr line = lines_.at(i);
+ line->position.setPosition(0, CheckListDimensions::TOTAL_LINE_HEIGHT * i + 2,
+ CheckListDimensions::TOTAL_WIDTH,
+ CheckListDimensions::TOTAL_LINE_HEIGHT * i + 3);
+ }
}
auto CheckList::checkChecklistCompleted() -> void {
@@ -46,7 +58,7 @@ auto CheckList::checkClosedLoopItems() -> void {
auto CheckList::serviceChecklistUpdateLoop() -> void {
checkClosedLoopItems();
- if(currentLine_ >= lines_.size()) {
+ if (currentLine_ >= lines_.size()) {
return;
}
const std::shared_ptr currentLine = lines_.at(currentLine_);
diff --git a/B78XH/CheckList.h b/B78XH/CheckList.h
index 69a2077..30af798 100644
--- a/B78XH/CheckList.h
+++ b/B78XH/CheckList.h
@@ -1,21 +1,23 @@
#pragma once
#include "CheckListItem.h"
#include "CheckListLine.h"
+#include "CheckListTitle.h"
+#include "CheckListLineSingle.h"
class CheckList : public CheckListItem {
public:
- CheckList(const string& name)
+ CheckList(const string& name, const CheckListTitle::TITLE_TYPE titleType, const string& titleText)
: CheckListItem(name),
- currentLine_(0) {
+ currentLine_(0), title_(std::make_shared("TITLE", titleType, titleText)) {
}
auto setupControls() -> void override;
protected:
/**
- * \brief These lines have operational effects and counts towards the checklists overall completeness
+ * \brief The lines in this checklist. These lines have operational effects and counts towards the checklists overall completeness
*/
- const std::vector> lines_;
+ std::vector> lines_{};
/**
* \brief Evaluates the entire checklists status. This does not care about overridden checklist.
@@ -33,9 +35,15 @@ class CheckList : public CheckListItem {
* \brief Used to check all closed loop items and set their completeness state.
*/
virtual auto checkClosedLoopItems() -> void;
+ /**
+ * \brief Setup layout for a basic checklist with all items in lines_ being 1 line height. This will suffice for most of the checklist.
+ * For special checklist (e.g. with branch items), override this with its own layout.
+ */
+ virtual auto setupChecklistLayout() -> void;
private:
int currentLine_;
+ const std::shared_ptr title_;
/**
* \brief Invoked periodically to check the checklist
diff --git a/B78XH/CheckListLine.cpp b/B78XH/CheckListLine.cpp
index effa30d..9b5bff1 100644
--- a/B78XH/CheckListLine.cpp
+++ b/B78XH/CheckListLine.cpp
@@ -20,8 +20,6 @@ void CheckListLine::render() {
void CheckListLine::prepareControls() {
CheckListItem::prepareControls();
-
- stateIndicator_ = std::make_shared("STATE_INDICATOR", this);
add(stateIndicator_);
}
diff --git a/B78XH/CheckListLine.h b/B78XH/CheckListLine.h
index fc6a7bc..7b10331 100644
--- a/B78XH/CheckListLine.h
+++ b/B78XH/CheckListLine.h
@@ -27,7 +27,7 @@ class CheckListLine : public CheckListItem {
auto setupControls() -> void override;
private:
- std::shared_ptr stateIndicator_;
+ std::shared_ptr stateIndicator_ = std::make_shared("STATE_INDICATOR", this);
bool isCurrent_;
auto drawIsCurrentBorder() -> void;
diff --git a/B78XH/MFDCHKLControl.cpp b/B78XH/MFDCHKLControl.cpp
index 9a1d21c..ad5d062 100644
--- a/B78XH/MFDCHKLControl.cpp
+++ b/B78XH/MFDCHKLControl.cpp
@@ -1,7 +1,5 @@
#include "MFDCHKLControl.h"
-#include "CheckListLineSingle.h"
-
auto MFDCHKLControl::render() -> void {
MFDBaseControl::render();
}
@@ -13,17 +11,7 @@ void MFDCHKLControl::prepareControls() {
add(resetsButton_);
add(nonNormalMenuButton_);
add(normalButton_);
-
- // TODO: Remove
- add(std::make_shared("TEST_TITLE", CheckListTitle::TITLE_TYPE::NORMAL_CHECKLIST, "PREFLIGHT"));
- const auto l1 = std::make_shared("TEST_LINE", CheckListLine::CHECKLIST_LINE_TYPE::OPEN_LOOP,
- "Oxygen . . . . . . . . . . . . . . . . . . . . . . Tested,100%");
- l1->setCurrentState(CheckListItem::CHECKLIST_ITEM_STATE::COMPLETED);
- l1->setIsCurrent(true);
- add(l1);
- const auto l2 = std::make_shared("TEST_LINE_2", CheckListLine::CHECKLIST_LINE_TYPE::OPEN_LOOP);
- l2->setCurrentState(CheckListItem::CHECKLIST_ITEM_STATE::COMPLETED);
- add(l2);
+ add(preflight_);
}
void MFDCHKLControl::setupControls() {
@@ -34,13 +22,7 @@ void MFDCHKLControl::setupControls() {
CheckListDimensions::TOTAL_LINE_HEIGHT);
normalButton_->position.setPosition(0, position.height - CheckListDimensions::TOTAL_LINE_HEIGHT, 150,
position.height);
- // TODO: Remove
- getControl("TEST_TITLE")->position.setPosition(200, CheckListDimensions::TOTAL_LINE_HEIGHT, 500,
- CheckListDimensions::TOTAL_LINE_HEIGHT * 2);
- getControl("TEST_LINE")->position.setPosition(0, CheckListDimensions::TOTAL_LINE_HEIGHT * 2,
- CheckListDimensions::TOTAL_WIDTH,
- CheckListDimensions::TOTAL_LINE_HEIGHT * 3);
- getControl("TEST_LINE_2")->position.setPosition(0, CheckListDimensions::TOTAL_LINE_HEIGHT * 3,
- CheckListDimensions::TOTAL_WIDTH,
- CheckListDimensions::TOTAL_LINE_HEIGHT * 4);
+
+ preflight_->position.setPosition(0, CheckListDimensions::TOTAL_LINE_HEIGHT, CheckListDimensions::TOTAL_WIDTH,
+ position.height - CheckListDimensions::TOTAL_LINE_HEIGHT);
}
diff --git a/B78XH/MFDCHKLControl.h b/B78XH/MFDCHKLControl.h
index ad38de6..18c0e82 100644
--- a/B78XH/MFDCHKLControl.h
+++ b/B78XH/MFDCHKLControl.h
@@ -4,6 +4,7 @@
#include "CheckListTitle.h"
#include "CheckListButton.h"
#include "CheckListDimensions.h"
+#include "PreFlightCheckList.h"
class MFDCHKLControl : public MFDBaseControl {
public:
@@ -20,6 +21,8 @@ class MFDCHKLControl : public MFDBaseControl {
std::shared_ptr normalMenuButton_ = std::make_shared("NORMAL_MENU", nullptr, "NORMAL MENU");
std::shared_ptr resetsButton_ = std::make_shared("RESETS", nullptr, "RESETS");
std::shared_ptr nonNormalMenuButton_ = std::make_shared("NON_NORMAL_MENU", nullptr, "NON-NORMAL MENU");
-
std::shared_ptr normalButton_ = std::make_shared("NORMAL", nullptr, "NORMAL");
+
+ // TODO: Temp, remove, use a "current pointer"
+ std::shared_ptr preflight_ = std::make_shared("PREFLIGHT");
};
diff --git a/B78XH/PreFlightCheckList.cpp b/B78XH/PreFlightCheckList.cpp
new file mode 100644
index 0000000..9f4bd2d
--- /dev/null
+++ b/B78XH/PreFlightCheckList.cpp
@@ -0,0 +1 @@
+#include "PreFlightCheckList.h"
diff --git a/B78XH/PreFlightCheckList.h b/B78XH/PreFlightCheckList.h
new file mode 100644
index 0000000..3ece37d
--- /dev/null
+++ b/B78XH/PreFlightCheckList.h
@@ -0,0 +1,12 @@
+#pragma once
+#include "CheckList.h"
+
+class PreFlightCheckList : public CheckList {
+ public:
+ explicit PreFlightCheckList(const string& name)
+ : CheckList(name, CheckListTitle::TITLE_TYPE::NORMAL_CHECKLIST, "PREFLIGHT") {
+ lines_.push_back(std::make_shared(
+ "OXYGEN", CheckListLine::CHECKLIST_LINE_TYPE::OPEN_LOOP,
+ "Oxygen . . . . . . . . . . . . . . . . . . . . . . Tested,100%"));
+ }
+};
From 2f48de0e0929fc8129d882089d6f9169af0a57cb Mon Sep 17 00:00:00 2001
From: Michael Lu <38804680+Yamazaki93@users.noreply.github.com>
Date: Fri, 24 Feb 2023 22:19:51 -0800
Subject: [PATCH 11/14] Checklist item interaction and status WIP
---
B78XH/B78XH.vcxproj | 2 ++
B78XH/B78XH.vcxproj.filters | 6 +++++
B78XH/CheckList.cpp | 50 ++++++++++++++++++++++++++-----------
B78XH/CheckList.h | 26 +++++++++++++++----
B78XH/CheckListItem.h | 8 +++---
B78XH/CheckListLine.cpp | 5 +++-
B78XH/CheckListStatus.cpp | 27 ++++++++++++++++++++
B78XH/CheckListStatus.h | 19 ++++++++++++++
B78XH/MFDCHKLControl.cpp | 2 ++
B78XH/MFDCHKLControl.h | 1 +
B78XH/PreFlightCheckList.h | 7 ++++++
11 files changed, 128 insertions(+), 25 deletions(-)
create mode 100644 B78XH/CheckListStatus.cpp
create mode 100644 B78XH/CheckListStatus.h
diff --git a/B78XH/B78XH.vcxproj b/B78XH/B78XH.vcxproj
index d32ab69..81468b4 100644
--- a/B78XH/B78XH.vcxproj
+++ b/B78XH/B78XH.vcxproj
@@ -159,6 +159,7 @@
+
@@ -387,6 +388,7 @@
+
diff --git a/B78XH/B78XH.vcxproj.filters b/B78XH/B78XH.vcxproj.filters
index 499b2cd..7137193 100644
--- a/B78XH/B78XH.vcxproj.filters
+++ b/B78XH/B78XH.vcxproj.filters
@@ -640,6 +640,9 @@
Source Files\Controls\Controls\MFD\CheckList\CheckLists
+
+ Source Files\Controls\Controls\MFD\CheckList\CheckListBasics
+
@@ -1389,6 +1392,9 @@
Source Files\Controls\Controls\MFD\CheckList\CheckLists
+
+ Source Files\Controls\Controls\MFD\CheckList\CheckListBasics
+
diff --git a/B78XH/CheckList.cpp b/B78XH/CheckList.cpp
index 3804e87..f28bc50 100644
--- a/B78XH/CheckList.cpp
+++ b/B78XH/CheckList.cpp
@@ -9,15 +9,23 @@ void CheckList::setupControls() {
setupChecklistLayout();
}
+void CheckList::prepareControls() {
+ CheckListItem::prepareControls();
+ addChecklistControls();
+}
+
auto CheckList::setupChecklistLayout() -> void {
- title_->position.setPosition(200, CheckListDimensions::TOTAL_LINE_HEIGHT, 500,
- CheckListDimensions::TOTAL_LINE_HEIGHT * 2);
+ title_->position.setPosition(200, 0, 500,
+ CheckListDimensions::TOTAL_LINE_HEIGHT * 1);
for (auto i = 0; i < lines_.size(); i++) {
+ // TODO: No pagination yet, no normal checklist needs pagination
const std::shared_ptr line = lines_.at(i);
- line->position.setPosition(0, CheckListDimensions::TOTAL_LINE_HEIGHT * i + 2,
+ line->position.setPosition(0, CheckListDimensions::TOTAL_LINE_HEIGHT * (i + 1),
CheckListDimensions::TOTAL_WIDTH,
- CheckListDimensions::TOTAL_LINE_HEIGHT * i + 3);
+ CheckListDimensions::TOTAL_LINE_HEIGHT * (i + 2));
}
+ status_->position.setPosition(200, position.getHeight() - CheckListDimensions::TOTAL_LINE_HEIGHT, 500,
+ position.getHeight());
}
auto CheckList::checkChecklistCompleted() -> void {
@@ -33,17 +41,10 @@ auto CheckList::checkChecklistCompleted() -> void {
}
auto CheckList::advanceCurrentLine() -> void {
- if (currentLine_ >= lines_.size()) {
- return;
- }
- const std::shared_ptr currentLine = lines_.at(currentLine_);
- currentLine->setIsCurrent(false);
+ toggleCurrentLineHighlight(false);
currentLine_++;
- if (currentLine_ >= lines_.size()) {
- return;
- }
- const std::shared_ptr nextLine = lines_.at(currentLine_);
- nextLine->setIsCurrent(true);
+ toggleCurrentLineHighlight(true);
+ checkChecklistCompleted();
}
auto CheckList::resetChecklist() -> void {
@@ -51,18 +52,37 @@ auto CheckList::resetChecklist() -> void {
l->setCurrentState(CHECKLIST_ITEM_STATE::OPEN);
}
setCurrentState(CHECKLIST_ITEM_STATE::OPEN);
+ currentLine_ = 0;
+ toggleCurrentLineHighlight(true);
}
auto CheckList::checkClosedLoopItems() -> void {
}
+auto CheckList::addChecklistControls() -> void {
+ add(title_);
+ add(status_);
+ for (std::shared_ptr l : lines_) {
+ add(l);
+ }
+}
+
auto CheckList::serviceChecklistUpdateLoop() -> void {
- checkClosedLoopItems();
if (currentLine_ >= lines_.size()) {
+ // overrun, so the checklist is either completed or overridden.
return;
}
+ checkClosedLoopItems();
const std::shared_ptr currentLine = lines_.at(currentLine_);
if (currentLine->getCurrentState() != CHECKLIST_ITEM_STATE::OPEN) {
advanceCurrentLine();
}
}
+
+auto CheckList::toggleCurrentLineHighlight(bool isCurrent) -> void {
+ if (currentLine_ >= lines_.size()) {
+ return;
+ }
+ const std::shared_ptr currentLine = lines_.at(currentLine_);
+ currentLine->setIsCurrent(isCurrent);
+}
diff --git a/B78XH/CheckList.h b/B78XH/CheckList.h
index 30af798..73f9f72 100644
--- a/B78XH/CheckList.h
+++ b/B78XH/CheckList.h
@@ -2,20 +2,23 @@
#include "CheckListItem.h"
#include "CheckListLine.h"
#include "CheckListTitle.h"
-#include "CheckListLineSingle.h"
+#include "CheckListStatus.h"
class CheckList : public CheckListItem {
public:
CheckList(const string& name, const CheckListTitle::TITLE_TYPE titleType, const string& titleText)
: CheckListItem(name),
- currentLine_(0), title_(std::make_shared("TITLE", titleType, titleText)) {
+ currentLine_(0), title_(std::make_shared("TITLE", titleType, titleText)),
+ status_(std::make_shared("STATUS", this)) {
}
auto setupControls() -> void override;
+ auto prepareControls() -> void override;
protected:
/**
- * \brief The lines in this checklist. These lines have operational effects and counts towards the checklists overall completeness
+ * \brief The lines in this checklist.
+ * These lines have operational effects and counts towards the checklists overall completeness
*/
std::vector> lines_{};
@@ -24,7 +27,7 @@ class CheckList : public CheckListItem {
*/
auto checkChecklistCompleted() -> void;
/**
- * \brief Advances the current line pointer. This does not change the checklist's status.
+ * \brief Advances the current line pointer. This also check if the checklist is completed.
*/
auto advanceCurrentLine() -> void;
/**
@@ -36,7 +39,14 @@ class CheckList : public CheckListItem {
*/
virtual auto checkClosedLoopItems() -> void;
/**
- * \brief Setup layout for a basic checklist with all items in lines_ being 1 line height. This will suffice for most of the checklist.
+ * \brief Add controls for a basic checklist with the title and all the item in lines_.
+ * This will suffice for most of the checklist.
+ * For special checklist with more items to render other than these, override this.
+ */
+ virtual auto addChecklistControls() -> void;
+ /**
+ * \brief Setup layout for a basic checklist with all items in lines_ being 1 line height.
+ * This will suffice for most of the checklist.
* For special checklist (e.g. with branch items), override this with its own layout.
*/
virtual auto setupChecklistLayout() -> void;
@@ -44,9 +54,15 @@ class CheckList : public CheckListItem {
private:
int currentLine_;
const std::shared_ptr title_;
+ const std::shared_ptr status_;
/**
* \brief Invoked periodically to check the checklist
*/
auto serviceChecklistUpdateLoop() -> void;
+ /**
+ * \brief Lower level UI utility. Highlight/Unhighlight the line pointed at currentLine_ if valid.
+ * For normal usage, use advanceCurrentLine, resetChecklist
+ */
+ auto toggleCurrentLineHighlight(bool isCurrent) -> void;
};
diff --git a/B78XH/CheckListItem.h b/B78XH/CheckListItem.h
index 71185e1..c482af4 100644
--- a/B78XH/CheckListItem.h
+++ b/B78XH/CheckListItem.h
@@ -27,6 +27,10 @@ class CheckListItem : public Control {
* \brief Gets the current state of the item.
*/
auto getCurrentState() const -> CHECKLIST_ITEM_STATE;
+ /**
+ * \brief Gets the color corresponding to the current state.
+ */
+ auto getItemStateColor() const -> NVGcolor;
protected:
/**
@@ -39,10 +43,6 @@ class CheckListItem : public Control {
* \return true if mouse is clicking, false otherwise
*/
auto shouldTriggerEvent() -> bool;
- /**
- * \brief Gets the color corresponding to the current state.
- */
- auto getItemStateColor() const -> NVGcolor;
/**
* \brief Draws a magenta border around the item.
*/
diff --git a/B78XH/CheckListLine.cpp b/B78XH/CheckListLine.cpp
index 9b5bff1..81ac597 100644
--- a/B78XH/CheckListLine.cpp
+++ b/B78XH/CheckListLine.cpp
@@ -13,9 +13,12 @@ void CheckListLine::render() {
if (isInFocus()) {
drawBorder();
}
- if(isCurrent_) {
+ if (isCurrent_) {
drawIsCurrentBorder();
}
+ if (shouldTriggerEvent()) {
+ setCurrentState(CHECKLIST_ITEM_STATE::COMPLETED);
+ }
}
void CheckListLine::prepareControls() {
diff --git a/B78XH/CheckListStatus.cpp b/B78XH/CheckListStatus.cpp
new file mode 100644
index 0000000..d165302
--- /dev/null
+++ b/B78XH/CheckListStatus.cpp
@@ -0,0 +1,27 @@
+#include "CheckListStatus.h"
+#include "CheckList.h"
+
+void CheckListStatus::render() {
+ Control::render();
+ const auto color = parentChecklist_->getItemStateColor();
+ const auto displayText = parentChecklist_->getCurrentState() == CheckListItem::CHECKLIST_ITEM_STATE::OVERRIDDEN
+ ? "CHECKLIST OVERRIDDEN"
+ : "CHECKLIST COMPLETE";
+ nvgFillColor(getContext(), color);
+ nvgBeginPath(getContext());
+ {
+ nvgRoundedRect(getContext(), 0, 0, position.getWidth(), position.getHeight(), position.getHeight() / 2);
+ nvgFill(getContext());
+ }
+ nvgClosePath(getContext());
+ nvgFontFace(getContext(), "heavy-mfc");
+ nvgFontSize(getContext(), 24);
+ nvgFillColor(getContext(), Tools::Colors::white);
+ nvgTextAlign(getContext(), NVG_ALIGN_CENTER | NVG_ALIGN_MIDDLE);
+ nvgBeginPath(getContext());
+ {
+ nvgText(getContext(), position.getWidth() / 2, position.getHeight() / 2, displayText, nullptr);
+ nvgFill(getContext());
+ }
+ nvgClosePath(getContext());
+}
diff --git a/B78XH/CheckListStatus.h b/B78XH/CheckListStatus.h
new file mode 100644
index 0000000..6d4c699
--- /dev/null
+++ b/B78XH/CheckListStatus.h
@@ -0,0 +1,19 @@
+#pragma once
+#include "Control.h"
+
+class CheckList;
+
+/**
+ * \brief The overall status indicator on a checklist.
+ */
+class CheckListStatus : public Control {
+ public:
+ CheckListStatus(const string& name, const CheckList* parentChecklist)
+ : Control(name),
+ parentChecklist_(parentChecklist) {
+ }
+
+ auto render() -> void override;
+ private:
+ const CheckList* parentChecklist_;
+};
diff --git a/B78XH/MFDCHKLControl.cpp b/B78XH/MFDCHKLControl.cpp
index ad5d062..f0f17bf 100644
--- a/B78XH/MFDCHKLControl.cpp
+++ b/B78XH/MFDCHKLControl.cpp
@@ -22,6 +22,8 @@ void MFDCHKLControl::setupControls() {
CheckListDimensions::TOTAL_LINE_HEIGHT);
normalButton_->position.setPosition(0, position.height - CheckListDimensions::TOTAL_LINE_HEIGHT, 150,
position.height);
+ resetChecklistButton_->position.setPosition(300, 450, position.height - CheckListDimensions::TOTAL_LINE_HEIGHT,
+ position.height);
preflight_->position.setPosition(0, CheckListDimensions::TOTAL_LINE_HEIGHT, CheckListDimensions::TOTAL_WIDTH,
position.height - CheckListDimensions::TOTAL_LINE_HEIGHT);
diff --git a/B78XH/MFDCHKLControl.h b/B78XH/MFDCHKLControl.h
index 18c0e82..74447cb 100644
--- a/B78XH/MFDCHKLControl.h
+++ b/B78XH/MFDCHKLControl.h
@@ -22,6 +22,7 @@ class MFDCHKLControl : public MFDBaseControl {
std::shared_ptr resetsButton_ = std::make_shared("RESETS", nullptr, "RESETS");
std::shared_ptr nonNormalMenuButton_ = std::make_shared("NON_NORMAL_MENU", nullptr, "NON-NORMAL MENU");
std::shared_ptr normalButton_ = std::make_shared("NORMAL", nullptr, "NORMAL");
+ std::shared_ptr resetChecklistButton_ = std::make_shared("CHKL_RESET", nullptr, "CHKL\nRESET");
// TODO: Temp, remove, use a "current pointer"
std::shared_ptr preflight_ = std::make_shared("PREFLIGHT");
diff --git a/B78XH/PreFlightCheckList.h b/B78XH/PreFlightCheckList.h
index 3ece37d..1940ccd 100644
--- a/B78XH/PreFlightCheckList.h
+++ b/B78XH/PreFlightCheckList.h
@@ -8,5 +8,12 @@ class PreFlightCheckList : public CheckList {
lines_.push_back(std::make_shared(
"OXYGEN", CheckListLine::CHECKLIST_LINE_TYPE::OPEN_LOOP,
"Oxygen . . . . . . . . . . . . . . . . . . . . . . Tested,100%"));
+ lines_.push_back(std::make_shared(
+ "FLIGHT_INST", CheckListLine::CHECKLIST_LINE_TYPE::OPEN_LOOP,
+ "Flight Instruments . . . Heading___,Altimeter___"));
+ lines_.push_back(std::make_shared(
+ "PAX_SIGN", CheckListLine::CHECKLIST_LINE_TYPE::OPEN_LOOP,
+ "Passenger Signs . . . . . . . . . . . . . . Set"));
+ resetChecklist();
}
};
From 0db6e8e662a4d5554b77213b66e416f30e139124 Mon Sep 17 00:00:00 2001
From: Michael Lu <38804680+Yamazaki93@users.noreply.github.com>
Date: Sat, 25 Feb 2023 17:22:31 -0800
Subject: [PATCH 12/14] Checklist status and WIP Reset button
---
B78XH/CheckList.cpp | 7 ++++---
B78XH/CheckList.h | 1 +
B78XH/CheckListStatus.cpp | 6 +++++-
B78XH/MFDCHKLControl.cpp | 3 ++-
B78XH/PreFlightCheckList.h | 2 +-
5 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/B78XH/CheckList.cpp b/B78XH/CheckList.cpp
index f28bc50..00ac7c4 100644
--- a/B78XH/CheckList.cpp
+++ b/B78XH/CheckList.cpp
@@ -24,8 +24,8 @@ auto CheckList::setupChecklistLayout() -> void {
CheckListDimensions::TOTAL_WIDTH,
CheckListDimensions::TOTAL_LINE_HEIGHT * (i + 2));
}
- status_->position.setPosition(200, position.getHeight() - CheckListDimensions::TOTAL_LINE_HEIGHT, 500,
- position.getHeight());
+ status_->position.setPosition(200, position.getHeight() - CheckListDimensions::TOTAL_LINE_HEIGHT / 2 - CheckListDimensions::MARGIN, 500,
+ position.getHeight() - CheckListDimensions::MARGIN);
}
auto CheckList::checkChecklistCompleted() -> void {
@@ -35,9 +35,10 @@ auto CheckList::checkChecklistCompleted() -> void {
for (const std::shared_ptr l : lines_) {
if (l->getCurrentState() == CHECKLIST_ITEM_STATE::OPEN) {
setCurrentState(CHECKLIST_ITEM_STATE::OPEN);
- break;
+ return;
}
}
+ setCurrentState(CHECKLIST_ITEM_STATE::COMPLETED);
}
auto CheckList::advanceCurrentLine() -> void {
diff --git a/B78XH/CheckList.h b/B78XH/CheckList.h
index 73f9f72..8dd74e6 100644
--- a/B78XH/CheckList.h
+++ b/B78XH/CheckList.h
@@ -3,6 +3,7 @@
#include "CheckListLine.h"
#include "CheckListTitle.h"
#include "CheckListStatus.h"
+#include "CheckListLineSingle.h"
class CheckList : public CheckListItem {
public:
diff --git a/B78XH/CheckListStatus.cpp b/B78XH/CheckListStatus.cpp
index d165302..b5c7949 100644
--- a/B78XH/CheckListStatus.cpp
+++ b/B78XH/CheckListStatus.cpp
@@ -3,8 +3,12 @@
void CheckListStatus::render() {
Control::render();
+ const auto currentState = parentChecklist_->getCurrentState();
+ if (currentState == CheckListItem::CHECKLIST_ITEM_STATE::OPEN) {
+ return;
+ }
const auto color = parentChecklist_->getItemStateColor();
- const auto displayText = parentChecklist_->getCurrentState() == CheckListItem::CHECKLIST_ITEM_STATE::OVERRIDDEN
+ const auto displayText = currentState == CheckListItem::CHECKLIST_ITEM_STATE::OVERRIDDEN
? "CHECKLIST OVERRIDDEN"
: "CHECKLIST COMPLETE";
nvgFillColor(getContext(), color);
diff --git a/B78XH/MFDCHKLControl.cpp b/B78XH/MFDCHKLControl.cpp
index f0f17bf..496cb89 100644
--- a/B78XH/MFDCHKLControl.cpp
+++ b/B78XH/MFDCHKLControl.cpp
@@ -11,6 +11,7 @@ void MFDCHKLControl::prepareControls() {
add(resetsButton_);
add(nonNormalMenuButton_);
add(normalButton_);
+ add(resetChecklistButton_);
add(preflight_);
}
@@ -22,7 +23,7 @@ void MFDCHKLControl::setupControls() {
CheckListDimensions::TOTAL_LINE_HEIGHT);
normalButton_->position.setPosition(0, position.height - CheckListDimensions::TOTAL_LINE_HEIGHT, 150,
position.height);
- resetChecklistButton_->position.setPosition(300, 450, position.height - CheckListDimensions::TOTAL_LINE_HEIGHT,
+ resetChecklistButton_->position.setPosition(300, position.height - CheckListDimensions::TOTAL_LINE_HEIGHT, 450,
position.height);
preflight_->position.setPosition(0, CheckListDimensions::TOTAL_LINE_HEIGHT, CheckListDimensions::TOTAL_WIDTH,
diff --git a/B78XH/PreFlightCheckList.h b/B78XH/PreFlightCheckList.h
index 1940ccd..bfc3729 100644
--- a/B78XH/PreFlightCheckList.h
+++ b/B78XH/PreFlightCheckList.h
@@ -13,7 +13,7 @@ class PreFlightCheckList : public CheckList {
"Flight Instruments . . . Heading___,Altimeter___"));
lines_.push_back(std::make_shared(
"PAX_SIGN", CheckListLine::CHECKLIST_LINE_TYPE::OPEN_LOOP,
- "Passenger Signs . . . . . . . . . . . . . . Set"));
+ "Passenger Signs . . . . . . . . . . . . . . . . . . . . . Set"));
resetChecklist();
}
};
From e23c5a6049da010f8db039d87775a99380c0484c Mon Sep 17 00:00:00 2001
From: Michael Lu <38804680+Yamazaki93@users.noreply.github.com>
Date: Thu, 9 Mar 2023 21:13:18 -0800
Subject: [PATCH 13/14] Adjust button to allow multi line text
---
B78XH/CheckListButton.cpp | 6 ++++--
B78XH/CheckListButton.h | 1 +
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/B78XH/CheckListButton.cpp b/B78XH/CheckListButton.cpp
index 5c18485..d9539f1 100644
--- a/B78XH/CheckListButton.cpp
+++ b/B78XH/CheckListButton.cpp
@@ -11,10 +11,12 @@ void CheckListButton::render() {
nvgFontFace(getContext(), "heavy-fmc");
nvgFontSize(getContext(), 24.0f);
nvgFillColor(getContext(), Tools::Colors::white);
- nvgTextAlign(getContext(), NVG_ALIGN_CENTER | NVG_ALIGN_MIDDLE);
+ nvgTextAlign(getContext(), NVG_ALIGN_CENTER | NVG_ALIGN_TOP);
nvgBeginPath(getContext());
{
- nvgText(getContext(), position.width / 2, position.height / 2, displayText_.c_str(), nullptr);
+ nvgTextBoxBounds(getContext(), 0, position.height / 2, position.width, displayText_.c_str(), nullptr, textBounds_);
+ const auto boundsHeight = textBounds_[3] - textBounds_[1];
+ nvgTextBox(getContext(), 0, position.height / 2 - boundsHeight / 2 + CheckListDimensions::BORDER_WIDTH, position.width, displayText_.c_str(), nullptr);
nvgFill(getContext());
}
nvgClosePath(getContext());
diff --git a/B78XH/CheckListButton.h b/B78XH/CheckListButton.h
index 2678dc4..980ce03 100644
--- a/B78XH/CheckListButton.h
+++ b/B78XH/CheckListButton.h
@@ -19,4 +19,5 @@ class CheckListButton : public CheckListItem {
private:
const std::function invoke_;
const string displayText_;
+ float textBounds_[4] = {0, 0, 0, 0};
};
From d08526f707abb8d9697292c6b93431f5f3354dd6 Mon Sep 17 00:00:00 2001
From: Michael Lu <38804680+Yamazaki93@users.noreply.github.com>
Date: Fri, 10 Mar 2023 18:52:01 -0800
Subject: [PATCH 14/14] Fix text display in checklist status
---
B78XH/CheckListStatus.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/B78XH/CheckListStatus.cpp b/B78XH/CheckListStatus.cpp
index b5c7949..33c7db5 100644
--- a/B78XH/CheckListStatus.cpp
+++ b/B78XH/CheckListStatus.cpp
@@ -10,7 +10,7 @@ void CheckListStatus::render() {
const auto color = parentChecklist_->getItemStateColor();
const auto displayText = currentState == CheckListItem::CHECKLIST_ITEM_STATE::OVERRIDDEN
? "CHECKLIST OVERRIDDEN"
- : "CHECKLIST COMPLETE";
+ : "CHECKLIST COMPLETED";
nvgFillColor(getContext(), color);
nvgBeginPath(getContext());
{
@@ -18,7 +18,7 @@ void CheckListStatus::render() {
nvgFill(getContext());
}
nvgClosePath(getContext());
- nvgFontFace(getContext(), "heavy-mfc");
+ nvgFontFace(getContext(), "heavy-fmc");
nvgFontSize(getContext(), 24);
nvgFillColor(getContext(), Tools::Colors::white);
nvgTextAlign(getContext(), NVG_ALIGN_CENTER | NVG_ALIGN_MIDDLE);