RenderSettingsInspector.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. using System;
  4. using BansheeEngine;
  5. namespace BansheeEditor
  6. {
  7. /** @addtogroup Inspectors
  8. * @{
  9. */
  10. /// <summary>
  11. /// Draws GUI elements for inspecting an <see cref="AutoExposureSettings"/> object.
  12. /// </summary>
  13. internal class AutoExposureSettingsGUI
  14. {
  15. private AutoExposureSettings settings;
  16. private GUISliderField histogramLog2MinField = new GUISliderField(-16.0f, 0.0f, new LocEdString("Histogram min."));
  17. private GUISliderField histogramLog2MaxField = new GUISliderField(0.0f, 16.0f, new LocEdString("Histogram max."));
  18. private GUISliderField histogramPctLowField = new GUISliderField(0.0f, 1.0f, new LocEdString("Histogram % low"));
  19. private GUISliderField histogramPctHighField = new GUISliderField(0.0f, 1.0f, new LocEdString("Histogram % high"));
  20. private GUISliderField minEyeAdaptationField = new GUISliderField(0.0f, 10.0f, new LocEdString("Min. eye adapatation"));
  21. private GUISliderField maxEyeAdaptationField = new GUISliderField(0.0f, 10.0f, new LocEdString("Max. eye adapatation"));
  22. private GUISliderField eyeAdaptationSpeedUpField = new GUISliderField(0.01f, 20.0f, new LocEdString("Eye adaptation speed up"));
  23. private GUISliderField eyeAdaptationSpeedDownField = new GUISliderField(0.01f, 20.0f, new LocEdString("Eye adaptation speed down"));
  24. public Action<AutoExposureSettings> OnChanged;
  25. public Action OnConfirmed;
  26. /// <summary>
  27. /// Current value of the settings object.
  28. /// </summary>
  29. public AutoExposureSettings Settings
  30. {
  31. get { return settings; }
  32. set
  33. {
  34. settings = value;
  35. histogramLog2MinField.Value = value.HistogramLog2Min;
  36. histogramLog2MaxField.Value = value.HistogramLog2Max;
  37. histogramPctLowField.Value = value.HistogramPctLow;
  38. histogramPctHighField.Value = value.HistogramPctHigh;
  39. minEyeAdaptationField.Value = value.MinEyeAdaptation;
  40. maxEyeAdaptationField.Value = value.MaxEyeAdaptation;
  41. eyeAdaptationSpeedUpField.Value = value.EyeAdaptationSpeedUp;
  42. eyeAdaptationSpeedDownField.Value = value.EyeAdaptationSpeedDown;
  43. }
  44. }
  45. /// <summary>
  46. /// Constructs a new set of GUI elements for inspecting the auto exposure settings object.
  47. /// </summary>
  48. /// <param name="settings">Initial values to assign to the GUI elements.</param>
  49. /// <param name="layout">Layout to append the GUI elements to.</param>
  50. public AutoExposureSettingsGUI(AutoExposureSettings settings, GUILayout layout)
  51. {
  52. this.settings = settings;
  53. histogramLog2MinField.OnChanged += x => { this.settings.HistogramLog2Min = x; MarkAsModified(); ConfirmModify(); };
  54. histogramLog2MaxField.OnChanged += x => { this.settings.HistogramLog2Max = x; MarkAsModified(); ConfirmModify(); };
  55. histogramPctLowField.OnChanged += x => { this.settings.HistogramPctLow = x; MarkAsModified(); ConfirmModify(); };
  56. histogramPctHighField.OnChanged += x => { this.settings.HistogramPctHigh = x; MarkAsModified(); ConfirmModify(); };
  57. minEyeAdaptationField.OnChanged += x => { this.settings.MinEyeAdaptation = x; MarkAsModified(); ConfirmModify(); };
  58. maxEyeAdaptationField.OnChanged += x => { this.settings.MaxEyeAdaptation = x; MarkAsModified(); ConfirmModify(); };
  59. eyeAdaptationSpeedUpField.OnChanged += x => { this.settings.EyeAdaptationSpeedUp = x; MarkAsModified(); ConfirmModify(); };
  60. eyeAdaptationSpeedDownField.OnChanged += x => { this.settings.EyeAdaptationSpeedDown = x; MarkAsModified(); ConfirmModify(); };
  61. layout.AddElement(histogramLog2MinField);
  62. layout.AddElement(histogramLog2MaxField);
  63. layout.AddElement(histogramPctLowField);
  64. layout.AddElement(histogramPctHighField);
  65. layout.AddElement(minEyeAdaptationField);
  66. layout.AddElement(maxEyeAdaptationField);
  67. layout.AddElement(eyeAdaptationSpeedUpField);
  68. layout.AddElement(eyeAdaptationSpeedDownField);
  69. }
  70. /// <summary>
  71. /// Marks the contents of the inspector as modified.
  72. /// </summary>
  73. private void MarkAsModified()
  74. {
  75. if (OnChanged != null)
  76. OnChanged(settings);
  77. }
  78. /// <summary>
  79. /// Confirms any queued modifications.
  80. /// </summary>
  81. private void ConfirmModify()
  82. {
  83. if (OnConfirmed != null)
  84. OnConfirmed();
  85. }
  86. }
  87. /// <summary>
  88. /// Draws GUI elements for inspecting an <see cref="TonemappingSettings"/> object.
  89. /// </summary>
  90. internal class TonemappingSettingsGUI
  91. {
  92. private TonemappingSettings settings;
  93. private GUIFloatField shoulderStrengthField = new GUIFloatField(new LocEdString("Shoulder strength"));
  94. private GUIFloatField linearStrengthField = new GUIFloatField(new LocEdString("Linear strength"));
  95. private GUIFloatField linearAngleField = new GUIFloatField(new LocEdString("Linear angle"));
  96. private GUIFloatField toeStrengthField = new GUIFloatField(new LocEdString("Toe strength"));
  97. private GUIFloatField toeNumeratorField = new GUIFloatField(new LocEdString("Toe numerator"));
  98. private GUIFloatField toeDenominatorField = new GUIFloatField(new LocEdString("Toe denominator"));
  99. private GUIFloatField whitePointField = new GUIFloatField(new LocEdString("White point"));
  100. public Action<TonemappingSettings> OnChanged;
  101. public Action OnConfirmed;
  102. /// <summary>
  103. /// Current value of the settings object.
  104. /// </summary>
  105. public TonemappingSettings Settings
  106. {
  107. get { return settings; }
  108. set
  109. {
  110. settings = value;
  111. shoulderStrengthField.Value = value.FilmicCurveShoulderStrength;
  112. linearStrengthField.Value = value.FilmicCurveLinearStrength;
  113. linearAngleField.Value = value.FilmicCurveLinearAngle;
  114. toeStrengthField.Value = value.FilmicCurveToeStrength;
  115. toeNumeratorField.Value = value.FilmicCurveToeNumerator;
  116. toeDenominatorField.Value = value.FilmicCurveToeDenominator;
  117. whitePointField.Value = value.FilmicCurveLinearWhitePoint;
  118. }
  119. }
  120. /// <summary>
  121. /// Constructs a new set of GUI elements for inspecting the tone mapping settings object.
  122. /// </summary>
  123. /// <param name="settings">Initial values to assign to the GUI elements.</param>
  124. /// <param name="layout">Layout to append the GUI elements to.</param>
  125. public TonemappingSettingsGUI(TonemappingSettings settings, GUILayout layout)
  126. {
  127. this.settings = settings;
  128. shoulderStrengthField.OnChanged += x => { this.settings.FilmicCurveShoulderStrength = x; MarkAsModified(); };
  129. shoulderStrengthField.OnFocusLost += ConfirmModify;
  130. shoulderStrengthField.OnConfirmed += ConfirmModify;
  131. linearStrengthField.OnChanged += x => { this.settings.FilmicCurveLinearStrength = x; MarkAsModified(); };
  132. linearStrengthField.OnFocusLost += ConfirmModify;
  133. linearStrengthField.OnConfirmed += ConfirmModify;
  134. linearAngleField.OnChanged += x => { this.settings.FilmicCurveLinearAngle = x; MarkAsModified(); };
  135. linearAngleField.OnFocusLost += ConfirmModify;
  136. linearAngleField.OnConfirmed += ConfirmModify;
  137. toeStrengthField.OnChanged += x => { this.settings.FilmicCurveToeStrength = x; MarkAsModified(); };
  138. toeStrengthField.OnFocusLost += ConfirmModify;
  139. toeStrengthField.OnConfirmed += ConfirmModify;
  140. toeNumeratorField.OnChanged += x => { this.settings.FilmicCurveToeNumerator = x; MarkAsModified(); };
  141. toeNumeratorField.OnFocusLost += ConfirmModify;
  142. toeNumeratorField.OnConfirmed += ConfirmModify;
  143. toeDenominatorField.OnChanged += x => { this.settings.FilmicCurveToeDenominator = x; MarkAsModified(); };
  144. toeDenominatorField.OnFocusLost += ConfirmModify;
  145. toeDenominatorField.OnConfirmed += ConfirmModify;
  146. whitePointField.OnChanged += x => { this.settings.FilmicCurveLinearWhitePoint = x; MarkAsModified(); };
  147. whitePointField.OnFocusLost += ConfirmModify;
  148. whitePointField.OnConfirmed += ConfirmModify;
  149. layout.AddElement(shoulderStrengthField);
  150. layout.AddElement(linearStrengthField);
  151. layout.AddElement(linearAngleField);
  152. layout.AddElement(toeStrengthField);
  153. layout.AddElement(toeNumeratorField);
  154. layout.AddElement(toeDenominatorField);
  155. layout.AddElement(whitePointField);
  156. }
  157. /// <summary>
  158. /// Marks the contents of the inspector as modified.
  159. /// </summary>
  160. private void MarkAsModified()
  161. {
  162. if (OnChanged != null)
  163. OnChanged(settings);
  164. }
  165. /// <summary>
  166. /// Confirms any queued modifications.
  167. /// </summary>
  168. private void ConfirmModify()
  169. {
  170. if (OnConfirmed != null)
  171. OnConfirmed();
  172. }
  173. }
  174. /// <summary>
  175. /// Draws GUI elements for inspecting an <see cref="ColorGradingSettings"/> object.
  176. /// </summary>
  177. internal class ColorGradingSettingsGUI
  178. {
  179. private ColorGradingSettings settings;
  180. private GUIVector3Field saturationField = new GUIVector3Field(new LocEdString("Saturation"));
  181. private GUIVector3Field contrastField = new GUIVector3Field(new LocEdString("Contrast"));
  182. private GUIVector3Field gainField = new GUIVector3Field(new LocEdString("Gain"));
  183. private GUIVector3Field offsetField = new GUIVector3Field(new LocEdString("Offset"));
  184. public Action<ColorGradingSettings> OnChanged;
  185. public Action OnConfirmed;
  186. /// <summary>
  187. /// Current value of the settings object.
  188. /// </summary>
  189. public ColorGradingSettings Settings
  190. {
  191. get { return settings; }
  192. set
  193. {
  194. settings = value;
  195. saturationField.Value = value.Saturation;
  196. contrastField.Value = value.Contrast;
  197. gainField.Value = value.Gain;
  198. offsetField.Value = value.Offset;
  199. }
  200. }
  201. /// <summary>
  202. /// Constructs a new set of GUI elements for inspecting the color grading settings object.
  203. /// </summary>
  204. /// <param name="settings">Initial values to assign to the GUI elements.</param>
  205. /// <param name="layout">Layout to append the GUI elements to.</param>
  206. public ColorGradingSettingsGUI(ColorGradingSettings settings, GUILayout layout)
  207. {
  208. this.settings = settings;
  209. saturationField.OnChanged += x => { this.settings.Saturation = x; MarkAsModified(); };
  210. saturationField.OnFocusLost += ConfirmModify;
  211. saturationField.OnConfirmed += ConfirmModify;
  212. contrastField.OnChanged += x => { this.settings.Contrast = x; MarkAsModified(); };
  213. contrastField.OnFocusLost += ConfirmModify;
  214. contrastField.OnConfirmed += ConfirmModify;
  215. gainField.OnChanged += x => { this.settings.Gain = x; MarkAsModified(); };
  216. gainField.OnFocusLost += ConfirmModify;
  217. gainField.OnConfirmed += ConfirmModify;
  218. offsetField.OnChanged += x => { this.settings.Offset = x; MarkAsModified(); };
  219. offsetField.OnFocusLost += ConfirmModify;
  220. offsetField.OnConfirmed += ConfirmModify;
  221. layout.AddElement(saturationField);
  222. layout.AddElement(contrastField);
  223. layout.AddElement(gainField);
  224. layout.AddElement(offsetField);
  225. }
  226. /// <summary>
  227. /// Marks the contents of the inspector as modified.
  228. /// </summary>
  229. private void MarkAsModified()
  230. {
  231. if (OnChanged != null)
  232. OnChanged(settings);
  233. }
  234. /// <summary>
  235. /// Confirms any queued modifications.
  236. /// </summary>
  237. private void ConfirmModify()
  238. {
  239. if (OnConfirmed != null)
  240. OnConfirmed();
  241. }
  242. }
  243. /// <summary>
  244. /// Draws GUI elements for inspecting an <see cref="WhiteBalanceSettings"/> object.
  245. /// </summary>
  246. internal class WhiteBalanceSettingsGUI
  247. {
  248. private WhiteBalanceSettings settings;
  249. private GUISliderField temperatureField = new GUISliderField(1500.0f, 15000.0f, new LocEdString("Temperature"));
  250. private GUISliderField tintField = new GUISliderField(-1.0f, 1.0f, new LocEdString("Tint"));
  251. public Action<WhiteBalanceSettings> OnChanged;
  252. public Action OnConfirmed;
  253. /// <summary>
  254. /// Current value of the settings object.
  255. /// </summary>
  256. public WhiteBalanceSettings Settings
  257. {
  258. get { return settings; }
  259. set
  260. {
  261. settings = value;
  262. temperatureField.Value = value.Temperature;
  263. tintField.Value = value.Tint;
  264. }
  265. }
  266. /// <summary>
  267. /// Constructs a new set of GUI elements for inspecting the white balance settings object.
  268. /// </summary>
  269. /// <param name="settings">Initial values to assign to the GUI elements.</param>
  270. /// <param name="layout">Layout to append the GUI elements to.</param>
  271. public WhiteBalanceSettingsGUI(WhiteBalanceSettings settings, GUILayout layout)
  272. {
  273. this.settings = settings;
  274. temperatureField.OnChanged += x => { this.settings.Temperature = x; MarkAsModified(); ConfirmModify(); };
  275. tintField.OnChanged += x => { this.settings.Tint = x; MarkAsModified(); ConfirmModify(); };
  276. layout.AddElement(temperatureField);
  277. layout.AddElement(tintField);
  278. }
  279. /// <summary>
  280. /// Marks the contents of the inspector as modified.
  281. /// </summary>
  282. private void MarkAsModified()
  283. {
  284. if (OnChanged != null)
  285. OnChanged(settings);
  286. }
  287. /// <summary>
  288. /// Confirms any queued modifications.
  289. /// </summary>
  290. private void ConfirmModify()
  291. {
  292. if (OnConfirmed != null)
  293. OnConfirmed();
  294. }
  295. }
  296. /// <summary>
  297. /// Draws GUI elements for inspecting an <see cref="RenderSettings"/> object.
  298. /// </summary>
  299. internal class RenderSettingsGUI
  300. {
  301. private RenderSettings settings;
  302. private SerializableProperties properties;
  303. private GUIToggleField enableHDRField = new GUIToggleField(new LocEdString("Enable HDR"));
  304. private GUIToggleField enableLightingField = new GUIToggleField(new LocEdString("Enable lighting"));
  305. private GUIToggleField enableShadowsField = new GUIToggleField(new LocEdString("Enable shadows"));
  306. private GUIToggleField overlayOnlyField = new GUIToggleField(new LocEdString("Overlay only"));
  307. private GUIToggleField enableAutoExposureField = new GUIToggleField(new LocEdString("Enable auto exposure"));
  308. private GUIToggle autoExposureFoldout = new GUIToggle(new LocEdString("Auto exposure"), EditorStyles.Foldout);
  309. private AutoExposureSettingsGUI autoExposureGUI;
  310. private GUIToggleField enableToneMappingField = new GUIToggleField(new LocEdString("Enable tone mapping"));
  311. private GUIToggle toneMappingFoldout = new GUIToggle(new LocEdString("Tone mapping"), EditorStyles.Foldout);
  312. private TonemappingSettingsGUI toneMappingGUI;
  313. private GUIToggle whiteBalanceFoldout = new GUIToggle(new LocEdString("White balance"), EditorStyles.Foldout);
  314. private WhiteBalanceSettingsGUI whiteBalanceGUI;
  315. private GUIToggle colorGradingFoldout = new GUIToggle(new LocEdString("Color grading"), EditorStyles.Foldout);
  316. private ColorGradingSettingsGUI colorGradingGUI;
  317. private GUISliderField gammaField = new GUISliderField(1.0f, 3.0f, new LocEdString("Gamma"));
  318. private GUISliderField exposureScaleField = new GUISliderField(-8.0f, 8.0f, new LocEdString("Exposure scale"));
  319. private GUILayout autoExposureLayout;
  320. private GUILayout toneMappingLayout;
  321. private GUILayout whiteBalanceLayout;
  322. private GUILayout colorGradingLayout;
  323. public Action<RenderSettings> OnChanged;
  324. public Action OnConfirmed;
  325. /// <summary>
  326. /// Current value of the settings object.
  327. /// </summary>
  328. public RenderSettings Settings
  329. {
  330. get { return settings; }
  331. set
  332. {
  333. settings = value;
  334. enableAutoExposureField.Value = value.EnableAutoExposure;
  335. autoExposureGUI.Settings = value.AutoExposure;
  336. enableToneMappingField.Value = value.EnableTonemapping;
  337. toneMappingGUI.Settings = value.Tonemapping;
  338. whiteBalanceGUI.Settings = value.WhiteBalance;
  339. colorGradingGUI.Settings = value.ColorGrading;
  340. gammaField.Value = value.Gamma;
  341. exposureScaleField.Value = value.ExposureScale;
  342. enableHDRField.Value = value.EnableHDR;
  343. enableLightingField.Value = value.EnableLighting;
  344. enableShadowsField.Value = value.EnableShadows;
  345. overlayOnlyField.Value = value.OverlayOnly;
  346. }
  347. }
  348. /// <summary>
  349. /// Constructs a new set of GUI elements for inspecting the post process settings object.
  350. /// </summary>
  351. /// <param name="settings">Initial values to assign to the GUI elements.</param>
  352. /// <param name="layout">Layout to append the GUI elements to.</param>
  353. /// <param name="properties">A set of properties that are persisted by the parent inspector. Used for saving state.
  354. /// </param>
  355. public RenderSettingsGUI(RenderSettings settings, GUILayout layout, SerializableProperties properties)
  356. {
  357. this.settings = settings;
  358. this.properties = properties;
  359. // Enable HDR
  360. enableHDRField.OnChanged += x => { this.settings.EnableHDR = x; MarkAsModified(); ConfirmModify(); };
  361. layout.AddElement(enableHDRField);
  362. // Enable lighting
  363. enableLightingField.OnChanged += x => { this.settings.EnableLighting = x; MarkAsModified(); ConfirmModify(); };
  364. layout.AddElement(enableLightingField);
  365. // Enable shadows
  366. enableShadowsField.OnChanged += x => { this.settings.EnableShadows = x; MarkAsModified(); ConfirmModify(); };
  367. layout.AddElement(enableShadowsField);
  368. // Overlay only
  369. overlayOnlyField.OnChanged += x => { this.settings.OverlayOnly = x; MarkAsModified(); ConfirmModify(); };
  370. layout.AddElement(overlayOnlyField);
  371. // Auto exposure
  372. enableAutoExposureField.OnChanged += x => { this.settings.EnableAutoExposure = x; MarkAsModified(); ConfirmModify(); };
  373. layout.AddElement(enableAutoExposureField);
  374. autoExposureFoldout.OnToggled += x =>
  375. {
  376. properties.SetBool("autoExposure_Expanded", x);
  377. ToggleFoldoutFields();
  378. };
  379. layout.AddElement(autoExposureFoldout);
  380. autoExposureLayout = layout.AddLayoutX();
  381. {
  382. autoExposureLayout.AddSpace(10);
  383. GUILayoutY contentsLayout = autoExposureLayout.AddLayoutY();
  384. autoExposureGUI = new AutoExposureSettingsGUI(settings.AutoExposure, contentsLayout);
  385. autoExposureGUI.OnChanged += x => { this.settings.AutoExposure = x; MarkAsModified(); };
  386. autoExposureGUI.OnConfirmed += ConfirmModify;
  387. }
  388. // Tonemapping
  389. enableToneMappingField.OnChanged += x => { this.settings.EnableTonemapping = x; MarkAsModified(); ConfirmModify(); };
  390. layout.AddElement(enableToneMappingField);
  391. //// Tonemapping settings
  392. toneMappingFoldout.OnToggled += x =>
  393. {
  394. properties.SetBool("toneMapping_Expanded", x);
  395. ToggleFoldoutFields();
  396. };
  397. layout.AddElement(toneMappingFoldout);
  398. toneMappingLayout = layout.AddLayoutX();
  399. {
  400. toneMappingLayout.AddSpace(10);
  401. GUILayoutY contentsLayout = toneMappingLayout.AddLayoutY();
  402. toneMappingGUI = new TonemappingSettingsGUI(settings.Tonemapping, contentsLayout);
  403. toneMappingGUI.OnChanged += x => { this.settings.Tonemapping = x; MarkAsModified(); };
  404. toneMappingGUI.OnConfirmed += ConfirmModify;
  405. }
  406. //// White balance settings
  407. whiteBalanceFoldout.OnToggled += x =>
  408. {
  409. properties.SetBool("whiteBalance_Expanded", x);
  410. ToggleFoldoutFields();
  411. };
  412. layout.AddElement(whiteBalanceFoldout);
  413. whiteBalanceLayout = layout.AddLayoutX();
  414. {
  415. whiteBalanceLayout.AddSpace(10);
  416. GUILayoutY contentsLayout = whiteBalanceLayout.AddLayoutY();
  417. whiteBalanceGUI = new WhiteBalanceSettingsGUI(settings.WhiteBalance, contentsLayout);
  418. whiteBalanceGUI.OnChanged += x => { this.settings.WhiteBalance = x; MarkAsModified(); };
  419. whiteBalanceGUI.OnConfirmed += ConfirmModify;
  420. }
  421. //// Color grading settings
  422. colorGradingFoldout.OnToggled += x =>
  423. {
  424. properties.SetBool("colorGrading_Expanded", x);
  425. ToggleFoldoutFields();
  426. };
  427. layout.AddElement(colorGradingFoldout);
  428. colorGradingLayout = layout.AddLayoutX();
  429. {
  430. colorGradingLayout.AddSpace(10);
  431. GUILayoutY contentsLayout = colorGradingLayout.AddLayoutY();
  432. colorGradingGUI = new ColorGradingSettingsGUI(settings.ColorGrading, contentsLayout);
  433. colorGradingGUI.OnChanged += x => { this.settings.ColorGrading = x; MarkAsModified(); };
  434. colorGradingGUI.OnConfirmed += ConfirmModify;
  435. }
  436. // Gamma
  437. gammaField.OnChanged += x => { this.settings.Gamma = x; MarkAsModified(); ConfirmModify(); };
  438. layout.AddElement(gammaField);
  439. // Exposure scale
  440. exposureScaleField.OnChanged += x => { this.settings.ExposureScale = x; MarkAsModified(); ConfirmModify(); };
  441. layout.AddElement(exposureScaleField);
  442. ToggleFoldoutFields();
  443. }
  444. /// <summary>
  445. /// Marks the contents of the inspector as modified.
  446. /// </summary>
  447. private void MarkAsModified()
  448. {
  449. if (OnChanged != null)
  450. OnChanged(settings);
  451. }
  452. /// <summary>
  453. /// Confirms any queued modifications.
  454. /// </summary>
  455. private void ConfirmModify()
  456. {
  457. if (OnConfirmed != null)
  458. OnConfirmed();
  459. }
  460. /// <summary>
  461. /// Hides or shows settings property GUI elements depending on set values.
  462. /// </summary>
  463. private void ToggleFoldoutFields()
  464. {
  465. autoExposureLayout.Active = properties.GetBool("autoExposure_Expanded");
  466. toneMappingLayout.Active = properties.GetBool("toneMapping_Expanded");
  467. whiteBalanceLayout.Active = properties.GetBool("whiteBalance_Expanded");
  468. colorGradingLayout.Active = properties.GetBool("colorGrading_Expanded");
  469. }
  470. }
  471. /** @} */
  472. }