@@ -334,11 +334,9 @@ bool Init(sf::Window& window, const sf::Vector2f& displaySize, bool loadDefaultF
334
334
loadMouseCursor (ImGuiMouseCursor_Hand, sf::Cursor::Type::Hand);
335
335
336
336
if (loadDefaultFont)
337
- {
338
337
// this will load default font automatically
339
338
// No need to call AddDefaultFont
340
339
return UpdateFontTexture ();
341
- }
342
340
343
341
return true ;
344
342
}
@@ -403,13 +401,9 @@ void ProcessEvent(const sf::Window& window, const sf::Event& event)
403
401
{
404
402
if (mouseWheelScrolled->wheel == sf::Mouse::Wheel::Vertical ||
405
403
(mouseWheelScrolled->wheel == sf::Mouse::Wheel::Horizontal && io.KeyShift ))
406
- {
407
404
io.AddMouseWheelEvent (0 , mouseWheelScrolled->delta );
408
- }
409
405
else if (mouseWheelScrolled->wheel == sf::Mouse::Wheel::Horizontal)
410
- {
411
406
io.AddMouseWheelEvent (mouseWheelScrolled->delta , 0 );
412
- }
413
407
}
414
408
const auto handleKeyChanged = [&io](const auto & keyChanged, bool down)
415
409
{
@@ -513,13 +507,10 @@ void Update(const sf::Vector2i& mousePos, const sf::Vector2f& displaySize, sf::T
513
507
if (s_currWindowCtx->windowHasFocus )
514
508
{
515
509
if (io.WantSetMousePos )
516
- {
517
510
sf::Mouse::setPosition (sf::Vector2i (toSfVector2f (io.MousePos )));
518
- }
519
511
else
520
- {
521
512
io.MousePos = toImVec2 (sf::Vector2f (mousePos));
522
- }
513
+
523
514
for (unsigned int i = 0 ; i < 3 ; i++)
524
515
{
525
516
io.MouseDown [i] = s_currWindowCtx->touchDown [i] || sf::Touch::isDown (i) ||
@@ -633,9 +624,7 @@ bool UpdateFontTexture()
633
624
634
625
sf::Texture newTexture;
635
626
if (!newTexture.resize (sf::Vector2u (sf::Vector2 (width, height))))
636
- {
637
627
return false ;
638
- }
639
628
640
629
newTexture.update (pixels);
641
630
@@ -943,9 +932,7 @@ void RenderDrawLists(ImDrawData* draw_data)
943
932
{
944
933
ImGui::GetDrawData ();
945
934
if (draw_data->CmdListsCount == 0 )
946
- {
947
935
return ;
948
- }
949
936
950
937
const ImGuiIO& io = ImGui::GetIO ();
951
938
assert (io.Fonts ->TexID != (ImTextureID) nullptr ); // You forgot to create and set font texture
@@ -1115,9 +1102,7 @@ void updateJoystickButtonState(ImGuiIO& io)
1115
1102
const bool isPressed = sf::Joystick::isButtonPressed (s_currWindowCtx->joystickId .value (),
1116
1103
static_cast <unsigned >(i));
1117
1104
if (s_currWindowCtx->windowHasFocus || !isPressed)
1118
- {
1119
1105
io.AddKeyEvent (key, isPressed);
1120
- }
1121
1106
}
1122
1107
}
1123
1108
}
@@ -1126,18 +1111,12 @@ void updateJoystickAxis(ImGuiIO& io, ImGuiKey key, sf::Joystick::Axis axis, floa
1126
1111
{
1127
1112
float pos = sf::Joystick::getAxisPosition (s_currWindowCtx->joystickId .value (), axis);
1128
1113
if (inverted)
1129
- {
1130
1114
pos = -pos;
1131
- }
1132
1115
const bool passedThreshold = (pos > threshold) == (maxThreshold > threshold);
1133
1116
if (passedThreshold && s_currWindowCtx->windowHasFocus )
1134
- {
1135
1117
io.AddKeyAnalogEvent (key, true , std::abs (pos / 100 .f ));
1136
- }
1137
1118
else
1138
- {
1139
1119
io.AddKeyAnalogEvent (key, false , 0 );
1140
- }
1141
1120
}
1142
1121
1143
1122
void updateJoystickAxisPair (ImGuiIO& io, ImGuiKey key1, ImGuiKey key2, sf::Joystick::Axis axis, float threshold, bool inverted)
0 commit comments