6#include "absl/strings/str_format.h"
15#include "imgui/imgui.h"
38 const char* fallback) {
39 switch (status.
state) {
53 const char* fallback_icon) {
57 const std::string label =
60 return ImGui::CalcTextSize(label.c_str()).x + 24.0f;
67 const bool interactive =
static_cast<bool>(opts.
on_click);
68 if (interactive && ImGui::IsItemHovered()) {
69 ImGui::SetMouseCursor(ImGuiMouseCursor_Hand);
71 if (!opts.
tooltip.empty() && ImGui::IsItemHovered()) {
72 ImGui::SetTooltip(
"%s", opts.
tooltip.c_str());
74 if (interactive && ImGui::IsItemClicked(ImGuiMouseButton_Left)) {
115 switch (event.
type) {
118 event.
text.empty() ?
nullptr :
event.text.c_str());
216 const std::string& value) {
221 const std::string& value,
224 if (seg.key == key) {
226 seg.options = std::move(options);
254 const std::string& model,
bool active) {
273 const ImGuiViewport* viewport = ImGui::GetMainViewport();
280 viewport->WorkPos.y + viewport->WorkSize.y - bar_height - bottom_safe;
282 const ImVec2 panel_padding =
283 touch_mode ? ImVec2(14.0f, 7.0f) : ImVec2(8.0f, 4.0f);
284 const ImVec2 panel_spacing =
285 touch_mode ? ImVec2(12.0f, 0.0f) : ImVec2(8.0f, 0.0f);
291 ImGuiWindowFlags extra_flags =
292 ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse |
293 ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNavFocus |
294 ImGuiWindowFlags_NoBringToFrontOnFocus;
297 ImVec2(viewport->WorkSize.x, bar_height),
299 .border = bar_border,
300 .padding = panel_padding,
301 .spacing = panel_spacing,
302 .border_size = 1.0f},
329 float right_section_width = 0.0f;
330 std::string agent_label;
333 if (agent_label.empty()) {
334 agent_label =
"Agent";
336 const size_t max_len = 20;
337 if (agent_label.size() > max_len) {
338 agent_label = agent_label.substr(0, max_len - 3) +
"...";
341 right_section_width += ImGui::CalcTextSize(label.c_str()).x +
342 ImGui::GetStyle().FramePadding.x * 2.0f + 10.0f;
345 right_section_width += ImGui::CalcTextSize(
"100%").x + 20.0f;
348 right_section_width +=
354 right_section_width += 16.0f;
357 right_section_width += 16.0f;
360 if (right_section_width > 0.0f) {
361 float available = ImGui::GetContentRegionAvail().x;
362 if (available > right_section_width + 20.0f) {
363 ImGui::SameLine(ImGui::GetWindowWidth() - right_section_width - 16.0f);
406 const size_t max_len = 20;
407 if (label.size() > max_len) {
408 label = label.substr(0, max_len - 3) +
"...";
415 {ImGuiCol_Text, text_color},
425 if (ImGui::IsItemHovered()) {
426 ImGui::BeginTooltip();
431 ImGui::TextDisabled(tr(
"Model: %s"),
agent_model_.empty()
434 ImGui::TextDisabled(tr(
"Toggle chat panel"));
440 const char* default_icon) {
441 const std::string display =
444 WorkflowStatusIcon(status, default_icon), display.c_str());
446 if (ImGui::IsItemHovered()) {
447 ImGui::BeginTooltip();
448 ImGui::Text(
"%s", status.
label.c_str());
450 ImGui::TextDisabled(
"%s", status.
summary.c_str());
452 if (!status.
detail.empty()) {
454 ImGui::TextWrapped(
"%s", status.
detail.c_str());
458 ImGui::TextWrapped(
"%s", status.
output_tail.c_str());
478 if (ImGui::IsItemHovered()) {
479 ImGui::SetTooltip(tr(
"Unsaved changes"));
492 if (ImGui::IsItemHovered()) {
493 ImGui::SetTooltip(tr(
"Session %zu of %zu"),
session_id_ + 1,
517 int zoom_percent =
static_cast<int>(
zoom_level_ * 100.0f);
524 if (ImGui::IsItemHovered()) {
525 ImGui::SetTooltip(tr(
"Zoom: %d%%"), zoom_percent);
541 segment.key.c_str(), segment.value.c_str());
542 ApplySegmentInteraction(segment.options);
HandlerId Subscribe(std::function< void(const T &)> handler)
Instance-based runtime context replacing ContentRegistry::Context.
static constexpr float kStatusBarHeight
void DrawCustomSegments()
void DrawSelectionSegment()
void HandleStatusUpdate(const StatusUpdateEvent &event)
GlobalEditorContext * context_
float GetHeight() const
Get the height of the status bar.
std::vector< CustomSegment > custom_segments_
void SetSessionInfo(size_t session_id, size_t total_sessions)
Set session information.
StatusBarSegmentOptions cursor_options_
static constexpr float kStatusBarTouchHeight
std::string agent_provider_
void ClearCursorPosition()
Clear cursor position (no cursor in editor)
std::function< void()> agent_toggle_callback_
void SetSelection(int count, int width=0, int height=0)
Set selection information.
StatusBarSegmentOptions zoom_options_
void ClearZoom()
Clear zoom display.
StatusBarSegmentOptions mode_options_
void SetCustomSegment(const std::string &key, const std::string &value)
Set a custom segment with key-value pair.
void SetZoom(float level)
Set current zoom level.
void DrawProjectWorkflowSegment(const ProjectWorkflowStatus &status, const char *default_icon)
std::string cursor_label_
void ClearSelection()
Clear selection info.
void ClearEditorMode()
Clear editor mode display.
void Initialize(GlobalEditorContext *context)
void ClearEditorContributions()
Clear frame-scoped editor contributions.
void SetCursorPosition(int x, int y, const char *label="Pos")
Set cursor/mouse position in editor coordinates.
void SetEditorMode(const std::string &mode)
Set the current editor mode or tool.
ProjectWorkflowStatus build_status_
void Draw()
Draw the status bar.
void ClearAllContext()
Clear all context (cursor, selection, zoom, mode, custom)
void ClearCustomSegment(const std::string &key)
Remove a custom segment.
ProjectWorkflowStatus run_status_
void DrawSessionSegment()
void SetAgentInfo(const std::string &provider, const std::string &model, bool active)
RAII for fixed-position panels (activity bar, side panel, status bar).
static SafeAreaInsets GetSafeAreaInsets()
static bool IsTouchDevice()
RAII guard for ImGui style colors.
const Theme & GetCurrentTheme() const
static ThemeManager & Get()
#define ICON_MD_PLAY_ARROW
#define ICON_MD_CHECK_CIRCLE
#define ICON_MD_DESCRIPTION
#define ICON_MD_SELECT_ALL
#define ICON_MD_FIBER_MANUAL_RECORD
#define ICON_MD_SMART_TOY
const char * WorkflowStatusIcon(const ProjectWorkflowStatus &status, const char *fallback)
ImVec4 WorkflowStatusColor(ProjectWorkflowState state)
void ApplySegmentInteraction(const StatusBarSegmentOptions &opts)
float WorkflowStatusWidth(const ProjectWorkflowStatus &status, const char *fallback_icon)
ImVec4 ConvertColorToImVec4(const Color &color)
void ColoredText(const char *text, const ImVec4 &color)
ImVec4 GetSurfaceContainerHighestVec4()
bool ThemedButton(const char *label, const ImVec2 &size, const char *panel_id, const char *anim_id)
Draw a standard text button with theme colors.
ImVec4 GetTextSecondaryVec4()
void ColoredTextF(const ImVec4 &color, const char *fmt,...)
ImVec4 GetSurfaceContainerHighVec4()
ImVec4 GetSurfaceContainerVec4()
ProjectWorkflowState state
Published when selection changes in any editor.
Optional behavior for an interactive status bar segment.
std::function< void()> on_click
Published when zoom level changes in any canvas/editor.