video.cpp 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. VideoSettings::VideoSettings(View* parent) : PanelItem(parent, Size{~0, ~0}) {
  2. setCollapsible().setVisible(false);
  3. driverHeader.setText("Video Driver").setFont(Font().setBold());
  4. driverLabel.setText("Driver:");
  5. for(auto& driver : Video::hasDrivers()) {
  6. ComboButtonItem item{&driverOption};
  7. item.setText(driver);
  8. if(driver == settings.video.driver) item.setSelected();
  9. }
  10. changeButton.setText("Change").onActivate([&] { eventChange(); });
  11. settingsHeader.setText("Driver Settings").setFont(Font().setBold());
  12. monitorLabel.setText("Monitor:");
  13. monitorOption.append(ComboButtonItem().setText(settings.video.monitor)).onChange([&] {
  14. settings.video.monitor = monitorOption.selected().text();
  15. refresh();
  16. });
  17. formatLabel.setText("Format:");
  18. formatOption.append(ComboButtonItem().setText(settings.video.format)).onChange([&] {
  19. settings.video.format = formatOption.selected().text();
  20. refresh();
  21. });
  22. exclusiveOption.setText("Exclusive").setChecked(settings.video.exclusive).onToggle([&] {
  23. settings.video.exclusive = exclusiveOption.checked();
  24. refresh();
  25. });
  26. blockingOption.setText("Blocking").setChecked(settings.video.blocking).onToggle([&] {
  27. settings.video.blocking = blockingOption.checked();
  28. refresh();
  29. });
  30. flushOption.setText("Flush").setChecked(settings.video.flush).onToggle([&] {
  31. settings.video.flush = flushOption.checked();
  32. refresh();
  33. });
  34. colorHeader.setText("Color Adjustment").setFont(Font().setBold());
  35. colorLayout.setSize({3, 3});
  36. colorLayout.column(0).setAlignment(1.0);
  37. luminanceLabel.setText("Luminance:");
  38. luminanceValue.setAlignment(0.5);
  39. luminanceSlider.setLength(101).setPosition(settings.video.luminance * 100.0).onChange([&] {
  40. settings.video.luminance = luminanceSlider.position() / 100.0;
  41. luminanceValue.setText({luminanceSlider.position(), "%"});
  42. emulator.videoUpdateColors();
  43. }).doChange();
  44. saturationLabel.setText("Saturation:");
  45. saturationValue.setAlignment(0.5);
  46. saturationSlider.setLength(201).setPosition(settings.video.saturation * 100.0).onChange([&] {
  47. settings.video.saturation = saturationSlider.position() / 100.0;
  48. saturationValue.setText({saturationSlider.position(), "%"});
  49. emulator.videoUpdateColors();
  50. }).doChange();
  51. gammaLabel.setText("Gamma:");
  52. gammaValue.setAlignment(0.5);
  53. gammaSlider.setLength(101).setPosition((settings.video.gamma - 1.0) * 100.0).onChange([&] {
  54. settings.video.gamma = 1.0 + gammaSlider.position() / 100.0;
  55. gammaValue.setText({100 + gammaSlider.position(), "%"});
  56. emulator.videoUpdateColors();
  57. }).doChange();
  58. viewport.setVisible(false);
  59. }
  60. auto VideoSettings::show() -> void {
  61. setVisible(true);
  62. }
  63. auto VideoSettings::hide() -> void {
  64. setVisible(false);
  65. }
  66. auto VideoSettings::refresh() -> void {
  67. emulator.videoUpdate();
  68. monitorOption.reset();
  69. for(auto& monitor : Video::hasMonitors()) {
  70. ComboButtonItem item{&monitorOption};
  71. item.setText(monitor.name);
  72. if(monitor.name == settings.video.monitor) item.setSelected();
  73. }
  74. monitorOption.setEnabled(monitorOption.itemCount() > 1);
  75. formatOption.reset();
  76. for(auto& format : videoInstance.hasFormats()) {
  77. ComboButtonItem item{&formatOption};
  78. item.setText(format);
  79. if(format == settings.video.format) item.setSelected();
  80. }
  81. //formatOption.setEnabled(formatOption.itemCount() > 1);
  82. //temporarily disabled; Emulator::Node::Sprite needs to be able to handle non-ARGB8888 formats first.
  83. formatOption.setEnabled(false);
  84. optionsLayout.resize();
  85. exclusiveOption.setEnabled(videoInstance.hasExclusive()).setChecked(videoInstance.exclusive());
  86. blockingOption.setEnabled(videoInstance.hasBlocking()).setChecked(videoInstance.blocking());
  87. flushOption.setEnabled(videoInstance.hasFlush()).setChecked(videoInstance.flush());
  88. }
  89. auto VideoSettings::eventChange() -> void {
  90. settings.video.driver = driverOption.selected().text();
  91. refresh();
  92. driverHeader.setText({"Video Driver (", settings.video.driver, ")"});
  93. settingsLayout.setEnabled(true);
  94. }