gui2: modify reduce logic
Moderator: Forum Moderators
gui2: modify reduce logic
Reference to: http://www.freeors.com/bbs/forum.php?mo ... a=page%3D1
I think wesnoth's reduce logic exists tow problem.
Moddify tscrollbar_container::calculate_best_size
In WML, add tow attribute: width and height.
[table=90%,Silver]
[tr][td]width value[/td][td]Result[/td][td]Require calculate content_grid[/td][td]Conside scrollbar[/td][td]Use case[/td][/tr]
[tr][td]< screen_width[/td][td]width[/td][td]No[/td][td]No[/td][td]Reserve min width[/td][/tr]
[tr][td]screen_width[/td][td]content_grid width[/td][td]Require[/td][td]Yes[/td][td]content_grid size is best_size.x[/td][/tr]
[tr][td]> screen_width[/td][td]width - screen_width[/td][td]Require[/td][td]Yes[/td][td]Limit max width[/td][/tr]
[/table]
To height, it has same semanteme. "screen_width" and "screen_height" are screen size variables when twindow::layout.
In twindow::layout, get_best_size of window must not large than (maximum_width, maximum_height)!
On the basis of the above said, I had modified relative code, they can been seen at https://github.com/freeors/Rose
Reduce logic is simplified greatly. No longer need request_reduce_width, request_reduce_height, etc.
I think wesnoth's reduce logic exists tow problem.
- When exist tow or more require reducing widget in one row/column, logic maybe not slove it.
Relative code is obscure, especially involve scrollbar.
- There is tow mode about scrollbar, always_invisible and auto_visible. Get rid of always_visible, auto_visible_first_run.
- always_invisible: The scrollbar is never shown even not when needed. There's also no space reserved for the scrollbar.
- auto_visible: The scrollbar is shown when the number of items is larger as the visible items. The space for the scrollbar is always reserved, just in case it's needed after the initial sizing (due to adding items).
- Size of scrollbar is as narrow as possible. For example, both height of horizontal and width of vertical is 6 pixel.
Moddify tscrollbar_container::calculate_best_size
In WML, add tow attribute: width and height.
[table=90%,Silver]
[tr][td]width value[/td][td]Result[/td][td]Require calculate content_grid[/td][td]Conside scrollbar[/td][td]Use case[/td][/tr]
[tr][td]< screen_width[/td][td]width[/td][td]No[/td][td]No[/td][td]Reserve min width[/td][/tr]
[tr][td]screen_width[/td][td]content_grid width[/td][td]Require[/td][td]Yes[/td][td]content_grid size is best_size.x[/td][/tr]
[tr][td]> screen_width[/td][td]width - screen_width[/td][td]Require[/td][td]Yes[/td][td]Limit max width[/td][/tr]
[/table]
To height, it has same semanteme. "screen_width" and "screen_height" are screen size variables when twindow::layout.
In twindow::layout, get_best_size of window must not large than (maximum_width, maximum_height)!
On the basis of the above said, I had modified relative code, they can been seen at https://github.com/freeors/Rose
Reduce logic is simplified greatly. No longer need request_reduce_width, request_reduce_height, etc.
Re: gui2: modify reduce logic
These kinds of "hey come copy my code" or "why don't you code it this way" posts are unlikely to get a response.
You are welcome to make a pull request on github. Not sure who is likely to review or merge it.
You are welcome to make a pull request on github. Not sure who is likely to review or merge it.
Re: gui2: modify reduce logic
Of course, I am glad to pull my code to wesnoth github. Just as above seen, I have setup new SDK originates in wesnoth, named Rose. My code is poll into it. If want to make it usable for wesnoth, it require modify and test.iceiceice wrote:These kinds of "hey come copy my code" or "why don't you code it this way" posts are unlikely to get a response.
You are welcome to make a pull request on github. Not sure who is likely to review or merge it.
To this post topic, new reduce logic not only modifies C++ code, but also window block in WML. It means almost scrollable widget should be modify. The workload maybe enormous.
Modifying reduce logic is my recent work in, and basically completed. Use new method, not only improve layout effect but alose simplify C++ code obscure greatly. So I advice wesnoth to modify.
So far, I have modify a lot at gui2. Below point some.
1) Use last SDL-2.0.3. It is importmant to mobile program.
2) Let canvas support animation. Canvas shape include rectangle, circle, image, text and anim.
3) Remove widget: multi_page.
4) Add widget: scroll_text_box, report. Based on report make tabbar.
5) Support fixed rect layout. Theme requirt it.