Group platform components into descriptive subfolders

PiperOrigin-RevId: 895832492
Change-Id: I6cc56b0e4b002b2998579cde95f4b88dfbd88184
This commit is contained in:
Matija Kecman
2026-04-07 04:57:45 -07:00
committed by Copybara-Service
parent 6273331d82
commit 9f3babd60c
43 changed files with 252 additions and 264 deletions
+39 -39
View File
@@ -20,67 +20,67 @@ add_library(${MUJOCO_PLATFORM_TARGET_NAME} STATIC)
target_sources(${MUJOCO_PLATFORM_TARGET_NAME}
PUBLIC
egl_utils.cc
egl_utils.h
enum_utils.h
file_dialog.h
graphics_mode.cc
graphics_mode.h
gui.cc
gui.h
gui_spec.cc
gui_spec.h
helpers.cc
helpers.h
imgui_widgets.cc
imgui_widgets.h
interaction.cc
interaction.h
model_holder.cc
model_holder.h
picture_gui.h
picture_gui.cc
plugin.cc
plugin.h
renderer.cc
renderer.h
sim_history.cc
sim_history.h
sim_profiler.cc
sim_profiler.h
spec_editor.cc
spec_editor.h
step_control.cc
step_control.h
window.cc
window.h
hal/egl_utils.cc
hal/egl_utils.h
hal/graphics_mode.cc
hal/graphics_mode.h
hal/renderer.cc
hal/renderer.h
hal/window.cc
hal/window.h
sim/model_holder.cc
sim/model_holder.h
sim/sim_history.cc
sim/sim_history.h
sim/sim_profiler.cc
sim/sim_profiler.h
sim/step_control.cc
sim/step_control.h
ux/enum_utils.h
ux/file_dialog.h
ux/gui.cc
ux/gui.h
ux/gui_spec.cc
ux/gui_spec.h
ux/imgui_widgets.cc
ux/imgui_widgets.h
ux/interaction.cc
ux/interaction.h
ux/picture_gui.h
ux/picture_gui.cc
ux/plugin.cc
ux/plugin.h
ux/spec_editor.cc
ux/spec_editor.h
)
if(NOT WIN32)
target_sources(${MUJOCO_PLATFORM_TARGET_NAME}
PUBLIC
object_launcher_plugin.cc
ux/object_launcher_plugin.cc
)
endif()
if(APPLE)
set_source_files_properties(window_osx.mm PROPERTIES
set_source_files_properties(hal/window_osx.mm PROPERTIES
COMPILE_FLAGS "-x objective-c++")
target_sources(${MUJOCO_PLATFORM_TARGET_NAME} PUBLIC
window_osx.mm
file_dialog_cocoa.mm
hal/window_osx.mm
ux/file_dialog_cocoa.mm
)
elseif(UNIX AND NOT APPLE)
target_sources(${MUJOCO_PLATFORM_TARGET_NAME} PUBLIC
file_dialog_zenity.cc
ux/file_dialog_zenity.cc
)
elseif(WIN32)
target_sources(${MUJOCO_PLATFORM_TARGET_NAME} PUBLIC
file_dialog_win.cc
ux/file_dialog_win.cc
)
else()
target_sources(${MUJOCO_PLATFORM_TARGET_NAME} PUBLIC
file_dialog.cc
ux/file_dialog.cc
)
endif()
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "experimental/platform/egl_utils.h"
#include "experimental/platform/hal/egl_utils.h"
#include <memory>
@@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef MUJOCO_SRC_EXPERIMENTAL_PLATFORM_EGL_UTILS_H_
#define MUJOCO_SRC_EXPERIMENTAL_PLATFORM_EGL_UTILS_H_
#ifndef MUJOCO_SRC_EXPERIMENTAL_PLATFORM_HAL_EGL_UTILS_H_
#define MUJOCO_SRC_EXPERIMENTAL_PLATFORM_HAL_EGL_UTILS_H_
#include <memory>
@@ -25,4 +25,4 @@ std::shared_ptr<void> CreateEglContext();
} // namespace mujoco::platform
#endif // MUJOCO_SRC_EXPERIMENTAL_PLATFORM_EGL_UTILS_H_
#endif // MUJOCO_SRC_EXPERIMENTAL_PLATFORM_HAL_EGL_UTILS_H_
@@ -12,9 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "experimental/platform/graphics_mode.h"
#include "experimental/platform/hal/graphics_mode.h"
#include <string_view>
#include <mujoco/mujoco.h>
namespace mujoco::platform {
@@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef MUJOCO_SRC_EXPERIMENTAL_PLATFORM_GRAPHICS_MODE_H_
#define MUJOCO_SRC_EXPERIMENTAL_PLATFORM_GRAPHICS_MODE_H_
#ifndef MUJOCO_SRC_EXPERIMENTAL_PLATFORM_HAL_GRAPHICS_MODE_H_
#define MUJOCO_SRC_EXPERIMENTAL_PLATFORM_HAL_GRAPHICS_MODE_H_
#include <string_view>
@@ -56,4 +56,4 @@ GraphicsMode GraphicsModeFromString(std::string_view str,
} // namespace mujoco::platform
#endif // MUJOCO_SRC_EXPERIMENTAL_PLATFORM_GRAPHICS_MODE_H_
#endif // MUJOCO_SRC_EXPERIMENTAL_PLATFORM_HAL_GRAPHICS_MODE_H_
@@ -12,23 +12,22 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "experimental/platform/renderer.h"
#include "experimental/platform/hal/renderer.h"
#include <chrono>
#include <cstddef>
#include <span>
#include <utility>
#include <mujoco/mujoco.h>
#include <imgui.h>
#include <backends/imgui_impl_opengl3.h>
#include <imgui.h>
#include <mujoco/mujoco.h>
#if !defined(__EMSCRIPTEN__) && !defined(__APPLE__)
#include "experimental/platform/egl_utils.h"
#include "experimental/platform/hal/egl_utils.h"
#endif
#include "experimental/filament/render_context_filament.h"
#include "experimental/platform/graphics_mode.h"
#include "experimental/platform/plugin.h"
#include "experimental/platform/hal/graphics_mode.h"
#include "experimental/platform/ux/plugin.h"
namespace mujoco::platform {
@@ -47,9 +46,9 @@ Renderer::Renderer(void* native_window, GraphicsMode gfx)
: native_window_(native_window), gfx_(gfx) {
if (IsClassic(gfx_)) {
if (native_window == nullptr) {
#if !defined(__EMSCRIPTEN__) && !defined(__APPLE__)
graphics_api_context_ = CreateEglContext();
#endif
#if !defined(__EMSCRIPTEN__) && !defined(__APPLE__)
graphics_api_context_ = CreateEglContext();
#endif
}
if (ImGui::GetCurrentContext()) {
ImGui_ImplOpenGL3_Init();
@@ -147,8 +146,7 @@ void Renderer::Render(const mjModel* model, mjData* data,
vis_option = &default_opt;
}
mjv_updateScene(model, data, vis_option, perturb, camera, mjCAT_ALL,
&scene_);
mjv_updateScene(model, data, vis_option, perturb, camera, mjCAT_ALL, &scene_);
const bool render_to_texture = !pixels.empty();
if (render_to_texture) {
@@ -215,8 +213,8 @@ int Renderer::UploadImage(int texture_id, const std::byte* pixels, int width,
return 0;
} else {
return mjrf_uploadGuiImage(texture_id,
reinterpret_cast<const unsigned char*>(pixels),
width, height, bpp, &render_context_);
reinterpret_cast<const unsigned char*>(pixels),
width, height, bpp, &render_context_);
}
}
@@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef MUJOCO_SRC_EXPERIMENTAL_PLATFORM_RENDERER_H_
#define MUJOCO_SRC_EXPERIMENTAL_PLATFORM_RENDERER_H_
#ifndef MUJOCO_SRC_EXPERIMENTAL_PLATFORM_HAL_RENDERER_H_
#define MUJOCO_SRC_EXPERIMENTAL_PLATFORM_HAL_RENDERER_H_
#include <chrono>
#include <cstddef>
@@ -23,7 +23,7 @@
#include <span>
#include <mujoco/mujoco.h>
#include "experimental/platform/graphics_mode.h"
#include "experimental/platform/hal/graphics_mode.h"
namespace mujoco::platform {
@@ -113,4 +113,4 @@ class Renderer {
} // namespace mujoco::platform
#endif // MUJOCO_SRC_EXPERIMENTAL_PLATFORM_RENDERER_H_
#endif // MUJOCO_SRC_EXPERIMENTAL_PLATFORM_HAL_RENDERER_H_
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "experimental/platform/window.h"
#include "experimental/platform/hal/window.h"
#include <algorithm>
#include <cstddef>
@@ -32,10 +32,9 @@
#include <backends/imgui_impl_sdl2.h>
#include <imgui.h>
#include <mujoco/mujoco.h>
#include "experimental/platform/graphics_mode.h"
#include "experimental/platform/hal/graphics_mode.h"
#include "user/user_resource.h"
// Because X11/Xlib.h defines Status.
#ifdef Status
#undef Status
@@ -126,9 +125,9 @@ Window::Window(std::string_view title, int width, int height, Config config)
}
const float content_scale = ImGui_ImplSDL2_GetContentScaleForDisplay(0);
sdl_window_ = SDL_CreateWindow(title.data(), SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED, width,
height, window_flags);
sdl_window_ =
SDL_CreateWindow(title.data(), SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED, width, height, window_flags);
if (!sdl_window_) {
mju_error("Error creating window: %s", SDL_GetError());
}
@@ -156,14 +155,14 @@ Window::Window(std::string_view title, int width, int height, Config config)
SDL_VERSION(&wmi.version);
SDL_GetWindowWMInfo(sdl_window_, &wmi);
#if defined(__linux__)
native_window_ = reinterpret_cast<void*>(wmi.info.x11.window);
#elif defined(__WIN32__)
native_window_ = reinterpret_cast<void*>(wmi.info.win.window);
#elif defined(__APPLE__)
native_window_ =
GetNativeWindowOsx(reinterpret_cast<void*>(wmi.info.cocoa.window));
#endif
#if defined(__linux__)
native_window_ = reinterpret_cast<void*>(wmi.info.x11.window);
#elif defined(__WIN32__)
native_window_ = reinterpret_cast<void*>(wmi.info.win.window);
#elif defined(__APPLE__)
native_window_ =
GetNativeWindowOsx(reinterpret_cast<void*>(wmi.info.cocoa.window));
#endif
}
int drawable_width = width;
@@ -244,8 +243,7 @@ void Window::Present(std::span<const std::byte> pixels) {
SDL_Surface* surface = SDL_GetWindowSurface(sdl_window_);
const unsigned char* src =
reinterpret_cast<const unsigned char*>(pixels.data());
unsigned char* dst =
static_cast<unsigned char*>(surface->pixels);
unsigned char* dst = static_cast<unsigned char*>(surface->pixels);
for (int i = 0; i < height_; ++i) {
for (int j = 0; j < width_; ++j) {
@@ -260,14 +258,12 @@ void Window::Present(std::span<const std::byte> pixels) {
}
SDL_RenderPresent(sdl_renderer_);
} else if (config_.gfx_mode != GraphicsMode::FilamentVulkan
&& config_.gfx_mode != GraphicsMode::FilamentOpenGl) {
} else if (config_.gfx_mode != GraphicsMode::FilamentVulkan &&
config_.gfx_mode != GraphicsMode::FilamentOpenGl) {
SDL_GL_SwapWindow(sdl_window_);
}
}
GraphicsMode Window::GetGraphicsMode() const {
return config_.gfx_mode;
}
GraphicsMode Window::GetGraphicsMode() const { return config_.gfx_mode; }
} // namespace mujoco::platform
@@ -12,17 +12,17 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef MUJOCO_SRC_EXPERIMENTAL_PLATFORM_WINDOW_H_
#define MUJOCO_SRC_EXPERIMENTAL_PLATFORM_WINDOW_H_
#ifndef MUJOCO_SRC_EXPERIMENTAL_PLATFORM_HAL_WINDOW_H_
#define MUJOCO_SRC_EXPERIMENTAL_PLATFORM_HAL_WINDOW_H_
#include <cstddef>
#include <span>
#include <string>
#include <string_view>
#include <SDL_video.h>
#include <SDL_render.h>
#include "experimental/platform/graphics_mode.h"
#include <SDL_video.h>
#include "experimental/platform/hal/graphics_mode.h"
namespace mujoco::platform {
@@ -104,4 +104,4 @@ class Window {
} // namespace mujoco::platform
#endif // MUJOCO_SRC_EXPERIMENTAL_PLATFORM_WINDOW_H_
#endif // MUJOCO_SRC_EXPERIMENTAL_PLATFORM_HAL_WINDOW_H_
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "experimental/platform/model_holder.h"
#include "experimental/platform/sim/model_holder.h"
#include <cstddef>
#include <cstring>
@@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef MUJOCO_SRC_EXPERIMENTAL_PLATFORM_MODEL_HOLDER_H_
#define MUJOCO_SRC_EXPERIMENTAL_PLATFORM_MODEL_HOLDER_H_
#ifndef MUJOCO_SRC_EXPERIMENTAL_PLATFORM_SIM_MODEL_HOLDER_H_
#define MUJOCO_SRC_EXPERIMENTAL_PLATFORM_SIM_MODEL_HOLDER_H_
#include <memory>
#include <cstddef>
@@ -81,4 +81,4 @@ class ModelHolder {
};
} // namespace mujoco::platform
#endif // MUJOCO_SRC_EXPERIMENTAL_PLATFORM_MODEL_HOLDER_H_
#endif // MUJOCO_SRC_EXPERIMENTAL_PLATFORM_SIM_MODEL_HOLDER_H_
@@ -12,11 +12,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "experimental/platform/sim_history.h"
#include "experimental/platform/sim/sim_history.h"
#include <algorithm>
#include <climits>
#include <span>
#include <mujoco/mujoco.h>
namespace mujoco::platform {
@@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef MUJOCO_SRC_EXPERIMENTAL_PLATFORM_SIM_HISTORY_H_
#define MUJOCO_SRC_EXPERIMENTAL_PLATFORM_SIM_HISTORY_H_
#ifndef MUJOCO_SRC_EXPERIMENTAL_PLATFORM_SIM_SIM_HISTORY_H_
#define MUJOCO_SRC_EXPERIMENTAL_PLATFORM_SIM_SIM_HISTORY_H_
#include <span>
#include <vector>
@@ -91,4 +91,4 @@ class SimHistory {
} // namespace mujoco::platform
#endif // MUJOCO_SRC_EXPERIMENTAL_PLATFORM_SIM_HISTORY_H_
#endif // MUJOCO_SRC_EXPERIMENTAL_PLATFORM_SIM_SIM_HISTORY_H_
@@ -12,11 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "experimental/platform/sim_profiler.h"
#include "experimental/platform/sim/sim_profiler.h"
#include <mujoco/mujoco.h>
#include <imgui.h>
#include <implot.h>
#include <mujoco/mujoco.h>
namespace mujoco::platform {
@@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef MUJOCO_SRC_EXPERIMENTAL_PLATFORM_SIM_PROFILER_H_
#define MUJOCO_SRC_EXPERIMENTAL_PLATFORM_SIM_PROFILER_H_
#ifndef MUJOCO_SRC_EXPERIMENTAL_PLATFORM_SIM_SIM_PROFILER_H_
#define MUJOCO_SRC_EXPERIMENTAL_PLATFORM_SIM_SIM_PROFILER_H_
#include <vector>
@@ -52,4 +52,4 @@ class SimProfiler {
} // namespace mujoco::platform
#endif // MUJOCO_SRC_EXPERIMENTAL_PLATFORM_SIM_PROFILER_H_
#endif // MUJOCO_SRC_EXPERIMENTAL_PLATFORM_SIM_SIM_PROFILER_H_
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "experimental/platform/step_control.h"
#include "experimental/platform/sim/step_control.h"
#include <algorithm>
#include <chrono>
@@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef MUJOCO_SRC_EXPERIMENTAL_PLATFORM_STEP_CONTROL_H_
#define MUJOCO_SRC_EXPERIMENTAL_PLATFORM_STEP_CONTROL_H_
#ifndef MUJOCO_SRC_EXPERIMENTAL_PLATFORM_SIM_STEP_CONTROL_H_
#define MUJOCO_SRC_EXPERIMENTAL_PLATFORM_SIM_STEP_CONTROL_H_
#include <chrono>
#include <string>
@@ -123,4 +123,4 @@ class StepControl {
} // namespace mujoco::platform
#endif // MUJOCO_SRC_EXPERIMENTAL_PLATFORM_STEP_CONTROL_H_
#endif // MUJOCO_SRC_EXPERIMENTAL_PLATFORM_SIM_STEP_CONTROL_H_
@@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef MUJOCO_SRC_EXPERIMENTAL_PLATFORM_ENUM_UTILS_H_
#define MUJOCO_SRC_EXPERIMENTAL_PLATFORM_ENUM_UTILS_H_
#ifndef MUJOCO_SRC_EXPERIMENTAL_PLATFORM_UX_ENUM_UTILS_H_
#define MUJOCO_SRC_EXPERIMENTAL_PLATFORM_UX_ENUM_UTILS_H_
#include <array>
#include <bit>
@@ -167,4 +167,4 @@ constexpr std::string_view enum_to_string(E value) {
} // namespace mujoco::platform::enum_utils
#endif // MUJOCO_SRC_EXPERIMENTAL_PLATFORM_ENUM_UTILS_H_
#endif // MUJOCO_SRC_EXPERIMENTAL_PLATFORM_UX_ENUM_UTILS_H_
@@ -12,10 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "experimental/platform/file_dialog.h"
#include "experimental/platform/ux/file_dialog.h"
#include <cstring>
#include <span>
#include <string>
#include <string_view>
@@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef MUJOCO_SRC_EXPERIMENTAL_PLATFORM_FILE_DIALOG_H_
#define MUJOCO_SRC_EXPERIMENTAL_PLATFORM_FILE_DIALOG_H_
#ifndef MUJOCO_SRC_EXPERIMENTAL_PLATFORM_UX_FILE_DIALOG_H_
#define MUJOCO_SRC_EXPERIMENTAL_PLATFORM_UX_FILE_DIALOG_H_
#include <span>
#include <string>
@@ -56,4 +56,4 @@ DialogResult SelectPathDialog(std::string_view path);
} // namespace mujoco::platform
#endif // MUJOCO_SRC_EXPERIMENTAL_PLATFORM_FILE_DIALOG_H_
#endif // MUJOCO_SRC_EXPERIMENTAL_PLATFORM_UX_FILE_DIALOG_H_
@@ -16,7 +16,7 @@
#include <string>
#include <Cocoa/Cocoa.h>
#include "experimental/platform/file_dialog.h"
#include "experimental/platform/ux/file_dialog.h"
namespace mujoco::platform {
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "experimental/platform/file_dialog.h"
#include "experimental/platform/ux/file_dialog.h"
#ifndef UNICODE
#define UNICODE
@@ -12,10 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "experimental/platform/file_dialog.h"
#include <assert.h>
#include <cstring>
#include <fcntl.h>
#include <stdarg.h>
#include <stdio.h>
@@ -23,11 +20,14 @@
#include <sys/wait.h>
#include <unistd.h>
#include <cstring>
#include <span>
#include <string_view>
#include <string>
#include <string_view>
#include <vector>
#include "experimental/platform/ux/file_dialog.h"
namespace mujoco::platform {
static DialogResult RunZenity(std::vector<std::string>& args) {
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "experimental/platform/gui.h"
#include "experimental/platform/ux/gui.h"
#include <algorithm>
#include <cmath>
@@ -26,8 +26,8 @@
#include <implot.h>
#include <mujoco/mujoco.h>
#include "experimental/platform/helpers.h"
#include "experimental/platform/interaction.h"
#include "experimental/platform/imgui_widgets.h"
#include "experimental/platform/ux/imgui_widgets.h"
#include "experimental/platform/ux/interaction.h"
namespace mujoco::platform {
@@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef MUJOCO_SRC_EXPERIMENTAL_PLATFORM_GUI_H_
#define MUJOCO_SRC_EXPERIMENTAL_PLATFORM_GUI_H_
#ifndef MUJOCO_SRC_EXPERIMENTAL_PLATFORM_UX_GUI_H_
#define MUJOCO_SRC_EXPERIMENTAL_PLATFORM_UX_GUI_H_
// A collection of functions for building ImGui panels for common MuJoCo
// visualization and manipulation UX. These functions are primarily used by
@@ -131,4 +131,4 @@ void StatsGui(const mjModel* model, const mjData* data, bool paused, float fps);
} // namespace mujoco::platform
#endif // MUJOCO_SRC_EXPERIMENTAL_PLATFORM_GUI_H_
#endif // MUJOCO_SRC_EXPERIMENTAL_PLATFORM_UX_GUI_H_
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "experimental/platform/gui_spec.h"
#include "experimental/platform/ux/gui_spec.h"
#include <string>
#include <string_view>
@@ -20,8 +20,8 @@
#include <imgui.h>
#include <mujoco/mjxmacro.h>
#include <mujoco/mujoco.h>
#include "experimental/platform/imgui_widgets.h"
#include "experimental/platform/spec_editor.h"
#include "experimental/platform/ux/imgui_widgets.h"
#include "experimental/platform/ux/spec_editor.h"
// Define the mujoco X macros to add fields to the ImGui_DataTable.
// We limit the fields to the ones with a matching element by comparing the
@@ -12,11 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef MUJOCO_SRC_EXPERIMENTAL_PLATFORM_GUI_SPEC_H_
#define MUJOCO_SRC_EXPERIMENTAL_PLATFORM_GUI_SPEC_H_
#ifndef MUJOCO_SRC_EXPERIMENTAL_PLATFORM_UX_GUI_SPEC_H_
#define MUJOCO_SRC_EXPERIMENTAL_PLATFORM_UX_GUI_SPEC_H_
#include <mujoco/mujoco.h>
#include "experimental/platform/spec_editor.h"
#include "experimental/platform/ux/spec_editor.h"
namespace mujoco::platform {
@@ -44,4 +44,4 @@ void ElementModelGui(const mjModel* model, mjsElement* element);
} // namespace mujoco::platform
#endif // MUJOCO_SRC_EXPERIMENTAL_PLATFORM_GUI_SPEC_H_
#endif // MUJOCO_SRC_EXPERIMENTAL_PLATFORM_UX_GUI_SPEC_H_
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "experimental/platform/imgui_widgets.h"
#include "experimental/platform/ux/imgui_widgets.h"
#include <cstdint>
#include <cstring>
@@ -62,8 +62,7 @@ KeyValues ReadIniSection(const std::string& contents,
}
ImGui_DataPtrTable::ImGui_DataPtrTable(float w1, float w2) {
ImGui::BeginTable("##PropertiesTable", 2,
ImGuiTableFlags_RowBg);
ImGui::BeginTable("##PropertiesTable", 2, ImGuiTableFlags_RowBg);
const float width = ImGui::GetContentRegionAvail().x;
ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, width * w1);
ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, width * w2);
@@ -87,43 +86,44 @@ void ImGui_DataPtrTable::DataPtr(const char* label, const uintptr_t* ptr,
}
void ImGui_DataPtrTable::DataPtr(const char* label, const char* ptr, int index,
int n) {
int n) {
MakeLabel(label);
ScopedStyle style;
style.Color(ImGuiCol_Text, ImColor(255, 0, 0, 255));
ImGui::Text("%s", "(char not implemented, please report bug)");
}
void ImGui_DataPtrTable::DataPtr(const char* label, const mjtByte* ptr, int index,
int n) {
void ImGui_DataPtrTable::DataPtr(const char* label, const mjtByte* ptr,
int index, int n) {
for (int i = 0; i < n; ++i) {
MakeLabel(label, i, n);
ImGui::Text("%s", ptr[index + i] ? "true" : "false");
}
}
void ImGui_DataPtrTable::DataPtr(const char* label, const mjtSize* ptr, int index,
int n) {
void ImGui_DataPtrTable::DataPtr(const char* label, const mjtSize* ptr,
int index, int n) {
Numeric(label, ptr, index, n);
}
void ImGui_DataPtrTable::DataPtr(const char* label, const int* ptr, int index,
int n) {
int n) {
Numeric(label, ptr, index, n);
}
void ImGui_DataPtrTable::DataPtr(const char* label, const float* ptr, int index,
int n) {
int n) {
Numeric(label, ptr, index, n);
}
void ImGui_DataPtrTable::DataPtr(const char* label, const double* ptr, int index,
int n) {
void ImGui_DataPtrTable::DataPtr(const char* label, const double* ptr,
int index, int n) {
Numeric(label, ptr, index, n);
}
template <typename T>
void ImGui_DataPtrTable::Numeric(const char* label, const T* ptr, int index, int n) {
void ImGui_DataPtrTable::Numeric(const char* label, const T* ptr, int index,
int n) {
const T* addr = ptr + index * n;
using U = std::conditional_t<std::is_floating_point_v<T>, float, int>;
@@ -137,8 +137,7 @@ void ImGui_DataPtrTable::Numeric(const char* label, const T* ptr, int index, int
}
}
constexpr const char* fmt1 =
std::is_floating_point_v<U> ? "%f" : "%d";
constexpr const char* fmt1 = std::is_floating_point_v<U> ? "%f" : "%d";
constexpr const char* fmt2 =
std::is_floating_point_v<U> ? "%f %f" : "%d %d";
constexpr const char* fmt3 =
@@ -146,9 +145,7 @@ void ImGui_DataPtrTable::Numeric(const char* label, const T* ptr, int index, int
constexpr const char* fmt4 =
std::is_floating_point_v<U> ? "%f %f %f %f" : "%d %d %d %d";
auto text1 = [&](int offset) {
ImGui::Text(fmt1, (U)(addr[offset]));
};
auto text1 = [&](int offset) { ImGui::Text(fmt1, (U)(addr[offset])); };
auto text2 = [&](int offset) {
ImGui::Text(fmt2, (U)(addr[offset + 0]), (U)(addr[offset + 1]));
};
@@ -299,7 +296,8 @@ void ImGui_SpecElementTable::operator()(const char* name, const char* alt_name,
(*this)(name, quat, ref_quat, tooltip);
break;
case mjORIENTATION_AXISANGLE:
(*this)(aname("axisangle").c_str(), alt.axisangle, ref_alt.axisangle, tooltip);
(*this)(aname("axisangle").c_str(), alt.axisangle, ref_alt.axisangle,
tooltip);
break;
case mjORIENTATION_XYAXES:
(*this)(aname("xyaxes").c_str(), alt.xyaxes, ref_alt.xyaxes, tooltip);
@@ -328,7 +326,6 @@ bool ImGui_Slider(const char* name, mjtNum* value, mjtNum min, mjtNum max) {
return res;
}
bool ImGui_BeginHSplit(const char* id, float* height, bool* open) {
const ImVec2 region = ImGui::GetContentRegionAvail();
if (*height < 0) {
@@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef MUJOCO_SRC_EXPERIMENTAL_PLATFORM_IMGUI_WIDGETS_H_
#define MUJOCO_SRC_EXPERIMENTAL_PLATFORM_IMGUI_WIDGETS_H_
#ifndef MUJOCO_SRC_EXPERIMENTAL_PLATFORM_UX_IMGUI_WIDGETS_H_
#define MUJOCO_SRC_EXPERIMENTAL_PLATFORM_UX_IMGUI_WIDGETS_H_
#include <cstddef>
#include <cstdint>
@@ -28,7 +28,7 @@
#include <imgui_internal.h>
#include <misc/cpp/imgui_stdlib.h>
#include <mujoco/mujoco.h>
#include "experimental/platform/enum_utils.h"
#include "experimental/platform/ux/enum_utils.h"
namespace mujoco::platform {
@@ -140,9 +140,7 @@ struct ScopedStyle {
return *this;
}
ImVec4 CurrentColor(ImGuiCol col) {
return ImGui::GetStyle().Colors[col];
}
ImVec4 CurrentColor(ImGuiCol col) { return ImGui::GetStyle().Colors[col]; }
void Reset() {
ImGui::PopStyleVar(num_vars);
@@ -200,8 +198,7 @@ class ImGui_DataPtrTable {
class ImGui_SpecElementTable : public ImGui_DataPtrTable {
public:
explicit ImGui_SpecElementTable(bool read_only = true)
: read_only_(read_only) {
}
: read_only_(read_only) {}
// Scalar values used by mjSpec elements.
void operator()(const char* label, mjtByte& val, const mjtByte& ref,
@@ -273,8 +270,9 @@ class ImGui_SpecElementTable : public ImGui_DataPtrTable {
}
// Special handling for treating enum values as integers.
template <typename T, typename U=std::enable_if_t<std::is_enum_v<T>, T>>
void operator()(const char* label, T& val, const T& ref, const char* tooltip) {
template <typename T, typename U = std::enable_if_t<std::is_enum_v<T>, T>>
void operator()(const char* label, T& val, const T& ref,
const char* tooltip) {
Label(label, tooltip);
Input(val, ref);
}
@@ -570,4 +568,4 @@ void MaybeSaveToClipboard(const std::string& contents);
} // namespace mujoco::platform
#endif // MUJOCO_SRC_EXPERIMENTAL_PLATFORM_IMGUI_WIDGETS_H_
#endif // MUJOCO_SRC_EXPERIMENTAL_PLATFORM_UX_IMGUI_WIDGETS_H_
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "experimental/platform/interaction.h"
#include "experimental/platform/ux/interaction.h"
#include <algorithm>
#include <cmath>
@@ -245,7 +245,8 @@ void MoveCamera(const mjModel* m, const mjData* d, mjvCamera* cam,
// y movement: either dolly (forward/back) or pedestal (up/down)
mju_addToScl3(cam->lookat,
(motion == CameraMotion::TRUCK_PEDESTAL) ? up : forward, dy);
(motion == CameraMotion::TRUCK_PEDESTAL) ? up : forward,
dy);
// x movement: camera truck (left/right)
mju_addToScl3(cam->lookat, right, dx);
@@ -341,8 +342,9 @@ static PickResult PickGeom(const mjModel* m, const mjData* d,
const mjtNum ray_pos[3], const mjtNum ray_dir[3],
const mjvOption* vis_options) {
PickResult result;
result.dist = mj_ray(m, d, ray_pos, ray_dir, vis_options->geomgroup,
vis_options->flags[mjVIS_STATIC], -1, &result.geom, nullptr);
result.dist =
mj_ray(m, d, ray_pos, ray_dir, vis_options->geomgroup,
vis_options->flags[mjVIS_STATIC], -1, &result.geom, nullptr);
mju_addScl3(result.point, ray_pos, ray_dir, result.dist);
result.body = m->geom_bodyid[result.geom];
return result;
@@ -541,8 +543,8 @@ static PickResult PickSkin(const mjModel* m, const mjData* d,
int vertid;
mjtNum test_dist = mju_raySkin(m->skin_facenum[i], m->skin_vertnum[i],
m->skin_face + 3 * m->skin_faceadr[i],
skinvert, ray_pos, ray_dir, &vertid);
m->skin_face + 3 * m->skin_faceadr[i],
skinvert, ray_pos, ray_dir, &vertid);
if (test_dist < 0) {
continue;
} else if (result.dist >= 0 && test_dist >= result.dist) {
@@ -554,9 +556,9 @@ static PickResult PickSkin(const mjModel* m, const mjData* d,
// find body with largest weight for this vertex
float best_weight = -1;
for (int j = m->skin_boneadr[i];
j < m->skin_boneadr[i] + m->skin_bonenum[i]; j++) {
j < m->skin_boneadr[i] + m->skin_bonenum[i]; j++) {
for (int k = m->skin_bonevertadr[j];
k < m->skin_bonevertadr[j] + m->skin_bonevertnum[j]; k++) {
k < m->skin_bonevertadr[j] + m->skin_bonevertnum[j]; k++) {
// get vertex id and weight
const int vertex_id = m->skin_bonevertid[k];
const float vertex_weight = m->skin_bonevertweight[k];
@@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef MUJOCO_SRC_EXPERIMENTAL_PLATFORM_INTERACTION_H_
#define MUJOCO_SRC_EXPERIMENTAL_PLATFORM_INTERACTION_H_
#ifndef MUJOCO_SRC_EXPERIMENTAL_PLATFORM_UX_INTERACTION_H_
#define MUJOCO_SRC_EXPERIMENTAL_PLATFORM_UX_INTERACTION_H_
#include <mujoco/mujoco.h>
@@ -22,7 +22,7 @@ namespace mujoco::platform {
// The result of a pick operation.
struct PickResult {
mjtNum point[3] = {0, 0, 0}; // World coordinates
mjtNum dist = -1; // Distance from the camera.
mjtNum dist = -1; // Distance from the camera.
int body = -1;
int geom = -1;
int flex = -1;
@@ -77,9 +77,8 @@ void InitPerturb(const mjModel* m, const mjData* d, const mjvCamera* cam,
mjvPerturb* pert, mjtPertBit active);
void MovePerturb(const mjModel* m, const mjData* d, const mjvCamera* cam,
mjvPerturb* pert, mjtMouse action, mjtNum reldx,
mjtNum reldy);
mjvPerturb* pert, mjtMouse action, mjtNum reldx, mjtNum reldy);
} // namespace mujoco::platform
#endif // MUJOCO_SRC_EXPERIMENTAL_PLATFORM_INTERACTION_H_
#endif // MUJOCO_SRC_EXPERIMENTAL_PLATFORM_UX_INTERACTION_H_
@@ -19,8 +19,8 @@
#include <imgui.h>
#include <mujoco/mujoco.h>
#include "experimental/platform/imgui_widgets.h"
#include "experimental/platform/plugin.h"
#include "experimental/platform/ux/imgui_widgets.h"
#include "experimental/platform/ux/plugin.h"
namespace mujoco::studio {
@@ -53,7 +53,9 @@ class ObjectLauncher {
}
}
void HandleKeyboardEvent() { if (enabled_) active_ = true; }
void HandleKeyboardEvent() {
if (enabled_) active_ = true;
}
bool UpdateSpecPreCompile(mjSpec* spec, const mjModel* model,
const mjData* data, const mjvCamera* camera) {
@@ -88,7 +90,8 @@ class ObjectLauncher {
if (!geom) return false;
ObjectInfo& object = objects_.emplace_back();
object.name = "projectile" + std::to_string(counter_++);;
object.name = "projectile" + std::to_string(counter_++);
;
object.expiration = data->time + lifetime_;
mjtNum pos[3];
@@ -12,16 +12,16 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "experimental/platform/picture_gui.h"
#include "experimental/platform/ux/picture_gui.h"
#include <cstddef>
#include <vector>
#include <imgui.h>
#include <mujoco/mujoco.h>
#include "experimental/platform/imgui_widgets.h"
#include "experimental/platform/renderer.h"
#include "experimental/platform/window.h"
#include "experimental/platform/hal/renderer.h"
#include "experimental/platform/hal/window.h"
#include "experimental/platform/ux/imgui_widgets.h"
namespace mujoco::platform {
@@ -44,7 +44,7 @@ static bool PipGuiImpl(const mjModel* model, mjData* data,
const int height = width / window->GetAspectRatio();
std::vector<std::byte> output(width * height * 3);
const int combo_width = (width-30) / 2;
const int combo_width = (width - 30) / 2;
ImGui::PushID(pip);
ImGui::SetNextItemWidth(combo_width);
@@ -12,14 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef MUJOCO_SRC_EXPERIMENTAL_PLATFORM_PICTURE_GUI_H_
#define MUJOCO_SRC_EXPERIMENTAL_PLATFORM_PICTURE_GUI_H_
#ifndef MUJOCO_SRC_EXPERIMENTAL_PLATFORM_UX_PICTURE_GUI_H_
#define MUJOCO_SRC_EXPERIMENTAL_PLATFORM_UX_PICTURE_GUI_H_
#include <vector>
#include <mujoco/mujoco.h>
#include "experimental/platform/renderer.h"
#include "experimental/platform/window.h"
#include "experimental/platform/hal/renderer.h"
#include "experimental/platform/hal/window.h"
namespace mujoco::platform {
@@ -37,4 +37,4 @@ void PipGui(const mjModel* model, mjData* data, platform::Window* window,
} // namespace mujoco::platform
#endif // MUJOCO_SRC_EXPERIMENTAL_PLATFORM_PICTURE_GUI_H_
#endif // MUJOCO_SRC_EXPERIMENTAL_PLATFORM_UX_PICTURE_GUI_H_
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "experimental/platform/plugin.h"
#include "experimental/platform/ux/plugin.h"
#include <functional>
#include <string_view>
@@ -12,10 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef MUJOCO_SRC_EXPERIMENTAL_PLATFORM_PLUGIN_H_
#define MUJOCO_SRC_EXPERIMENTAL_PLATFORM_PLUGIN_H_
#ifndef MUJOCO_SRC_EXPERIMENTAL_PLATFORM_UX_PLUGIN_H_
#define MUJOCO_SRC_EXPERIMENTAL_PLATFORM_UX_PLUGIN_H_
#include <functional>
#include <mujoco/mujoco.h>
namespace mujoco::platform {
@@ -30,7 +31,6 @@ void RegisterPlugin(T plugin);
template <typename T>
void ForEachPlugin(const std::function<void(T*)>& fn);
// Plugin for processing custom UI windows. The plugin will be listed in the
// "Plugins" main menu and, when selected, an ImGui window will be opened with
// the name of the plugin as the title. The `update` function can then be used
@@ -123,4 +123,4 @@ struct SpecEditorPlugin final {
} // namespace mujoco::platform
#endif // MUJOCO_SRC_EXPERIMENTAL_PLATFORM_PLUGIN_H_
#endif // MUJOCO_SRC_EXPERIMENTAL_PLATFORM_UX_PLUGIN_H_
@@ -12,12 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "experimental/platform/spec_editor.h"
#include "experimental/platform/ux/spec_editor.h"
#include <memory>
#include <utility>
#include <mujoco/mujoco.h>
#include "experimental/platform/model_holder.h"
#include "experimental/platform/sim/model_holder.h"
namespace mujoco::platform {
@@ -62,9 +63,7 @@ std::unique_ptr<ModelHolder> SpecEditor::Compile() {
return holder;
}
mjSpec* SpecEditor::GetActiveSpec() const {
return active_spec_.get();
}
mjSpec* SpecEditor::GetActiveSpec() const { return active_spec_.get(); }
mjsElement* SpecEditor::AddElement(mjtObj type) {
// TODO: check that type is only for spec elements.
@@ -135,7 +134,7 @@ void SpecEditor::SetActiveElement(mjsElement* element) {
int index = 0;
for (mjsElement* iter = mjs_firstElement(spec, type); iter != nullptr;
iter = mjs_nextElement(spec, iter), ++index) {
iter = mjs_nextElement(spec, iter), ++index) {
if (iter == element) {
active_element_key_ = active_map_.LookupElementKey({type, index});
if (active_element_key_ == kInvalidElementKey) {
@@ -171,13 +170,9 @@ void SpecEditor::UpdateReferenceElement() {
}
}
mjsElement* SpecEditor::GetActiveElement() const {
return active_element_;
}
mjsElement* SpecEditor::GetActiveElement() const { return active_element_; }
mjsElement* SpecEditor::GetRefElement() const {
return ref_element_;
}
mjsElement* SpecEditor::GetRefElement() const { return ref_element_; }
void SpecEditor::CommitChanges(mjsElement* element) {
if (element == nullptr) {
@@ -209,14 +204,13 @@ void SpecEditor::Undo() {
active_map_.Insert(entry.key, entry.type_index);
}
active_element_ = active_map_.Resolve(active_spec_.get(), active_element_key_);
active_element_ =
active_map_.Resolve(active_spec_.get(), active_element_key_);
UpdateReferenceElement();
}
}
bool SpecEditor::CanUndo() const {
return cursor_ > 0;
}
bool SpecEditor::CanUndo() const { return cursor_ > 0; }
void SpecEditor::Redo() {
if (CanRedo()) {
@@ -230,14 +224,13 @@ void SpecEditor::Redo() {
active_map_.Remove(entry.key);
}
active_element_ = active_map_.Resolve(active_spec_.get(), active_element_key_);
active_element_ =
active_map_.Resolve(active_spec_.get(), active_element_key_);
UpdateReferenceElement();
}
}
bool SpecEditor::CanRedo() const {
return cursor_ < history_.size() - 1;
}
bool SpecEditor::CanRedo() const { return cursor_ < history_.size() - 1; }
void SpecEditor::AppendHistory(HistoryEntry entry) {
++cursor_;
@@ -312,7 +305,8 @@ SpecEditor::SpecPtr SpecEditor::Copy(const mjSpec* spec) {
return SpecPtr(mj_copySpec(spec), mj_deleteSpec);
}
mjsElement* SpecEditor::AddElementToSpec(mjSpec* spec, mjtObj type, mjsBody* body) {
mjsElement* SpecEditor::AddElementToSpec(mjSpec* spec, mjtObj type,
mjsBody* body) {
if (spec == nullptr || type == mjOBJ_UNKNOWN) {
return nullptr;
}
@@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef MUJOCO_SRC_EXPERIMENTAL_PLATFORM_SPEC_EDITOR_H_
#define MUJOCO_SRC_EXPERIMENTAL_PLATFORM_SPEC_EDITOR_H_
#ifndef MUJOCO_SRC_EXPERIMENTAL_PLATFORM_UX_SPEC_EDITOR_H_
#define MUJOCO_SRC_EXPERIMENTAL_PLATFORM_UX_SPEC_EDITOR_H_
#include <array>
#include <cstddef>
@@ -22,7 +22,7 @@
#include <vector>
#include <mujoco/mujoco.h>
#include "experimental/platform/model_holder.h"
#include "experimental/platform/sim/model_holder.h"
namespace mujoco::platform {
@@ -139,10 +139,10 @@ class SpecEditor {
// A single entry in the history buffer.
struct HistoryEntry {
SpecPtr spec; // A full copy of a spec.
Operation op; // The operation performed on the spec.
ElementKey key; // The key of the element being modified.
TypeIndex type_index; // The type/index of the element after the change.
SpecPtr spec; // A full copy of a spec.
Operation op; // The operation performed on the spec.
ElementKey key; // The key of the element being modified.
TypeIndex type_index; // The type/index of the element after the change.
};
// Appends a new HistoryEntry to the history buffer.
@@ -174,4 +174,4 @@ class SpecEditor {
};
} // namespace mujoco::platform
#endif // MUJOCO_SRC_EXPERIMENTAL_PLATFORM_SPEC_EDITOR_H_
#endif // MUJOCO_SRC_EXPERIMENTAL_PLATFORM_UX_SPEC_EDITOR_H_
+22 -22
View File
@@ -35,19 +35,19 @@
#include <imgui.h>
#include <implot.h>
#include <mujoco/mujoco.h>
#include "experimental/platform/file_dialog.h"
#include "experimental/platform/graphics_mode.h"
#include "experimental/platform/gui.h"
#include "experimental/platform/gui_spec.h"
#include "experimental/platform/hal/graphics_mode.h"
#include "experimental/platform/hal/renderer.h"
#include "experimental/platform/hal/window.h"
#include "experimental/platform/helpers.h"
#include "experimental/platform/imgui_widgets.h"
#include "experimental/platform/interaction.h"
#include "experimental/platform/model_holder.h"
#include "experimental/platform/picture_gui.h"
#include "experimental/platform/plugin.h"
#include "experimental/platform/renderer.h"
#include "experimental/platform/step_control.h"
#include "experimental/platform/window.h"
#include "experimental/platform/sim/model_holder.h"
#include "experimental/platform/sim/step_control.h"
#include "experimental/platform/ux/file_dialog.h"
#include "experimental/platform/ux/gui.h"
#include "experimental/platform/ux/gui_spec.h"
#include "experimental/platform/ux/imgui_widgets.h"
#include "experimental/platform/ux/interaction.h"
#include "experimental/platform/ux/picture_gui.h"
#include "experimental/platform/ux/plugin.h"
namespace mujoco::studio {
@@ -727,7 +727,7 @@ void App::HandleKeyboardEvents() {
ui_.camera_idx = platform::SetCamera(model(), &camera_, ui_.camera_idx - 1);
} else if (has_model() && ImGui_IsChordJustPressed(ImGuiKey_RightBracket)) {
ui_.camera_idx = platform::SetCamera(model(), &camera_, ui_.camera_idx + 1);
// WASD camera controls for free camera.
// WASD camera controls for free camera.
} else if (is_freecam_wasd &&
(ImGui::IsKeyDown(ImGuiKey_W) || ImGui::IsKeyDown(ImGuiKey_S) ||
ImGui::IsKeyDown(ImGuiKey_A) || ImGui::IsKeyDown(ImGuiKey_D) ||
@@ -1129,8 +1129,8 @@ void App::SpecExplorerGui() {
mjsElement* element = tmp_.curr_element;
bool open = element != nullptr;
if (platform::ImGui_BeginHSplit("SpecExplorerTree",
&tmp_.explorer_split, &open)) {
if (platform::ImGui_BeginHSplit("SpecExplorerTree", &tmp_.explorer_split,
&open)) {
platform::SpecTreeGui(&element, spec());
if (element != tmp_.curr_element) {
@@ -1147,8 +1147,8 @@ void App::SpecExplorerGui() {
}
}
if (platform::ImGui_HSplit("SpecExplorerProperties",
&tmp_.explorer_split, &open)) {
if (platform::ImGui_HSplit("SpecExplorerProperties", &tmp_.explorer_split,
&open)) {
ImGui::Text("%s", mju_type2Str(tmp_.curr_element->elemtype));
ImGui::SameLine();
ImGui::Text("(%d)", mjs_getId(tmp_.curr_element));
@@ -1434,8 +1434,9 @@ void App::ToolBarGui() {
const float label_width = GetExpectedLabelWidth();
const float copy_btn_width = ImGui::CalcTextSize(ICON_COPY_CAMERA).x +
ImGui::GetStyle().FramePadding.x * 2;
const float theme_width = ImGui::CalcTextSize(platform::ICON_FA_CIRCLE_O).x +
ImGui::GetStyle().FramePadding.x * 2;
const float theme_width =
ImGui::CalcTextSize(platform::ICON_FA_CIRCLE_O).x +
ImGui::GetStyle().FramePadding.x * 2;
const float sp = ImGui::GetStyle().ItemSpacing.x;
const float right_width = label_width + sp + label_width + sp +
label_width + sp + copy_btn_width + sp +
@@ -1766,8 +1767,7 @@ void App::MainMenuGui() {
}
ImGui::Separator();
#ifdef __linux__
#ifdef __linux__
if (ImGui::BeginMenu("Graphics Mode (Experimental)")) {
std::optional<platform::GraphicsMode> mode;
if (ImGui::MenuItem(
@@ -1814,7 +1814,7 @@ void App::MainMenuGui() {
}
ImGui::EndMenu();
}
#endif // __linux__
#endif // __linux__
ImGui::EndMenu();
}
+12 -12
View File
@@ -26,18 +26,18 @@
#include <vector>
#include <mujoco/mujoco.h>
#include "experimental/platform/graphics_mode.h"
#include "experimental/platform/gui.h"
#include "experimental/platform/gui_spec.h"
#include "experimental/platform/interaction.h"
#include "experimental/platform/model_holder.h"
#include "experimental/platform/picture_gui.h"
#include "experimental/platform/renderer.h"
#include "experimental/platform/sim_history.h"
#include "experimental/platform/sim_profiler.h"
#include "experimental/platform/spec_editor.h"
#include "experimental/platform/step_control.h"
#include "experimental/platform/window.h"
#include "experimental/platform/hal/graphics_mode.h"
#include "experimental/platform/hal/renderer.h"
#include "experimental/platform/hal/window.h"
#include "experimental/platform/sim/model_holder.h"
#include "experimental/platform/sim/sim_history.h"
#include "experimental/platform/sim/sim_profiler.h"
#include "experimental/platform/sim/step_control.h"
#include "experimental/platform/ux/gui.h"
#include "experimental/platform/ux/gui_spec.h"
#include "experimental/platform/ux/interaction.h"
#include "experimental/platform/ux/picture_gui.h"
#include "experimental/platform/ux/spec_editor.h"
namespace mujoco::studio {
+1 -1
View File
@@ -26,7 +26,7 @@
#include <absl/flags/flag.h>
#include <absl/flags/parse.h>
#include <mujoco/mujoco.h>
#include "experimental/platform/graphics_mode.h"
#include "experimental/platform/hal/graphics_mode.h"
#include "experimental/studio/app.h"
ABSL_FLAG(int, window_width, 1400, "Window width");
+1 -1
View File
@@ -25,7 +25,7 @@
#include <utility>
#include <mujoco/mujoco.h>
#include "experimental/platform/graphics_mode.h"
#include "experimental/platform/hal/graphics_mode.h"
#include "experimental/studio/app.h"
// Global app instance. Lifetime is controlled by Init/Deinit calls which are