diff --git a/src/ui/timeline.h b/src/ui/timeline.h index 278fa3c..9af5e00 100644 --- a/src/ui/timeline.h +++ b/src/ui/timeline.h @@ -15,58 +15,28 @@ #include "localization.h" #include "ui/popup.h" -inline const 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); +constexpr Vec4 ROOT_COLOR = Vec4(0.140f, 0.310f, 0.560f, 1.000f); -inline const Vec4 LAYER_COLOR = Vec4(0.640f, 0.320f, 0.110f, 1.000f); -inline const Vec4 LAYER_COLOR_ACTIVE = Vec4(0.840f, 0.450f, 0.170f, 1.000f); -inline const Vec4 LAYER_COLOR_HOVERED = Vec4(0.960f, 0.560f, 0.240f, 1.000f); - -inline const Vec4 NULL_COLOR = Vec4(0.140f, 0.430f, 0.200f, 1.000f); -inline const Vec4 NULL_COLOR_ACTIVE = Vec4(0.250f, 0.650f, 0.350f, 1.000f); -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 +// How each item type shows in the timeline: its name, icon, and color (normal, active and hovered). +struct ItemTypeStyle +{ + StringType label; + Icon icon; + Vec4 colors[3]; }; -constexpr Icon TYPE_ICONS[] = { -#define X(symbol, string, icon, color, colorActive, colorHovered) icon, - ANM2_ITEM_TYPES -#undef X -}; - -inline const Vec4 TYPE_COLOR[] = { -#define X(symbol, string, icon, color, colorActive, colorHovered) color, - ANM2_ITEM_TYPES -#undef X -}; - -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 -}; +constexpr ItemTypeStyle ITEM_TYPE_STYLES[] = { + {STRING_UNDEFINED, ICON_NONE, {}}, + {BASIC_ROOT, ICON_ROOT, {ROOT_COLOR, {0.240f, 0.520f, 0.880f, 1.000f}, {0.320f, 0.640f, 1.000f, 1.000f}}}, + {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}}}, + {BASIC_NULL_ANIMATION, + ICON_NULL, + {{0.140f, 0.430f, 0.200f, 1.000f}, {0.250f, 0.650f, 0.350f, 1.000f}, {0.350f, 0.800f, 0.480f, 1.000f}}}, + {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}}}}; struct TimelineContext; diff --git a/src/ui/timeline_children.cpp b/src/ui/timeline_children.cpp index 188f15d..6fa9b97 100644 --- a/src/ui/timeline_children.cpp +++ b/src/ui/timeline_children.cpp @@ -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) { 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 (auto layer = ::item_get(peek.source->content.layers, peek.track->id)) 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::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::TextUnformatted(label.c_str()); ImGui::EndDisabled(); diff --git a/src/ui/timeline_context.h b/src/ui/timeline_context.h index b2da481..8ce4612 100644 --- a/src/ui/timeline_context.h +++ b/src/ui/timeline_context.h @@ -105,18 +105,16 @@ enum TimelineColor 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 { const Vec4* light; - const Vec4* dark; + int dark; }; -inline const TimelineColorSet TIMELINE_COLORS[] = {{FRAME_COLOR_LIGHT_BASE, TYPE_COLOR}, - {FRAME_COLOR_LIGHT_ACTIVE, TYPE_COLOR_ACTIVE}, - {FRAME_COLOR_LIGHT_HOVERED, TYPE_COLOR_HOVERED}, - {ITEM_COLOR_LIGHT_BASE, TYPE_COLOR}, - {ITEM_COLOR_LIGHT_ACTIVE, TYPE_COLOR_ACTIVE}, - {ITEM_COLOR_LIGHT_SELECTED, TYPE_COLOR_ACTIVE}}; +constexpr TimelineColorSet TIMELINE_COLORS[] = {{FRAME_COLOR_LIGHT_BASE, 0}, {FRAME_COLOR_LIGHT_ACTIVE, 1}, + {FRAME_COLOR_LIGHT_HOVERED, 2}, {ITEM_COLOR_LIGHT_BASE, 0}, + {ITEM_COLOR_LIGHT_ACTIVE, 1}, {ITEM_COLOR_LIGHT_SELECTED, 1}}; inline bool is_trigger_reference(const Reference& reference) { diff --git a/src/ui/timeline_selection.cpp b/src/ui/timeline_selection.cpp index 7746c87..c42a672 100644 --- a/src/ui/timeline_selection.cpp +++ b/src/ui/timeline_selection.cpp @@ -36,7 +36,7 @@ const Track* TimelineContext::selected_item_get() Vec4 TimelineContext::color_get(TimelineColor color, int type) { 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 TimelineContext::drag_frame_references_get(const Reference& frameReference) diff --git a/src/ui/timeline_tracks.cpp b/src/ui/timeline_tracks.cpp index 9cabcec..fdd8db5 100644 --- a/src/ui/timeline_tracks.cpp +++ b/src/ui/timeline_tracks.cpp @@ -164,19 +164,19 @@ void TimelineContext::item_child(const TimelineRow& row, int index) { auto layer = ::item_get(model.content.layers, id); if (!layer) - return localize.get(TYPE_STRINGS[type]); + return localize.get(ITEM_TYPE_STYLES[type].label); return layer_label_get(*layer); } if (type == NULL_) { auto null = ::item_get(model.content.nulls, id); 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.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 colorVec = color_get(isItemSelected && type != NONE ? COLOR_ITEM_SELECTED : COLOR_ITEM_BASE, type); auto color = to_imvec4(colorVec);