mirror of
https://github.com/ocornut/imgui.git
synced 2025-12-22 14:19:04 +00:00
Drag and Drop, Style: added basic styling options to DragDrop target rect. (#9056)
This commit is contained in:
14
imgui.cpp
14
imgui.cpp
@@ -1450,6 +1450,9 @@ ImGuiStyle::ImGuiStyle()
|
|||||||
AntiAliasedFill = true; // Enable anti-aliased filled shapes (rounded rectangles, circles, etc.).
|
AntiAliasedFill = true; // Enable anti-aliased filled shapes (rounded rectangles, circles, etc.).
|
||||||
CurveTessellationTol = 1.25f; // Tessellation tolerance when using PathBezierCurveTo() without a specific number of segments. Decrease for highly tessellated curves (higher quality, more polygons), increase to reduce quality.
|
CurveTessellationTol = 1.25f; // Tessellation tolerance when using PathBezierCurveTo() without a specific number of segments. Decrease for highly tessellated curves (higher quality, more polygons), increase to reduce quality.
|
||||||
CircleTessellationMaxError = 0.30f; // Maximum error (in pixels) allowed when using AddCircle()/AddCircleFilled() or drawing rounded corner rectangles with no explicit segment count specified. Decrease for higher quality but more geometry.
|
CircleTessellationMaxError = 0.30f; // Maximum error (in pixels) allowed when using AddCircle()/AddCircleFilled() or drawing rounded corner rectangles with no explicit segment count specified. Decrease for higher quality but more geometry.
|
||||||
|
DragDropTargetRectRounding = 0.0f; // Corner radius of the drag-drop hover frame
|
||||||
|
DragDropTargetRectLineThickness = 2.0f; // Thickness of the drop-drop hover frame lines
|
||||||
|
DragDropTargetRectExpansionSize = 3.5f; // The size in which the drag-drop hover rect will expand over the target
|
||||||
|
|
||||||
// Behaviors
|
// Behaviors
|
||||||
HoverStationaryDelay = 0.15f; // Delay for IsItemHovered(ImGuiHoveredFlags_Stationary). Time required to consider mouse stationary.
|
HoverStationaryDelay = 0.15f; // Delay for IsItemHovered(ImGuiHoveredFlags_Stationary). Time required to consider mouse stationary.
|
||||||
@@ -3711,6 +3714,7 @@ const char* ImGui::GetStyleColorName(ImGuiCol idx)
|
|||||||
case ImGuiCol_TextSelectedBg: return "TextSelectedBg";
|
case ImGuiCol_TextSelectedBg: return "TextSelectedBg";
|
||||||
case ImGuiCol_TreeLines: return "TreeLines";
|
case ImGuiCol_TreeLines: return "TreeLines";
|
||||||
case ImGuiCol_DragDropTarget: return "DragDropTarget";
|
case ImGuiCol_DragDropTarget: return "DragDropTarget";
|
||||||
|
case ImGuiCol_DragDropTargetBg: return "DragDropTargetBg";
|
||||||
case ImGuiCol_UnsavedMarker: return "UnsavedMarker";
|
case ImGuiCol_UnsavedMarker: return "UnsavedMarker";
|
||||||
case ImGuiCol_NavCursor: return "NavCursor";
|
case ImGuiCol_NavCursor: return "NavCursor";
|
||||||
case ImGuiCol_NavWindowingHighlight: return "NavWindowingHighlight";
|
case ImGuiCol_NavWindowingHighlight: return "NavWindowingHighlight";
|
||||||
@@ -14893,7 +14897,7 @@ void ImGui::RenderDragDropTargetRectForItem(const ImRect& bb)
|
|||||||
ImGuiWindow* window = g.CurrentWindow;
|
ImGuiWindow* window = g.CurrentWindow;
|
||||||
ImRect bb_display = bb;
|
ImRect bb_display = bb;
|
||||||
bb_display.ClipWith(g.DragDropTargetClipRect); // Clip THEN expand so we have a way to visualize that target is not entirely visible.
|
bb_display.ClipWith(g.DragDropTargetClipRect); // Clip THEN expand so we have a way to visualize that target is not entirely visible.
|
||||||
bb_display.Expand(3.5f);
|
bb_display.Expand(g.Style.DragDropTargetRectExpansionSize);
|
||||||
bool push_clip_rect = !window->ClipRect.Contains(bb_display);
|
bool push_clip_rect = !window->ClipRect.Contains(bb_display);
|
||||||
if (push_clip_rect)
|
if (push_clip_rect)
|
||||||
window->DrawList->PushClipRectFullScreen();
|
window->DrawList->PushClipRectFullScreen();
|
||||||
@@ -14904,7 +14908,13 @@ void ImGui::RenderDragDropTargetRectForItem(const ImRect& bb)
|
|||||||
|
|
||||||
void ImGui::RenderDragDropTargetRectEx(ImDrawList* draw_list, const ImRect& bb)
|
void ImGui::RenderDragDropTargetRectEx(ImDrawList* draw_list, const ImRect& bb)
|
||||||
{
|
{
|
||||||
draw_list->AddRect(bb.Min, bb.Max, GetColorU32(ImGuiCol_DragDropTarget), 0.0f, 0, 2.0f); // FIXME-DPI
|
ImGuiContext& g = *GImGui;
|
||||||
|
|
||||||
|
const ImVec4& color_bg = GetStyleColorVec4(ImGuiCol_DragDropTargetBg);
|
||||||
|
if (color_bg.w > 0.0f)
|
||||||
|
draw_list->AddRectFilled(bb.Min, bb.Max, GetColorU32(color_bg), g.Style.DragDropTargetRectRounding, 0);
|
||||||
|
|
||||||
|
draw_list->AddRect(bb.Min, bb.Max, GetColorU32(ImGuiCol_DragDropTarget), g.Style.DragDropTargetRectRounding, 0, g.Style.DragDropTargetRectLineThickness); // FIXME-DPI
|
||||||
}
|
}
|
||||||
|
|
||||||
const ImGuiPayload* ImGui::GetDragDropPayload()
|
const ImGuiPayload* ImGui::GetDragDropPayload()
|
||||||
|
|||||||
6
imgui.h
6
imgui.h
@@ -1776,7 +1776,8 @@ enum ImGuiCol_
|
|||||||
ImGuiCol_TextLink, // Hyperlink color
|
ImGuiCol_TextLink, // Hyperlink color
|
||||||
ImGuiCol_TextSelectedBg, // Selected text inside an InputText
|
ImGuiCol_TextSelectedBg, // Selected text inside an InputText
|
||||||
ImGuiCol_TreeLines, // Tree node hierarchy outlines when using ImGuiTreeNodeFlags_DrawLines
|
ImGuiCol_TreeLines, // Tree node hierarchy outlines when using ImGuiTreeNodeFlags_DrawLines
|
||||||
ImGuiCol_DragDropTarget, // Rectangle highlighting a drop target
|
ImGuiCol_DragDropTarget, // Rectangle border highlighting a drop target
|
||||||
|
ImGuiCol_DragDropTargetBg, // Rectangle background highlighting a drop target
|
||||||
ImGuiCol_UnsavedMarker, // Unsaved Document marker (in window title and tabs)
|
ImGuiCol_UnsavedMarker, // Unsaved Document marker (in window title and tabs)
|
||||||
ImGuiCol_NavCursor, // Color of keyboard/gamepad navigation cursor/rectangle, when visible
|
ImGuiCol_NavCursor, // Color of keyboard/gamepad navigation cursor/rectangle, when visible
|
||||||
ImGuiCol_NavWindowingHighlight, // Highlight window when using CTRL+TAB
|
ImGuiCol_NavWindowingHighlight, // Highlight window when using CTRL+TAB
|
||||||
@@ -2322,6 +2323,9 @@ struct ImGuiStyle
|
|||||||
bool AntiAliasedFill; // Enable anti-aliased edges around filled shapes (rounded rectangles, circles, etc.). Disable if you are really tight on CPU/GPU. Latched at the beginning of the frame (copied to ImDrawList).
|
bool AntiAliasedFill; // Enable anti-aliased edges around filled shapes (rounded rectangles, circles, etc.). Disable if you are really tight on CPU/GPU. Latched at the beginning of the frame (copied to ImDrawList).
|
||||||
float CurveTessellationTol; // Tessellation tolerance when using PathBezierCurveTo() without a specific number of segments. Decrease for highly tessellated curves (higher quality, more polygons), increase to reduce quality.
|
float CurveTessellationTol; // Tessellation tolerance when using PathBezierCurveTo() without a specific number of segments. Decrease for highly tessellated curves (higher quality, more polygons), increase to reduce quality.
|
||||||
float CircleTessellationMaxError; // Maximum error (in pixels) allowed when using AddCircle()/AddCircleFilled() or drawing rounded corner rectangles with no explicit segment count specified. Decrease for higher quality but more geometry.
|
float CircleTessellationMaxError; // Maximum error (in pixels) allowed when using AddCircle()/AddCircleFilled() or drawing rounded corner rectangles with no explicit segment count specified. Decrease for higher quality but more geometry.
|
||||||
|
float DragDropTargetRectRounding; // Corner radius of the drag-drop target rect
|
||||||
|
float DragDropTargetRectLineThickness; // Thickness of the drop-drop target rect lines
|
||||||
|
float DragDropTargetRectExpansionSize; // The size in which the drag-drop target rect will expand over the target
|
||||||
|
|
||||||
// Colors
|
// Colors
|
||||||
ImVec4 Colors[ImGuiCol_COUNT];
|
ImVec4 Colors[ImGuiCol_COUNT];
|
||||||
|
|||||||
@@ -240,6 +240,7 @@ void ImGui::StyleColorsDark(ImGuiStyle* dst)
|
|||||||
colors[ImGuiCol_TextSelectedBg] = ImVec4(0.26f, 0.59f, 0.98f, 0.35f);
|
colors[ImGuiCol_TextSelectedBg] = ImVec4(0.26f, 0.59f, 0.98f, 0.35f);
|
||||||
colors[ImGuiCol_TreeLines] = colors[ImGuiCol_Border];
|
colors[ImGuiCol_TreeLines] = colors[ImGuiCol_Border];
|
||||||
colors[ImGuiCol_DragDropTarget] = ImVec4(1.00f, 1.00f, 0.00f, 0.90f);
|
colors[ImGuiCol_DragDropTarget] = ImVec4(1.00f, 1.00f, 0.00f, 0.90f);
|
||||||
|
colors[ImGuiCol_DragDropTargetBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
|
||||||
colors[ImGuiCol_UnsavedMarker] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
|
colors[ImGuiCol_UnsavedMarker] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
|
||||||
colors[ImGuiCol_NavCursor] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
|
colors[ImGuiCol_NavCursor] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
|
||||||
colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.00f, 1.00f, 1.00f, 0.70f);
|
colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.00f, 1.00f, 1.00f, 0.70f);
|
||||||
@@ -306,6 +307,7 @@ void ImGui::StyleColorsClassic(ImGuiStyle* dst)
|
|||||||
colors[ImGuiCol_TextSelectedBg] = ImVec4(0.00f, 0.00f, 1.00f, 0.35f);
|
colors[ImGuiCol_TextSelectedBg] = ImVec4(0.00f, 0.00f, 1.00f, 0.35f);
|
||||||
colors[ImGuiCol_TreeLines] = colors[ImGuiCol_Border];
|
colors[ImGuiCol_TreeLines] = colors[ImGuiCol_Border];
|
||||||
colors[ImGuiCol_DragDropTarget] = ImVec4(1.00f, 1.00f, 0.00f, 0.90f);
|
colors[ImGuiCol_DragDropTarget] = ImVec4(1.00f, 1.00f, 0.00f, 0.90f);
|
||||||
|
colors[ImGuiCol_DragDropTargetBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
|
||||||
colors[ImGuiCol_UnsavedMarker] = ImVec4(0.90f, 0.90f, 0.90f, 1.00f);
|
colors[ImGuiCol_UnsavedMarker] = ImVec4(0.90f, 0.90f, 0.90f, 1.00f);
|
||||||
colors[ImGuiCol_NavCursor] = colors[ImGuiCol_HeaderHovered];
|
colors[ImGuiCol_NavCursor] = colors[ImGuiCol_HeaderHovered];
|
||||||
colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.00f, 1.00f, 1.00f, 0.70f);
|
colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.00f, 1.00f, 1.00f, 0.70f);
|
||||||
@@ -373,6 +375,7 @@ void ImGui::StyleColorsLight(ImGuiStyle* dst)
|
|||||||
colors[ImGuiCol_TextSelectedBg] = ImVec4(0.26f, 0.59f, 0.98f, 0.35f);
|
colors[ImGuiCol_TextSelectedBg] = ImVec4(0.26f, 0.59f, 0.98f, 0.35f);
|
||||||
colors[ImGuiCol_TreeLines] = colors[ImGuiCol_Border];
|
colors[ImGuiCol_TreeLines] = colors[ImGuiCol_Border];
|
||||||
colors[ImGuiCol_DragDropTarget] = ImVec4(0.26f, 0.59f, 0.98f, 0.95f);
|
colors[ImGuiCol_DragDropTarget] = ImVec4(0.26f, 0.59f, 0.98f, 0.95f);
|
||||||
|
colors[ImGuiCol_DragDropTargetBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
|
||||||
colors[ImGuiCol_UnsavedMarker] = ImVec4(0.00f, 0.00f, 0.00f, 1.00f);
|
colors[ImGuiCol_UnsavedMarker] = ImVec4(0.00f, 0.00f, 0.00f, 1.00f);
|
||||||
colors[ImGuiCol_NavCursor] = colors[ImGuiCol_HeaderHovered];
|
colors[ImGuiCol_NavCursor] = colors[ImGuiCol_HeaderHovered];
|
||||||
colors[ImGuiCol_NavWindowingHighlight] = ImVec4(0.70f, 0.70f, 0.70f, 0.70f);
|
colors[ImGuiCol_NavWindowingHighlight] = ImVec4(0.70f, 0.70f, 0.70f, 0.70f);
|
||||||
|
|||||||
Reference in New Issue
Block a user