diff --git a/radiant/ui/lightinspector/LightInspector.cpp b/radiant/ui/lightinspector/LightInspector.cpp index c2ba916b75..0c6094b6a6 100644 --- a/radiant/ui/lightinspector/LightInspector.cpp +++ b/radiant/ui/lightinspector/LightInspector.cpp @@ -150,11 +150,26 @@ void LightInspector::setupOptionsPanel() findNamedObject(this, "LightInspectorColour")->Bind( wxEVT_COLOURPICKER_CHANGED, &LightInspector::_onColourChange, this ); - _brightnessSlider->Bind( - wxEVT_SLIDER, [=](wxCommandEvent&) { adjustBrightness(); } + _brightnessSlider->Bind( // drag in progress + wxEVT_SCROLL_THUMBTRACK, + [=](wxScrollEvent&) { + if (!_adjustingBrightness && !GlobalUndoSystem().operationStarted()) + { + GlobalUndoSystem().start(); + _adjustingBrightness = true; + } + adjustBrightness(); + } ); - _brightnessSlider->Bind( - wxEVT_SCROLL_CHANGED, [=](wxScrollEvent&) { updateColourPicker(); } + _brightnessSlider->Bind( // drag finished + wxEVT_SCROLL_CHANGED, + [=](wxScrollEvent&) { + if (_adjustingBrightness) { + GlobalUndoSystem().finish("Adjust light brightness"); + _adjustingBrightness = false; + } + updateColourPicker(); + } ); findNamedObject(this, "LightInspectorParallel")->Bind(wxEVT_CHECKBOX, &LightInspector::_onOptionsToggle, this); diff --git a/radiant/ui/lightinspector/LightInspector.h b/radiant/ui/lightinspector/LightInspector.h index 5c096db4e5..a4035fccd6 100644 --- a/radiant/ui/lightinspector/LightInspector.h +++ b/radiant/ui/lightinspector/LightInspector.h @@ -48,6 +48,10 @@ class LightInspector : // Disables callbacks if set to TRUE (during widget updates) bool _updateActive; + // Track if a brightness adjustment is in progress (which needs an undo + // command when finished) + bool _adjustingBrightness = false; + bool _supportsAiSee; sigc::connection _selectionChanged;