Skip to content

Commit

Permalink
Widgets|libappfw: Scroll bars can be dragged with the mouse
Browse files Browse the repository at this point in the history
When a scroll bar indicator is visible, it can be dragged with
the mouse. Updated existing widgets to use the common scroll bar
indicators implemented by ScrollAreaWidget.
  • Loading branch information
skyjake committed Jun 26, 2016
1 parent 129e715 commit a5bd710
Show file tree
Hide file tree
Showing 5 changed files with 166 additions and 82 deletions.
1 change: 0 additions & 1 deletion doomsday/sdk/libappfw/include/de/widgets/documentwidget.h
Expand Up @@ -81,7 +81,6 @@ class LIBAPPFW_PUBLIC DocumentWidget : public ScrollAreaWidget
protected:
void glInit();
void glDeinit();
void glMakeGeometry(DefaultVertexBuf::Builder &verts);
void updateStyle();

private:
Expand Down
2 changes: 1 addition & 1 deletion doomsday/sdk/libappfw/src/guiwidget.cpp
Expand Up @@ -829,7 +829,7 @@ GuiWidget::MouseClickStatus GuiWidget::handleMouseClick(Event const &event, Mous

if (mouse.state() == MouseEvent::Released && root().isEventRouted(event.type(), this))
{
root().routeMouse(0);
root().routeMouse(nullptr);
if (hitTest(mouse.pos()))
{
return MouseClickFinished;
Expand Down
12 changes: 3 additions & 9 deletions doomsday/sdk/libappfw/src/widgets/documentwidget.cpp
Expand Up @@ -265,8 +265,9 @@ DocumentWidget::DocumentWidget(String const &name)
, d(new Instance(this))
{
setWidthPolicy(ui::Expand);

rule().setInput(Rule::Height, contentRule().height() + margins().height());

enableIndicatorDraw(true);
}

void DocumentWidget::setText(String const &styledText)
Expand Down Expand Up @@ -329,6 +330,7 @@ void DocumentWidget::viewResized()
void DocumentWidget::drawContent()
{
d->draw();
ScrollAreaWidget::drawContent();
}

void DocumentWidget::glInit()
Expand All @@ -343,14 +345,6 @@ void DocumentWidget::glDeinit()
d->glDeinit();
}

void DocumentWidget::glMakeGeometry(DefaultVertexBuf::Builder &verts)
{
ScrollAreaWidget::glMakeGeometry(verts);

glMakeScrollIndicatorGeometry(verts, Vector2f(rule().left().value() + margins().left().value(),
rule().top().value() + margins().top().value()));
}

void DocumentWidget::updateStyle()
{
ScrollAreaWidget::updateStyle();
Expand Down
13 changes: 9 additions & 4 deletions doomsday/sdk/libappfw/src/widgets/logwidget.cpp
Expand Up @@ -464,10 +464,11 @@ public Font::RichFormat::IStyle
entryAtlas->audienceForOutOfSpace() += this;

// Simple texture for the scroll indicator.
Image solidWhitePixel = Image::solidColor(Image::Color(255, 255, 255, 255),
/*Image solidWhitePixel = Image::solidColor(Image::Color(255, 255, 255, 255),
Image::Size(1, 1));
scrollTex = entryAtlas->alloc(solidWhitePixel);
self.setIndicatorUv(entryAtlas->imageRectf(scrollTex).middle());
self.setIndicatorUv(entryAtlas->imageRectf(scrollTex).middle());*/
//self.setIndicatorUv(root().atlas().imageRectf(root().solidWhitePixel()).middle());

uTex = entryAtlas;
uColor = Vector4f(1, 1, 1, 1);
Expand Down Expand Up @@ -731,7 +732,7 @@ public Font::RichFormat::IStyle
}

// Draw the scroll indicator, too.
self.glMakeScrollIndicatorGeometry(verts);
//self.glMakeScrollIndicatorGeometry(verts);

buf->setVertices(gl::TriangleStrip, verts, gl::Dynamic);

Expand Down Expand Up @@ -800,6 +801,7 @@ LogWidget::LogWidget(String const &name)
: ScrollAreaWidget(name), d(new Instance(this))
{
setOrigin(Bottom);
enableIndicatorDraw(true);

LogBuffer::get().addSink(d->sink);
}
Expand Down Expand Up @@ -844,7 +846,7 @@ Animation const &LogWidget::contentYOffset() const

void LogWidget::viewResized()
{
GuiWidget::viewResized();
ScrollAreaWidget::viewResized();

d->updateProjection();
}
Expand All @@ -864,6 +866,7 @@ void LogWidget::update()
void LogWidget::drawContent()
{
d->draw();
ScrollAreaWidget::drawContent();
}

bool LogWidget::handleEvent(Event const &event)
Expand All @@ -873,11 +876,13 @@ bool LogWidget::handleEvent(Event const &event)

void LogWidget::glInit()
{
ScrollAreaWidget::glInit();
d->glInit();
}

void LogWidget::glDeinit()
{
ScrollAreaWidget::glDeinit();
d->glDeinit();
}

Expand Down

0 comments on commit a5bd710

Please sign in to comment.