Describe timeline item types in one style table

This commit is contained in:
shweet committed 2026-11-22 18:53:11 -05:00
1 parent a5ffa916d8
commit f9dcfb8d79
5 files changed
+31 -63

No files matched your search

+19 -49
View File
@@ -15,58 +15,28 @@
#include "localization.h" #include "localization.h"
#include "ui/popup.h" #include "ui/popup.h"
inline const Vec4 ROOT_COLOR = Vec4(0.140f, 0.310f, 0.560f, 1.000f); constexpr Vec4 ROOT_COLOR = Vec4(0.140f, 0.310f, 0.560f, 1.000f);
inline const Vec4 ROOT_COLOR_ACTIVE = Vec4(0.240f, 0.520f, 0.880f, 1.000f);
inline const Vec4 ROOT_COLOR_HOVERED = Vec4(0.320f, 0.640f, 1.000f, 1.000f);
inline const Vec4 LAYER_COLOR = Vec4(0.640f, 0.320f, 0.110f, 1.000f); // How each item type shows in the timeline: its name, icon, and color (normal, active and hovered).
inline const Vec4 LAYER_COLOR_ACTIVE = Vec4(0.840f, 0.450f, 0.170f, 1.000f); struct ItemTypeStyle
inline const Vec4 LAYER_COLOR_HOVERED = Vec4(0.960f, 0.560f, 0.240f, 1.000f); {
StringType label;
inline const Vec4 NULL_COLOR = Vec4(0.140f, 0.430f, 0.200f, 1.000f); Icon icon;
inline const Vec4 NULL_COLOR_ACTIVE = Vec4(0.250f, 0.650f, 0.350f, 1.000f); Vec4 colors[3];
inline const Vec4 NULL_COLOR_HOVERED = Vec4(0.350f, 0.800f, 0.480f, 1.000f);
inline const Vec4 TRIGGER_COLOR = Vec4(0.620f, 0.150f, 0.260f, 1.000f);
inline const Vec4 TRIGGER_COLOR_ACTIVE = Vec4(0.820f, 0.250f, 0.380f, 1.000f);
inline const Vec4 TRIGGER_COLOR_HOVERED = Vec4(0.950f, 0.330f, 0.490f, 1.000f);
#define ANM2_ITEM_TYPES \
X(NONE, STRING_UNDEFINED, ICON_NONE, Vec4(), Vec4(), Vec4()) \
X(ROOT, BASIC_ROOT, ICON_ROOT, ROOT_COLOR, ROOT_COLOR_ACTIVE, ROOT_COLOR_HOVERED) \
X(LAYER, BASIC_LAYER_ANIMATION, ICON_LAYER, LAYER_COLOR, LAYER_COLOR_ACTIVE, LAYER_COLOR_HOVERED) \
X(NULL_, BASIC_NULL_ANIMATION, ICON_NULL, NULL_COLOR, NULL_COLOR_ACTIVE, NULL_COLOR_HOVERED) \
X(TRIGGER, BASIC_TRIGGERS, ICON_TRIGGERS, TRIGGER_COLOR, TRIGGER_COLOR_ACTIVE, TRIGGER_COLOR_HOVERED)
constexpr StringType TYPE_STRINGS[] = {
#define X(symbol, string, icon, color, colorActive, colorHovered) string,
ANM2_ITEM_TYPES
#undef X
}; };
constexpr Icon TYPE_ICONS[] = { constexpr ItemTypeStyle ITEM_TYPE_STYLES[] = {
#define X(symbol, string, icon, color, colorActive, colorHovered) icon, {STRING_UNDEFINED, ICON_NONE, {}},
ANM2_ITEM_TYPES {BASIC_ROOT, ICON_ROOT, {ROOT_COLOR, {0.240f, 0.520f, 0.880f, 1.000f}, {0.320f, 0.640f, 1.000f, 1.000f}}},
#undef X {BASIC_LAYER_ANIMATION,
}; ICON_LAYER,
{{0.640f, 0.320f, 0.110f, 1.000f}, {0.840f, 0.450f, 0.170f, 1.000f}, {0.960f, 0.560f, 0.240f, 1.000f}}},
inline const Vec4 TYPE_COLOR[] = { {BASIC_NULL_ANIMATION,
#define X(symbol, string, icon, color, colorActive, colorHovered) color, ICON_NULL,
ANM2_ITEM_TYPES {{0.140f, 0.430f, 0.200f, 1.000f}, {0.250f, 0.650f, 0.350f, 1.000f}, {0.350f, 0.800f, 0.480f, 1.000f}}},
#undef X {BASIC_TRIGGERS,
}; ICON_TRIGGERS,
{{0.620f, 0.150f, 0.260f, 1.000f}, {0.820f, 0.250f, 0.380f, 1.000f}, {0.950f, 0.330f, 0.490f, 1.000f}}}};
inline const Vec4 TYPE_COLOR_ACTIVE[] = {
#define X(symbol, string, icon, color, colorActive, colorHovered) colorActive,
ANM2_ITEM_TYPES
#undef X
};
inline const Vec4 TYPE_COLOR_HOVERED[] = {
#define X(symbol, string, icon, color, colorActive, colorHovered) colorHovered,
ANM2_ITEM_TYPES
#undef X
};
struct TimelineContext; struct TimelineContext;
+2 -2
View File
@@ -42,7 +42,7 @@ void TimelineContext::child_step_in(const TimelineRow& row)
void TimelineContext::peek_item_child(const TimelineRow& row, const PeekRow& peek, int index) void TimelineContext::peek_item_child(const TimelineRow& row, const PeekRow& peek, int index)
{ {
auto type = (int)peek.track->type; auto type = (int)peek.track->type;
auto label = std::string(localize.get(TYPE_STRINGS[type])); auto label = std::string(localize.get(ITEM_TYPE_STYLES[type].label));
if (type == LAYER) if (type == LAYER)
if (auto layer = ::item_get(peek.source->content.layers, peek.track->id)) if (auto layer = ::item_get(peek.source->content.layers, peek.track->id))
label = layer_label_get(*layer); label = layer_label_get(*layer);
@@ -59,7 +59,7 @@ void TimelineContext::peek_item_child(const TimelineRow& row, const PeekRow& pee
{ {
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + (float)(row.depth + 1) * ImGui::GetTextLineHeightWithSpacing()); ImGui::SetCursorPosX(ImGui::GetCursorPosX() + (float)(row.depth + 1) * ImGui::GetTextLineHeightWithSpacing());
ImGui::BeginDisabled(); ImGui::BeginDisabled();
ImGui::Image(resources.icon_id_get(TYPE_ICONS[type]), icon_size_get()); ImGui::Image(resources.icon_id_get(ITEM_TYPE_STYLES[type].icon), icon_size_get());
ImGui::SameLine(); ImGui::SameLine();
ImGui::TextUnformatted(label.c_str()); ImGui::TextUnformatted(label.c_str());
ImGui::EndDisabled(); ImGui::EndDisabled();
+5 -7
View File
@@ -105,18 +105,16 @@ enum TimelineColor
COLOR_ITEM_SELECTED COLOR_ITEM_SELECTED
}; };
// A timeline color's light theme colors by item type, and which of an item type's colors it is in the dark theme.
struct TimelineColorSet struct TimelineColorSet
{ {
const Vec4* light; const Vec4* light;
const Vec4* dark; int dark;
}; };
inline const TimelineColorSet TIMELINE_COLORS[] = {{FRAME_COLOR_LIGHT_BASE, TYPE_COLOR}, constexpr TimelineColorSet TIMELINE_COLORS[] = {{FRAME_COLOR_LIGHT_BASE, 0}, {FRAME_COLOR_LIGHT_ACTIVE, 1},
{FRAME_COLOR_LIGHT_ACTIVE, TYPE_COLOR_ACTIVE}, {FRAME_COLOR_LIGHT_HOVERED, 2}, {ITEM_COLOR_LIGHT_BASE, 0},
{FRAME_COLOR_LIGHT_HOVERED, TYPE_COLOR_HOVERED}, {ITEM_COLOR_LIGHT_ACTIVE, 1}, {ITEM_COLOR_LIGHT_SELECTED, 1}};
{ITEM_COLOR_LIGHT_BASE, TYPE_COLOR},
{ITEM_COLOR_LIGHT_ACTIVE, TYPE_COLOR_ACTIVE},
{ITEM_COLOR_LIGHT_SELECTED, TYPE_COLOR_ACTIVE}};
inline bool is_trigger_reference(const Reference& reference) inline bool is_trigger_reference(const Reference& reference)
{ {
+1 -1
View File
@@ -36,7 +36,7 @@ const Track* TimelineContext::selected_item_get()
Vec4 TimelineContext::color_get(TimelineColor color, int type) Vec4 TimelineContext::color_get(TimelineColor color, int type)
{ {
auto& colors = TIMELINE_COLORS[color]; auto& colors = TIMELINE_COLORS[color];
return isLightTheme ? colors.light[std::clamp(type, 0, TRIGGER)] : colors.dark[type]; return isLightTheme ? colors.light[std::clamp(type, 0, TRIGGER)] : ITEM_TYPE_STYLES[type].colors[colors.dark];
} }
std::set<Reference> TimelineContext::drag_frame_references_get(const Reference& frameReference) std::set<Reference> TimelineContext::drag_frame_references_get(const Reference& frameReference)
+4 -4
View File
@@ -164,19 +164,19 @@ void TimelineContext::item_child(const TimelineRow& row, int index)
{ {
auto layer = ::item_get(model.content.layers, id); auto layer = ::item_get(model.content.layers, id);
if (!layer) if (!layer)
return localize.get(TYPE_STRINGS[type]); return localize.get(ITEM_TYPE_STYLES[type].label);
return layer_label_get(*layer); return layer_label_get(*layer);
} }
if (type == NULL_) if (type == NULL_)
{ {
auto null = ::item_get(model.content.nulls, id); auto null = ::item_get(model.content.nulls, id);
if (!null) if (!null)
return localize.get(TYPE_STRINGS[type]); return localize.get(ITEM_TYPE_STYLES[type].label);
return localize_format(FORMAT_NULL, id, null->name); return localize_format(FORMAT_NULL, id, null->name);
} }
return localize.get(TYPE_STRINGS[type]); return localize.get(ITEM_TYPE_STYLES[type].label);
}(); }();
auto icon = TYPE_ICONS[type]; auto icon = ITEM_TYPE_STYLES[type].icon;
auto iconTintCurrent = isLightTheme && type == NONE ? ImVec4(1.0f, 1.0f, 1.0f, 1.0f) : itemIconTint; auto iconTintCurrent = isLightTheme && type == NONE ? ImVec4(1.0f, 1.0f, 1.0f, 1.0f) : itemIconTint;
auto colorVec = color_get(isItemSelected && type != NONE ? COLOR_ITEM_SELECTED : COLOR_ITEM_BASE, type); auto colorVec = color_get(isItemSelected && type != NONE ? COLOR_ITEM_SELECTED : COLOR_ITEM_BASE, type);
auto color = to_imvec4(colorVec); auto color = to_imvec4(colorVec);