mirror of
https://github.com/ocornut/imgui.git
synced 2025-02-02 20:47:23 +01:00
Drags, Sliders: store initial value on activation, as a convenience for some mods. (#8223)
This commit is contained in:
parent
4ad5496474
commit
8237ab450e
@ -3927,6 +3927,7 @@ ImGuiContext::ImGuiContext(ImFontAtlas* shared_font_atlas)
|
|||||||
ActiveIdPreviousFrameIsAlive = false;
|
ActiveIdPreviousFrameIsAlive = false;
|
||||||
ActiveIdPreviousFrameHasBeenEditedBefore = false;
|
ActiveIdPreviousFrameHasBeenEditedBefore = false;
|
||||||
ActiveIdPreviousFrameWindow = NULL;
|
ActiveIdPreviousFrameWindow = NULL;
|
||||||
|
memset(&ActiveIdValueOnActivation, 0, sizeof(ActiveIdValueOnActivation));
|
||||||
LastActiveId = 0;
|
LastActiveId = 0;
|
||||||
LastActiveIdTimer = 0.0f;
|
LastActiveIdTimer = 0.0f;
|
||||||
|
|
||||||
|
@ -2109,6 +2109,7 @@ struct ImGuiContext
|
|||||||
bool ActiveIdPreviousFrameIsAlive;
|
bool ActiveIdPreviousFrameIsAlive;
|
||||||
bool ActiveIdPreviousFrameHasBeenEditedBefore;
|
bool ActiveIdPreviousFrameHasBeenEditedBefore;
|
||||||
ImGuiWindow* ActiveIdPreviousFrameWindow;
|
ImGuiWindow* ActiveIdPreviousFrameWindow;
|
||||||
|
ImGuiDataTypeStorage ActiveIdValueOnActivation; // Backup of initial value at the time of activation. ONLY SET BY SPECIFIC WIDGETS: DragXXX and SliderXXX.
|
||||||
ImGuiID LastActiveId; // Store the last non-zero ActiveId, useful for animation.
|
ImGuiID LastActiveId; // Store the last non-zero ActiveId, useful for animation.
|
||||||
float LastActiveIdTimer; // Store the last non-zero ActiveId timer since the beginning of activation, useful for animation.
|
float LastActiveIdTimer; // Store the last non-zero ActiveId timer since the beginning of activation, useful for animation.
|
||||||
|
|
||||||
|
@ -2632,6 +2632,10 @@ bool ImGui::DragScalar(const char* label, ImGuiDataType data_type, void* p_data,
|
|||||||
temp_input_is_active = true;
|
temp_input_is_active = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Store initial value (not used by main lib but available as a convenience but some mods e.g. to revert)
|
||||||
|
if (make_active)
|
||||||
|
memcpy(&g.ActiveIdValueOnActivation, p_data, DataTypeGetInfo(data_type)->Size);
|
||||||
|
|
||||||
if (make_active && !temp_input_is_active)
|
if (make_active && !temp_input_is_active)
|
||||||
{
|
{
|
||||||
SetActiveID(id, window);
|
SetActiveID(id, window);
|
||||||
@ -3222,6 +3226,10 @@ bool ImGui::SliderScalar(const char* label, ImGuiDataType data_type, void* p_dat
|
|||||||
if ((clicked && g.IO.KeyCtrl) || (g.NavActivateId == id && (g.NavActivateFlags & ImGuiActivateFlags_PreferInput)))
|
if ((clicked && g.IO.KeyCtrl) || (g.NavActivateId == id && (g.NavActivateFlags & ImGuiActivateFlags_PreferInput)))
|
||||||
temp_input_is_active = true;
|
temp_input_is_active = true;
|
||||||
|
|
||||||
|
// Store initial value (not used by main lib but available as a convenience but some mods e.g. to revert)
|
||||||
|
if (make_active)
|
||||||
|
memcpy(&g.ActiveIdValueOnActivation, p_data, DataTypeGetInfo(data_type)->Size);
|
||||||
|
|
||||||
if (make_active && !temp_input_is_active)
|
if (make_active && !temp_input_is_active)
|
||||||
{
|
{
|
||||||
SetActiveID(id, window);
|
SetActiveID(id, window);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user