#3905 closed defect (fixed)
[PATCH] Add a function to manipulate selected_column_order and selected_column of COList
Reported by: | Imarok | Owned by: | elexis |
---|---|---|---|
Priority: | Should Have | Milestone: | Alpha 21 |
Component: | UI & Simulation | Keywords: | patch |
Cc: | Patch: |
Description (last modified by )
the parameters would be name and selected_column_order or selected_column.
getting the specific object could maybe done by IGUIObject* guiObj = g_GUI->FindObjectByName(name);
An alternative would be to add a function that refreshes the COList
This is needed for #3742
Attachments (7)
Change History (18)
comment:1 by , 8 years ago
Description: | modified (diff) |
---|
comment:2 by , 8 years ago
Description: | modified (diff) |
---|
comment:3 by , 8 years ago
by , 8 years ago
Attachment: | 3905_COList_refresh.patch added |
---|
comment:4 by , 8 years ago
Keywords: | rfc patch added |
---|---|
Milestone: | Backlog → Alpha 21 |
Summary: | Add a function to manipulate selected_column_order and selected_column of COList → [PATCH] Add a function to manipulate selected_column_order and selected_column of COList |
comment:5 by , 8 years ago
Keywords: | rfc removed |
---|
About the existing code:
- The name m_SelectedDef is terrible and should be renamed to m_SelectedColumn.
- Someone write a simple ticket about that default style TODO that is copied to most GUI objects
- It seems those COList bugs come from the COList implementation not being cleanly / completely being implemented when the features were added. This should be compensated by cleaning up the mess instead of supplementing checks for some edge cases.
About the patch:
- Should become consistent, either
substr(5)
or"list_" + ...
everywhere - Messy code appearance:
Use
m_SelectedDef
andm_SelectedColumnOrder
instead of introducingselected column
andselectedColumnOrder
. The checkselectedColumn.size() != 0
seems inconsistent, as the other code checks form_SelectedDef != (size_t)-1
It were cleaner if the member variables would just be updated onGUIM_SETTINGS_UPDATED
, so it doesn't have to fetch the setting again whenever it wants to use it. - If the code won't become more readable, it should have a comment about what the code is doing there
by , 8 years ago
Attachment: | 3905_COList_refresh_v2.patch added |
---|
Rename m_SelectedDef to m_SelectedColumn. Update on GUIM_SETTINGS_UPDATED
comment:6 by , 8 years ago
Keywords: | rfc added |
---|
by , 8 years ago
Attachment: | 3905_COList_refresh_v2.1.patch added |
---|
renaming ObjectDef and m_ObjectsDefs. Change one if to an else if
by , 8 years ago
Attachment: | 3905_COList_refresh_v3.patch added |
---|
Remove every "def". Store the selected column string instead of the selected column index. Some cleanup
comment:7 by , 8 years ago
- TODO 1: Do we need
default_column
anddefault_column_order
at all if we can just useselected_column
andselected_column_order
instead from both JS and XML?
Implementing some but not all settings on GUIM_SETTINGS_UPDATED
seems incomplete. However it is complete, as DrawList
gets the current setting value right away by using GetSettingPointer
and sortable
also using GetSetting
on GUIM_MOUSE_PRESS_LEFT
. Only m_SelectedColumn
and m_SelectedColumnOrder
are bugging. Since all the other code calls GetSetting
again and again and thus avoids the described bug,
- TODO 2: it would be cleaner to remove these member variables altogether. (single source of truth)
The code from L88 to L99 could be removed entirely probably.
- Independent cleanup: The repetition of
GetScrollBar(0)
seems ugly. Insteadm_ScrollBars[index]
should becomem_VerticalSrollBar
(andm_HorizontalScrollbar
in the future), since there likely won't be more than 2 scrollbars. TheCRect rect
assignment could be moved some lines up to avoid that otherGetListRect
call.
- Independent cleanup: Having
m_HeadingHeight
hardcoded as 30 seems bad, should become a Setting just like the other settings. The member variable should be nuked then as well.
by , 8 years ago
Attachment: | 3905_COList_refresh_v4.patch added |
---|
Made all changes proposed in comment:7 besides the GetScrollBar(0)
thing. COList don't requires a column "name" anymore. Some cleanup.
by , 8 years ago
Attachment: | 3905_COList_refresh_v4.1.patch added |
---|
Through a warning when no selected_column_order is set. Fix some oversights in lobby.xml
comment:9 by , 8 years ago
Keywords: | rfc removed |
---|
Thanks for taking care of this bug that was deeply buried in weird code!
by , 8 years ago
Attachment: | COList.cpp.patch added |
---|
Do not show the sort sprites (little arrows) when list is not sortable.
comment:11 by , 8 years ago
- Thanks user1 for reporting the error.
- Nice cleanup Imarok, we only need one sprite variable indeed!
- Therefore nuking sprite_not_sorted too
- Thus being able to flip the selected_column_order and selected_column call nicely
- Moving the
// Draw column headers
comment a bit below, so that those 4 setting calls are grouped - (Not sure if most compilers were smart enough to optimize out a string variable, if one were to remove the duplicate GetSettingPointer calls)
- Rephrasing comment
If the list sorted by current column
-> adding an "is" and "the" - trailing whitespace
- removing unneeded comment
- moved the drawsprites comment
- adding few newline
Problem: When setting `selected_column_order" via JS, the GUI arrows aren't updated:
The
COList.cpp
should be notified implicitly and update the graphics without a new function ideally.