Unravel Engine C++ Reference
Loading...
Searching...
No Matches
viewport_resolution.cpp File Reference
#include "viewport_resolution.h"
#include "../hub.h"
#include <engine/rendering/ecs/components/camera_component.h>
#include <imgui/imgui.h>
#include <algorithm>

Go to the source code of this file.

Namespaces

namespace  unravel
 
namespace  unravel::viewport_resolution
 

Functions

auto unravel::viewport_resolution::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 unravel::viewport_resolution::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 dimensions in the preset). This is useful when the on-screen image rectangle must match the camera viewport (e.g. for picking and gizmos).
 
void unravel::viewport_resolution::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 is modified; viewport position is left untouched.
 
auto unravel::viewport_resolution::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). Returns nullptr if no resolutions are configured.
 
auto unravel::viewport_resolution::draw_menu (rtti::context &ctx, int &current_index) -> bool
 Draw the resolution selection drop-down for the current menu bar. The selection is read and written through the supplied index parameter. Returns true if the user changed the selection - the caller is responsible for persisting the new index if desired (e.g. project settings vs. a transient panel-local value). Adds an "Edit ..." entry that opens the project settings panel scoped to the Resolution section.