From bbfdafb0060f66e5be90c078575480108f5194f0 Mon Sep 17 00:00:00 2001 From: shweet Date: Sun, 22 Nov 2026 19:08:30 -0500 Subject: [PATCH] Draw localized checkboxes and radio buttons with their tooltips in one call --- src/ui/animation_preview.cpp | 18 ++++------ src/ui/canvas_view.cpp | 3 +- src/ui/configure.cpp | 25 +++++--------- src/ui/generate_animation_from_grid.cpp | 3 +- src/ui/input.cpp | 18 ++++++++++ src/ui/input.h | 3 ++ src/ui/item_properties.cpp | 44 ++++++++----------------- src/ui/items.cpp | 3 +- src/ui/onionskin.cpp | 12 +++---- src/ui/regions.cpp | 8 ++--- src/ui/render_animation.cpp | 12 +++---- src/ui/spritesheet_editor.cpp | 8 ++--- src/ui/spritesheets.cpp | 4 +-- src/ui/timeline.cpp | 23 +++++-------- src/ui/timeline_frames.cpp | 4 +-- 15 files changed, 79 insertions(+), 109 deletions(-) diff --git a/src/ui/animation_preview.cpp b/src/ui/animation_preview.cpp index 9c0f858..6d201d7 100644 --- a/src/ui/animation_preview.cpp +++ b/src/ui/animation_preview.cpp @@ -342,8 +342,7 @@ void AnimationPreview::update(Manager& manager, Settings& settings, Resources& r } ImGui::EndDisabled(); ImGui::SameLine(); - ImGui::Checkbox(localize.get(LABEL_AXES), &isAxes); - tooltip_set(TOOLTIP_AXES); + checkbox_draw(LABEL_AXES, isAxes, TOOLTIP_AXES); ImGui::SameLine(); ImGui::ColorEdit4(localize.get(BASIC_COLOR), values_get(axesColor), ImGuiColorEditFlags_NoInputs); tooltip_set(TOOLTIP_AXES_COLOR); @@ -400,12 +399,9 @@ void AnimationPreview::update(Manager& manager, Settings& settings, Resources& r if (ImGui::BeginChild("##Helpers Child 1", helpersChildSize)) { - ImGui::Checkbox(localize.get(LABEL_ROOT_TRANSFORM), &isRootTransform); - tooltip_set(TOOLTIP_ROOT_TRANSFORM); - ImGui::Checkbox(localize.get(LABEL_PIVOTS), &isPivots); - tooltip_set(TOOLTIP_PIVOTS); - ImGui::Checkbox(localize.get(LABEL_TRANSPARENT), &isTransparent); - tooltip_set(TOOLTIP_PREVIEW_TRANSPARENT); + checkbox_draw(LABEL_ROOT_TRANSFORM, isRootTransform, TOOLTIP_ROOT_TRANSFORM); + checkbox_draw(LABEL_PIVOTS, isPivots, TOOLTIP_PIVOTS); + checkbox_draw(LABEL_TRANSPARENT, isTransparent, TOOLTIP_PREVIEW_TRANSPARENT); } ImGui::EndChild(); @@ -413,10 +409,8 @@ void AnimationPreview::update(Manager& manager, Settings& settings, Resources& r if (ImGui::BeginChild("##Helpers Child 2", helpersChildSize)) { - ImGui::Checkbox(localize.get(LABEL_ALT_ICONS), &isAltIcons); - tooltip_set(TOOLTIP_ALT_ICONS); - ImGui::Checkbox(localize.get(LABEL_BORDER), &isBorder); - tooltip_set(TOOLTIP_BORDER); + checkbox_draw(LABEL_ALT_ICONS, isAltIcons, TOOLTIP_ALT_ICONS); + checkbox_draw(LABEL_BORDER, isBorder, TOOLTIP_BORDER); } ImGui::EndChild(); } diff --git a/src/ui/canvas_view.cpp b/src/ui/canvas_view.cpp index 89fcc81..8c41c11 100644 --- a/src/ui/canvas_view.cpp +++ b/src/ui/canvas_view.cpp @@ -155,8 +155,7 @@ void CanvasView::grid_child_draw(ImVec2 childSize, bool& isGrid, Vec4& gridColor { if (ImGui::BeginChild("##Grid Child", childSize, true, ImGuiWindowFlags_HorizontalScrollbar)) { - ImGui::Checkbox(localize.get(BASIC_GRID), &isGrid); - tooltip_set(TOOLTIP_GRID_VISIBILITY); + checkbox_draw(BASIC_GRID, isGrid, TOOLTIP_GRID_VISIBILITY); if (isGridSnap) { ImGui::SameLine(); diff --git a/src/ui/configure.cpp b/src/ui/configure.cpp index 8f92824..3ff657d 100644 --- a/src/ui/configure.cpp +++ b/src/ui/configure.cpp @@ -28,11 +28,9 @@ void Configure::update(Manager& manager, Settings& settings) input_float_range(localize.get(LABEL_UI_SCALE), temporary.uiScale, UI_SCALE_MIN, UI_SCALE_MAX, UI_SCALE_STEP, UI_SCALE_STEP, "%.0f%%"); tooltip_set(TOOLTIP_UI_SCALE); - ImGui::Checkbox(localize.get(LABEL_VSYNC), &temporary.isVsync); - tooltip_set(TOOLTIP_VSYNC); + checkbox_draw(LABEL_VSYNC, temporary.isVsync, TOOLTIP_VSYNC); ImGui::SameLine(); - ImGui::Checkbox(localize.get(LABEL_DETACHABLE_WINDOWS), &temporary.isDetachableWindows); - tooltip_set(TOOLTIP_DETACHABLE_WINDOWS); + checkbox_draw(LABEL_DETACHABLE_WINDOWS, temporary.isDetachableWindows, TOOLTIP_DETACHABLE_WINDOWS); ImGui::SeparatorText(localize.get(LABEL_PLAYBACK_MENU)); ImGui::RadioButton("30 Hz", &temporary.playbackTickRate, 30); @@ -64,13 +62,11 @@ void Configure::update(Manager& manager, Settings& settings) { ImGui::SeparatorText(localize.get(LABEL_AUTOSAVE)); - ImGui::Checkbox(localize.get(BASIC_ENABLED), &temporary.fileIsAutosave); - tooltip_set(TOOLTIP_AUTOSAVE_ENABLED); + checkbox_draw(BASIC_ENABLED, temporary.fileIsAutosave, TOOLTIP_AUTOSAVE_ENABLED); ImGui::SeparatorText(localize.get(LABEL_AUTO_RESOURCE_RELOAD)); ImGui::PushID(LABEL_AUTO_RESOURCE_RELOAD); - ImGui::Checkbox(localize.get(BASIC_ENABLED), &temporary.fileIsAutoReloadResources); - tooltip_set(TOOLTIP_AUTO_RESOURCE_RELOAD); + checkbox_draw(BASIC_ENABLED, temporary.fileIsAutoReloadResources, TOOLTIP_AUTO_RESOURCE_RELOAD); ImGui::PopID(); ImGui::SeparatorText(localize.get(LABEL_SNAPSHOTS)); @@ -78,15 +74,13 @@ void Configure::update(Manager& manager, Settings& settings) tooltip_set(TOOLTIP_STACK_SIZE); ImGui::SeparatorText(localize.get(LABEL_OPTIONS)); - ImGui::Checkbox(localize.get(LABEL_OVERWRITE_WARNING), &temporary.fileIsWarnOverwrite); - tooltip_set(TOOLTIP_OVERWRITE_WARNING); + checkbox_draw(LABEL_OVERWRITE_WARNING, temporary.fileIsWarnOverwrite, TOOLTIP_OVERWRITE_WARNING); ImGui::SameLine(); - ImGui::Checkbox(localize.get(LABEL_ISAAC_COMPATIBILITY_WARNING), &temporary.fileIsWarnIsaac); - tooltip_set(TOOLTIP_ISAAC_COMPATIBILITY_WARNING); + checkbox_draw(LABEL_ISAAC_COMPATIBILITY_WARNING, temporary.fileIsWarnIsaac, + TOOLTIP_ISAAC_COMPATIBILITY_WARNING); ImGui::SeparatorText(localize.get(LABEL_SERIALIZATION)); - ImGui::Checkbox(localize.get(LABEL_SAVE_AS_JSON), &temporary.fileIsJson); - tooltip_set(TOOLTIP_SAVE_AS_JSON); + checkbox_draw(LABEL_SAVE_AS_JSON, temporary.fileIsJson, TOOLTIP_SAVE_AS_JSON); } ImGui::EndChild(); @@ -109,8 +103,7 @@ void Configure::update(Manager& manager, Settings& settings) ImGui::SeparatorText(localize.get(LABEL_TOOL)); - ImGui::Checkbox(localize.get(LABEL_MOVE_TOOL_SNAP), &temporary.inputIsMoveToolSnapToMouse); - tooltip_set(TOOLTIP_MOVE_TOOL_SNAP); + checkbox_draw(LABEL_MOVE_TOOL_SNAP, temporary.inputIsMoveToolSnapToMouse, TOOLTIP_MOVE_TOOL_SNAP); } ImGui::EndChild(); diff --git a/src/ui/generate_animation_from_grid.cpp b/src/ui/generate_animation_from_grid.cpp index 3303435..3c8637f 100644 --- a/src/ui/generate_animation_from_grid.cpp +++ b/src/ui/generate_animation_from_grid.cpp @@ -51,8 +51,7 @@ void GenerateAnimationFromGrid::update(Manager& manager, Document& document, Res ImGui::InputInt(localize.get(BASIC_DURATION), &delay, STEP, STEP_FAST); ImGui::Separator(); - ImGui::Checkbox(localize.get(LABEL_GENERATE_MAKE_REGIONS), &isMakeRegions); - tooltip_set(TOOLTIP_GENERATE_MAKE_REGIONS); + checkbox_draw(LABEL_GENERATE_MAKE_REGIONS, isMakeRegions, TOOLTIP_GENERATE_MAKE_REGIONS); ImGui::BeginDisabled(!isMakeRegions); input_text_string(localize.get(LABEL_FORMAT), ®ionNameFormat); tooltip_set(TOOLTIP_GENERATE_REGION_NAME_FORMAT); diff --git a/src/ui/input.cpp b/src/ui/input.cpp index 34ef7ca..b40a3c3 100644 --- a/src/ui/input.cpp +++ b/src/ui/input.cpp @@ -1,4 +1,5 @@ #include "ui/input.h" +#include "ui/layout.h" #include #include @@ -167,3 +168,20 @@ bool input_float_range(const char* label, float& value, float min, float max, fl value = vec_clamp(value, min, max); return isActivated; } + +// A localized checkbox or radio button, with its tooltip. +bool checkbox_draw(StringType label, bool& value, StringType tooltip) +{ + auto isChanged = ImGui::Checkbox(localize.get(label), &value); + if (tooltip != STRING_UNDEFINED) + tooltip_set(tooltip); + return isChanged; +} + +bool radio_draw(StringType label, int& value, int buttonValue, StringType tooltip) +{ + auto isChanged = ImGui::RadioButton(localize.get(label), &value, buttonValue); + if (tooltip != STRING_UNDEFINED) + tooltip_set(tooltip); + return isChanged; +} diff --git a/src/ui/input.h b/src/ui/input.h index 60bee9c..224e6cf 100644 --- a/src/ui/input.h +++ b/src/ui/input.h @@ -4,6 +4,7 @@ #include #include +#include "localization.h" #include "vec.h" #include @@ -26,6 +27,8 @@ EditState drag_float_persistent(const char*, float*, float = DRAG_SPEED, float = EditState drag_float2_persistent(const char*, Vec2*, float = DRAG_SPEED, float = {}, float = {}, const char* = "%.3f", ImGuiSliderFlags = 0); EditState color_edit4_persistent(const char*, Vec4*, ImGuiColorEditFlags = 0); +bool checkbox_draw(StringType, bool&, StringType = STRING_UNDEFINED); +bool radio_draw(StringType, int&, int, StringType = STRING_UNDEFINED); bool radio_button_icon(const char*, int*, int, ImTextureID, ImVec2, ImVec4 = ImVec4(1.0f, 1.0f, 1.0f, 1.0f)); bool combo_id_mapped(const std::string&, int*, const std::vector&, const std::vector&); bool combo_string_mapped(const std::string&, std::string*, const std::vector&, diff --git a/src/ui/item_properties.cpp b/src/ui/item_properties.cpp index dc1e893..11b2095 100644 --- a/src/ui/item_properties.cpp +++ b/src/ui/item_properties.cpp @@ -55,42 +55,27 @@ bool ItemProperties::update(Manager& manager, Settings& settings, Document& docu ImGui::SeparatorText(localize.get(LABEL_TYPE)); - spaced_pair( - [&]() { - ImGui::RadioButton(localize.get(LABEL_LAYER), &type, LAYER); - tooltip_set(TOOLTIP_LAYER_TYPE); - }, - [&]() { - ImGui::RadioButton(localize.get(LABEL_NULL), &type, NULL_); - tooltip_set(TOOLTIP_NULL_TYPE); - }); + spaced_pair([&]() { radio_draw(LABEL_LAYER, type, LAYER, TOOLTIP_LAYER_TYPE); }, + [&]() { radio_draw(LABEL_NULL, type, NULL_, TOOLTIP_NULL_TYPE); }); ImGui::SeparatorText(localize.get(LABEL_SOURCE)); auto isUnusedItems = animation && !unused_items_get(type).empty(); - spaced_pair( - [&]() { - ImGui::RadioButton(localize.get(LABEL_NEW), &source, SOURCE_NEW); - tooltip_set(TOOLTIP_NEW_ITEM); - }, - [&]() { - ImGui::BeginDisabled(!isUnusedItems); - ImGui::RadioButton(localize.get(LABEL_EXISTING), &source, SOURCE_EXISTING); - ImGui::EndDisabled(); - ImGui::SetItemTooltip("%s", isUnusedItems ? localize.get(TOOLTIP_USE_EXISTING_ITEM) - : localize.get(TOOLTIP_NO_UNUSED_ITEMS)); - }); + spaced_pair([&]() { radio_draw(LABEL_NEW, source, SOURCE_NEW, TOOLTIP_NEW_ITEM); }, + [&]() { + ImGui::BeginDisabled(!isUnusedItems); + ImGui::RadioButton(localize.get(LABEL_EXISTING), &source, SOURCE_EXISTING); + ImGui::EndDisabled(); + ImGui::SetItemTooltip("%s", isUnusedItems ? localize.get(TOOLTIP_USE_EXISTING_ITEM) + : localize.get(TOOLTIP_NO_UNUSED_ITEMS)); + }); ImGui::SeparatorText(localize.get(LABEL_DESTINATION)); spaced_pair( + [&]() { radio_draw(LABEL_ALL_ANIMATIONS, destination, DESTINATION_ALL, TOOLTIP_ITEM_ALL_ANIMATIONS); }, [&]() { - ImGui::RadioButton(localize.get(LABEL_ALL_ANIMATIONS), &destination, DESTINATION_ALL); - tooltip_set(TOOLTIP_ITEM_ALL_ANIMATIONS); - }, - [&]() { - ImGui::RadioButton(localize.get(LABEL_THIS_ANIMATION), &destination, DESTINATION_THIS); - tooltip_set(TOOLTIP_ITEM_THIS_ANIMATION); + radio_draw(LABEL_THIS_ANIMATION, destination, DESTINATION_THIS, TOOLTIP_ITEM_THIS_ANIMATION); }); if (source == SOURCE_NEW) @@ -102,10 +87,7 @@ bool ItemProperties::update(Manager& manager, Settings& settings, Document& docu if (type == LAYER) layer_source_draw(document, edit); else if (type == NULL_) - { - ImGui::Checkbox(localize.get(LABEL_RECT), &edit.isShowRect); - tooltip_set(TOOLTIP_NULL_RECT); - } + checkbox_draw(LABEL_RECT, edit.isShowRect, TOOLTIP_NULL_RECT); } else if (animation) { diff --git a/src/ui/items.cpp b/src/ui/items.cpp index 74e9a2d..5f97d61 100644 --- a/src/ui/items.cpp +++ b/src/ui/items.cpp @@ -234,8 +234,7 @@ void nulls_update(Panel& panel) item_properties_update(panel, 1, NULL_PROPERTIES_ROWS, SelectionKind::NULLS, TOOLTIP_NULL_NAME, EDIT_ADD_NULL, EDIT_SET_NULL_PROPERTIES, nulls_get, [](Manager::ItemEdit& null) { - ImGui::Checkbox(localize.get(LABEL_RECT), &null.isShowRect); - tooltip_set(TOOLTIP_NULL_RECT); + checkbox_draw(LABEL_RECT, null.isShowRect, TOOLTIP_NULL_RECT); }); } diff --git a/src/ui/onionskin.cpp b/src/ui/onionskin.cpp index 6826044..29b4320 100644 --- a/src/ui/onionskin.cpp +++ b/src/ui/onionskin.cpp @@ -36,18 +36,14 @@ void onionskin_update(Manager& manager, Settings& settings) configure_widgets(localize.get(BASIC_BEFORE), beforeCount, beforeColor); configure_widgets(localize.get(BASIC_AFTER), afterCount, afterColor); ImGui::SeparatorText(localize.get(BASIC_MODE)); - ImGui::RadioButton(localize.get(BASIC_TIME), &mode, (int)OnionskinMode::TIME); - tooltip_set(TOOLTIP_ONIONSKIN_TIME); + radio_draw(BASIC_TIME, mode, (int)OnionskinMode::TIME, TOOLTIP_ONIONSKIN_TIME); ImGui::SameLine(); - ImGui::RadioButton(localize.get(BASIC_INDEX), &mode, (int)OnionskinMode::INDEX); - tooltip_set(TOOLTIP_ONIONSKIN_INDEX); + radio_draw(BASIC_INDEX, mode, (int)OnionskinMode::INDEX, TOOLTIP_ONIONSKIN_INDEX); ImGui::SeparatorText(localize.get(LABEL_OPTIONS)); - ImGui::Checkbox(localize.get(LABEL_PIVOT_PATH), &settings.onionskinIsPivotPath); - tooltip_set(TOOLTIP_PIVOT_PATH); + checkbox_draw(LABEL_PIVOT_PATH, settings.onionskinIsPivotPath, TOOLTIP_PIVOT_PATH); ImGui::SameLine(); - ImGui::Checkbox(localize.get(LABEL_ONLY_SELECTED_ITEM), &settings.onionskinIsOnlySelected); - tooltip_set(TOOLTIP_ONLY_SELECTED_ITEM); + checkbox_draw(LABEL_ONLY_SELECTED_ITEM, settings.onionskinIsOnlySelected, TOOLTIP_ONLY_SELECTED_ITEM); } ImGui::End(); diff --git a/src/ui/regions.cpp b/src/ui/regions.cpp index 1d87f99..a266da1 100644 --- a/src/ui/regions.cpp +++ b/src/ui/regions.cpp @@ -357,10 +357,10 @@ static void region_export_popup_update(Panel& panel, RegionsPanel& regions) ImGui::SameLine(); input_text_path(localize.get(LABEL_OUTPUT_PATH), &settings.exportRegionPath); tooltip_set(TOOLTIP_OUTPUT_PATH); - ImGui::Checkbox(localize.get(LABEL_EXPORT_MAKE_SPRITESHEET), &settings.isExportRegionMakeSpritesheet); - tooltip_set(TOOLTIP_EXPORT_MAKE_SPRITESHEET); - ImGui::Checkbox(localize.get(LABEL_EXPORT_REMOVE_CURRENT_REGION), &settings.isExportRegionRemoveCurrent); - tooltip_set(TOOLTIP_EXPORT_REMOVE_CURRENT_REGION); + checkbox_draw(LABEL_EXPORT_MAKE_SPRITESHEET, settings.isExportRegionMakeSpritesheet, + TOOLTIP_EXPORT_MAKE_SPRITESHEET); + checkbox_draw(LABEL_EXPORT_REMOVE_CURRENT_REGION, settings.isExportRegionRemoveCurrent, + TOOLTIP_EXPORT_REMOVE_CURRENT_REGION); } ImGui::EndChild(); diff --git a/src/ui/render_animation.cpp b/src/ui/render_animation.cpp index 6a11a06..71749d5 100644 --- a/src/ui/render_animation.cpp +++ b/src/ui/render_animation.cpp @@ -160,8 +160,7 @@ void RenderAnimation::update(Manager& manager, Document& document, Resources& re ImGui::Separator(); - ImGui::Checkbox(localize.get(LABEL_CUSTOM_RANGE), &isRange); - tooltip_set(TOOLTIP_CUSTOM_RANGE); + checkbox_draw(LABEL_CUSTOM_RANGE, isRange, TOOLTIP_CUSTOM_RANGE); ImGui::SameLine(); @@ -197,13 +196,11 @@ void RenderAnimation::update(Manager& manager, Document& document, Resources& re ImGui::Separator(); - ImGui::Checkbox(localize.get(LABEL_USE_ANIMATION_BOUNDS), &isUseAnimationBounds); - tooltip_set(TOOLTIP_USE_ANIMATION_BOUNDS); + checkbox_draw(LABEL_USE_ANIMATION_BOUNDS, isUseAnimationBounds, TOOLTIP_USE_ANIMATION_BOUNDS); ImGui::SameLine(); - ImGui::Checkbox(localize.get(LABEL_USE_ISOLATED_ANIMATION), &isUseIsolatedAnimation); - tooltip_set(TOOLTIP_USE_ISOLATED_ANIMATION); + checkbox_draw(LABEL_USE_ISOLATED_ANIMATION, isUseIsolatedAnimation, TOOLTIP_USE_ISOLATED_ANIMATION); ImGui::BeginDisabled(!isUseAnimationBounds); { @@ -230,8 +227,7 @@ void RenderAnimation::update(Manager& manager, Document& document, Resources& re ImGui::Separator(); - ImGui::Checkbox(localize.get(LABEL_SOUND), &settings.timelineIsSound); - tooltip_set(TOOLTIP_SOUND); + checkbox_draw(LABEL_SOUND, settings.timelineIsSound, TOOLTIP_SOUND); ImGui::Separator(); diff --git a/src/ui/spritesheet_editor.cpp b/src/ui/spritesheet_editor.cpp index 32dd02e..a9b1056 100644 --- a/src/ui/spritesheet_editor.cpp +++ b/src/ui/spritesheet_editor.cpp @@ -102,18 +102,14 @@ void SpritesheetEditor::update(Manager& manager, Settings& settings, Resources& } ImGui::EndDisabled(); - ImGui::Checkbox(localize.get(LABEL_BORDER), &isBorder); - tooltip_set(TOOLTIP_SPRITESHEET_BORDER); + checkbox_draw(LABEL_BORDER, isBorder, TOOLTIP_SPRITESHEET_BORDER); } ImGui::EndChild(); ImGui::SameLine(); if (ImGui::BeginChild("##Background Child 2", subChildSize)) - { - ImGui::Checkbox(localize.get(LABEL_TRANSPARENT), &isTransparent); - tooltip_set(TOOLTIP_TRANSPARENT); - } + checkbox_draw(LABEL_TRANSPARENT, isTransparent, TOOLTIP_TRANSPARENT); ImGui::EndChild(); } diff --git a/src/ui/spritesheets.cpp b/src/ui/spritesheets.cpp index f403767..88094c0 100644 --- a/src/ui/spritesheets.cpp +++ b/src/ui/spritesheets.cpp @@ -134,8 +134,8 @@ static void spritesheets_merge_popup_update(Panel& panel, SpritesheetsPanel& spr tooltip_set(TOOLTIP_MERGE_SPRITESHEETS_TOP_RIGHT); ImGui::SeparatorText(localize.get(LABEL_OPTIONS)); - ImGui::Checkbox(localize.get(LABEL_MERGE_MAKE_SPRITESHEET_REGIONS), &settings.mergeSpritesheetsIsMakeRegions); - tooltip_set(TOOLTIP_MERGE_MAKE_SPRITESHEET_REGIONS); + checkbox_draw(LABEL_MERGE_MAKE_SPRITESHEET_REGIONS, settings.mergeSpritesheetsIsMakeRegions, + TOOLTIP_MERGE_MAKE_SPRITESHEET_REGIONS); ImGui::BeginDisabled(!settings.mergeSpritesheetsIsMakeRegions); ImGui::Checkbox(localize.get(LABEL_MERGE_MAKE_PRIMARY_SPRITESHEET_REGION), diff --git a/src/ui/timeline.cpp b/src/ui/timeline.cpp index 0d5ea4f..fa708ff 100644 --- a/src/ui/timeline.cpp +++ b/src/ui/timeline.cpp @@ -1,4 +1,5 @@ #include "ui/timeline_context.h" +#include "ui/input.h" #include "ui/layout.h" Timeline::Timeline() = default; @@ -95,11 +96,9 @@ void TimelineContext::popups_update() frame ? frame->duration : FRAME_DURATION_MIN); tooltip_set(TOOLTIP_INTERVAL); - ImGui::Checkbox(localize.get(LABEL_ROUND_ROTATION), &isRoundRotation); - tooltip_set(TOOLTIP_ROUND_ROTATION); + checkbox_draw(LABEL_ROUND_ROTATION, isRoundRotation, TOOLTIP_ROUND_ROTATION); - ImGui::Checkbox(localize.get(LABEL_ROUND_SCALE), &isRoundScale); - tooltip_set(TOOLTIP_ROUND_SCALE); + checkbox_draw(LABEL_ROUND_SCALE, isRoundScale, TOOLTIP_ROUND_SCALE); auto result = popup_buttons_draw(manager, {.confirm = LABEL_BAKE, .confirmTooltip = TOOLTIP_BAKE_FRAMES_OPTIONS, @@ -123,8 +122,7 @@ void TimelineContext::popups_update() (int)BakeIntoOtherFramesTarget::CURRENT_SELECTION); tooltip_set(TOOLTIP_BAKE_INTO_OTHER_FRAMES_CURRENT_SELECTION); ImGui::SameLine(); - ImGui::RadioButton(localize.get(LABEL_ALL), &target, (int)BakeIntoOtherFramesTarget::ALL); - tooltip_set(TOOLTIP_BAKE_INTO_OTHER_FRAMES_ALL); + radio_draw(LABEL_ALL, target, (int)BakeIntoOtherFramesTarget::ALL, TOOLTIP_BAKE_INTO_OTHER_FRAMES_ALL); bakeIntoOtherFramesTarget = (BakeIntoOtherFramesTarget)target; auto isCurrentSelection = bakeIntoOtherFramesTarget == BakeIntoOtherFramesTarget::CURRENT_SELECTION; @@ -134,17 +132,14 @@ void TimelineContext::popups_update() ImGui::Checkbox(localize.get(LABEL_NULLS), &isBakeIntoOtherFramesNulls); ImGui::EndDisabled(); - ImGui::Checkbox(localize.get(LABEL_ROUND_ROTATION), &isRoundRotation); - tooltip_set(TOOLTIP_ROUND_ROTATION); + checkbox_draw(LABEL_ROUND_ROTATION, isRoundRotation, TOOLTIP_ROUND_ROTATION); - ImGui::Checkbox(localize.get(LABEL_ROUND_SCALE), &isRoundScale); - tooltip_set(TOOLTIP_ROUND_SCALE); + checkbox_draw(LABEL_ROUND_SCALE, isRoundScale, TOOLTIP_ROUND_SCALE); - ImGui::Checkbox(localize.get(LABEL_BAKE_MATCH_ROOT_INTERPOLATION), &isMatchRootInterpolation); - tooltip_set(TOOLTIP_BAKE_MATCH_ROOT_INTERPOLATION); + checkbox_draw(LABEL_BAKE_MATCH_ROOT_INTERPOLATION, isMatchRootInterpolation, + TOOLTIP_BAKE_MATCH_ROOT_INTERPOLATION); - ImGui::Checkbox(localize.get(LABEL_BAKE_USE_ROOT_PIVOT), &isUseRootPivot); - tooltip_set(TOOLTIP_BAKE_USE_ROOT_PIVOT); + checkbox_draw(LABEL_BAKE_USE_ROOT_PIVOT, isUseRootPivot, TOOLTIP_BAKE_USE_ROOT_PIVOT); auto result = popup_buttons_draw(manager, {.confirm = LABEL_BAKE, .cancelTooltip = TOOLTIP_CANCEL_BAKE_FRAMES, diff --git a/src/ui/timeline_frames.cpp b/src/ui/timeline_frames.cpp index 0ba24b1..a45c55e 100644 --- a/src/ui/timeline_frames.cpp +++ b/src/ui/timeline_frames.cpp @@ -1,4 +1,5 @@ #include "ui/timeline_context.h" +#include "ui/input.h" #include "ui/layout.h" // Moves the dragged frames to `target`'s track, before its frame index. @@ -941,8 +942,7 @@ void TimelineContext::frames_child() ImGui::SameLine(); ImGui::SetNextItemWidth(widgetSize.x); - ImGui::Checkbox(localize.get(LABEL_SOUND), &settings.timelineIsSound); - tooltip_set(TOOLTIP_SOUND); + checkbox_draw(LABEL_SOUND, settings.timelineIsSound, TOOLTIP_SOUND); ImGui::PopStyleVar(); }