Browse Source

More special handling for resize

Signed-off-by: falkTX <falktx@falktx.com>
pull/281/head
falkTX 4 years ago
parent
commit
df5bff7440
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
6 changed files with 69 additions and 4 deletions
  1. +31
    -0
      dgl/TopLevelWidget.hpp
  2. +1
    -1
      dgl/Window.hpp
  3. +1
    -2
      dgl/src/SubWidget.cpp
  4. +25
    -0
      dgl/src/TopLevelWidget.cpp
  5. +2
    -0
      dgl/src/Widget.cpp
  6. +9
    -1
      dgl/src/WindowPrivateData.cpp

+ 31
- 0
dgl/TopLevelWidget.hpp View File

@@ -66,6 +66,37 @@ public:
*/ */
Window& getWindow() const noexcept; Window& getWindow() const noexcept;


/**
Check if this top-level widget's window is resizable (by the user or window manager).
For situations where this top-level widget is an embed plugin UI and the plugin host does not support resizing,
this function can return false where it normally returns true.

You might want to add a resize handle for such cases, so the user is still allowed to resize the window.
(programatically resizing a window is always possible, but the same is not true for the window manager)
*/
bool isResizable() const noexcept;

/**
Set width of this widget's window.
@note This will not change the widget's size right away, but be pending on OS resizing the window
*/
void setWidth(uint width);

/**
Set height of this widget's window.
*/
void setHeight(uint height);

/**
Set size of this widget's window, using @a width and @a height values.
*/
void setSize(uint width, uint height);

/**
Set size of this widget's window.
*/
void setSize(const Size<uint>& size);

// TODO group stuff after here, convenience functions present in Window class // TODO group stuff after here, convenience functions present in Window class
bool addIdleCallback(IdleCallback* callback, uint timerFrequencyInMs = 0); bool addIdleCallback(IdleCallback* callback, uint timerFrequencyInMs = 0);
bool removeIdleCallback(IdleCallback* callback); bool removeIdleCallback(IdleCallback* callback);


+ 1
- 1
dgl/Window.hpp View File

@@ -185,7 +185,7 @@ public:
void close(); void close();


/** /**
Check if this window is resizable.
Check if this window is resizable (by the user or window manager).
@see setResizable @see setResizable
*/ */
bool isResizable() const noexcept; bool isResizable() const noexcept;


+ 1
- 2
dgl/src/SubWidget.cpp View File

@@ -96,8 +96,7 @@ void SubWidget::setAbsolutePos(const Point<int>& pos) noexcept
pData->absolutePos = pos; pData->absolutePos = pos;
onPositionChanged(ev); onPositionChanged(ev);


// repaint the bounds of parent
pData->parentWidget->repaint();
repaint();
} }


Widget* SubWidget::getParentWidget() const noexcept Widget* SubWidget::getParentWidget() const noexcept


+ 25
- 0
dgl/src/TopLevelWidget.cpp View File

@@ -40,6 +40,31 @@ Window& TopLevelWidget::getWindow() const noexcept
return pData->window; return pData->window;
} }


bool TopLevelWidget::isResizable() const noexcept
{
return pData->window.isResizable();
}

void TopLevelWidget::setWidth(const uint width)
{
pData->window.setWidth(width);
}

void TopLevelWidget::setHeight(const uint height)
{
pData->window.setHeight(height);
}

void TopLevelWidget::setSize(const uint width, const uint height)
{
pData->window.setSize(width, height);
}

void TopLevelWidget::setSize(const Size<uint>& size)
{
pData->window.setSize(size);
}

bool TopLevelWidget::addIdleCallback(IdleCallback* const callback, const uint timerFrequencyInMs) bool TopLevelWidget::addIdleCallback(IdleCallback* const callback, const uint timerFrequencyInMs)
{ {
return pData->window.addIdleCallback(callback, timerFrequencyInMs); return pData->window.addIdleCallback(callback, timerFrequencyInMs);


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

@@ -46,6 +46,8 @@ void Widget::setVisible(bool visible)


pData->visible = visible; pData->visible = visible;
repaint(); repaint();

// FIXME check case of hiding a previously visible widget, does it trigger a repaint?
} }


void Widget::show() void Widget::show()


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

@@ -652,7 +652,15 @@ void Window::PrivateData::onPuglConfigure(const double width, const double heigh
{ {
TopLevelWidget* const widget(*it); TopLevelWidget* const widget(*it);


widget->setSize(uwidth, uheight);
/* Some special care here, we call Widget::setSize instead of the TopLevelWidget one.
* This is because we want TopLevelWidget::setSize to handle both window and widget size,
* but we dont want to change window size here, because we are the window..
*
* So we just call the Widget specific method manually.
* Alternatively, we could expose a resize function on the pData, like done with the display function.
* But there is nothing extra we need to do in there, so this works fine.
*/
((Widget*)widget)->setSize(uwidth, uheight);
} }
#endif #endif




Loading…
Cancel
Save