Browse Source

Fix for ImageSlider

gh-pages
falkTX 9 years ago
parent
commit
568b765007
6 changed files with 34 additions and 17 deletions
  1. +6
    -0
      dgl/ImageSlider.hpp
  2. +1
    -4
      dgl/NanoVG.hpp
  3. +7
    -6
      dgl/Widget.hpp
  4. +4
    -4
      dgl/src/ImageSlider.cpp
  5. +7
    -2
      dgl/src/Widget.cpp
  6. +9
    -1
      dgl/src/Window.cpp

+ 6
- 0
dgl/ImageSlider.hpp View File

@@ -84,6 +84,12 @@ private:

void _recheckArea() noexcept;

// these should not be used
void setAbsoluteX(int) const noexcept {}
void setAbsoluteY(int) const noexcept {}
void setAbsolutePos(int, int) const noexcept {}
void setAbsolutePos(const Point<int>&) const noexcept {}

DISTRHO_LEAK_DETECTOR(ImageSlider)
};



+ 1
- 4
dgl/NanoVG.hpp View File

@@ -793,10 +793,7 @@ public:
*/
NanoWidget(Window& parent)
: Widget(parent),
NanoVG()
{
fInvertedY = true;
}
NanoVG() {}

protected:
/**


+ 7
- 6
dgl/Widget.hpp View File

@@ -159,6 +159,12 @@ public:
*/
void hide();

/**
Tell the parent window this widget this the full viewport.
When enabled, the local widget coordinates are ignored.
*/
void setNeedsFullViewport(bool yesNo) noexcept;

/**
Get width.
*/
@@ -296,14 +302,9 @@ protected:
*/
virtual void onResize(const ResizeEvent&);

/**
Wherever the Y position is inverted.
(starts at the bottom)
*/
bool fInvertedY;

private:
Window& fParent;
bool fNeedsFullViewport;
bool fVisible;
Rectangle<int> fArea;



+ 4
- 4
dgl/src/ImageSlider.cpp View File

@@ -37,7 +37,7 @@ ImageSlider::ImageSlider(Window& parent, const Image& image, int id) noexcept
fStartedY(0),
fCallback(nullptr)
{
setSize(fImage.getSize());
setNeedsFullViewport(true);
}

ImageSlider::ImageSlider(Widget* widget, const Image& image, int id) noexcept
@@ -55,7 +55,7 @@ ImageSlider::ImageSlider(Widget* widget, const Image& image, int id) noexcept
fStartedY(0),
fCallback(nullptr)
{
setSize(fImage.getSize());
setNeedsFullViewport(true);
}

ImageSlider::ImageSlider(const ImageSlider& imageSlider) noexcept
@@ -76,7 +76,7 @@ ImageSlider::ImageSlider(const ImageSlider& imageSlider) noexcept
fEndPos(imageSlider.fEndPos),
fSliderArea(imageSlider.fSliderArea)
{
setSize(fImage.getSize());
setNeedsFullViewport(true);
}

int ImageSlider::getId() const noexcept
@@ -86,7 +86,7 @@ int ImageSlider::getId() const noexcept

void ImageSlider::setId(int id) noexcept
{
fId = id;;
fId = id;
}

float ImageSlider::getValue() const noexcept


+ 7
- 2
dgl/src/Widget.cpp View File

@@ -23,8 +23,8 @@ START_NAMESPACE_DGL
// Widget

Widget::Widget(Window& parent)
: fInvertedY(false),
fParent(parent),
: fParent(parent),
fNeedsFullViewport(false),
fVisible(true)
{
fParent._addWidget(this);
@@ -59,6 +59,11 @@ void Widget::hide()
setVisible(false);
}

void Widget::setNeedsFullViewport(bool yesNo) noexcept
{
fNeedsFullViewport = yesNo;
}

int Widget::getWidth() const noexcept
{
return fArea.getWidth();


+ 9
- 1
dgl/src/Window.cpp View File

@@ -578,7 +578,7 @@ struct Window::PrivateData {
// reset color
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);

if (widget->fArea == Rectangle<int>(0, 0, fView->width, fView->height))
if (widget->fNeedsFullViewport || widget->fArea == Rectangle<int>(0, 0, fView->width, fView->height))
{
// full viewport size
glViewport(0, 0, fView->width, fView->height);
@@ -725,6 +725,14 @@ struct Window::PrivateData {
DBGp("PUGL: onReshape : %i %i\n", width, height);

fSelf->onReshape(width, height);

FOR_EACH_WIDGET(it)
{
Widget* const widget(*it);

if (widget->fNeedsFullViewport)
widget->setSize(width, height);
}
}

void onClose()


Loading…
Cancel
Save