Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImGuiIntegration: Add conversion between ImStrv and StringView #96

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hugoam
Copy link

@hugoam hugoam commented Jun 17, 2022

Hello !
This one is kind of self-explanatory :)
Do you think we could merge something in this spirit?

@hugoam hugoam force-pushed the imgui-stringview-convert branch from 8064fe3 to a2eab62 Compare June 17, 2022 10:25
@mosra mosra added this to the 2022.0a milestone Jun 17, 2022
@mosra
Copy link
Owner

mosra commented Jun 17, 2022

Yes, absolutely! :)

Couldn't find this in the main imgui branch, so I suppose it's originating from this PR, right? ocornut/imgui#3038 Can you add a bit of documentation, in a similar spirit to the other types listed above? Especially mentioning the PR/branch, and the IMGUI_HAS_IMSTR macro. And a test case as well, into Test/IntegrationTest.cpp. Thanks!


}}}
#endif
#endif
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of closing #ifndef DOXYGEN_GENERATING_OUTPUT here, you could just move the below #ifndef above, including the comment.

#ifdef IMGUI_HAS_IMSTR
namespace Corrade { namespace Containers { namespace Implementation {

template <> struct StringViewConverter<const char, ImStrv> {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
template <> struct StringViewConverter<const char, ImStrv> {
template<> struct StringViewConverter<const char, ImStrv> {

Sorry, being picky :P

#include <Magnum/Types.h>
#include <Magnum/Math/Vector.h>

#ifndef DOXYGEN_GENERATING_OUTPUT
#ifdef IMGUI_HAS_IMSTR
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#ifdef IMGUI_HAS_IMSTR
/* Currently present only in the features/string_view branch of ImGui */
#ifdef IMGUI_HAS_IMSTR

... or something like that, to make it clear why the ifdef is there.

@hugoam hugoam force-pushed the imgui-stringview-convert branch from a2eab62 to 5588c06 Compare June 24, 2022 16:30
@hugoam hugoam force-pushed the imgui-stringview-convert branch from 5588c06 to e51eafc Compare June 24, 2022 16:42
@mosra
Copy link
Owner

mosra commented Jun 24, 2022

Apologies for cancelling the CI, I have very little free CircleCI credits left for June and saving them for emergency reasons 🔥

If you can wait with pushing until July 1st, that'd be best. Thanks 😅

@mosra
Copy link
Owner

mosra commented Jun 24, 2022

Actually, I just went and temporarily disabled PR builds on CircleCI, so that should preserve the scarce minutes, hopefully. AppVeyor could be enough to verify correctness, ImGui is tested there as well I hope.

But due to CircleCI I'll likely not merge before 1st, sorry 😅

Copy link
Owner

@mosra mosra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, CIs are capable of running again :)

Be sure to rebase on master, as there were some breaking changes in Magnum that would otherwise cause the CI to fail to build.

Comment on lines +38 to +40
#ifdef IMGUI_HAS_IMSTR
void stringView();
#endif
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#ifdef IMGUI_HAS_IMSTR
void stringView();
#endif
#ifdef IMGUI_HAS_IMSTR
void stringView();
#endif

Indent preprocessor same as other code. Same below :)

Comment on lines +55 to +56
&IntegrationTest::colorLiterals
});
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unneeded change.

CORRADE_COMPARE(StringView(imStrv), stringView);

ImStrv c(stringView);
CORRADE_COMPARE(c, stringView);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, as far as I can see, this would convert c to a StringView and then use Corrade's own equality comparison. Which I don't think is wanted, since it is no different from the other comparison above.

Instead, isn't there something like ImStrCmp that could be used here?

@@ -57,11 +57,27 @@ Example usage:
#include "Magnum/ImGuiIntegration/visibility.h" /* defines IMGUI_API */
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update the docs above to mention the string conversion, please ;)

Also feel free to add yourself to the copyright header in the license block above the file.

@@ -57,11 +57,27 @@ Example usage:
#include "Magnum/ImGuiIntegration/visibility.h" /* defines IMGUI_API */

#include <imgui.h>
#include <Corrade/Containers/StringView.h>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would ideally be also wrapped in #ifdef IMGUI_HAS_IMSTR.

Alternatively I was thinking of deinlining the conversion into a new Integration.cpp file and having just a forward declaration here, but that's maybe taking it a bit too far. The StringView header is not that huge.

@mosra
Copy link
Owner

mosra commented Aug 18, 2022

@hugoam ping ;)

@hugoam
Copy link
Author

hugoam commented Aug 30, 2022

Sorry, didn't have much time to look at this again and then I went on a vacation. I'll try to have a look soonish, I promise

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

2 participants