public static bool ButtonGradient(string strId, Vector2 buttonSizeVector) { String[] strIdArray = strId.Split("###"); Vector2 p = ImGuiNET.ImGui.GetCursorScreenPos(); Vector2 sizeText = ImGui.CalcTextSize(strIdArray[0]); ImDrawListPtr drawList = ImGuiNET.ImGui.GetWindowDrawList(); //ButtonHeight += ImGuiNET.ImGui.GetFrameHeight(); //Dynamically Allocated Height //float ButtonWidth = sizeText.X + ButtonHeight; //Dynamically Allocated Width float buttonHeight = buttonSizeVector.Y; //Fixed Height float buttonWidth = buttonSizeVector.X; //Dynamically Allocated Width if (buttonWidth < sizeText.X) { buttonWidth = sizeText.X + sizeText.X * 0.20f; } Vector2 buttonSize = new Vector2(p.X + buttonWidth, p.Y + buttonHeight); uint colTop; uint colBottom; if (strIdArray.Length > 1) { if (ImGuiNET.ImGui.InvisibleButton(strIdArray[1], new Vector2(buttonWidth, buttonHeight))) { return(true); } } else { if (ImGuiNET.ImGui.InvisibleButton(strIdArray[0], new Vector2(buttonWidth, buttonHeight))) { return(true); } } if (ImGuiNET.ImGui.IsItemHovered()) { colTop = ImGuiNET.ImGui.GetColorU32(ImGuiCol.ButtonActive); colBottom = ImGuiNET.ImGui.GetColorU32(ImGuiCol.ButtonHovered); } else { colTop = ImGuiNET.ImGui.GetColorU32(ImGuiCol.ButtonHovered); colBottom = ImGuiNET.ImGui.GetColorU32(ImGuiCol.Button); } drawList.AddRectFilledMultiColor(p, buttonSize, colTop, colTop, colBottom, colBottom); drawList.AddRect(p, buttonSize, ImGuiNET.ImGui.GetColorU32(ImGuiCol.ButtonActive)); drawList.AddText(new Vector2(p.X + (buttonWidth / 2) - (sizeText.X / 2), p.Y + (buttonHeight / 2) - (sizeText.Y / 2)), ImGui.GetColorU32(ImGuiCol.Text), strIdArray[0]); return(false); }
private static bool SequencerAddDelButton(ImDrawListPtr draw_list, Vector2 pos, bool add = true) { var io = ImGui.GetIO(); var delRect = new ImRect(pos, new Vector2(pos.X + ButtonSize, pos.Y + ButtonSize)); var overDel = delRect.Contains(io.MousePos); var delColor = overDel ? 0xFFAAAAAAu : 0x50000000u; var midy = pos.Y + 16 / 2 - 0.5f; var midx = pos.X + 16 / 2 - 0.5f; draw_list.AddRect(delRect.Min, delRect.Max, delColor, 4); draw_list.AddLine(new Vector2(delRect.Min.X + 3, midy), new Vector2(delRect.Max.X - 3, midy), delColor, 2); if (add) { draw_list.AddLine(new Vector2(midx, delRect.Min.Y + 3), new Vector2(midx, delRect.Max.Y - 3), delColor, 2); } return(overDel); }
public static bool ButtonGradient(string strId) { String[] strIdArray = strId.Split("##"); Vector2 p = ImGuiNET.ImGui.GetCursorScreenPos(); Vector2 sizeText = ImGui.CalcTextSize(strIdArray[0]); ImDrawListPtr drawList = ImGuiNET.ImGui.GetWindowDrawList(); float buttonHeight = ImGuiNET.ImGui.GetFrameHeight(); float buttonWidth = sizeText.X + sizeText.X * 0.20f; Vector2 buttonSize = new Vector2(p.X + buttonWidth, p.Y + buttonHeight); uint colTop; uint colBottom; if (strIdArray.Length > 1) { if (ImGuiNET.ImGui.InvisibleButton(strIdArray[1], new Vector2(buttonWidth, buttonHeight))) { return(true); } } else { if (ImGuiNET.ImGui.InvisibleButton(strIdArray[0], new Vector2(buttonWidth, buttonHeight))) { return(true); } } if (ImGuiNET.ImGui.IsItemHovered()) { colTop = ImGuiNET.ImGui.GetColorU32(ImGuiCol.ButtonHovered, 1.50f); colBottom = ImGuiNET.ImGui.GetColorU32(ImGuiCol.Button, 0.50f); } else { colTop = ImGuiNET.ImGui.GetColorU32(ImGuiCol.ButtonHovered); colBottom = ImGuiNET.ImGui.GetColorU32(ImGuiCol.Button, 0.20f); } drawList.AddRectFilledMultiColor(p, buttonSize, colTop, colTop, colBottom, colBottom); drawList.AddRect(p, buttonSize, ImGuiNET.ImGui.GetColorU32(ImGuiCol.Separator)); drawList.AddText(new Vector2(p.X + (buttonWidth / 2) - (sizeText.X / 2), p.Y + (buttonHeight / 2) - (sizeText.Y / 2)), ImGui.GetColorU32(ImGuiCol.Text), strIdArray[0]); return(false); }
private static bool SequencerButton( ImDrawListPtr draw_list, Vector2 pos, char ch, bool isSelected = false, uint color = ColorWhite) { var io = ImGui.GetIO(); var rect = new ImRect(pos, new Vector2(pos.X + 16, pos.Y + 16)); var isMouseOver = rect.Contains(io.MousePos); if (!isSelected) { color = isMouseOver ? 0xFFFFFFFFu : 0x50FFFFFFu; } draw_list.AddRect(rect.Min, rect.Max, color, 4); draw_list.AddText(new Vector2(pos.X + 4, pos.Y - 1), color, $"{ch}"); return(isMouseOver); }
public static void Display() { if (ImGui.Begin("Size Demo")) { var getCursorScreenPos1st = ImGui.GetCursorScreenPos(); var getCursorPos1st = ImGui.GetCursorPos(); ImGui.Columns(2, "", true); var getCursorStartPos = ImGui.GetCursorStartPos(); _windowPos = ImGui.GetWindowPos(); var getContentRegionMax = ImGui.GetContentRegionMax(); var getContentRegionAvail = ImGui.GetContentRegionAvail(); var getWindowSize = ImGui.GetWindowSize(); var getWindowContentRegionMax = ImGui.GetWindowContentRegionMax(); var getWindowContentRegionMin = ImGui.GetWindowContentRegionMin(); var getWindowContentRegionWidth = ImGui.GetWindowContentRegionWidth(); var getFontSize = ImGui.GetFontSize(); var getFrameHeight = ImGui.GetFrameHeight(); var getFrameHeightWithSpacing = ImGui.GetFrameHeightWithSpacing(); var getTextLineHeight = ImGui.GetTextLineHeight(); var getTextLineHeightWithSpacing = ImGui.GetTextLineHeightWithSpacing(); var getColomnWidth = ImGui.GetColumnWidth(); var getColomnOffset = ImGui.GetColumnOffset(1); var itemStartPos = new Vector2(); var cursorScreenStartPos = _windowPos + getCursorStartPos; DoPoint("GetCursorStartPos", getCursorStartPos, FrameOfReference.Window); DoPoint("GetCursorPos (1st call in window)", getCursorPos1st, FrameOfReference.Window); DoPoint("GetWindowPos", _windowPos, FrameOfReference.Screen); DoPoint("GetCursorScreenPos (1st call in window)", getCursorScreenPos1st, FrameOfReference.Screen); DoPoint("WindowPos + CursorStartPos", _windowPos + getCursorStartPos, FrameOfReference.Screen); var getCursorScreenPos = ImGui.GetCursorScreenPos(); DoPoint("GetCursorScreenPos (before this item)", getCursorScreenPos, FrameOfReference.Screen); var getCursorPos = ImGui.GetCursorPos(); DoPoint("GetCursorPos (before this item)", getCursorPos, FrameOfReference.Window); DoRectangle("GetWindowSize", _windowPos, getWindowSize); var windowContentRegionStart = new Vector2(cursorScreenStartPos.X, _windowPos.Y);//this seems a bit obtuse DoRectangle("GetWindowContentRegionMax", windowContentRegionStart, getWindowContentRegionMax); DoRectangle("GetWindowContentRegionMin", cursorScreenStartPos, getWindowContentRegionMin); DoRectangle("GetContentRegionMax", _windowPos, getContentRegionMax); DoRectangle("GetContentRegionAvail", cursorScreenStartPos, getContentRegionAvail); itemStartPos = ImGui.GetCursorScreenPos(); DoHLine("GetWindowContentRegionWidth", cursorScreenStartPos, getWindowContentRegionWidth); var colomnWidthstart = new Vector2(_windowPos.X, cursorScreenStartPos.Y); DoHLine("GetColomnWidth", colomnWidthstart, getColomnWidth); DoHLine("GetColomnOffset (colomn[1])", colomnWidthstart, getColomnOffset); itemStartPos = ImGui.GetCursorScreenPos(); DoVLine("GetFontSize", itemStartPos, getFontSize); itemStartPos = ImGui.GetCursorScreenPos(); DoVLine("GetTextLineHeight", itemStartPos, getTextLineHeight); itemStartPos = ImGui.GetCursorScreenPos(); DoVLine("GetTextLineHeightWithSpacing", itemStartPos, getTextLineHeightWithSpacing); itemStartPos = ImGui.GetCursorScreenPos(); DoVLine("GetFrameHeight", itemStartPos, getFrameHeight); itemStartPos = ImGui.GetCursorScreenPos(); DoVLine("GetFrameHeightWithSpacing", itemStartPos, getFrameHeightWithSpacing); //we have to code the following one in full because we need to call GetItemRectSize after Imgui.Text() //so we can't just send it off to DoRectangle(); itemStartPos = ImGui.GetCursorScreenPos(); ImGui.Text("GetItemRectSize"); var getItemRectSize = ImGui.GetItemRectSize(); if (ImGui.IsItemHovered()) { var endRect = itemStartPos + getItemRectSize; _wdl.AddRect(itemStartPos, endRect, _lineColour); DrawCrosshair(itemStartPos, 3); } ImGui.NextColumn(); ImGui.Text(getItemRectSize.ToString()); ImGui.NextColumn(); //we have to code the following one in full because we need to call GetItemRectSize after Imgui.Text() //so we can't just send it off to DoRectangle(); itemStartPos = ImGui.GetCursorScreenPos(); ImGui.Text("GetCursorScreenPos before & after"); var itemEndPos = ImGui.GetCursorScreenPos(); var height = itemEndPos.Y - itemStartPos.Y; if (ImGui.IsItemHovered()) { _wdl.AddLine(itemStartPos, itemEndPos, _lineColour); DrawCrosshair(itemStartPos, 3); } ImGui.NextColumn(); ImGui.Text(height.ToString()); ImGui.NextColumn(); ImGui.Columns(0); ImGui.NewLine(); ImGui.NewLine(); ImGui.Text("Note: DrawList.AddRect takes two positions, not position and size"); ImGui.End(); } void DoPoint(string name, Vector2 point, FrameOfReference foR) { ImGui.Text(name); if (ImGui.IsItemHovered()) { if (foR == FrameOfReference.Window) { DrawCrosshair(_windowPos + point, 3); } else { DrawCrosshair(point, 3); } } ImGui.NextColumn(); ImGui.Text(point.ToString()); ImGui.SameLine(); if (foR == FrameOfReference.Window) { ImGui.Text("Frame of Reference: Window"); } else { ImGui.Text("Frame of Reference: Screen"); } ImGui.NextColumn(); } void DoRectangle(string name, Vector2 start, Vector2 size) { ImGui.Text(name); if (ImGui.IsItemHovered()) { var endRect = start + size; _wdl.AddRect(start, endRect, _lineColour); DrawCrosshair(start, 3); } ImGui.NextColumn(); ImGui.Text(size.ToString()); ImGui.NextColumn(); } void DoHLine(string name, Vector2 start, float width) { ImGui.Text(name); if (ImGui.IsItemHovered()) { var endPos = start; endPos.X += width; _wdl.AddLine(start, endPos, _lineColour); DrawCrosshair(start, 3); } ImGui.NextColumn(); ImGui.Text(width.ToString()); ImGui.NextColumn(); } void DoVLine(string name, Vector2 start, float height) { ImGui.Text(name); if (ImGui.IsItemHovered()) { var endPos = start; endPos.Y += height; _wdl.AddLine(start, endPos, _lineColour); DrawCrosshair(start, 3); } ImGui.NextColumn(); ImGui.Text(height.ToString()); ImGui.NextColumn(); } void DrawCrosshair(Vector2 atPos, float radius) { var p1 = new Vector2(atPos.X - radius, atPos.Y); var p2 = new Vector2(atPos.X + radius, atPos.Y); var p3 = new Vector2(atPos.X, atPos.Y - radius); var p4 = new Vector2(atPos.X, atPos.Y + radius); _wdl.AddLine(p1, p2, _pointColour); _wdl.AddLine(p3, p4, _pointColour); } }
internal override void Display() { // if (!IsActive || _selectedEntitySate == null) { return; } ImGui.SetNextWindowSize(new Vector2(1500, 800)); if (ImGui.Begin("Sensor Display", ref IsActive)) { if (_selectedEntity.HasDataBlob <SensorAbilityDB>()) { if (_selectedReceverAtb == null || ImGui.Button("refresh")) { SetSensorData(); } ImGui.Columns(2); ImGui.SetColumnWidth(0, 300); if (ImGui.Combo("Targets", ref _targetIndex, _potentialTargetNames, _potentialTargetNames.Length)) { _targetEntity = _potentialTargetEntities[_targetIndex]; SetTargetData(); } ImGui.Text("lowest_x: " + lowestWave); ImGui.Text("highest_x: " + highestWave); ImGui.Text("lowest_y: " + lowestMag); ImGui.Text("highest_y: " + highestMag); if (_targetSensorProfile != null) { ImGui.Text("target cross section: " + _targetSensorProfile.TargetCrossSection_msq); } uint borderColour = ImGui.ColorConvertFloat4ToU32(new Vector4(0.5f, 0.5f, 0.5f, 1.0f)); uint receverColour = ImGui.ColorConvertFloat4ToU32(new Vector4(0.25f, 1.0f, 0.5f, 1.0f)); uint receverFill = ImGui.ColorConvertFloat4ToU32(new Vector4(0.25f, 1.0f, 0.5f, 0.75f)); uint reflectedColour = ImGui.ColorConvertFloat4ToU32(new Vector4(1.0f, 0.0f, 0.5f, 1.0f)); uint reflectedFill = ImGui.ColorConvertFloat4ToU32(new Vector4(1.0f, 0.0f, 0.5f, 0.75f)); uint emittedColour = ImGui.ColorConvertFloat4ToU32(new Vector4(1.0f, 0.0f, 0.25f, 1.0f)); uint emittedFill = ImGui.ColorConvertFloat4ToU32(new Vector4(1.0f, 0.0f, 0.25f, 0.5f)); uint detectedColour = ImGui.ColorConvertFloat4ToU32(new Vector4(0.0f, 0.0f, 1.0f, 0.75f)); ImGui.BeginChild("stuff"); BorderGroup.Begin("Recevers:", borderColour); DisplayWavInfo(_receverDat); BorderGroup.End(); if (_reflectDat != null) { BorderGroup.Begin("Reflectors:", borderColour); DisplayWavInfo(_reflectDat); BorderGroup.End(); } if (_emmittrDat != null) { BorderGroup.Begin("Emmiters:", borderColour); DisplayWavInfo(_emmittrDat); BorderGroup.End(); } if (_detectedDat != null) { BorderGroup.Begin("Detected:", borderColour); DisplayWavInfo(_detectedDat); BorderGroup.End(); } ImGui.EndChild(); ImGui.NextColumn(); // ImDrawList API uses screen coordinates! Vector2 canvas_pos = ImGui.GetCursorScreenPos(); Vector2 canvas_size = ImGui.GetContentRegionAvail(); Vector2 canvas_endPos = canvas_pos + canvas_size; Vector2 waveBounds = new Vector2((float)(highestWave - lowestWave), (float)(highestMag - lowestMag)); _scalingFactor.X = 1 / (waveBounds.X / canvas_size.X); _scalingFactor.Y = 1 / (waveBounds.Y / canvas_size.Y); _translation.X = (float)(canvas_pos.X - lowestWave * _scalingFactor.X); _translation.Y = (float)(canvas_pos.Y - lowestMag * _scalingFactor.Y); _draw_list.AddRect(canvas_pos, canvas_endPos, borderColour); ImGui.Text("Scale:"); ImGui.Text("X: " + _scalingFactor.X + " Y: " + _scalingFactor.Y); Vector2 p0 = _translation + new Vector2((float)lowestWave, (float)lowestMag) * _scalingFactor; Vector2 p1 = _translation + new Vector2((float)highestWave, (float)highestMag) * _scalingFactor; ImGui.Text("Box From: " + p0); ImGui.Text("Box To: " + p1); DrawWav(_receverDat, receverFill); if (_reflectDat != null) { DrawWav(_reflectDat, reflectedFill); } if (_emmittrDat != null) { DrawWav(_emmittrDat, emittedFill); } if (_detectedDat != null) { DrawWav(_detectedDat, detectedColour); } } } void DrawWav(WaveDrawData wavesArry, uint colour) { for (int i = 0; i < wavesArry.Count; i++) { Vector2 p0 = _translation + wavesArry.Points[i].p0 * _scalingFactor; Vector2 p1 = _translation + wavesArry.Points[i].p1 * _scalingFactor; Vector2 p2 = _translation + wavesArry.Points[i].p2 * _scalingFactor; if (wavesArry.IsWaveDrawn[i].drawSrc) { //_draw_list.AddLine(p0, p1, colour); //_draw_list.AddLine(p1, p2, colour); _draw_list.AddTriangleFilled(p0, p1, p2, colour); } if (wavesArry.HasAtn && wavesArry.IsWaveDrawn[i].drawAtn) { Vector2 p3 = _translation + wavesArry.Points[i].p3 * _scalingFactor; _draw_list.AddTriangleFilled(p0, p3, p2, colour); } } } void DisplayWavInfo(WaveDrawData wavesArry) { for (int i = 0; i < wavesArry.Count; i++) { if (ImGui.Checkbox("Show Wave##drawbool" + i, ref wavesArry.IsWaveDrawn[i].drawSrc)) { ResetBounds(); } if (wavesArry.HasAtn) { ImGui.SameLine(); if (ImGui.Checkbox("Show Attenuated Wave##drawbool" + i, ref wavesArry.IsWaveDrawn[i].drawAtn)) { ResetBounds(); } } ImGui.Text("MinWav: " + Stringify.DistanceSmall(wavesArry.Points[i].p0.X)); ImGui.SameLine(); ImGui.Text("Magnitude: " + Stringify.Power(wavesArry.Points[i].p0.Y)); ImGui.Text("AvgWav: " + Stringify.DistanceSmall(wavesArry.Points[i].p1.X)); if (wavesArry.HasAtn) { ImGui.SameLine(); ImGui.Text(" Magnitude peak/attenuated:"); ImGui.Text(" " + Stringify.Power(wavesArry.Points[i].p1.Y) + "/" + Stringify.Power(wavesArry.Points[i].p3.Y)); } else { ImGui.SameLine(); ImGui.Text(" Magnitude peak:"); ImGui.Text(" " + Stringify.Power(wavesArry.Points[i].p1.Y)); } ImGui.Text("MaxWav: " + Stringify.DistanceSmall(wavesArry.Points[i].p2.X)); ImGui.SameLine(); ImGui.Text("Magnitude: " + Stringify.Power(wavesArry.Points[i].p2.Y)); } } void ResetBounds() { lowestWave = float.PositiveInfinity; lowestMag = float.PositiveInfinity; highestMag = float.NegativeInfinity; highestWave = float.NegativeInfinity; var dat = _receverDat; for (int i = 0; i < dat.Count; i++) { if (dat.IsWaveDrawn[i].drawSrc) { float low = dat.Points[i].p0.X; float high = dat.Points[i].p2.X; float mag1 = dat.Points[i].p0.Y; //recever highest value float mag2 = dat.Points[i].p1.Y; //recever lowest value if (low < lowestWave) { lowestWave = low; } if (high > highestWave) { highestWave = high; } if (mag1 > highestMag) { highestMag = mag1; } if (mag2 < lowestMag) { lowestMag = mag2; } } } if (_reflectDat != null) { ResetTargetBounds(_reflectDat); } if (_emmittrDat != null) { ResetTargetBounds(_emmittrDat); } if (_detectedDat != null) { ResetTargetBounds(_detectedDat); } } void ResetTargetBounds(WaveDrawData dat) { for (int i = 0; i < dat.Count; i++) { if (dat.IsWaveDrawn[i].drawSrc || dat.IsWaveDrawn[i].drawAtn) { float low = dat.Points[i].p0.X; float high = dat.Points[i].p2.X; float mag1 = dat.Points[i].p0.Y; //xmit lowest value prob 0 float mag2 = dat.Points[i].p1.Y; //xmit highest value float mag3 = dat.Points[i].p3.Y; //xmit 2nd highest value if (low < lowestWave) { lowestWave = low; } if (high > highestWave) { highestWave = high; } if (mag1 < lowestMag) //will likely be 0 { lowestMag = mag1; } if (dat.IsWaveDrawn[i].drawSrc) { if (mag2 > highestMag) { highestMag = mag2; } } if (dat.IsWaveDrawn[i].drawAtn) { if (mag3 > highestMag) { highestMag = mag3; } } } } } void SetSensorData() { if (_selectedEntity.GetDataBlob <ComponentInstancesDB>().TryGetComponentsByAttribute <SensorReceverAtbDB>(out var recevers)) { _receverDat = new WaveDrawData(); _receverDat.HasAtn = false; var points = _receverDat.Points = new (Vector2 p0, Vector2 p1, Vector2 p2, Vector2 p3)[recevers.Count]; _receverDat.IsWaveDrawn = new (bool drawSrc, bool drawAtn)[recevers.Count]; _selectedReceverAtb = new SensorReceverAtbDB[recevers.Count]; _selectedReceverInstanceAbility = new SensorReceverAbility[recevers.Count]; int i = 0; foreach (var recever in recevers) { _selectedReceverAtb[i] = recever.Design.GetAttribute <SensorReceverAtbDB>(); _selectedReceverInstanceAbility[i] = recever.GetAbilityState <SensorReceverAbility>(); float low = (float)_selectedReceverAtb[i].RecevingWaveformCapabilty.WavelengthMin_nm; float mid = (float)_selectedReceverAtb[i].RecevingWaveformCapabilty.WavelengthAverage_nm; float high = (float)_selectedReceverAtb[i].RecevingWaveformCapabilty.WavelengthMax_nm; float mag1 = (float)_selectedReceverAtb[i].WorstSensitivity_kW; float mag2 = (float)_selectedReceverAtb[i].BestSensitivity_kW; points[i].p0 = new Vector2(low, mag1); points[i].p1 = new Vector2(mid, mag2); points[i].p2 = new Vector2(high, mag1); i++; } var tgts = _selectedStarSys.GetAllEntitiesWithDataBlob <SensorProfileDB>(); _potentialTargetNames = new string[tgts.Count]; _potentialTargetEntities = tgts.ToArray(); i = 0; foreach (var target in tgts) { string name = target.GetDataBlob <NameDB>().GetName(_uiState.Faction); _potentialTargetNames[i] = name; i++; } for (int j = 0; j < _selectedReceverInstanceAbility.Length; j++) { //SetTargetData(); //var foo = _selectedReceverInstanceAbility[i].CurrentContacts; //foreach (SensorProcessorTools.SensorReturnValues val in foo.Values) //{ //val.SignalStrength_kW //} } }
/// <summary> /// Draw a preview graph texture on the preview pane /// </summary> /// <param name="plot">The graph being drawn</param> /// <param name="xPadding">horizontal padding</param> /// <param name="captionHeight">height of the caption</param> /// <param name="captionBackgroundcolor">contrast background colour of the caption</param> /// <param name="canHover">output flag states if we can safely draw a mouseover tooltip</param> /// <param name="mainWidgetSize">Size of the maingraph widget, used for projecting the zoom envelope</param> /// <returns>The graph was clicked</returns> private bool DrawPreviewGraph(PlottedGraph plot, float xPadding, float captionHeight, uint captionBackgroundcolor, out bool canHover, Vector2 mainWidgetSize) { ImDrawListPtr imdp = ImGui.GetWindowDrawList(); //draw on and clipped to this window bool clicked = false; canHover = false; if (plot == null) { return(clicked); } int graphNodeCount = plot.GraphNodeCount(); if (graphNodeCount == 0) { return(clicked); } plot.GetLatestTexture(out Texture previewTexture); if (previewTexture == null) { return(clicked); } bool isSelected = plot.TID == selectedGraphTID; canHover = true; //copy in the actual rendered graph ImGui.SetCursorPosY(ImGui.GetCursorPosY()); Vector2 subGraphPosition = ImGui.GetCursorScreenPos() + new Vector2(xPadding, 0); IntPtr CPUframeBufferTextureId = _ImGuiController !.GetOrCreateImGuiBinding(_gd !.ResourceFactory, previewTexture, $"PreviewPlot{plot.TID}"); imdp.AddImage(user_texture_id: CPUframeBufferTextureId, p_min: subGraphPosition, p_max: new Vector2(subGraphPosition.X + EachGraphWidth, subGraphPosition.Y + EachGraphHeight), uv_min: new Vector2(0, 1), uv_max: new Vector2(1, 0)); float borderThickness = Themes.GetThemeSize(Themes.eThemeSize.PreviewSelectedBorder); float halfBorderThickness = (float)Math.Floor(borderThickness / 2f); if (isSelected) { DrawPreviewZoomEnvelope(plot, subGraphPosition); //Draw the thicker selected graph border if (borderThickness > 0) { imdp.AddRect( p_min: new Vector2(subGraphPosition.X + halfBorderThickness, subGraphPosition.Y + halfBorderThickness), p_max: new Vector2((subGraphPosition.X + EachGraphWidth - halfBorderThickness), subGraphPosition.Y + EachGraphHeight - halfBorderThickness), col: GetGraphBorderColour(plot), 0, ImDrawFlags.None, borderThickness); } } //write the caption string Caption = $"TID:{plot.TID} {graphNodeCount} nodes {(isSelected ? "[Selected]" : "")}"; ImGui.SetCursorPosX(ImGui.GetCursorPosX()); Vector2 captionBGStart = subGraphPosition + new Vector2(borderThickness, borderThickness); Vector2 captionBGEnd = new Vector2((captionBGStart.X + EachGraphWidth - borderThickness * 2), captionBGStart.Y + captionHeight); imdp.AddRectFilled(p_min: captionBGStart, p_max: captionBGEnd, col: captionBackgroundcolor); ImGui.PushStyleColor(ImGuiCol.Text, Themes.GetThemeColourUINT(Themes.eThemeColour.PreviewText)); ImGui.SetCursorPosX(ImGui.GetCursorPosX() + CONSTANTS.UI.PREVIEW_PANE_X_PADDING + borderThickness + 1); ImGui.SetCursorPosY(ImGui.GetCursorPosY() + borderThickness); ImGui.Text(Caption); ImGui.PopStyleColor(); ImGui.SetCursorPosX(ImGui.GetCursorPosX() + EachGraphWidth - 48); //live thread activity plot if (ActiveTrace is not null && !ActiveTrace.WasLoadedFromSave) { ImGui.SetCursorPosY(ImGui.GetCursorPosY() - captionHeight); float maxVal; float[]? invalues = null; if (plot.InternalProtoGraph.TraceReader != null) { plot.InternalProtoGraph.TraceReader.RecentMessageRates(out invalues); } if (invalues == null || invalues.Length == 0) { invalues = new List <float>() { 0, 0, 0, 0, 0 }.ToArray(); maxVal = 100; } else { maxVal = invalues.Max(); } ImGui.PushStyleColor(ImGuiCol.FrameBg, captionBackgroundcolor); ImGui.PlotLines("", ref invalues[0], invalues.Length, 0, "", 0, maxVal, new Vector2(40, captionHeight)); if (ImGui.IsItemHovered()) { canHover = false; //The PlotLines widget doesn't allow disabling the mouseover, so have to prevent our mousover to avoid a merged tooltip } ImGui.PopStyleColor(); } //invisible button to detect graph click ImGui.SetCursorPos(new Vector2(1, ImGui.GetCursorPosY() - (float)(captionHeight))); if (ImGui.InvisibleButton("PrevGraphBtn" + plot.TID, new Vector2(EachGraphWidth, EachGraphHeight - 2)) || ImGui.IsItemActive()) { clicked = true; if (isSelected) { Vector2 clickPos = ImGui.GetMousePos(); Vector2 clickOffset = clickPos - subGraphPosition; clickOffset.Y = EachGraphHeight - clickOffset.Y; plot.MoveCameraToPreviewClick(clickOffset, new Vector2(EachGraphWidth, EachGraphHeight), mainGraphWidgetSize: mainWidgetSize, PreviewProjection); } } return(clicked); }