Aurore
A Switch-like interface for your app, on every screen
Loading...
Searching...
No Matches
cadran_list.hpp
Go to the documentation of this file.
1// cadran::List — the Cadran look for the list screens (the tabs' lines under
2// their tops, every other screen) without rewriting them: the original
3// tab is built as usual (its XML, its i18n strings, its actions), then its
4// lines are restyled after the boards' settings lists. A section header
5// becomes a kicker (kit::TEXT_KICKER, capitals, text2); each run of cells a
6// card (surf, 1 px border, kit::RADIUS_CARD, a line between rows); a cell
7// gets an icon in a soft square before its title, a chevron when it opens
8// something, a switch for a BooleanCell; the notes go to kit::TEXT_NOTE. tiles() turns a few cells into
9// the boards' tiles instead (a row of cards; the icon on top, or before an action's title
10// over two soft lights in its own ink).
11//
12// The tab keeps every view it binds (they move, they are not rebuilt), and
13// its own show / hide logic: a card or a tile row with all its lines hidden
14// draws nothing and takes no room. The restyle adds no words of its own.
15// Copyright (C) 2026 JigSawFr. GPLv3-or-later (see LICENSE.GPL).
16#pragma once
17
18#include <string>
19#include <utility>
20#include <vector>
21#include <aurore.hpp>
23
24namespace cadran
25{
28std::string upper(const std::string& text);
29
34class Card : public aurore::Box
35{
36 public:
38 void setAccent(const std::string& key);
39 void setFill(const std::string& key);
43 void draw(NVGcontext* vg, float x, float y, float width, float height,
44 aurore::Style style, aurore::FrameContext* ctx) override;
45
46 private:
47 std::string fill = "cadran/surf", border = "cadran/line";
48};
49
52class Switch : public aurore::View
53{
54 public:
55 explicit Switch(aurore::BooleanCell* cell);
56 void draw(NVGcontext* vg, float x, float y, float width, float height,
57 aurore::Style style, aurore::FrameContext* ctx) override;
58
59 private:
61};
62
65class List
66{
67 public:
71 explicit List(aurore::View* tab, bool sub_screen = false);
75 List(aurore::View* screen, aurore::Box* column);
76
78 aurore::Box* content() const { return this->box; }
79
85 aurore::Box* tiles(const std::vector<std::pair<const char*, const char*>>& cells, bool status);
86
90 void state(const char* id, const char* color_key);
91
97 void tag(const char* id, const std::string& text, bool warn, const std::string& note = "");
98
102 aurore::Box* head(const char* id) const;
103
105 Card* wrap(const char* id);
106
109 void apply(const std::vector<std::pair<const char*, const char*>>& icons);
110
112 Card* card_of(const char* id) const;
113
117 void sync();
118
122 static void section(aurore::Header* header);
123 static void row(aurore::DetailCell* cell, const char* icon = nullptr, bool alone = false);
126 static void row_image(aurore::DetailCell* cell, const std::string& image);
128 static void row_swatch(aurore::DetailCell* cell, const CadranSwatch::Colors& colors);
131 static void recolor_icon(aurore::DetailCell* cell, const char* icon, const char* color_key,
132 const char* square_key = nullptr);
136
137 private:
138 aurore::View* tab;
139 aurore::Box* box = nullptr;
140 std::vector<aurore::Header*> headers;
141 std::vector<aurore::DetailCell*> readings;
142 std::vector<std::pair<aurore::DetailCell*, aurore::Box*>> heads;
143 std::vector<std::pair<aurore::DetailCell*, aurore::View*>> marks;
144 std::vector<std::pair<aurore::DetailCell*, aurore::Box*>> tags;
145};
146} // namespace cadran
Definition cell_bool.hpp:29
Generic FlexBox layout.
Definition box.hpp:74
Definition cell_detail.hpp:28
Definition frame_context.hpp:30
Definition header.hpp:30
Simple wrapper around StyleValues for the array operator.
Definition style.hpp:115
Definition view.hpp:232
Definition cadran_list.hpp:35
void follow_rows()
void setFill(const std::string &key)
void draw(NVGcontext *vg, float x, float y, float width, float height, aurore::Style style, aurore::FrameContext *ctx) override
void setAccent(const std::string &key)
Definition cadran_list.hpp:66
aurore::Box * head(const char *id) const
static void row_image(aurore::DetailCell *cell, const std::string &image)
static void section(aurore::Header *header)
void tag(const char *id, const std::string &text, bool warn, const std::string &note="")
static aurore::Box * rows_in(aurore::Box *list)
void state(const char *id, const char *color_key)
List(aurore::View *screen, aurore::Box *column)
aurore::Box * content() const
The column of lines (nullptr when the tab has none).
Definition cadran_list.hpp:78
static void row(aurore::DetailCell *cell, const char *icon=nullptr, bool alone=false)
void apply(const std::vector< std::pair< const char *, const char * > > &icons)
aurore::Box * tiles(const std::vector< std::pair< const char *, const char * > > &cells, bool status)
Card * card_of(const char *id) const
The card holding this cell (after apply()).
List(aurore::View *tab, bool sub_screen=false)
static void row_swatch(aurore::DetailCell *cell, const CadranSwatch::Colors &colors)
The same with a swatch of colours in its icon's place (CadranSwatch).
Card * wrap(const char *id)
Puts this line (not a cell: a box of text) in a card of its own.
static void recolor_icon(aurore::DetailCell *cell, const char *icon, const char *color_key, const char *square_key=nullptr)
Definition cadran_list.hpp:53
void draw(NVGcontext *vg, float x, float y, float width, float height, aurore::Style style, aurore::FrameContext *ctx) override
Switch(aurore::BooleanCell *cell)
Definition cadran.hpp:31
std::string upper(const std::string &text)
Definition text.hpp:13
Definition cadran_icon.hpp:76