@@ -5214,28 +5214,29 @@ bool ImGui::ListBox(const char* label, int* current_item, bool (*items_getter)(v
5214
5214
// - PlotHistogram()
5215
5215
// -------------------------------------------------------------------------
5216
5216
5217
- void ImGui::PlotEx (ImGuiPlotType plot_type, const char * label, float (*values_getter)(void * data, int idx), void* data, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 graph_size )
5217
+ void ImGui::PlotEx (ImGuiPlotType plot_type, const char * label, float (*values_getter)(void * data, int idx), void* data, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 frame_size )
5218
5218
{
5219
5219
ImGuiWindow* window = GetCurrentWindow ();
5220
5220
if (window->SkipItems )
5221
5221
return ;
5222
5222
5223
5223
ImGuiContext& g = *GImGui;
5224
5224
const ImGuiStyle& style = g.Style ;
5225
+ const ImGuiID id = window->GetID (label);
5225
5226
5226
5227
const ImVec2 label_size = CalcTextSize (label, NULL , true );
5227
- if (graph_size .x == 0 .0f )
5228
- graph_size .x = CalcItemWidth ();
5229
- if (graph_size .y == 0 .0f )
5230
- graph_size .y = label_size.y + (style.FramePadding .y * 2 );
5228
+ if (frame_size .x == 0 .0f )
5229
+ frame_size .x = CalcItemWidth ();
5230
+ if (frame_size .y == 0 .0f )
5231
+ frame_size .y = label_size.y + (style.FramePadding .y * 2 );
5231
5232
5232
- const ImRect frame_bb (window->DC .CursorPos , window->DC .CursorPos + ImVec2 (graph_size. x , graph_size. y ) );
5233
+ const ImRect frame_bb (window->DC .CursorPos , window->DC .CursorPos + frame_size );
5233
5234
const ImRect inner_bb (frame_bb.Min + style.FramePadding , frame_bb.Max - style.FramePadding );
5234
5235
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 ));
5235
5236
ItemSize (total_bb, style.FramePadding .y );
5236
5237
if (!ItemAdd (total_bb, 0 , &frame_bb))
5237
5238
return ;
5238
- const bool hovered = ItemHoverable (inner_bb, 0 );
5239
+ const bool hovered = ItemHoverable (frame_bb, id );
5239
5240
5240
5241
// Determine scale from values if not specified
5241
5242
if (scale_min == FLT_MAX || scale_max == FLT_MAX)
@@ -5258,12 +5259,12 @@ void ImGui::PlotEx(ImGuiPlotType plot_type, const char* label, float (*values_ge
5258
5259
5259
5260
if (values_count > 0 )
5260
5261
{
5261
- int res_w = ImMin ((int )graph_size .x , values_count) + ((plot_type == ImGuiPlotType_Lines) ? -1 : 0 );
5262
+ int res_w = ImMin ((int )frame_size .x , values_count) + ((plot_type == ImGuiPlotType_Lines) ? -1 : 0 );
5262
5263
int item_count = values_count + ((plot_type == ImGuiPlotType_Lines) ? -1 : 0 );
5263
5264
5264
5265
// Tooltip on hover
5265
5266
int v_hovered = -1 ;
5266
- if (hovered)
5267
+ if (hovered && inner_bb. Contains (g. IO . MousePos ) )
5267
5268
{
5268
5269
const float t = ImClamp ((g.IO .MousePos .x - inner_bb.Min .x ) / (inner_bb.Max .x - inner_bb.Min .x ), 0 .0f , 0 .9999f );
5269
5270
const int v_idx = (int )(t * item_count);
0 commit comments