Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: [Release][GUI] ImGui-SFML  (Read 93570 times)

0 Members and 3 Guests are viewing this topic.

Elias Daler

  • Hero Member
  • *****
  • Posts: 599
    • View Profile
    • Blog
    • Email
Re: [Release][GUI] ImGui-SFML
« Reply #60 on: February 23, 2021, 02:09:47 am »
ImGui-SFML v.2.2 is released. It's small, but it felt wrong to not have a release for the whole year...

https://github.com/eliasdaler/imgui-sfml/tree/v2.2

This release is an accumulation of small things which are important to release:

    - Dear ImGui >= 1.80 is now required. ImGui added imgui_tables.cpp and some
    of the functions were deprecated. It's important to stay up-to-date

    - Fixed Image/ImageButton and sf::RenderTexture problems (texture was
    shown upside down)

    - Removed an overload for Image/ImageButton which took sf::Texture and
    sf::IntRect textureRect. You should use sf::Sprite now.

    - Added sf::Cursor::Hand

    - Restored C++03 support

    - Fix MSVC warnings
Tomb Painter, Re:creation dev (abandoned, doing other things) | edw.is | @EliasDaler

Sub

  • Full Member
  • ***
  • Posts: 159
    • View Profile
Re: [Release][GUI] ImGui-SFML
« Reply #61 on: February 24, 2021, 12:43:11 am »
Wow, I wasn't expecting any further releases on this since you changed over to your own engine.

Thank you, this is really nice and helpful.

Paul

  • Jr. Member
  • **
  • Posts: 78
    • View Profile
Re: [Release][GUI] ImGui-SFML
« Reply #62 on: February 26, 2021, 01:52:34 pm »
Thanks. And I thought the texture upside down was a feature :)

Elias Daler

  • Hero Member
  • *****
  • Posts: 599
    • View Profile
    • Blog
    • Email
Re: [Release][GUI] ImGui-SFML
« Reply #63 on: February 28, 2021, 12:07:32 am »
Wow, I wasn't expecting any further releases on this since you changed over to your own engine.

Thank you, this is really nice and helpful.
Nope, it'll be maintained because I love SFML and I care about it's community even if I don't use it myself. Plus, it's still the most easy way to use Dear ImGui from scratch (compared to SDL/OpenGL way) - that's another thing which makes ImGui-SFML so important.
Tomb Painter, Re:creation dev (abandoned, doing other things) | edw.is | @EliasDaler

vale

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: [Release][GUI] ImGui-SFML
« Reply #64 on: September 10, 2023, 06:03:47 am »
Hi, I'm not exactly sure I understand how I should be using the events with sfml.

I'd like to know if, for example, a click happened on an Imgur pane/control rather than the rest of the window. Is there any way to know if the event actually had effect on the UI?

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: [Release][GUI] ImGui-SFML
« Reply #65 on: September 10, 2023, 11:20:52 pm »
Imgui (not Imgui-SFML) has a few globals for that called WantCaptureMouse, WantCaptureKeyboard, WantTextInput, etc.: https://github.com/ocornut/imgui/blob/master/imgui.h#L2081C17-L2081C33

I remember using those plus SFML event type (so if WantCaptureKeyboard is true then don't handle keyboard SFML event myself, etc.) and it was quite fine, I think.. I don't have the code anymore, but I'm sure it was using those.
Back to C++ gamedev with SFML in May 2023

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: [Release][GUI] ImGui-SFML
« Reply #66 on: September 19, 2023, 09:26:10 pm »
I am doing it right now in my own game and yes, it's simple (for basic cases, maybe it'll break later and require more code):
static bool isMouseEvent(const sf::Event& eve)
{
    switch(eve.type)
    {
    case sf::Event::MouseButtonPressed:
    case sf::Event::MouseButtonReleased:
    case sf::Event::MouseMoved:
        return true;
    default:
        return false;
    }
    return false;
}


static bool isKeyboardEvent(const sf::Event& eve)
{
    switch(eve.type)
    {
    case sf::Event::TextEntered:
    case sf::Event::KeyPressed:
    case sf::Event::KeyReleased:
        return true;
    default:
        return false;
    }
    return false;
}

bool Game::handleEventGui(const sf::Event& eve)
{
    ImGui::SFML::ProcessEvent(m_win, eve);

    if(ImGui::GetIO().WantCaptureMouse && isMouseEvent(eve))
        return true;

    if(ImGui::GetIO().WantTextInput && isKeyboardEvent(eve))
        return true;

    return false;
}
Back to C++ gamedev with SFML in May 2023

 

anything