Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update video fit options #12037

Merged
merged 1 commit into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 29 additions & 10 deletions src/FlightDisplay/FlightDisplayViewVideo.qml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ Item {
property bool _hasZoom: _camera && _camera.hasZoom
property int _fitMode: QGroundControl.settingsManager.videoSettings.videoFit.rawValue

property bool _isMode_FIT_WIDTH: _fitMode === 0
property bool _isMode_FIT_HEIGHT: _fitMode === 1
property bool _isMode_FILL: _fitMode === 2
property bool _isMode_NO_CROP: _fitMode === 3

function getWidth() {
return videoBackground.getWidth()
}
Expand Down Expand Up @@ -79,20 +84,34 @@ Item {
color: "black"
visible: QGroundControl.videoManager.decoding
function getWidth() {
//-- Fit Width or Stretch
if(_fitMode === 0 || _fitMode === 2) {
return parent.width
if(_ar != 0.0){
if(_isMode_FIT_HEIGHT
|| (_isMode_FILL && (root.width/root.height < _ar))
|| (_isMode_NO_CROP && (root.width/root.height > _ar))){
// This return value has different implications depending on the mode
// For FIT_HEIGHT and FILL
// makes so the video width will be larger than (or equal to) the screen width
// For NO_CROP Mode
// makes so the video width will be smaller than (or equal to) the screen width
return root.height * _ar
}
}
//-- Fit Height
return _ar != 0.0 ? parent.height * _ar : parent.width
return root.width
}
function getHeight() {
//-- Fit Height or Stretch
if(_fitMode === 1 || _fitMode === 2) {
return parent.height
if(_ar != 0.0){
if(_isMode_FIT_WIDTH
|| (_isMode_FILL && (root.width/root.height > _ar))
|| (_isMode_NO_CROP && (root.width/root.height < _ar))){
// This return value has different implications depending on the mode
// For FIT_WIDTH and FILL
// makes so the video height will be larger than (or equal to) the screen height
// For NO_CROP Mode
// makes so the video height will be smaller than (or equal to) the screen height
return root.width * (1 / _ar)
}
}
//-- Fit Width
return _ar != 0.0 ? parent.width * (1 / _ar) : parent.height
return root.height
}
Component {
id: videoBackgroundComponent
Expand Down
4 changes: 2 additions & 2 deletions src/Settings/Video.SettingsGroup.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
"shortDesc": "Video Display Fit",
"longDesc": "Handle Video Aspect Ratio.",
"type": "uint32",
"enumStrings": "Fit Width,Fit Height,Stretch",
"enumValues": "0,1,2",
"enumStrings": "Fit Width,Fit Height,Fill,No Crop",
"enumValues": "0,1,2,3",
"default": 1
},
{
Expand Down
Loading