MCPcopy Create free account
hub / github.com/WarmUpTill/SceneSwitcher / CreateRationalFPS

Function CreateRationalFPS

plugins/scripting/utils/properties-view.cpp:1272–1324  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1270}
1271
1272static QWidget *CreateRationalFPS(OBSFrameRatePropertyWidget *fpsProps,
1273 bool &selected,
1274 const media_frames_per_second *current_fps)
1275{
1276 auto widget = new QWidget{};
1277 widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
1278
1279 auto layout = new QFormLayout{};
1280 layout->setContentsMargins(0, 0, 0, 0);
1281 layout->setSpacing(4);
1282
1283 auto str = QTStr("Basic.PropertiesView.FPS.ValidFPSRanges");
1284 auto rlabel = new QLabel{str};
1285
1286 auto combo = fpsProps->fpsRange = new QComboBox();
1287 auto convert_fps = media_frames_per_second_to_fps;
1288 //auto convert_fi = media_frames_per_second_to_frame_interval;
1289
1290 for (size_t i = 0; i < fpsProps->fps_ranges.size(); i++) {
1291 auto &pair = fpsProps->fps_ranges[i];
1292 combo->addItem(QString{"%1 - %2"}
1293 .arg(convert_fps(pair.first))
1294 .arg(convert_fps(pair.second)),
1295 QVariant::fromValue(i));
1296
1297 media_frames_per_second match;
1298 if (!current_fps || !matches_range(match, *current_fps, pair))
1299 continue;
1300
1301 combo->setCurrentIndex(combo->count() - 1);
1302 selected = true;
1303 }
1304
1305 layout->addRow(rlabel, combo);
1306
1307 auto num_edit = fpsProps->numEdit = new SpinBoxIgnoreScroll{};
1308 auto den_edit = fpsProps->denEdit = new SpinBoxIgnoreScroll{};
1309
1310 num_edit->setRange(0, INT_MAX);
1311 den_edit->setRange(0, INT_MAX);
1312
1313 if (current_fps) {
1314 num_edit->setValue(current_fps->numerator);
1315 den_edit->setValue(current_fps->denominator);
1316 }
1317
1318 layout->addRow(QTStr("Basic.Settings.Video.Numerator"), num_edit);
1319 layout->addRow(QTStr("Basic.Settings.Video.Denominator"), den_edit);
1320
1321 widget->setLayout(layout);
1322
1323 return widget;
1324}
1325
1326static OBSFrameRatePropertyWidget *
1327CreateFrameRateWidget(obs_property_t *prop, bool &warning, const char *option,

Callers

nothing calls this directly

Calls 5

matches_rangeFunction · 0.85
sizeMethod · 0.80
countMethod · 0.80
addRowMethod · 0.80
setValueMethod · 0.45

Tested by

no test coverage detected