Unravel Engine C++ Reference
Loading...
Searching...
No Matches
unravel::viewport_resolution Namespace Reference

Functions

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 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 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 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 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.
 

Function Documentation

◆ apply_to_camera()

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.

Definition at line 55 of file viewport_resolution.cpp.

◆ compute_fitted_size()

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).

Definition at line 40 of file viewport_resolution.cpp.

◆ compute_viewport_size()

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.

  • Free aspect (aspect == 0): returns avail_size unchanged.
  • Fixed resolution (width > 0 && height > 0): returns the exact pixel dimensions configured in the preset.
  • Aspect-only (aspect > 0, no fixed pixels): fits the aspect ratio inside avail_size.

Definition at line 25 of file viewport_resolution.cpp.

◆ draw_menu()

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.

Definition at line 79 of file viewport_resolution.cpp.

◆ get_resolution()

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.

Definition at line 63 of file viewport_resolution.cpp.