-
Notifications
You must be signed in to change notification settings - Fork 333
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
Add ability for user to override container types #110
Conversation
Now that build is fixed and i have some time - i should talk about stinks of this PR. In order to make RmlUi work with EASTL i had to remove Second thing i do not really like is Let me know how you would like to handle this. |
Thank you for the PR! Looks very good so far.
I think it would be good to discuss these things in a new issue.
Looks like this is just for the
I'm a bit worried that splitting the config and types would make the CMake settings a bit overwhelming and make it harder to navigate the configuration. I'd prefer just the name I think the new CMake settings should only be enabled and displayed if a I'm in the process of moving this coming week, so a bit busy, but I will try to find some time here and there to go through it and review it in more detail. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor additional comments.
Include/RmlUi/Core/DataModel.h
Outdated
@@ -168,7 +169,7 @@ class RMLUICORE_API DataModelConstructor { | |||
// Register an array type. | |||
// @note The type applies to every data model associated with the current Context. | |||
// @note If 'Container::value_type' represents a non-scalar type, that type must already have been registered with the appropriate 'Register...()' functions. | |||
// @note Container requires the following functions to be implemented: size() and begin(). This is satisfied by several containers such as std::vector and std::array. | |||
// @note Container requires the following functions to be implemented: size() and begin(). This is satisfied by several containers such as Vector and Array. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather keep the original here.
Include/RmlUi/Core/Types.h
Outdated
using Matrix4f = ColumnMajorMatrix4f; | ||
using Matrix4f = RMLUI_DEFAULT_MATRIX_TYPE; | ||
|
||
} // namespace Rml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why the namespace is closed and then opened?
@@ -33,7 +33,7 @@ | |||
|
|||
namespace FontProviderBitmap | |||
{ | |||
static std::vector<std::unique_ptr<FontFaceBitmap>> fonts; | |||
static Rml::Vector<std::unique_ptr<FontFaceBitmap>> fonts; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing UniquePtr (maybe do a find all on the samples?)
Include/RmlUi/UserConfig.h
Outdated
#define RMLUI_COLOUR_USER_EXTRA | ||
// Extra code to be inserted into RmlUi::Vector2<> class body. | ||
#define RMLUI_VECTOR2_USER_EXTRA | ||
// Extra code to be inserted into RmlUi::Vector3<> class body. | ||
#define RMLUI_VECTOR3_USER_EXTRA | ||
// Extra code to be inserted into RmlUi::Vector4<> class body. | ||
#define RMLUI_VECTOR4_USER_EXTRA | ||
// Extra code to be inserted into RmlUi::Matrix4<> class body. | ||
#define RMLUI_MATRIX4_USER_EXTRA |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should comment out these optional defines in the default configuration.
Also, it would be nice with an example in comments, at least for one of these options.
Include/RmlUi/UserConfig.h
Outdated
|
||
// Following defines should be used for insering custom type cast operators for conversion of RmlUi types | ||
// to user types. RmlUi uses template math types, therefore conversion operators to non-templated types | ||
// should be done using SFINAE as in example below. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the examples. I must admit all the SFINAE hurts my eyes a lot. I'd prefer if the examples assumed the user types are templated, and tell them to use SFINAE with perhaps a single SFINAE example for eg. vector2.
The color example is a bit problematic, because float colors are usually interpreted in linear color space, while byte versions are usually in SRGB. At least this is the assumption used internally in RmlUi. I don't think we ever use the float color in any public API though. By the way they should be divided by 255 and not 256 :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure about the example? SFINAE is horrible. However duty of the library is to make people's lives easier. More often than not i bump into engines with non-templated math types, but for the sake of argument we can say there is about equal amount of engines with either implementation. Now if engine is using templated types then it would be trivial to implement type conversion operators, ignoring SFINAE junk here. But if engine uses non-templated types then writing this stuff takes some effort, especially for people not familiar with these arcane arts. I think it would be much more helpful if we left an extensive example for something that is quite a common case.
The color example is a bit problematic,
Hmm i do not have an answer to that, other than adding a comment warning to mind differences of colorspaces.
By the way they should be divided by 255 and not 256 :)
Nobody saw that 😊
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, you have me convinced :) If I get too miserable looking at those examples after a while I might move them to the documentation later. The color part is fine like that.
How do you feel this is coming along? We should probably try to merge it as soon as possible so it doesn't diverge too much with new commits. What do you think about the cmake and filename suggestions in #110 (comment) ? |
Looks like i only missed adding |
I was thinking about these suggestions as well:
|
That makes sense yes. Will do. I tried forward-declaring |
Alright, if you prefer I'm fine with splitting the configuration into |
Maybe we could look into making some common include that would pull in
header.h/config/types/traits headers. They all are basic building blocks
after all.
…On July 19, 2020 11:39:31 "Michael R. P. Ragazzon" ***@***.***> wrote:
I tried forward-declaring Releaser. Outcome is bit hairy. This introduces a
dependency on configuration header when Traits.h is included. So we must
always include Types.h before/instead of Traits.h. Traits.h can not be
included alone. Unless that header itself also included config header. Not
ideal.
Alright, if you prefer I'm fine with splitting the configuration into
Config.h and ConfigTypes.h or TypeConfig.h as you suggested earlier.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Yeah that's a good idea. We have some headers that need to be included everywhere, such as We could add a |
791dde2
to
7925763
Compare
Moved configuration into |
Co-authored-by: Michael R. P. Ragazzon <mikke89@users.noreply.github.com> Update Include/RmlUi/Core/Types.h Co-authored-by: Michael R. P. Ragazzon <mikke89@users.noreply.github.com>
Hmm, I'm fine with having it as it is, I think it's a bit weird to include any Lua stuff if you don't use it. I think all headers should be able to be included separately though, so I'd like to see With those changes and the CMake configuration changes mentioned earlier, I'm fine with merging this :) |
Oh but i am not suggesting to include lua when it is not used. We configure use of lua at build time, however. Thing is lua support is essentially a part of main library. I think original developer split it to a separate dll because intention was a commercial middleware, where you could ignore a part of unused functionality without having to recompile a library. And now that library is opensource this makes little sense. I mean look at I have dropped |
Ah, I see what you mean now. Yeah that actually makes sense. This would make it harder to provide binaries though, but binaries for C++ libraries are problematic enough so I guess that's okay. But yeah let's ignore it for now and take that discussion later if we care enough to change :)
Yup, I like those changes. Thanks! Looks good for merging to me. I might change up the CMake configuration a bit later. |
Thanks again for the PR :) |
Looks like i left an oopsie: https://github.com/mikke89/RmlUi/blob/master/Source/Core/StyleSheetParser.h#L42 |
Yup, I got it! :) |
This is an implementation of my ideas raised in #107. Please review and comment.
It was nice to find out that lua integration did not require any changes whatsoever. Yay!
Few unrelated observations:
.editorconfig
. I had to restore bunch of trailing spaces to avoid extra noise in commits. Editor was eager to get rid of them. This would also configure editors to use tabs..gitattributes
and normalize line endings. Most files use\n
while some use\r\n
. This puts us in a position where one line change may flag entire file as changed only because editor changed line endings.CMakeLists.txt
are not proper, but then again entire build script is in a state where it just can not be fixed, but should be rewritten instead. I might do it in the future (no promises).