5#include "absl/strings/str_format.h"
14#include "imgui/imgui.h"
37 const char* fallback) {
38 switch (status.
state) {
52 const char* fallback_icon) {
56 const std::string label =
59 return ImGui::CalcTextSize(label.c_str()).x + 24.0f;
66 const bool interactive =
static_cast<bool>(opts.
on_click);
67 if (interactive && ImGui::IsItemHovered()) {
68 ImGui::SetMouseCursor(ImGuiMouseCursor_Hand);
70 if (!opts.
tooltip.empty() && ImGui::IsItemHovered()) {
71 ImGui::SetTooltip(
"%s", opts.
tooltip.c_str());
73 if (interactive && ImGui::IsItemClicked(ImGuiMouseButton_Left)) {
114 switch (event.
type) {
117 event.
text.empty() ?
nullptr :
event.text.c_str());
215 const std::string& value) {
220 const std::string& value,
223 if (seg.key == key) {
225 seg.options = std::move(options);
253 const std::string& model,
bool active) {
272 const ImGuiViewport* viewport = ImGui::GetMainViewport();
279 viewport->WorkPos.y + viewport->WorkSize.y - bar_height - bottom_safe;
281 const ImVec2 panel_padding =
282 touch_mode ? ImVec2(14.0f, 7.0f) : ImVec2(8.0f, 4.0f);
283 const ImVec2 panel_spacing =
284 touch_mode ? ImVec2(12.0f, 0.0f) : ImVec2(8.0f, 0.0f);
290 ImGuiWindowFlags extra_flags =
291 ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse |
292 ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNavFocus |
293 ImGuiWindowFlags_NoBringToFrontOnFocus;
296 ImVec2(viewport->WorkSize.x, bar_height),
298 .border = bar_border,
299 .padding = panel_padding,
300 .spacing = panel_spacing,
301 .border_size = 1.0f},
328 float right_section_width = 0.0f;
329 std::string agent_label;
332 if (agent_label.empty()) {
333 agent_label =
"Agent";
335 const size_t max_len = 20;
336 if (agent_label.size() > max_len) {
337 agent_label = agent_label.substr(0, max_len - 3) +
"...";
340 right_section_width += ImGui::CalcTextSize(label.c_str()).x +
341 ImGui::GetStyle().FramePadding.x * 2.0f + 10.0f;
344 right_section_width += ImGui::CalcTextSize(
"100%").x + 20.0f;
347 right_section_width +=
353 right_section_width += 16.0f;
356 right_section_width += 16.0f;
359 if (right_section_width > 0.0f) {
360 float available = ImGui::GetContentRegionAvail().x;
361 if (available > right_section_width + 20.0f) {
362 ImGui::SameLine(ImGui::GetWindowWidth() - right_section_width - 16.0f);
405 const size_t max_len = 20;
406 if (label.size() > max_len) {
407 label = label.substr(0, max_len - 3) +
"...";
414 {ImGuiCol_Text, text_color},
424 if (ImGui::IsItemHovered()) {
425 ImGui::BeginTooltip();
432 ImGui::TextDisabled(
"Toggle chat panel");
438 const char* default_icon) {
439 const std::string display =
442 WorkflowStatusIcon(status, default_icon), display.c_str());
444 if (ImGui::IsItemHovered()) {
445 ImGui::BeginTooltip();
446 ImGui::Text(
"%s", status.
label.c_str());
448 ImGui::TextDisabled(
"%s", status.
summary.c_str());
450 if (!status.
detail.empty()) {
452 ImGui::TextWrapped(
"%s", status.
detail.c_str());
456 ImGui::TextWrapped(
"%s", status.
output_tail.c_str());
476 if (ImGui::IsItemHovered()) {
477 ImGui::SetTooltip(
"Unsaved changes");
490 if (ImGui::IsItemHovered()) {
514 int zoom_percent =
static_cast<int>(
zoom_level_ * 100.0f);
521 if (ImGui::IsItemHovered()) {
522 ImGui::SetTooltip(
"Zoom: %d%%", zoom_percent);
538 segment.key.c_str(), segment.value.c_str());
539 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.