0.2.0
Loading...
Searching...
No Matches
EnumComboWithAbbreviation.hpp
Go to the documentation of this file.
1
// This file is part of INSTINCT, the INS Toolkit for Integrated
2
// Navigation Concepts and Training by the Institute of Navigation of
3
// the University of Stuttgart, Germany.
4
//
5
// This Source Code Form is subject to the terms of the Mozilla Public
6
// License, v. 2.0. If a copy of the MPL was not distributed with this
7
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
8
13
14
#pragma once
15
16
#include <imgui.h>
17
#include <fmt/core.h>
18
19
namespace
NAV::gui::widgets
20
{
21
29
template
<
typename
T>
30
bool
EnumComboAbbreviation
(
const
char
* label, T& enumeration,
size_t
startIdx = 0)
31
{
32
bool
clicked =
false
;
33
if
(ImGui::BeginCombo(label, NAV::to_string_short(enumeration)))
34
{
35
for
(
size_t
i = startIdx; i < static_cast<size_t>(T::COUNT); i++)
36
{
37
const
bool
is_selected = (
static_cast<
size_t
>
(enumeration) == i);
38
if
(ImGui::Selectable(
NAV::to_string
(
static_cast<
T
>
(i)), is_selected))
39
{
40
enumeration =
static_cast<
T
>
(i);
41
clicked =
true
;
42
}
43
44
// Set the initial focus when opening the combo (scrolling + keyboard navigation focus)
45
if
(is_selected)
46
{
47
ImGui::SetItemDefaultFocus();
48
}
49
}
50
51
ImGui::EndCombo();
52
}
53
return
clicked;
54
}
55
56
}
// namespace NAV::gui::widgets
NAV::gui::widgets::EnumComboAbbreviation
bool EnumComboAbbreviation(const char *label, T &enumeration, size_t startIdx=0)
Combo representing an enumeration and use abbreviations to display in the preview.
Definition
EnumComboWithAbbreviation.hpp:30
NAV::to_string
const char * to_string(gui::widgets::PositionWithFrame::ReferenceFrame refFrame)
Converts the enum to a string.
src
internal
gui
widgets
EnumComboWithAbbreviation.hpp
Generated by
1.10.0