-
-
Notifications
You must be signed in to change notification settings - Fork 101
Added alignment to TabContainer #174
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
Conversation
The tabs of a TabContainer can now be aligned at the top (above the panels - the previous and default behavior) or at the bottom (below the panels) and additionally spread over the whole widget width or left-aligned with fixed width.
The tabs of a TabContainer can now be aligned at the top (above the panels - the previous and default behavior) or at the bottom (below the panels) and additionally spread over the whole widget width or left-aligned with fixed width.
I'm grateful for your contribution, but I fear you did too much work. I apologize for the long list of critics, I don't want to discourage contributing, but it just seem like you have have over-engineered some things, and many comments are about things that can be removed again.
|
Thank you for your detailed comment. It makes some things clear that are not apparent from the code and documentation - and that's a real shame, because it unnecessarily increases the idle effort.
|
Thanks for making the changes, there are still a few things I notice:
If you have specific suggestions on where I could add which information then I'm definitely open for them.
The reason layouts aren't useful for this is because they don't do anything automatically. Unless I'm overlooking something, your implementation won't actually do anything. When adding new tabs or removing new tabs, how is the width of the Tabs widget updated? When you set the fixed size then you call layoutTabs which calls (a slightly more verbose version of) Having BindingNumberOfChildren for containers is a bit different, because there such logic (i.e. informing the layout about adding and removing widget from the container) could be implemented in the Container base class and you would simplify such functionality for any derived class (if such functionality would be needed). But even then I would need to see some use case to consider it, because the only use case that I can come up with is to auto-size a BoxLayout widget. And if that is the only use case then it would probably be better to implement it inside that class instead of involving the layouts (although that would be debatable). But specifically for the tabs widget I don't see how BindingNumberOfChildren simplifies anything (neither for maintenance nor for the user of the library). If I overlooked something and BindingNumberOfChildren is functional while inserting new tabs then you can keep the code and I will think about it again, my current opinion is based on the assumption that it won't work without extra work.
That's a very good point. I've ignored protected members for now but I guess a few people (those that inherit from the widget) would still benefit from the comments. I would keep it compact, without lines full of hyphens. If the comment is above the variable, the comment (one or more lines) needs to have I checked the documentation and it does already list the protected members, even those that aren't documented, so maybe documentating trivial members still isn't necessary.
Those are used for increasing readability. There are 3 situations where they are used:
I've never questioned my use of whitespace or hyphen-lines, as this is just my personal style and I've never had to create rules for them, so I'm open for changes in this style. I've noticed that e.g. your The two lines of whitespace between those functions looks bad though, I would recuce that to a single line. Which got me thinking further, why am I even using 2 lines between documented functions? While I did that for readability, I would be fine with just reducing the whitespace to only a single empty line between all functions, even the public ones, to be able to have a more consistent style. |
Will you still be updating this PR? Or should I make the last changes myself to finish what you started? |
Sorry for the late reply - I had a very intense time professionally. I had to successfully complete the monitoring audit for ISO 27001 as well as the audits for information security and data protection in order to pass TISAX label demands for my employer. I will try to work through the open items quickly now.... I agree that the TabAlignment class (hpp and cpp) can be deleted. In my source tree it is, but I'm not sure if that arrived in the pull request. Regarding BindingNumberOfChildren. I have to adjust to your philosophy first - which I would call "solve requirements locally if possible instead of providing generic extensions" based on your comments. I have mostly dealt with Microsoft frameworks so far - whose philosophy I would describe as "provide generic extensions, we don't know all the use cases of the application programmers out there". In fact, I have a GUI test app that adds and deletes tabs and also tests whether the currently active tab can be deleted without crashing (buttonTabSizeCallBack). It also tests the 4 possible combinations of alignment/fixedSize (buttonTabAlignCallBack).
So - if TabAlignment class is removed now and you agree to the BindingNumberOfChildren implementation - I'd say I'm done. |
Two tests are failing because the TabAlign class isn't deleted completely.
Adjustment of overlooked minor inadequacies.
No problem, I didn't have much time myself either (this is the first day since August where I would have enough time to further look into this myself, so your timing was perfect). I've merged your changes in 5dccd0d I've made another commit afterwards that removes the BindingNumberOfChildren again. This is partially a philosophy difference, but the more "generic" method was hiding the fact that your code wasn't actually doing anything. Your code worked because you recreated the layout every time, so using a layout had no use. I could literally replace your BindingNumberOfChildren layout with a constant value, and the code still does exactly the same thing. This has nothing to do with your changes, but I also made several other changes, such as removing m_index. I didn't like that it could potentially get out of sync with the selected index in the Tabs widget and it made implementing removeTab difficult without introducing subtle bugs (like the one you fixed). Because of this, you may want to re-run the tests that you created with the new code, to make certain that I didn't introduce any new bugs in doing so. |
Thank you so much for finishing my PR!
I've looked at your changes, including replacing the m_index with a direct pointer. I also understand your objections to some of my changes better now.
I think I need to get much more involved with the TGUI source code before I can make any meaningful contributions. But maybe I can do something for TGUI in another way, for example:
https://www.codeproject.com/Articles/5344092/First-Steps-Tutorial-How-to-Start-with-TGUI-Runnin
|
I haven't had time to look at the code yet, but here are some minor questions/remarks on the article:
Did it actually show an error message, or were those values just red (which only means that properties were added since the last time you pressed Configure)? This can be very confusing, the "NOTFOUND" does mean that those libraries couldn't be found, but that shouldn't be a problem: TGUI doesn't use them (it only needs X11/Xlib.h and X11/cursorfont.h). So even though it is red and says "NOTFOUND", it isn't necessarily an error. TGUI just asks CMake where to find X11, and CMake automatically also searches for X11 related components such as XCB. Whether XCB is found should make no difference for building TGUI. It would be a better user-experience if those XCB properties didn't show up, but that is up to CMake and outside my control. TGUI only uses X11 when the backend provide insufficient support for mouse cursors btw, so you won't see any of that output anymore once SFML 2.6 is released and available in openSUSE.
TGUI requires the project to be build with at least c++14, you will get compile errors if you include a TGUI header when using "-std=c++11" (the version used in your project should be equal or higher to the version specified with TGUI_CXX_STANDARD when compiling TGUI). GCC >= 11 uses c++17 by default, while GCC >= 6 uses c++14 by default, so you typically don't even need to specify the c++ version unless you need a specific version for your own code. Your screenshot is showing the C11 option by the way, not C++11.
I've had plenty of similar experiences in the past when swapping linux distros before I ended up with Manjaro, I really dislike installers that force a layout based on the language. I think I have switched the system language in the past after installation, but what I usually do is install it in English and then just change the keyboard layout after the installation.
Out of curiosity: what hardware do you still have that doesn't support OpenGL 3.3? |
Thank you for your feedback. At the time I ran Cmake, I already knew that red lines are not errors, but additions.
If I misinterpreted the message, it is poorly done from my point of view. If this library is not required, it should be removed from the list of prerequisites. If this is out of your control, it should be described how to handle this. - If it is really sure that this library is not needed, I would like to add that in the article.
Good hint - thanks! I have changed it.
I was going to do that too - but it ends up in a wild orgy of command line calls. 20 years ago I even calculated the Hsync and Vsync values for my monitor and entered them manually into the X11 monitor configuration. But in 2022 I simply don't feel like fiddling around like that anymore - especially since other distros show how it can be done. - Manjaro I actually do not know yet. The WiKi article sounds interesting. I think I'll do a test installation.
lenovo ThinkPad T520, 12GB RAM, core i5-2540M @ 2.60GHz, 1920x1080 SAMSUNG display |
There are 2 cases. When using GLFW or SFML >= 2.6, TGUI has no dependency to X11 and it won't search for it. When using SDL or SFML < 2.6, TGUI requires X11 and a call to The TGUI only needs the There are 2 things that I can think of which could do to improve the experience, but neither of them sound like a good idea.
I did a quick search and the HD 3000 graphics that come with that processor might actually support 3.3 on Linux and macOS. On Windows the drivers limit it to OpenGL 3.1, but the mesa driver on Linux might actually provide support for it, it might do more than just pretend to work 😄 |
Thanks for all the effort you took with my problems and questions and the many suggestions that came out of it. I will adjust the article again according to your comments. Thanks for the tip about Manjaro. Summarized in one word: Nice!
Yes I can ask Mesa to provide me with an OpenGL 3.3 and I will get it. Why Mesa only provides an OpenGL 3.1 without the request is not important to me - I can request a 3.3 and the world is nice. |
Added [Top, TopFixedWidth, Bottom and BottomFixedWidth] alignment to TabContainer; including the new Layout::Operation::BindingNumberOfChildren to achive this.