Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: MaximInterface
Diff: WindowManager.cpp
- Revision:
- 8:a0d75dff3c9b
- Parent:
- 7:66c5dedc750b
- Child:
- 10:71359af61af8
--- a/WindowManager.cpp Thu Mar 09 11:38:33 2017 -0600
+++ b/WindowManager.cpp Thu Apr 06 15:16:30 2017 -0500
@@ -33,6 +33,7 @@
#include <algorithm>
#include <functional>
#include "Bitmap.hpp"
+#include "Display.hpp"
#include "WindowManager.hpp"
static void deleteWindow(Window * window)
@@ -63,19 +64,12 @@
}
}
-Bitmap WindowManager::render() const
-{
- return m_windowStack.empty() ? Bitmap(m_width, m_height) : m_windowStack.back()->render();
-}
-
void WindowManager::push(std::auto_ptr<Window> & window)
{
if (window.get() != NULL)
{
- window->setWidth(m_width);
- window->setHeight(m_height);
- window->setX(0);
- window->setY(0);
+ window->resize(Display::width, Display::height);
+ window->move(0, 0);
window->setWindowManager(NULL);
m_actionQueue.push_back(window.release());
}
@@ -86,10 +80,8 @@
m_actionQueue.push_back(NULL);
}
-bool WindowManager::update()
+void WindowManager::update(Display & display)
{
- bool redraw = false;
-
// Perform all queued push / pop actions.
if (!m_actionQueue.empty())
{
@@ -100,23 +92,26 @@
std::for_each(m_actionQueue.begin(), m_actionQueue.end(),
std::bind1st(std::mem_fun(&WindowManager::processAction), this));
m_actionQueue.clear();
- if (!m_windowStack.empty())
+ if (m_windowStack.empty())
+ {
+ // Clear the display.
+ display.update(Bitmap(Display::width, Display::height));
+ }
+ else
{
m_windowStack.back()->setWindowManager(this);
+ // Window has been invalidated and will be redrawn in the next section.
}
- redraw = true;
}
- // Update all windows.
- for (std::vector<Window *>::reverse_iterator it = m_windowStack.rbegin(); it != m_windowStack.rend(); it++)
+ if (!m_windowStack.empty())
{
- if ((*it)->update() && (it == m_windowStack.rbegin()))
+ // Update all windows. Only allow redraw of the top window.
+ for (std::vector<Window *>::reverse_iterator it = m_windowStack.rbegin(); it != m_windowStack.rend(); it++)
{
- redraw = true;
+ (*it)->update(it == m_windowStack.rbegin() ? &display : NULL);
}
}
-
- return redraw;
}
void WindowManager::processKey(Key key)