1#define IMGUI_DEFINE_MATH_OPERATORS
5#include "absl/strings/str_format.h"
10#include "imgui/imgui.h"
11#include "imgui/imgui_internal.h"
22 const std::string layout_name = name.empty() ?
"workspace" : name;
28 return absl::OkStatus();
34 const std::string layout_name = name.empty() ?
"workspace" : name;
45 return absl::OkStatus();
52 std::filesystem::path workspace_dir = std::filesystem::current_path();
53 auto workspace_dir_status =
55 if (workspace_dir_status.ok()) {
56 workspace_dir = *workspace_dir_status;
62 std::filesystem::path ini_path =
63 workspace_dir / absl::StrFormat(
"workspace_%s.ini", name.c_str());
64 ImGui::SaveIniSettingsToDisk(ini_path.string().c_str());
75 std::ostringstream ss;
78 std::filesystem::path presets_path =
79 workspace_dir /
"workspace_presets.txt";
81 }
catch (
const std::exception& e) {
107 std::filesystem::path workspace_dir = std::filesystem::current_path();
108 auto workspace_dir_status =
110 if (workspace_dir_status.ok()) {
111 workspace_dir = *workspace_dir_status;
113 std::filesystem::path ini_path =
114 workspace_dir / absl::StrFormat(
"workspace_%s.ini", name.c_str());
115 ImGui::LoadIniSettingsFromDisk(ini_path.string().c_str());
125 std::vector<std::string> new_presets;
128 if (workspace_dir.ok()) {
129 std::filesystem::path presets_path =
130 *workspace_dir /
"workspace_presets.txt";
133 std::istringstream ss(data);
135 while (std::getline(ss, name)) {
136 name.erase(0, name.find_first_not_of(
" \t\r\n"));
137 name.erase(name.find_last_not_of(
" \t\r\n") + 1);
138 if (!name.empty() && name.length() < 256) {
139 new_presets.emplace_back(std::move(name));
146 }
catch (
const std::exception& e) {
197 ImGuiWindow* window = ImGui::GetCurrentWindowRead();
199 if (ImGuiDockNode* central = ImGui::DockBuilderGetCentralNode(
201 ImGui::DockBuilderDockWindow(window->Name, central->ID);
211 ImGuiContext* ctx = ImGui::GetCurrentContext();
213 for (ImGuiWindow* window : ctx->Windows) {
214 if (window && !window->Collapsed) {
215 ImGui::SetWindowSize(window->Name, ImVec2(0, 0));
226 ImGuiContext* ctx = ImGui::GetCurrentContext();
228 for (ImGuiWindow* window : ctx->Windows) {
229 if (window && !window->DockNode && !window->Collapsed) {
230 window->Hidden =
true;
245 if (session.rom && session.rom->is_loaded()) {
257 if (session.filepath == filepath && session.rom &&
258 session.rom->is_loaded()) {
267 ImGuiContext* ctx = ImGui::GetCurrentContext();
268 if (ctx && ctx->NavWindow) {
269 ImGui::FocusWindow(ImGui::FindWindowByName(ctx->NavWindow->Name));
279 ImGuiWindow* window = ImGui::GetCurrentWindowRead();
280 if (window && window->DockNode) {
281 ImGuiID node_id = window->DockNode->ID;
282 ImGuiID out_id_at_dir = 0;
283 ImGuiID out_id_at_opposite_dir = 0;
284 ImGui::DockBuilderSplitNode(node_id, ImGuiDir_Down, 0.5f, &out_id_at_dir,
285 &out_id_at_opposite_dir);
290 ImGuiWindow* window = ImGui::GetCurrentWindowRead();
291 if (window && window->DockNode) {
292 ImGuiID node_id = window->DockNode->ID;
293 ImGuiID out_id_at_dir = 0;
294 ImGuiID out_id_at_opposite_dir = 0;
295 ImGui::DockBuilderSplitNode(node_id, ImGuiDir_Right, 0.5f, &out_id_at_dir,
296 &out_id_at_opposite_dir);
301 ImGuiWindow* window = ImGui::GetCurrentWindowRead();
303 window->Hidden =
true;
void LoadLayout(const std::string &name)
Load a saved layout by name.
void SaveCurrentLayout(const std::string &name, bool persist=true)
Save the current layout with a custom name.
bool HasLayout(const std::string &name) const
Check if a layout exists.
ImGuiID GetMainDockspaceId() const
Get the cached main dockspace ID.
void Show(const std::string &message, ToastType type=ToastType::kInfo, float ttl_seconds=3.0f, std::string action_label={}, std::function< void()> on_action=nullptr)
std::string last_workspace_preset_
void SaveWorkspacePreset(const std::string &name)
bool HasDuplicateSession(const std::string &filepath) const
bool workspace_presets_loaded_
void FocusPreviousWindow()
void SplitWindowVertical()
std::function< void(const std::string &) apply_preset_callback_)
void MaximizeCurrentWindow()
std::vector< std::string > workspace_presets_
size_t GetActiveSessionCount() const
void LoadDeveloperLayout()
std::deque< SessionInfo > * sessions_
void LoadWorkspacePreset(const std::string &name)
absl::Status SaveWorkspaceLayout(const std::string &name="")
void CloseAllFloatingWindows()
LayoutManager * layout_manager_
WorkspaceWindowManager * window_manager_
void SplitWindowHorizontal()
void LoadDesignerLayout()
void CloseCurrentWindow()
absl::Status LoadWorkspaceLayout(const std::string &name="")
ToastManager * toast_manager_
void ShowAll(size_t session_id)
void HideAll(size_t session_id)
void SaveFile(const std::string &filename, const std::string &contents)
std::string LoadFile(const std::string &filename)
Loads the entire contents of a file into a string.