I have two CEGUI::ScrollablePane windows side-by-side (contain the same look byt have different data). They are used to perform a comparison of two entities using the same dataset. I want to keep the two scrollable panes synchronized as the user scrolls down (keeps the fields horizontally aligned).
Is this possible? Can I set the event callback to scroll the other pane?
Q: How to synchronize ScrollablePane scrolling?
Moderators: CEGUI MVP, CEGUI Team
- scriptkid
- Home away from home
- Posts: 1178
- Joined: Wed Jan 12, 2005 12:06
- Location: The Hague, The Netherlands
- Contact:
Hi,
IMO the nicest solution would be to handle both pane's scroll events seperately, and then do something like this:
Or something similar. You might add some checks in case the height of the content isn't equal.
HTH.
IMO the nicest solution would be to handle both pane's scroll events seperately, and then do something like this:
Code: Select all
OnScrollPane1()
{
Scrollbar* bar1 = pane1->getVertScrollbar();
Scrollbar* bar2 = pane2->getVertScrollbar();
bar2->setScrollPosition(bar1->getScrollPosition());
}
// And the opposite...
OnScrollPane2()
{
Scrollbar* bar2 = pane2->getVertScrollbar();
Scrollbar* bar1 = pane1->getVertScrollbar();
bar1->setScrollPosition(bar2->getScrollPosition());
}
Or something similar. You might add some checks in case the height of the content isn't equal.
HTH.
Check out my released snake game using Cegui!
pfft. I knew it was something simple. Thanks scriptkid!
However, if I use the EGUI::ScrollablePane::EventContentPaneScrolled to update each scrollable panes, is there the possibility of double jeopardy? That is, if ScrollablePaneA event fires and updates ScrollablePaneB, won't ScrollablePaneB fire and update ScrollablePaneA?
However, if I use the EGUI::ScrollablePane::EventContentPaneScrolled to update each scrollable panes, is there the possibility of double jeopardy? That is, if ScrollablePaneA event fires and updates ScrollablePaneB, won't ScrollablePaneB fire and update ScrollablePaneA?
- scriptkid
- Home away from home
- Posts: 1178
- Joined: Wed Jan 12, 2005 12:06
- Location: The Hague, The Netherlands
- Contact:
Van wrote:However, if I use the EGUI::ScrollablePane::EventContentPaneScrolled to update each scrollable panes, is there the possibility of double jeopardy? That is, if ScrollablePaneA event fires and updates ScrollablePaneB, won't ScrollablePaneB fire and update ScrollablePaneA?
Good one
You could be right about this one. However you can easily fix this by maintaining a member variable which is flagged during the handling on an event. So you'd get:
Code: Select all
OnScrollPane1()
{
if (mUpdating)
return;
Scrollbar* bar1 = pane1->getVertScrollbar();
Scrollbar* bar2 = pane2->getVertScrollbar();
mUpdating = true;
bar2->setScrollPosition(bar1->getScrollPosition());
mUpdating = false;
}
// And the opposite...
OnScrollPane2()
{
if (mUpdating)
return;
Scrollbar* bar2 = pane2->getVertScrollbar();
Scrollbar* bar1 = pane1->getVertScrollbar();
mUpdating = true;
bar1->setScrollPosition(bar2->getScrollPosition());
mUpdating = false;
}
Alternatively, you can temporarily disable events by calling "pane->setEnabled(false)" between the cross-updates. I think that works too.
HTH.
Check out my released snake game using Cegui!
Code: Select all
bar2->setMutedState(true);
bar2->setScrollPosition(bar1->getScrollPosition());
bar2->setMutedState(false);
Who is online
Users browsing this forum: No registered users and 25 guests