Opened 8 years ago

Closed 8 years ago

#7902 closed bug (fixed)

BSplitView - ItemWeight

Reported by: cipri Owned by: yourpalal
Priority: normal Milestone: R1
Component: Kits/Interface Kit Version: R1/alpha3
Keywords: Cc:
Blocked By: Blocking:
Has a Patch: no Platform: All

Description

I use in my game collapsible BSplitView's. The user can resize "collapse" the splitters, but I can not collapse the splitter with code. Setting the ItemWeight to 0, should collapse the splitter, but instead Item get's the same Weight as the other item of the splitter. And when an Item is collapsed, and i call ItemWeight, i get the weight of the splitter just before collapsing. Instead I should get 0. My problem is the following. I want that my gui saves the current state of the layout, and when the game is started again, it should restore to the values before closing the game.

Change History (6)

comment:1 by cipri, 8 years ago

if you want to test that behaviour, download the game http://haikuware.com/directory/view-details/games/board/puri-master-of-chess-v03 Start the game in "offline" mode, collapse a splitter to a side, then quite the game and start it again, and then you should see the problem.

comment:2 by bonefish, 8 years ago

Owner: changed from axeld to yourpalal
Status: newassigned

From the haiku-3rdparty-dev list (from cipri):

On Tue, 15 Nov 2011 19:11:47 +0000 Ingo Weinhold <ingo_weinhold@…> wrote:

I believe collapsing an item can be simply done by setting it to invisible (i.e. call Hide() on the view). If that doesn't work, please file a bug report.

Yes it works, it collapses the splitter, but the problem is, you can not "open" again the splitter usig the mouse. Whe you collapse a splitter using the mouse then the weight is zero. That means, it would be a great help, if setting the weight to zero would collapse the splitter too. Before the user closes the application the weights in my application are saved and restored at the next program start. In the case of a collapsed splitter the weight is saved as zero, but when restoring again the splitter is not collapsed anymore.

I don't think setting the item weight to 0 should collapse the item, as it is meant to do something else -- make the item as small as its minimum size allows -- at least IIRC and it would be consistent with how weights work in other layouts.

I'm not sure why a view can't be expanded with the mouse after hiding it. That does indeed seem to be a bug. Or maybe it is actually not supposed to be done like this (I don't recall). Then a dedicated interface is needed -- BSplitView::SetCollapsed(). I would be nice to have that anyway as it would be clearer for the API user.

Assigning to Alex. Maybe he's motivated to look into it.

in reply to:  2 comment:3 by yourpalal, 8 years ago

Replying to bonefish:

From the haiku-3rdparty-dev list (from cipri):

On Tue, 15 Nov 2011 19:11:47 +0000 Ingo Weinhold <ingo_weinhold@…> wrote:

I believe collapsing an item can be simply done by setting it to invisible (i.e. call Hide() on the view). If that doesn't work, please file a bug report.

Yes it works, it collapses the splitter, but the problem is, you can not "open" again the splitter usig the mouse. Whe you collapse a splitter using the mouse then the weight is zero. That means, it would be a great help, if setting the weight to zero would collapse the splitter too. Before the user closes the application the weights in my application are saved and restored at the next program start. In the case of a collapsed splitter the weight is saved as zero, but when restoring again the splitter is not collapsed anymore.

I don't think setting the item weight to 0 should collapse the item, as it is meant to do something else -- make the item as small as its minimum size allows -- at least IIRC and it would be consistent with how weights work in other layouts.

Yes, Ingo is bang-on here.

I'm not sure why a view can't be expanded with the mouse after hiding it. That does indeed seem to be a bug. Or maybe it is actually not supposed to be done like this (I don't recall). Then a dedicated interface is needed -- BSplitView::SetCollapsed(). I would be nice to have that anyway as it would be clearer for the API user.

I agree, a dedicated interface would be the best option. Hide()ing a view shouldn't have the same effect as collapsing it, IMO, since collapse/expand behaviour is controlled by the BSplitView.

Assigning to Alex. Maybe he's motivated to look into it.

Yes, I can do that :)

comment:4 by anevilyak, 8 years ago

I've implemented this in hrev43279 since I needed it for the Debugger as well. AFAICT it all works, but please review if it's correct, and if so, this ticket can be marked resolved.

comment:5 by yourpalal, 8 years ago

After chatting with anevilyak on IRC, we agreed to remove the clamping of the index for the new collapsible/collapsed getters and setters (see http://www.freelists.org/post/haiku-commits/haiku-hrev43279-srckitsinterface-srcappsdebuggeruser-interfaceguiteam-window-headersosinterface,3 for reference). I'm not going to do that right this instant, for git reasons, but once that's done, this ticket can be closed.

comment:6 by yourpalal, 8 years ago

Resolution: fixed
Status: assignedclosed

Clamping removed in hrev43547, closing this ticket now.

Note: See TracTickets for help on using tickets.