@@ -3443,66 +3443,51 @@ render_target *render_manager::target_by_index(int index) const
34433443// fonts
34443444// -------------------------------------------------
34453445
3446- float render_manager::ui_aspect (render_container *rc )
3446+ float render_manager::ui_aspect (render_target &target )
34473447{
3448- // work out if this is a UI container
3449- render_target *target = nullptr ;
3450- if (!rc)
3451- {
3452- target = &ui_target ();
3453- rc = target->ui_container ();
3454- assert (rc);
3455- }
3456- else
3457- {
3458- for (render_target &t : m_targetlist)
3459- {
3460- if (t.ui_container () == rc)
3461- {
3462- target = &t;
3463- break ;
3464- }
3465- }
3466- }
3448+ assert (target.ui_container ());
34673449
3450+ // based on the orientation of the target, compute height/width or width/height
3451+ int const orient = orientation_add (target.orientation (), target.ui_container ()->orientation ());
34683452 float aspect;
3453+ if (!(orient & ORIENTATION_SWAP_XY ))
3454+ aspect = float (target.height ()) / float (target.width ());
3455+ else
3456+ aspect = float (target.width ()) / float (target.height ());
34693457
3470- if (target)
3458+ // if we have a valid pixel aspect, apply that and return
3459+ if (target.pixel_aspect () != 0 .0F )
34713460 {
3472- // UI container, aggregated multi-screen target
3461+ float pixel_aspect = target. pixel_aspect ();
34733462
3474- // based on the orientation of the target, compute height/width or width/height
3475- int const orient = orientation_add (target->orientation (), rc->orientation ());
3476- if (!(orient & ORIENTATION_SWAP_XY ))
3477- aspect = float (target->height ()) / float (target->width ());
3478- else
3479- aspect = float (target->width ()) / float (target->height ());
3463+ if (orient & ORIENTATION_SWAP_XY )
3464+ pixel_aspect = 1 .0F / pixel_aspect;
34803465
3481- // if we have a valid pixel aspect, apply that and return
3482- if (target->pixel_aspect () != 0 .0f )
3483- {
3484- float pixel_aspect = target->pixel_aspect ();
3466+ return aspect / pixel_aspect;
3467+ }
34853468
3486- if (orient & ORIENTATION_SWAP_XY )
3487- pixel_aspect = 1 .0f / pixel_aspect;
3469+ // clamp for extreme proportions
3470+ return std::clamp (aspect, 0 .66F , 1 .5F );
3471+ }
34883472
3489- return aspect /= pixel_aspect;
3490- }
3491- }
3492- else
3473+ float render_manager::ui_aspect (render_container &rc)
3474+ {
3475+ // deal with UI containers
3476+ for (render_target &target : m_targetlist)
34933477 {
3494- // single screen container
3495-
3496- // based on the orientation of the target, compute height/width or width/height
3497- int const orient = rc->orientation ();
3498- if (!(orient & ORIENTATION_SWAP_XY ))
3499- aspect = (float )rc->screen ()->visible_area ().height () / (float )rc->screen ()->visible_area ().width ();
3500- else
3501- aspect = (float )rc->screen ()->visible_area ().width () / (float )rc->screen ()->visible_area ().height ();
3478+ if (target.ui_container () == &rc)
3479+ return ui_aspect (target);
35023480 }
35033481
3482+ // based on the orientation of the target, compute height/width or width/height
3483+ assert (rc.screen ());
3484+ int const orient = rc.orientation ();
3485+ float const viswidth = rc.screen ()->visible_area ().width ();
3486+ float const visheight = rc.screen ()->visible_area ().height ();
3487+ float const aspect = !(orient & ORIENTATION_SWAP_XY ) ? (visheight / viswidth) : (viswidth / visheight);
3488+
35043489 // clamp for extreme proportions
3505- return std::clamp (aspect, 0 .66f , 1 .5f );
3490+ return std::clamp (aspect, 0 .66F , 1 .5F );
35063491}
35073492
35083493
0 commit comments