I'm doing my little GUI, 200-300 lines of my own code instead of heavy IMGUI and such, and yes, I'm suck. I managed to draw stuff and make it even somewhat functional, but in case I'm drawing, let's assume, trackbar with size of 100 and MaxVal is 100 is okay, but in case MaxVal is 5 I have to use 5 as a width and my trackbar become very short. I would like to have static width regardless of MaxVal . The VariableValue is becoming wrong.
void Trackbar(const float X, const float Y, const float Width, bool Variable, const char* Caption, const float MaxVal, UINT& VariableValue)
{
POINT TrackbarPos;
GetCursorPos (&TrackbarPos);
ScreenToClient (GetForegroundWindow(), &TrackbarPos);
static float AbsolutePos = 0;
if (Variable) {
if (IsMouseCursorIn(X, Y-18, Width, 15)) {
if (KeyState_LButton == OnKeyPressed) {
AbsolutePos = TrackbarPos.x-X;
float RelativePos = (AbsolutePos/MaxVal)*Width; // this is wrong
VariableValue = RelativePos;
}
}
}
D3DCOLOR Color = D3DCOLOR_ARGB(255, 96, 96, 96);
if (Variable) {
Color = D3DCOLOR_ARGB(255, 106, 106, 106);
}
//! Bar
ToolkitRenderer::GetToolkitRenderer().Box(X, Y-10, Width+4, 1, Color, true);
//! Slider
ToolkitRenderer::GetToolkitRenderer().Box(X+AbsolutePos, Y-11, 3, 2, D3DCOLOR_ARGB(255, 89, 89, 89), true );
ToolkitRenderer::GetToolkitRenderer().Box(X+AbsolutePos, Y-11, 3, 2, D3DCOLOR_ARGB(255, 110, 110, 110), false);
//! Text
//ToolkitRenderer::GetToolkitRenderer().Text(X, Y-15, 0, Caption, Color);
}
↧