35 if(smart_init_samples_ > 0 && offset_ > smart_init_samples_)
38 smart_init_samples_ = -1;
41 values_[offset_] = value;
42 offset_ = (offset_ + 1) % NUM_SAMPLES;
44 float min = std::numeric_limits<float>::max();
45 float max = std::numeric_limits<float>::lowest();
48 for(
const auto& val : values_)
50 min = std::min(min, val);
51 max = std::max(max, val);
57 average_ = sum / NUM_SAMPLES;
60auto draw_progress_bar(
float width,
float max_width,
float height,
const ImVec4& color) ->
bool
62 const ImGuiStyle& style = ImGui::GetStyle();
65 color.x + color.x * HOVER_COLOR_MULTIPLIER,
66 color.y + color.y * HOVER_COLOR_MULTIPLIER,
67 color.z + color.z * HOVER_COLOR_MULTIPLIER,
68 color.w + color.w * HOVER_COLOR_MULTIPLIER
71 ImGui::PushStyleColor(ImGuiCol_Button, color);
72 ImGui::PushStyleColor(ImGuiCol_ButtonHovered, hovered_color);
73 ImGui::PushStyleColor(ImGuiCol_ButtonActive, color);
74 ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 0.0f);
75 ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.0f, style.ItemSpacing.y));
77 bool item_hovered =
false;
79 ImGui::Button(
"##bar_button", ImVec2(width, height));
80 item_hovered |= ImGui::IsItemHovered();
83 ImGui::InvisibleButton(
"##bar_invisible", ImVec2(max_width - width + 1, height));
84 item_hovered |= ImGui::IsItemHovered();
86 ImGui::PopStyleVar(2);
87 ImGui::PopStyleColor(3);
94 uint32_t current_value,
99 bool item_hovered =
false;
102 ImGui::AlignTextToFramePadding();
103 ImGui::Text(
"%s: %6d / %6d",
name, current_value, max_value);
104 item_hovered |= ImGui::IsItemHovered();
107 const float percentage =
static_cast<float>(current_value) /
static_cast<float>(max_value);
108 static const ImVec4 color(0.5f, 0.5f, 0.5f, 1.0f);
109 item_hovered |=
draw_progress_bar(std::max(1.0f, percentage * max_width), max_width, height, color);
112 ImGui::Text(
"%5.2f%%",
static_cast<double>(percentage * 100.0f));
116 ImGui::SetNextWindowViewportToCurrent();
117 ImGui::BeginTooltip();
118 ImGui::Text(
"%s %5.2f%%",
tooltip,
static_cast<double>(percentage * 100.0f));