From 8ef401eb7174245fcca277c6dff15426b0d9afd0 Mon Sep 17 00:00:00 2001 From: smolBlackCat <66385489+smolBlackCat@users.noreply.github.com> Date: Sat, 2 Nov 2024 08:51:06 -0300 Subject: [PATCH] (core): Update widgets documentation --- src/resources/ui/app-window.ui | 189 ++++++++++++++++++-------------- src/widgets/card.h | 36 ++++-- src/widgets/cardlist-widget.cpp | 28 ++--- src/widgets/cardlist-widget.h | 22 ++-- src/window.h | 3 + 5 files changed, 164 insertions(+), 114 deletions(-) diff --git a/src/resources/ui/app-window.ui b/src/resources/ui/app-window.ui index 186e3fc..efbfc8b 100644 --- a/src/resources/ui/app-window.ui +++ b/src/resources/ui/app-window.ui @@ -1,92 +1,111 @@ - + + - - - Progress - 400 - 400 - - - - - go-home - Homepage - false - - - - - list-add-symbolic - Add Board - true - - - - - board-grid-menu - open-menu-symbolic - Main Menu - true - + + + + + 400 + Progress + + + + + go-home + Homepage + false + + + + + list-add-symbolic + Add Board + true + + + + + open-menu-symbolic + board-grid-menu + true + Main Menu + + + + + 400 + + + slide-left-right + board-grid-page + + + + + + + + + 10 + 10 + 10 + 10 + none + start + + + -1 + -1 + - - + + + board-grid-page + + - - GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT_RIGHT + + + - - board-grid-page - - - - - -1 - -1 - - - start - 10 - 10 - 10 - 10 - GTK_SELECTION_NONE - - - - - - - - + + center + True + True + center + True + - - + + + loading-page + - - -
- - Delete Boards - win.delete - - - About Progress - win.about - -
-
- -
- - Preferences - win.preferences - - - About Progress - win.about - -
-
+
+ +
+ +
+ + win.delete + Delete Boards + + + win.about + About Progress + +
+
+ +
+ + win.preferences + Preferences + + + win.about + About Progress + +
+
- diff --git a/src/widgets/card.h b/src/widgets/card.h index 72171af..c3e775b 100644 --- a/src/widgets/card.h +++ b/src/widgets/card.h @@ -19,18 +19,18 @@ class CardWidget : public Gtk::Box { /** * @brief CardWidget constructor * - * @param card_ptr a smart pointer pointing to a Card object. + * @param card a smart pointer pointing to a Card object. * @param is_new flag indicating whether this object is being created from * scratch rather than being loaded from a Progress board file. True means * the Card did not come from a file otherwise False */ CardWidget(BaseObjectType* cobject, const Glib::RefPtr& builder, - std::shared_ptr card_refptr, bool is_new = false); + std::shared_ptr card, bool is_new = false); - void set_label(const std::string& label); + void set_title(const std::string& label); - std::string get_text() const; + std::string get_title() const; /** * @brief Removes itself from the associated CardlistWidget object. @@ -41,9 +41,6 @@ class CardWidget : public Gtk::Box { * @brief Sets a new parent to this card. * * @param cardlist_p pointer to a new CardlistWidget object (parent) - * - * @details Cards in Progress Tracker are the only ones that changes parents - * with a certain frequency, that's why this method exists. */ void set_cardlist(ui::CardlistWidget* cardlist_p); @@ -61,13 +58,38 @@ class CardWidget : public Gtk::Box { */ std::shared_ptr get_card(); + /** + * @brief Gets the cardlist widget from which this widget is associated with + */ CardlistWidget const* get_cardlist_widget() const; + /** + * @brief Updates label informing the amount of tasks complete + */ void update_complete_tasks(); + + /** + * @brief Updates label informing due date for this card + */ void update_due_date(); + + /** + * @brief Changes due date label colour depending on the card's + * situation. Red if it is past due date, green if it is complete and plain + * colour if it is due but not yet complete + */ void update_due_date_label_style(); + + /** + * @brief Changes the complete tasks label colour depending on the amount of + * tasks complete. Green if all tasks are complete, Yellow if half of the + * tasks are complete and Red if less than half of the task are complete + */ void update_complete_tasks_style(unsigned long n_complete_tasks); + /** + * @brief Helper method for creating a tooltip text for the card widget + */ std::string create_details_text() const; protected: diff --git a/src/widgets/cardlist-widget.cpp b/src/widgets/cardlist-widget.cpp index 6873999..632f4eb 100644 --- a/src/widgets/cardlist-widget.cpp +++ b/src/widgets/cardlist-widget.cpp @@ -11,7 +11,7 @@ ui::CardlistWidget::CardlistWidget(BoardWidget& board, : Gtk::ListBox{}, add_card_button{_("Add card")}, root{Gtk::Orientation::VERTICAL}, - cards_tracker{}, + card_widgets{}, board{board}, cardlist{cardlist_refptr}, is_new{is_new}, @@ -47,7 +47,7 @@ ui::CardlistWidget::CardlistWidget(BoardWidget& board, add_card_button.set_halign(Gtk::Align::FILL); add_card_button.set_hexpand(true); add_card_button.signal_clicked().connect( - [this]() { this->add_card(Card{_("New Card")}, true); }); + [this]() { this->add(Card{_("New Card")}, true); }); root.append(add_card_button); append(cardlist_header); @@ -57,7 +57,7 @@ ui::CardlistWidget::CardlistWidget(BoardWidget& board, auto cardwidget = Gtk::manage(cur_builder->get_widget_derived( cur_builder, "card-root", card)); - cards_tracker.push_back(cardwidget); + card_widgets.push_back(cardwidget); cardwidget->set_cardlist(this); root.append(*cardwidget); root.reorder_child_after(add_card_button, *cardwidget); @@ -83,15 +83,15 @@ ui::CardlistWidget::CardlistWidget(BoardWidget& board, ui::CardlistWidget::~CardlistWidget() {} -void ui::CardlistWidget::reorder_cardwidget(ui::CardWidget& next, +void ui::CardlistWidget::reorder(ui::CardWidget& next, ui::CardWidget& sibling) { root.reorder_child_after(next, sibling); cardlist->reorder(*next.get_card(), *sibling.get_card()); } const std::vector& -ui::CardlistWidget::get_cardwidget_vector() { - return cards_tracker; +ui::CardlistWidget::get_card_widgets() { + return card_widgets; } void ui::CardlistWidget::setup_drag_and_drop() { @@ -168,7 +168,7 @@ void ui::CardlistWidget::setup_drag_and_drop() { if (!this->is_child(dropped_card)) { auto card_in_dropped = dropped_card->get_card(); dropped_card->remove_from_parent(); - this->add_card(*card_in_dropped); + this->add(*card_in_dropped); } return true; } @@ -178,18 +178,18 @@ void ui::CardlistWidget::setup_drag_and_drop() { add_controller(drop_target_card); } -void ui::CardlistWidget::remove_card(ui::CardWidget* card) { +void ui::CardlistWidget::remove(ui::CardWidget* card) { root.remove(*card); cardlist->remove(*card->get_card()); - for (size_t i = 0; i < cards_tracker.size(); i++) { - if (cards_tracker[i] == card) { - cards_tracker.erase(cards_tracker.begin() + i); + for (size_t i = 0; i < card_widgets.size(); i++) { + if (card_widgets[i] == card) { + card_widgets.erase(card_widgets.begin() + i); } } } -ui::CardWidget* ui::CardlistWidget::add_card(const Card& card, +ui::CardWidget* ui::CardlistWidget::add(const Card& card, bool editing_mode) { auto card_builder = Gtk::Builder::create_from_resource( "/io/github/smolblackcat/Progress/card-widget.ui"); @@ -197,7 +197,7 @@ ui::CardWidget* ui::CardlistWidget::add_card(const Card& card, card_builder, "card-root", cardlist->add(card), editing_mode)); new_card->set_cardlist(this); - cards_tracker.push_back(new_card); + card_widgets.push_back(new_card); root.append(*new_card); root.reorder_child_after(add_card_button, *new_card); return new_card; @@ -208,7 +208,7 @@ const std::shared_ptr& ui::CardlistWidget::get_cardlist() { } bool ui::CardlistWidget::is_child(ui::CardWidget* card) { - for (auto& card_ : cards_tracker) { + for (auto& card_ : card_widgets) { if (card == card_) return true; } return false; diff --git a/src/widgets/cardlist-widget.h b/src/widgets/cardlist-widget.h index de4d088..66914ea 100644 --- a/src/widgets/cardlist-widget.h +++ b/src/widgets/cardlist-widget.h @@ -26,7 +26,7 @@ class CardlistWidget : public Gtk::ListBox { * @brief CardlistWidget's constructor * * @param board BoardWidget reference to where this widget belongs - * @param cardlist_refptr CardList smart pointer that this widget is allowed + * @param cardlist CardList smart pointer that this widget is allowed * to change * @param is_new Indicates whether it's completely new, therefore giving the * user the chance to cancel creation @@ -39,20 +39,20 @@ class CardlistWidget : public Gtk::ListBox { /** * @brief Adds a CardWidget object based on the given Card * - * @param card Card object + * @param card Card object reference * @param editing_mode Boolean indicating whether the card widget should * start in editing mode. Default is false * * @return The created CardWidget object pointer */ - ui::CardWidget* add_card(const Card& card, bool editing_mode = false); + ui::CardWidget* add(const Card& card, bool editing_mode = false); /** * @brief Removes the specified CardWidget * * @param card Pointer to the CardWidget to be deleted. */ - void remove_card(ui::CardWidget* card); + void remove(ui::CardWidget* card); /** * @brief Retrieves the underlying CardList smart pointer. @@ -72,11 +72,17 @@ class CardlistWidget : public Gtk::ListBox { */ bool is_child(ui::CardWidget* card); - BoardWidget& board; + /** + * @brief Reorders card widget "next" after card widget "sibling" + */ + void reorder(ui::CardWidget& next, ui::CardWidget& sibling); - void reorder_cardwidget(ui::CardWidget& next, ui::CardWidget& sibling); + /** + * @brief Access the card widgets tracker vector + */ + const std::vector& get_card_widgets(); - const std::vector& get_cardwidget_vector(); + BoardWidget& board; private: void setup_drag_and_drop(); @@ -88,7 +94,7 @@ class CardlistWidget : public Gtk::ListBox { // Data std::shared_ptr cardlist; - std::vector cards_tracker; + std::vector card_widgets; bool is_new; }; diff --git a/src/window.h b/src/window.h index ee0faa5..081b26b 100644 --- a/src/window.h +++ b/src/window.h @@ -40,6 +40,9 @@ class ProgressWindow : public Gtk::ApplicationWindow { Glib::RefPtr& progress_settings); ~ProgressWindow() override; + /** + * @brief Adds local boards from a given backend + */ void add_local_board(BoardBackend board_backend); /**