GUI: add functions to inhibit inertial scrolling
This commit is contained in:
parent
bb5b99ec96
commit
6b34b9fcab
25
extern/imgui_patched/imgui.cpp
vendored
25
extern/imgui_patched/imgui.cpp
vendored
|
@ -3447,6 +3447,15 @@ void ImGui::SetActiveID(ImGuiID id, ImGuiWindow* window)
|
||||||
{
|
{
|
||||||
g.ActiveIdIsAlive = id;
|
g.ActiveIdIsAlive = id;
|
||||||
g.ActiveIdSource = (g.NavActivateId == id || g.NavActivateInputId == id || g.NavJustMovedToId == id) ? (ImGuiInputSource)ImGuiInputSource_Nav : ImGuiInputSource_Mouse;
|
g.ActiveIdSource = (g.NavActivateId == id || g.NavActivateInputId == id || g.NavJustMovedToId == id) ? (ImGuiInputSource)ImGuiInputSource_Nav : ImGuiInputSource_Mouse;
|
||||||
|
// TODO: check whether this works
|
||||||
|
if (g.LastItemData.InFlags & ImGuiItemFlags_NoInertialScroll) {
|
||||||
|
if (window) {
|
||||||
|
window->InertialScrollInhibited=true;
|
||||||
|
printf("inhibiting scroll\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (window) window->InertialScrollInhibited=false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear declaration of inputs claimed by the widget
|
// Clear declaration of inputs claimed by the widget
|
||||||
|
@ -6923,7 +6932,8 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||||
if ((g.NavWindowingTarget ? g.NavWindowingTarget : g.NavWindow) == window) {
|
if ((g.NavWindowingTarget ? g.NavWindowingTarget : g.NavWindow) == window) {
|
||||||
if ((g.IO.MouseDown[ImGuiMouseButton_Left] || g.IO.MouseReleased[ImGuiMouseButton_Left]) &&
|
if ((g.IO.MouseDown[ImGuiMouseButton_Left] || g.IO.MouseReleased[ImGuiMouseButton_Left]) &&
|
||||||
g.ActiveId!=GetWindowScrollbarID(window,ImGuiAxis_X) &&
|
g.ActiveId!=GetWindowScrollbarID(window,ImGuiAxis_X) &&
|
||||||
g.ActiveId!=GetWindowScrollbarID(window,ImGuiAxis_Y)) {
|
g.ActiveId!=GetWindowScrollbarID(window,ImGuiAxis_Y) &&
|
||||||
|
!window->InertialScrollInhibited) {
|
||||||
// launch inertial scroll
|
// launch inertial scroll
|
||||||
if (g.IO.MouseClicked[ImGuiMouseButton_Left]) {
|
if (g.IO.MouseClicked[ImGuiMouseButton_Left]) {
|
||||||
window->InertialScrollSpeed=ImVec2(0.0f,0.0f);
|
window->InertialScrollSpeed=ImVec2(0.0f,0.0f);
|
||||||
|
@ -6970,6 +6980,9 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||||
window->InertialScrollSpeed.x=0.0f;
|
window->InertialScrollSpeed.x=0.0f;
|
||||||
window->InertialScrollSpeed.y=0.0f;
|
window->InertialScrollSpeed.y=0.0f;
|
||||||
}
|
}
|
||||||
|
if (g.IO.MouseReleased[ImGuiMouseButton_Left]) {
|
||||||
|
window->InertialScrollInhibited=false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply scrolling
|
// Apply scrolling
|
||||||
|
@ -7534,6 +7547,16 @@ void ImGui::EndDisabled()
|
||||||
g.Style.Alpha = g.DisabledAlphaBackup; //PopStyleVar();
|
g.Style.Alpha = g.DisabledAlphaBackup; //PopStyleVar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// InhibitInertialScroll()
|
||||||
|
|
||||||
|
void ImGui::InhibitInertialScroll()
|
||||||
|
{
|
||||||
|
ImGuiWindow* window = GetCurrentWindow();
|
||||||
|
if (window!=NULL) {
|
||||||
|
window->InertialScrollInhibited=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME: Look into renaming this once we have settled the new Focus/Activation/TabStop system.
|
// FIXME: Look into renaming this once we have settled the new Focus/Activation/TabStop system.
|
||||||
void ImGui::PushAllowKeyboardFocus(bool allow_keyboard_focus)
|
void ImGui::PushAllowKeyboardFocus(bool allow_keyboard_focus)
|
||||||
{
|
{
|
||||||
|
|
3
extern/imgui_patched/imgui.h
vendored
3
extern/imgui_patched/imgui.h
vendored
|
@ -838,6 +838,9 @@ namespace ImGui
|
||||||
IMGUI_API void BeginDisabled(bool disabled = true);
|
IMGUI_API void BeginDisabled(bool disabled = true);
|
||||||
IMGUI_API void EndDisabled();
|
IMGUI_API void EndDisabled();
|
||||||
|
|
||||||
|
// Inertial scroll
|
||||||
|
IMGUI_API void InhibitInertialScroll();
|
||||||
|
|
||||||
// Clipping
|
// Clipping
|
||||||
// - Mouse hovering is affected by ImGui::PushClipRect() calls, unlike direct calls to ImDrawList::PushClipRect() which are render only.
|
// - Mouse hovering is affected by ImGui::PushClipRect() calls, unlike direct calls to ImDrawList::PushClipRect() which are render only.
|
||||||
IMGUI_API void PushClipRect(const ImVec2& clip_rect_min, const ImVec2& clip_rect_max, bool intersect_with_current_clip_rect);
|
IMGUI_API void PushClipRect(const ImVec2& clip_rect_min, const ImVec2& clip_rect_max, bool intersect_with_current_clip_rect);
|
||||||
|
|
4
extern/imgui_patched/imgui_internal.h
vendored
4
extern/imgui_patched/imgui_internal.h
vendored
|
@ -815,7 +815,8 @@ enum ImGuiItemFlags_
|
||||||
ImGuiItemFlags_SelectableDontClosePopup = 1 << 5, // false // Disable MenuItem/Selectable() automatically closing their popup window
|
ImGuiItemFlags_SelectableDontClosePopup = 1 << 5, // false // Disable MenuItem/Selectable() automatically closing their popup window
|
||||||
ImGuiItemFlags_MixedValue = 1 << 6, // false // [BETA] Represent a mixed/indeterminate value, generally multi-selection where values differ. Currently only supported by Checkbox() (later should support all sorts of widgets)
|
ImGuiItemFlags_MixedValue = 1 << 6, // false // [BETA] Represent a mixed/indeterminate value, generally multi-selection where values differ. Currently only supported by Checkbox() (later should support all sorts of widgets)
|
||||||
ImGuiItemFlags_ReadOnly = 1 << 7, // false // [ALPHA] Allow hovering interactions but underlying value is not changed.
|
ImGuiItemFlags_ReadOnly = 1 << 7, // false // [ALPHA] Allow hovering interactions but underlying value is not changed.
|
||||||
ImGuiItemFlags_Inputable = 1 << 8 // false // [WIP] Auto-activate input mode when tab focused. Currently only used and supported by a few items before it becomes a generic feature.
|
ImGuiItemFlags_Inputable = 1 << 8, // false // [WIP] Auto-activate input mode when tab focused. Currently only used and supported by a few items before it becomes a generic feature.
|
||||||
|
ImGuiItemFlags_NoInertialScroll = 1 << 9 // false // Disable inertial scroll when activated
|
||||||
};
|
};
|
||||||
|
|
||||||
// Storage for LastItem data
|
// Storage for LastItem data
|
||||||
|
@ -2294,6 +2295,7 @@ struct IMGUI_API ImGuiWindow
|
||||||
ImVec2 ScrollTargetEdgeSnapDist; // 0.0f = no snapping, >0.0f snapping threshold
|
ImVec2 ScrollTargetEdgeSnapDist; // 0.0f = no snapping, >0.0f snapping threshold
|
||||||
ImVec2 ScrollbarSizes; // Size taken by each scrollbars on their smaller axis. Pay attention! ScrollbarSizes.x == width of the vertical scrollbar, ScrollbarSizes.y = height of the horizontal scrollbar.
|
ImVec2 ScrollbarSizes; // Size taken by each scrollbars on their smaller axis. Pay attention! ScrollbarSizes.x == width of the vertical scrollbar, ScrollbarSizes.y = height of the horizontal scrollbar.
|
||||||
ImVec2 InertialScrollSpeed; // current speed of inertial scroll (AKA "swipe")
|
ImVec2 InertialScrollSpeed; // current speed of inertial scroll (AKA "swipe")
|
||||||
|
bool InertialScrollInhibited; // Is inertial scroll inhibited? (e.g. by ImGuiItemFlags_NoInertialScroll)
|
||||||
bool ScrollbarX, ScrollbarY; // Are scrollbars visible?
|
bool ScrollbarX, ScrollbarY; // Are scrollbars visible?
|
||||||
bool ViewportOwned;
|
bool ViewportOwned;
|
||||||
bool Active; // Set to true on Begin(), unless Collapsed
|
bool Active; // Set to true on Begin(), unless Collapsed
|
||||||
|
|
2
extern/imgui_patched/imgui_widgets.cpp
vendored
2
extern/imgui_patched/imgui_widgets.cpp
vendored
|
@ -2949,7 +2949,7 @@ bool ImGui::SliderScalar(const char* label, ImGuiDataType data_type, void* p_dat
|
||||||
|
|
||||||
const bool temp_input_allowed = (flags & ImGuiSliderFlags_NoInput) == 0;
|
const bool temp_input_allowed = (flags & ImGuiSliderFlags_NoInput) == 0;
|
||||||
ItemSize(total_bb, style.FramePadding.y);
|
ItemSize(total_bb, style.FramePadding.y);
|
||||||
if (!ItemAdd(total_bb, id, &frame_bb, temp_input_allowed ? ImGuiItemFlags_Inputable : 0))
|
if (!ItemAdd(total_bb, id, &frame_bb, (temp_input_allowed ? ImGuiItemFlags_Inputable : 0) | ImGuiItemFlags_NoInertialScroll))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Default format string when passing NULL
|
// Default format string when passing NULL
|
||||||
|
|
|
@ -1378,6 +1378,7 @@ void FurnaceGUI::drawMacroEdit(FurnaceGUIMacroDesc& i, int totalFit, float avail
|
||||||
PlotCustom("##IMacro",asFloat,totalFit,macroDragScroll,NULL,i.min+i.macro->vScroll,i.min+i.macro->vScroll+i.macro->vZoom,ImVec2(availableWidth,(i.macro->open&1)?(i.height*dpiScale):(32.0f*dpiScale)),sizeof(float),i.color,i.macro->len-macroDragScroll,i.hoverFunc,i.hoverFuncUser,i.blockMode,(i.macro->open&1)?genericGuide:NULL,doHighlight);
|
PlotCustom("##IMacro",asFloat,totalFit,macroDragScroll,NULL,i.min+i.macro->vScroll,i.min+i.macro->vScroll+i.macro->vZoom,ImVec2(availableWidth,(i.macro->open&1)?(i.height*dpiScale):(32.0f*dpiScale)),sizeof(float),i.color,i.macro->len-macroDragScroll,i.hoverFunc,i.hoverFuncUser,i.blockMode,(i.macro->open&1)?genericGuide:NULL,doHighlight);
|
||||||
}
|
}
|
||||||
if ((i.macro->open&1) && (ImGui::IsItemClicked(ImGuiMouseButton_Left) || ImGui::IsItemClicked(ImGuiMouseButton_Right))) {
|
if ((i.macro->open&1) && (ImGui::IsItemClicked(ImGuiMouseButton_Left) || ImGui::IsItemClicked(ImGuiMouseButton_Right))) {
|
||||||
|
ImGui::InhibitInertialScroll();
|
||||||
macroDragStart=ImGui::GetItemRectMin();
|
macroDragStart=ImGui::GetItemRectMin();
|
||||||
macroDragAreaSize=ImVec2(availableWidth,i.height*dpiScale);
|
macroDragAreaSize=ImVec2(availableWidth,i.height*dpiScale);
|
||||||
if (i.isBitfield) {
|
if (i.isBitfield) {
|
||||||
|
@ -1466,6 +1467,7 @@ void FurnaceGUI::drawMacroEdit(FurnaceGUIMacroDesc& i, int totalFit, float avail
|
||||||
if (i.bit30) {
|
if (i.bit30) {
|
||||||
PlotCustom("##IMacroBit30",bit30Indicator,totalFit,macroDragScroll,NULL,0,1,ImVec2(availableWidth,12.0f*dpiScale),sizeof(float),i.color,i.macro->len-macroDragScroll,¯oHoverBit30);
|
PlotCustom("##IMacroBit30",bit30Indicator,totalFit,macroDragScroll,NULL,0,1,ImVec2(availableWidth,12.0f*dpiScale),sizeof(float),i.color,i.macro->len-macroDragScroll,¯oHoverBit30);
|
||||||
if (ImGui::IsItemClicked(ImGuiMouseButton_Left)) {
|
if (ImGui::IsItemClicked(ImGuiMouseButton_Left)) {
|
||||||
|
ImGui::InhibitInertialScroll();
|
||||||
macroDragStart=ImGui::GetItemRectMin();
|
macroDragStart=ImGui::GetItemRectMin();
|
||||||
macroDragAreaSize=ImVec2(availableWidth,12.0f*dpiScale);
|
macroDragAreaSize=ImVec2(availableWidth,12.0f*dpiScale);
|
||||||
macroDragInitialValueSet=false;
|
macroDragInitialValueSet=false;
|
||||||
|
@ -1486,6 +1488,7 @@ void FurnaceGUI::drawMacroEdit(FurnaceGUIMacroDesc& i, int totalFit, float avail
|
||||||
// loop area
|
// loop area
|
||||||
PlotCustom("##IMacroLoop",loopIndicator,totalFit,macroDragScroll,NULL,0,2,ImVec2(availableWidth,12.0f*dpiScale),sizeof(float),i.color,i.macro->len-macroDragScroll,¯oHoverLoop);
|
PlotCustom("##IMacroLoop",loopIndicator,totalFit,macroDragScroll,NULL,0,2,ImVec2(availableWidth,12.0f*dpiScale),sizeof(float),i.color,i.macro->len-macroDragScroll,¯oHoverLoop);
|
||||||
if (ImGui::IsItemClicked(ImGuiMouseButton_Left)) {
|
if (ImGui::IsItemClicked(ImGuiMouseButton_Left)) {
|
||||||
|
ImGui::InhibitInertialScroll();
|
||||||
macroLoopDragStart=ImGui::GetItemRectMin();
|
macroLoopDragStart=ImGui::GetItemRectMin();
|
||||||
macroLoopDragAreaSize=ImVec2(availableWidth,12.0f*dpiScale);
|
macroLoopDragAreaSize=ImVec2(availableWidth,12.0f*dpiScale);
|
||||||
macroLoopDragLen=totalFit;
|
macroLoopDragLen=totalFit;
|
||||||
|
@ -1498,6 +1501,7 @@ void FurnaceGUI::drawMacroEdit(FurnaceGUIMacroDesc& i, int totalFit, float avail
|
||||||
processDrags(ImGui::GetMousePos().x,ImGui::GetMousePos().y);
|
processDrags(ImGui::GetMousePos().x,ImGui::GetMousePos().y);
|
||||||
}
|
}
|
||||||
if (ImGui::IsItemClicked(ImGuiMouseButton_Right)) {
|
if (ImGui::IsItemClicked(ImGuiMouseButton_Right)) {
|
||||||
|
ImGui::InhibitInertialScroll();
|
||||||
if (ImGui::IsKeyDown(ImGuiKey_LeftShift) || ImGui::IsKeyDown(ImGuiKey_RightShift)) {
|
if (ImGui::IsKeyDown(ImGuiKey_LeftShift) || ImGui::IsKeyDown(ImGuiKey_RightShift)) {
|
||||||
i.macro->rel=255;
|
i.macro->rel=255;
|
||||||
} else {
|
} else {
|
||||||
|
@ -4423,6 +4427,7 @@ void FurnaceGUI::drawInsEdit() {
|
||||||
macroDragLineMode=false;
|
macroDragLineMode=false;
|
||||||
macroDragLineInitial=ImVec2(0,0);
|
macroDragLineInitial=ImVec2(0,0);
|
||||||
processDrags(ImGui::GetMousePos().x,ImGui::GetMousePos().y);
|
processDrags(ImGui::GetMousePos().x,ImGui::GetMousePos().y);
|
||||||
|
ImGui::InhibitInertialScroll();
|
||||||
}
|
}
|
||||||
ImGui::EndTabItem();
|
ImGui::EndTabItem();
|
||||||
}
|
}
|
||||||
|
@ -4452,6 +4457,7 @@ void FurnaceGUI::drawInsEdit() {
|
||||||
macroDragLineMode=false;
|
macroDragLineMode=false;
|
||||||
macroDragLineInitial=ImVec2(0,0);
|
macroDragLineInitial=ImVec2(0,0);
|
||||||
processDrags(ImGui::GetMousePos().x,ImGui::GetMousePos().y);
|
processDrags(ImGui::GetMousePos().x,ImGui::GetMousePos().y);
|
||||||
|
ImGui::InhibitInertialScroll();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::EndDisabled();
|
ImGui::EndDisabled();
|
||||||
|
|
|
@ -76,7 +76,7 @@ int PlotNoLerpEx(ImGuiPlotType plot_type, const char* label, float (*values_gett
|
||||||
const ImRect inner_bb(frame_bb.Min + style.FramePadding, frame_bb.Max - style.FramePadding);
|
const ImRect inner_bb(frame_bb.Min + style.FramePadding, frame_bb.Max - style.FramePadding);
|
||||||
const ImRect total_bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0));
|
const ImRect total_bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0));
|
||||||
ImGui::ItemSize(total_bb, style.FramePadding.y);
|
ImGui::ItemSize(total_bb, style.FramePadding.y);
|
||||||
if (!ImGui::ItemAdd(total_bb, 0, &frame_bb))
|
if (!ImGui::ItemAdd(total_bb, 0, &frame_bb, ImGuiItemFlags_NoInertialScroll))
|
||||||
return -1;
|
return -1;
|
||||||
const bool hovered = ImGui::ItemHoverable(frame_bb, id);
|
const bool hovered = ImGui::ItemHoverable(frame_bb, id);
|
||||||
|
|
||||||
|
@ -203,7 +203,7 @@ int PlotBitfieldEx(const char* label, int (*values_getter)(void* data, int idx),
|
||||||
const ImRect inner_bb(frame_bb.Min + style.FramePadding, frame_bb.Max - style.FramePadding);
|
const ImRect inner_bb(frame_bb.Min + style.FramePadding, frame_bb.Max - style.FramePadding);
|
||||||
const ImRect total_bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0));
|
const ImRect total_bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0));
|
||||||
ImGui::ItemSize(total_bb, style.FramePadding.y);
|
ImGui::ItemSize(total_bb, style.FramePadding.y);
|
||||||
if (!ImGui::ItemAdd(total_bb, 0, &frame_bb))
|
if (!ImGui::ItemAdd(total_bb, 0, &frame_bb, ImGuiItemFlags_NoInertialScroll))
|
||||||
return -1;
|
return -1;
|
||||||
const bool hovered = ImGui::ItemHoverable(frame_bb, id);
|
const bool hovered = ImGui::ItemHoverable(frame_bb, id);
|
||||||
|
|
||||||
|
@ -313,7 +313,7 @@ int PlotCustomEx(ImGuiPlotType plot_type, const char* label, float (*values_gett
|
||||||
const ImRect inner_bb(frame_bb.Min + style.FramePadding, frame_bb.Max - style.FramePadding);
|
const ImRect inner_bb(frame_bb.Min + style.FramePadding, frame_bb.Max - style.FramePadding);
|
||||||
const ImRect total_bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0));
|
const ImRect total_bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0));
|
||||||
ImGui::ItemSize(total_bb, style.FramePadding.y);
|
ImGui::ItemSize(total_bb, style.FramePadding.y);
|
||||||
if (!ImGui::ItemAdd(total_bb, 0, &frame_bb))
|
if (!ImGui::ItemAdd(total_bb, 0, &frame_bb, ImGuiItemFlags_NoInertialScroll))
|
||||||
return -1;
|
return -1;
|
||||||
const bool hovered = ImGui::ItemHoverable(frame_bb, id);
|
const bool hovered = ImGui::ItemHoverable(frame_bb, id);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue