Skip to content

Commit

Permalink
Scroll in LayoutVertical with not shown displays
Browse files Browse the repository at this point in the history
  • Loading branch information
caselitz authored and stevenlovegrove committed Oct 5, 2019
1 parent 96cc9ba commit b6cecf4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
4 changes: 3 additions & 1 deletion include/pangolin/display/view.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ struct PANGOLIN_EXPORT View
{
View(double aspect=0.0)
: aspect(aspect), top(1.0),left(0.0),right(1.0),bottom(0.0), hlock(LockCenter),vlock(LockCenter),
layout(LayoutOverlay), scroll_offset(0), show(1), zorder(0), handler(0) {}
layout(LayoutOverlay), scroll_offset(0), show(1), zorder(0), handler(0), scroll_show(1) {}

virtual ~View() {}

Expand Down Expand Up @@ -228,6 +228,8 @@ struct PANGOLIN_EXPORT View
private:
// Private copy constructor
View(View&) { /* Do Not copy - take reference instead*/ }

bool scroll_show;
};

}
11 changes: 6 additions & 5 deletions src/display/view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,12 @@ void View::ResizeChildren()
int num_children = 0;
for(std::vector<View*>::iterator iv = views.begin(); iv != views.end(); ++iv )
{
if (!(*iv)->show) continue;
num_children++;
if(scroll_offset > num_children ) {
(*iv)->show = false;
if(scroll_offset >= num_children ) {
(*iv)->scroll_show = false;
}else{
(*iv)->show = true;
(*iv)->scroll_show = true;
(*iv)->Resize(space);
space.h = (*iv)->v.b - panal_v_margin - space.b;
}
Expand Down Expand Up @@ -290,7 +291,7 @@ void View::ResizeChildren()

void View::Render()
{
if(extern_draw_function && show) {
if(extern_draw_function && show && scroll_show) {
extern_draw_function(*this);
}
RenderChildren();
Expand All @@ -300,7 +301,7 @@ void View::RenderChildren()
{
for(std::vector<View*>::iterator iv = views.begin(); iv != views.end(); ++iv )
{
if((*iv)->show) (*iv)->Render();
if((*iv)->show && (*iv)->scroll_show) (*iv)->Render();
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/handler/handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void HandlerScroll::Mouse(View& d, MouseButton button, int x, int y, bool presse
{
if( button == MouseWheelUp) d.scroll_offset -= 1;
if( button == MouseWheelDown) d.scroll_offset += 1;
d.scroll_offset = std::max(0, std::min(d.scroll_offset, (int)d.views.size()) );
d.scroll_offset = std::max(0, std::min(d.scroll_offset, (int)d.NumVisibleChildren()-1) );
d.ResizeChildren();
}else{
Handler::Mouse(d,button,x,y,pressed,button_state);
Expand All @@ -107,7 +107,7 @@ void HandlerScroll::Special(View& d, InputSpecial inType, float x, float y, floa
if( inType == InputSpecialScroll )
{
d.scroll_offset -= (int)(p2 / fabs(p2));
d.scroll_offset = std::max(0, std::min(d.scroll_offset, (int)d.views.size()) );
d.scroll_offset = std::max(0, std::min(d.scroll_offset, (int)d.NumVisibleChildren()-1) );
d.ResizeChildren();
}else{
Handler::Special(d,inType,x,y,p1,p2,p3,p4,button_state);
Expand Down

0 comments on commit b6cecf4

Please sign in to comment.