CodexPlacement.h header

#include <ew/app/CodexPlacement.h>

Namespace ew::app

CodexOrderEntry struct

struct ew::app::CodexOrderEntry

One node's place among its siblings, as a hand-arranged codex list reports itself.

Exactly one of entity and category is set, because the codex tree holds both kinds in one list and a writer arranging it moves whichever they grabbed.

Members

ew::core::foundation::ContentId ew::app::entity::CodexOrderEntry::entity

The entity being placed, or null when category is set.

ew::core::foundation::CategoryId ew::app::entity::CodexOrderEntry::category

The category being placed, or null when entity is set.

int ew::app::entity::CodexOrderEntry::sortIndex = 0

Its place among its siblings, counting from 1. Zero means "not placed", which is what returns it to the default alphabetical order.

CodexParent struct

struct ew::app::CodexParent

Where something in the codex tree is being put: under a category, or under an entity.

The codex tree ALTERNATES kinds – Kingdoms(category) > Vaertis(entity) > Cities(category) – so "the parent" is one of two things, and every caller that moves a node has to say which. A struct rather than two overloads because a drop lands on whichever the writer aimed at, and the answer is only known at runtime.

Members

ew::core::foundation::CategoryId ew::app::entity::CodexParent::category

The category to hang from; null when entity is set or nothing was aimed at.

ew::core::foundation::ContentId ew::app::entity::CodexParent::entity

The entity to hang from; null when category is set or nothing was aimed at.

bool ew::app::entity::CodexParent::isNull() const

Whether this names nothing – the invisible root, where a top-level category lives.

Enumerations

enum class CategoryMoveRefusal { None, NoSuchCategory, NoSuchEntity, WouldLoop }

Why a category move was refused.

A REASON rather than a bool, because a drag that silently springs back teaches the writer nothing – and a reason rather than a sentence, because the sentence is the client's to write: this library has no UI and no translation catalogue of its own.

Functions

std::vector< CodexOrderEntry > ew::app::entity::alphabeticalOrder(const ew::core::project::Project &project, ew::core::foundation::CategoryId categoryId)

The order that returns every direct child of categoryId to the default alphabetical one: an index of 0 for each. A null categoryId means the top level.

std::unique_ptr< ew::core::undo::Command > ew::app::entity::buildMoveCategoryCommand(ew::core::project::Project &project, ew::core::foundation::CategoryId categoryId, const CodexParent &parent)

A command re-parenting categoryId under parent, or null when categoryMoveRefusal refuses it (or the move would change nothing).

std::unique_ptr< ew::core::undo::Command > ew::app::entity::buildMoveEntityCommand(ew::core::project::Project &project, ew::core::foundation::ContentId entityId, ew::core::foundation::CategoryId categoryId)

A command filing entityId under categoryId, or null when the entity is already there or does not exist. A null categoryId leaves it uncategorised, which the tree shows at the top.

std::unique_ptr< ew::core::undo::Command > ew::app::entity::buildSetCodexOrderCommand(ew::core::project::Project &project, const std::vector< CodexOrderEntry > &order)

A command giving order to the codex, as ONE undoable step, or null when every node already sits where order puts it.

The codex is ordered by name by default. Applying an order is what turns a container into a hand-arranged one, and clearing it (every index 0) is what gives it back to the alphabet – so this one command serves both the drag and the "Sort A-Z" that undoes a lifetime of dragging.

CategoryMoveRefusal ew::app::entity::categoryMoveRefusal(const ew::core::project::Project &project, ew::core::foundation::CategoryId categoryId, const CodexParent &parent)

Why moving categoryId under parent would be refused, or CategoryMoveRefusal::None.

std::vector< ew::core::foundation::ContentId > ew::app::entity::entitiesUnder(const ew::core::project::Project &project, ew::core::foundation::CategoryId categoryId, ew::core::foundation::CategoryId excludeBeneath)

The entities filed in categoryId or in any category beneath it, in id order.

The answer to "which entities does this category reach", which is what every picker in the codex wants and none of them had: they listed every entity in the project, so a Cities category being nested under one of the Kingdoms, or a property being handed to one of the Peoples, was chosen from a list holding every age, item and map as well. That is not a choice, it is a haystack.

excludeBeneath, when set, leaves out any entity that already sits beneath THAT category – the ones a category being nested cannot hang from without making a loop. Null offers them all.

CodexParent ew::app::entity::newSubcategoryParent(ew::core::foundation::ContentId selectedEntity, ew::core::foundation::CategoryId selectedCategory)

The parent a NEW sub-category should hang from, given what the codex tree has selected.

The entity wins when there is one. "New Subcategory" invoked on a character means a category belonging to that character – Vaertis's own Cities – and answering with the entity's category instead files it as a sibling of the entity, which is a different thing entirely and reads as the command having ignored what was clicked.