6#include <imgui/imgui.h>
27 if(res.aspect == 0.0f)
32 if(res.width > 0 && res.height > 0)
34 return ImVec2(
static_cast<float>(res.width),
static_cast<float>(res.height));
42 if(res.aspect <= 0.0f)
47 const float avail_aspect = avail_size.x / std::max(avail_size.y, 1.0f);
48 if(avail_aspect > res.aspect)
50 return ImVec2(avail_size.y * res.aspect, avail_size.y);
52 return ImVec2(avail_size.x, avail_size.x / res.aspect);
60 camera_comp.
set_viewport_size({
static_cast<std::uint32_t
>(viewport.x),
static_cast<std::uint32_t
>(viewport.y)});
71 if(resolutions.empty())
76 return &resolutions[clamp_index(
index,
static_cast<int>(resolutions.size()))];
87 if(resolutions.empty())
92 current_index = clamp_index(current_index,
static_cast<int>(resolutions.size()));
96 if(ImGui::BeginMenu(label.c_str()))
98 for(
int i = 0; i < static_cast<int>(resolutions.size()); ++i)
100 if(ImGui::RadioButton(resolutions[i].
name.c_str(), ¤t_index, i))
106 if(ImGui::MenuItem(
"Edit ...",
"",
false))
108 ctx.get_cached<
hub>().open_project_settings(ctx,
"Resolution");
112 ImGui::SetItemTooltipEx(
"%s",
"Resolution Presets");
Class that contains core camera data, used for rendering and other purposes.
void set_viewport_size(const usize32_t &size)
Sets the viewport size.
#define ICON_MDI_ARROW_DOWN_BOLD
auto compute_viewport_size(const settings::resolution_settings::resolution &res, ImVec2 avail_size) -> ImVec2
Compute the camera viewport size to use for a resolution preset.
auto get_resolution(rtti::context &ctx, int index) -> const settings::resolution_settings::resolution *
Get the resolution preset at the given index (clamped against the configured presets)....
auto compute_fitted_size(const settings::resolution_settings::resolution &res, ImVec2 avail_size) -> ImVec2
Compute a viewport size that always fits within avail_size by aspect ratio (ignoring any fixed pixel ...
void apply_to_camera(camera_component &camera_comp, const settings::resolution_settings::resolution &res, ImVec2 avail_size)
Apply the resolution preset to the camera component using compute_viewport_size. Only viewport size i...
auto draw_menu(rtti::context &ctx, int ¤t_index) -> bool
Draw the resolution selection drop-down for the current menu bar. The selection is read and written t...