forked from ngscopeclient/scopehal-apps
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDialog.cpp
More file actions
703 lines (615 loc) · 20.9 KB
/
Dialog.cpp
File metadata and controls
703 lines (615 loc) · 20.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
/***********************************************************************************************************************
* *
* ngscopeclient *
* *
* Copyright (c) 2012-2024 Andrew D. Zonenberg and contributors *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
* following conditions are met: *
* *
* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
* following disclaimer. *
* *
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
* following disclaimer in the documentation and/or other materials provided with the distribution. *
* *
* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
* POSSIBILITY OF SUCH DAMAGE. *
* *
***********************************************************************************************************************/
/**
@file
@author Andrew D. Zonenberg
@brief Implementation of Dialog
*/
#include "ngscopeclient.h"
#include "Dialog.h"
using namespace std;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Construction / destruction
Dialog::Dialog(const string& title, const string& id, ImVec2 defaultSize)
: m_open(true)
, m_id(id)
, m_title(title)
, m_defaultSize(defaultSize)
{
}
Dialog::~Dialog()
{
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Rendering
/**
@brief Renders the dialog and handles UI events
@return True if we should continue showing the dialog
False if it's been closed
*/
bool Dialog::Render()
{
if(!m_open)
return false;
string name = m_title + "###" + m_id;
ImGui::SetNextWindowSize(m_defaultSize, ImGuiCond_Appearing);
if(!ImGui::Begin(name.c_str(), &m_open, ImGuiWindowFlags_NoCollapse))
{
//If we get here, the window is tabbed out or the content area is otherwise not visible.
//Save time by not drawing anything, but don't close the window!
ImGui::End();
return true;
}
if(!DoRender())
{
ImGui::End();
return false;
}
RenderErrorPopup();
ImGui::End();
return true;
}
/**
@brief Runs the dialog's contents directly into a parent window
*/
void Dialog::RenderAsChild()
{
DoRender();
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Error messages
/**
@brief Opens the error popup
*/
void Dialog::ShowErrorPopup(const string& title, const string& msg)
{
ImGui::OpenPopup(title.c_str());
m_errorPopupTitle = title;
m_errorPopupMessage = msg;
}
/**
@brief Popup message when we fail to connect
*/
void Dialog::RenderErrorPopup()
{
if(ImGui::BeginPopupModal(m_errorPopupTitle.c_str(), nullptr, ImGuiWindowFlags_AlwaysAutoResize))
{
ImGui::TextUnformatted(m_errorPopupMessage.c_str());
ImGui::Separator();
if(ImGui::Button("OK"))
ImGui::CloseCurrentPopup();
ImGui::EndPopup();
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Widget helpers for common imgui stuff
/**
@brief Displays a combo box from a vector<string>
*/
bool Dialog::Combo(const string& label, const vector<string>& items, int& selection)
{
string preview;
ImGuiComboFlags flags = 0;
//Hide arrow button if no items
if(items.empty())
flags = ImGuiComboFlags_NoArrowButton;
//Set preview to currently selected item
else if( (selection >= 0) && (selection < (int)items.size() ) )
preview = items[selection];
bool changed = false;
//Render the box
if(ImGui::BeginCombo(label.c_str(), preview.c_str(), flags))
{
for(int i=0; i<(int)items.size(); i++)
{
bool selected = (i == selection);
if(ImGui::Selectable(items[i].c_str(), selected))
{
changed = true;
selection = i;
}
if(selected)
ImGui::SetItemDefaultFocus();
}
ImGui::EndCombo();
}
return changed;
}
/**
@brief Helper based on imgui demo for displaying a help icon and tooltip text
*/
void Dialog::HelpMarker(const string& str)
{
ImGui::SameLine();
ImGui::TextDisabled("(?)");
Tooltip(str);
}
/**
@brief Helper based on imgui demo for displaying tooltip text over the previously rendered widget
*/
void Dialog::Tooltip(const string& str, bool allowDisabled)
{
int extraFlags = 0;
if(allowDisabled)
extraFlags |= ImGuiHoveredFlags_AllowWhenDisabled;
if(ImGui::IsItemHovered(ImGuiHoveredFlags_DelayShort | extraFlags))
{
ImGui::BeginTooltip();
ImGui::PushTextWrapPos(ImGui::GetFontSize() * 50);
ImGui::TextUnformatted(str.c_str());
ImGui::PopTextWrapPos();
ImGui::EndTooltip();
}
}
/**
@brief Helper based on imgui demo for displaying a help icon and tooltip text consisting of a header and bulleted text
*/
void Dialog::HelpMarker(const string& header, const vector<string>& bullets)
{
ImGui::SameLine();
ImGui::TextDisabled("(?)");
if(ImGui::IsItemHovered(ImGuiHoveredFlags_DelayShort))
{
ImGui::BeginTooltip();
ImGui::PushTextWrapPos(ImGui::GetFontSize() * 50);
ImGui::TextUnformatted(header.c_str());
for(auto s : bullets)
ImGui::BulletText("%s", s.c_str());
ImGui::PopTextWrapPos();
ImGui::EndTooltip();
}
}
/**
@brief Helper for displaying a floating-point input box with an "apply" button
*/
bool Dialog::FloatInputWithApplyButton(const string& label, float& currentValue, float& committedValue)
{
ImGui::BeginGroup();
bool dirty = currentValue != committedValue;
ImGui::InputFloat(label.c_str(), ¤tValue);
ImGui::SameLine();
if(!dirty)
ImGui::BeginDisabled();
auto applyLabel = string("Apply###Apply") + label;
bool changed = false;
if(ImGui::Button(applyLabel.c_str()))
{
changed = true;
committedValue = currentValue;
}
if(!dirty)
ImGui::EndDisabled();
ImGui::EndGroup();
return changed;
}
bool Dialog::TextInputWithApplyButton(const string& label, string& currentValue, string& committedValue)
{
ImGui::BeginGroup();
bool dirty = currentValue != committedValue;
ImGui::InputText(label.c_str(), ¤tValue);
ImGui::SameLine();
if(!dirty)
ImGui::BeginDisabled();
auto applyLabel = string("Apply###Apply") + label;
bool changed = false;
if(ImGui::Button(applyLabel.c_str()))
{
changed = true;
committedValue = currentValue;
}
if(!dirty)
ImGui::EndDisabled();
ImGui::EndGroup();
return changed;
}
bool Dialog::TextInputWithImplicitApply(const string& label, string& currentValue, string& committedValue)
{
bool dirty = currentValue != committedValue;
ImGui::InputText(label.c_str(), ¤tValue);
if(!ImGui::IsItemActive() && dirty )
{
committedValue = currentValue;
return true;
}
return false;
}
bool Dialog::IntInputWithImplicitApply(const string& label, int& currentValue, int& committedValue)
{
bool dirty = currentValue != committedValue;
ImGui::InputInt(label.c_str(), ¤tValue);
if(!ImGui::IsItemActive() && dirty )
{
committedValue = currentValue;
return true;
}
return false;
}
/**
@brief Input box for a floating point value with an associated unit
@param label Text label
@param currentValue Current text box content
@param committedValue Most recently applied value
@param unit The unit for the input
@return True when focus is lost or user presses enter
*/
bool Dialog::UnitInputWithImplicitApply(
const std::string& label,
std::string& currentValue,
float& committedValue,
Unit unit)
{
bool dirty = unit.PrettyPrint(committedValue) != currentValue;
ImGui::InputText(label.c_str(), ¤tValue);
if(!ImGui::IsItemActive() && dirty )
{
committedValue = unit.ParseString(currentValue);
currentValue = unit.PrettyPrint(committedValue);
return true;
}
return false;
}
/**
@brief Input box for a double precision floating point value with an associated unit
@param label Text label
@param currentValue Current text box content
@param committedValue Most recently applied value
@param unit The unit for the input
@return True when focus is lost or user presses enter
*/
bool Dialog::UnitInputWithImplicitApply(
const std::string& label,
std::string& currentValue,
double& committedValue,
Unit unit)
{
bool dirty = unit.PrettyPrint(committedValue) != currentValue;
ImGui::InputText(label.c_str(), ¤tValue);
if(!ImGui::IsItemActive() && dirty )
{
committedValue = unit.ParseString(currentValue);
currentValue = unit.PrettyPrint(committedValue);
return true;
}
return false;
}
/**
@brief Input box for an integer value with an associated unit
@param label Text label
@param currentValue Current text box content
@param committedValue Most recently applied value
@param unit The unit for the input
@return True when focus is lost or user presses enter
*/
bool Dialog::UnitInputWithImplicitApply(
const std::string& label,
std::string& currentValue,
int64_t& committedValue,
Unit unit)
{
bool dirty = unit.PrettyPrintInt64(committedValue) != currentValue;
ImGui::InputText(label.c_str(), ¤tValue);
if(!ImGui::IsItemActive() && dirty )
{
//Float path if the user input a decimal value like "3.5G"
if(currentValue.find(".") != string::npos)
committedValue = unit.ParseString(currentValue);
//Integer path otherwise for full precision
else
committedValue = unit.ParseStringInt64(currentValue);
currentValue = unit.PrettyPrintInt64(committedValue);
return true;
}
return false;
}
/**
@brief Input box for a floating point value with an associated unit and an "apply" button
@param label Text label
@param currentValue Current text box content
@param committedValue Most recently applied value
@param unit The unit for the input
@return True the "apply" button is pressed
*/
bool Dialog::UnitInputWithExplicitApply(
const std::string& label,
std::string& currentValue,
float& committedValue,
Unit unit)
{
bool dirty = unit.PrettyPrint(committedValue) != currentValue;
ImGui::BeginGroup();
ImGui::InputText(label.c_str(), ¤tValue);
ImGui::SameLine();
if(!dirty)
ImGui::BeginDisabled();
auto applyLabel = string("Apply###Apply") + label;
bool changed = false;
if(ImGui::Button(applyLabel.c_str()))
{
changed = true;
committedValue = unit.ParseString(currentValue);
currentValue = unit.PrettyPrint(committedValue);
}
if(!dirty)
ImGui::EndDisabled();
ImGui::EndGroup();
return changed;
}
/**
@brief Segment on/off state for each of the 10 digits + "L" (needed for OL / Overload)
0b01000000 : Top h segment
0b00100000 : Top right v seglent
0b00010000 : Bottom right v segment
0b00001000 : Bottom h segment
0b00000100 : Bottom left v segment
0b00000010 : Top left v segment
0b00000001 : Center h segment
*/
static char SEGMENTS[] =
{
0x7E, // 0
0x30, // 1
0x6D, // 2
0x79, // 3
0x33, // 4
0x5B, // 5
0x5F, // 6
0x70, // 7
0x7F, // 8
0x7B, // 9
0x0E, // L
};
/**
@brief Render a single digit in 7 segment display style
@param drawList the drawList used for rendering
@param digit the digit to render
@param size the size of the digit
@param position the position of the digit
@param thickness the thickness of a segment
@param colorOn the color for an "on" segment
@param colorOff the color for an "off" segment
*/
void Dialog::Render7SegmentDigit(ImDrawList* drawList, uint8_t digit, ImVec2 size, ImVec2 position, float thickness, ImU32 colorOn, ImU32 colorOff)
{
// Inspired by https://github.com/ocornut/imgui/issues/3606#issuecomment-736855952
if(digit > 10)
digit = 10; // 10 is for L of OL (Overload)
size.y += thickness;
ImVec2 halfSize(size.x/2,size.y/2);
ImVec2 centerPosition(position.x+halfSize.x,position.y+halfSize.y);
float w = thickness;
float h = thickness/2;
float segmentSpec[7][4] =
{
{-1, -1, h, h}, // Top h segment
{ 1, -1, -h, h}, // Top right v seglent
{ 1, 0, -h, -h}, // Bottom right v segment
{-1, 1, h, -w * 1.5f},// Bottom h segment
{-1, 0, h, -h}, // Bottom left v segment
{-1, -1, h, h}, // Top left v segment
{-1, 0, h, -h}, // Center h segment
};
for(int i = 0; i < 7; i++)
{
ImVec2 topLeft, bottomRight;
if(i % 3 == 0)
{
// Horizontal segment
topLeft = ImVec2(centerPosition.x + segmentSpec[i][0] * halfSize.x + segmentSpec[i][2], centerPosition.y + segmentSpec[i][1] * halfSize.y + segmentSpec[i][3] - h);
bottomRight = ImVec2(topLeft.x + size.x - w, topLeft.y + w);
}
else
{
// Vertical segment
topLeft = ImVec2(centerPosition.x + segmentSpec[i][0] * halfSize.x + segmentSpec[i][2] - h, centerPosition.y + segmentSpec[i][1] * halfSize.y + segmentSpec[i][3]);
bottomRight = ImVec2(topLeft.x + w, topLeft.y + halfSize.y - w);
}
ImVec2 segmentSize = bottomRight - topLeft;
float space = w * 0.6;
float u = space - h;
if(segmentSize.x > segmentSize.y)
{
// Horizontal segment
ImVec2 points[] =
{
{topLeft.x + u, topLeft.y + segmentSize.y * .5f},
{topLeft.x + space, topLeft.y},
{bottomRight.x - space, topLeft.y},
{bottomRight.x - u, topLeft.y + segmentSize.y * .5f},
{bottomRight.x - space, bottomRight.y},
{topLeft.x + space, bottomRight.y}
};
drawList->AddConvexPolyFilled(points, 6, (SEGMENTS[digit] >> (6 - i)) & 1 ? colorOn : colorOff);
}
else
{
// Vertical segment
ImVec2 points[] = {
{topLeft.x + segmentSize.x * .5f, topLeft.y + u},
{bottomRight.x, topLeft.y + space},
{bottomRight.x, bottomRight.y - space},
{bottomRight.x - segmentSize.x * .5f, bottomRight.y - u},
{topLeft.x, bottomRight.y - space},
{topLeft.x, topLeft.y + space}};
drawList->AddConvexPolyFilled(points, 6, (SEGMENTS[digit] >> (6 - i)) & 1 ? colorOn : colorOff);
}
}
}
// @brief ratio between unit font size and digit size
#define UNIT_SCALE 0.80f
// @brief ratio between digit width and height
#define DIGIT_WIDTH_RATIO 0.50f
/**
@brief Render a numeric value with a 7 segment display style
@param value the string representation of the value to display (may include the unit)
@param color the color to use
@param digitHeight the height of a digit
*/
void Dialog::Render7SegmentValue(const std::string& value, ImVec4 color, float digitHeight)
{
bool ignoredClicked, ignoredHovered;
Render7SegmentValue(value,color,digitHeight,ignoredClicked,ignoredHovered,false);
}
/**
@brief Render a numeric value with a 7 segment display style
@param value the string representation of the value to display (may include the unit)
@param color the color to use
@param digitHeight the height of a digit
@param clicked output value for clicked state
@param hovered output value for hovered state
@param clickable true (default) if the displayed value should be clickable
*/
void Dialog::Render7SegmentValue(const std::string& value, ImVec4 color, float digitHeight, bool &clicked, bool &hovered, bool clickable)
{
ImDrawList* draw_list = ImGui::GetWindowDrawList();
// Compute digit width according th height
float digitWidth = digitHeight*DIGIT_WIDTH_RATIO;
// Compute front and back color
float bgmul = 0.15;
auto bcolor = ImGui::ColorConvertFloat4ToU32(ImVec4(color.x*bgmul, color.y*bgmul, color.z*bgmul, color.w));
auto fcolor = ImGui::ColorConvertFloat4ToU32(color);
// Parse value string to get integer and fractional part + unit
bool inIntPart = true;
bool inFractPart = false;
vector<uint8_t> intPart;
vector<uint8_t> fractPart;
string unit;
if(value == UNIT_OVERLOAD_LABEL)
{
// Overload
intPart.push_back(0);
intPart.push_back(10); // 10 is for L
unit = "Inf.";
}
else
{
// Iterate on each char of the value string
for(const char c : value)
{
if(c >= '0' && c <='9')
{
// This is a numeric digit
if(inIntPart)
intPart.push_back((uint8_t)(c-'0'));
else if(inFractPart)
fractPart.push_back((uint8_t)(c-'0'));
else
unit += c;
}
else if(c == '.' || c == std::use_facet<std::numpunct<char> >(std::locale()).decimal_point() || c == ',')
{
// This is the decimal separator
if(inIntPart)
{
inFractPart = true;
inIntPart = false;
}
else
LogWarning("Unexpected decimal separator '%c' in value '%s'.\n",c,value.c_str());
}
else if(isspace(c) || c == std::use_facet< std::numpunct<char> >(std::locale()).thousands_sep())
{
// We ingore spaces (except in unit part)
if(inIntPart || inFractPart) {} // Ignore
else
unit += c;
}
else // Anything else
{
// This is the unit
inFractPart = false;
inIntPart = false;
unit += c;
}
}
// Trim the unit string
unit = Trim(unit);
// Fill fractional part with 2 zeros if it's empty
if(fractPart.empty())
{
fractPart.push_back(0);
fractPart.push_back(0);
}
}
// Segment thickness
float thickness = digitHeight/10;
// Space between digits
float spacing = 0.08 * digitWidth;
// Size of decimal separator
float dotSize = 2*thickness;
// Size of unit font and unit text
float unitSize = digitHeight*UNIT_SCALE;
float unitTextWidth = ImGui::GetFont()->CalcTextSizeA(unitSize,FLT_MAX, 0.0f,unit.c_str()).x;
ImVec2 size(digitWidth*(intPart.size()+fractPart.size())+dotSize+2*spacing+unitTextWidth+thickness, digitHeight);
if(clickable)
{
bgmul = 0.0f;
ImVec4 buttonColor = ImVec4(color.x*bgmul, color.y*bgmul, color.z*bgmul, 0);
bgmul = 0.2f;
ImVec4 buttonColorHovered = ImVec4(color.x*bgmul, color.y*bgmul, color.z*bgmul, color.w);
bgmul = 0.3f;
ImVec4 buttonColorActive = ImVec4(color.x*bgmul, color.y*bgmul, color.z*bgmul, color.w);
ImGui::PushStyleColor(ImGuiCol_Button, buttonColor);
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, buttonColorHovered);
ImGui::PushStyleColor(ImGuiCol_ButtonActive, buttonColorActive);
clicked |= ImGui::Button(" ",size);
hovered |= ImGui::IsItemHovered();
ImGui::PopStyleColor(3);
if(hovered)
ImGui::SetMouseCursor(ImGuiMouseCursor_Hand);
}
else
ImGui::InvisibleButton("seven", size, ImGuiButtonFlags_EnableNav);
ImVec2 position = ImGui::GetItemRectMin();
// Actual digit width (without space)
float digitActualWidth = digitWidth - spacing;
// Current x position
float x = 0;
// Integer part
for(size_t i = 0; i < intPart.size(); i++)
{
Render7SegmentDigit(draw_list, intPart[i], ImVec2(digitActualWidth, digitHeight), ImVec2(position.x + x, position.y),thickness,fcolor,bcolor);
x += digitWidth;
}
// Decimal separator
x+= spacing;
draw_list->AddCircleFilled(ImVec2(position.x+x+dotSize/2-spacing/2,position.y+digitHeight-dotSize/2),dotSize/2,fcolor);
x+= dotSize;
x+= spacing;
// Factional part
for(size_t i = 0; i < fractPart.size(); i++)
{
Render7SegmentDigit(draw_list, fractPart[i], ImVec2(digitActualWidth, digitHeight), ImVec2(position.x + x, position.y),thickness,fcolor,bcolor);
x += digitWidth;
}
// Unit
draw_list->AddText(NULL,unitSize,
ImVec2(position.x + x + thickness, position.y),
fcolor,
unit.c_str());
}