Skip to content

Commit

Permalink
GLK: Add methods for sending windows to the front/back of draw order
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Aug 9, 2019
1 parent 6fe59d1 commit b2f6280
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
9 changes: 9 additions & 0 deletions engines/glk/utils.h
Expand Up @@ -67,6 +67,15 @@ template<class T>class Array : public Common::Array<T> {

return -1;
}

/**
* Remove an item from an array by value
*/
void remove(T val) {
int index = indexOf(val);
if (index != -1)
Common::Array<T>::remove_at(index);
}
};

/**
Expand Down
18 changes: 18 additions & 0 deletions engines/glk/windows.cpp
Expand Up @@ -735,6 +735,24 @@ void Window::getSize(uint *width, uint *height) const {
*height = 0;
}

void Window::bringToFront() {
PairWindow *pairWin = dynamic_cast<PairWindow *>(_parent);

if (pairWin && pairWin->_dir == winmethod_Arbitrary && pairWin->_children.back() != this) {
pairWin->_children.remove(this);
pairWin->_children.push_back(this);
}
}

void Window::sendToBack() {
PairWindow *pairWin = dynamic_cast<PairWindow *>(_parent);

if (pairWin && pairWin->_dir == winmethod_Arbitrary && pairWin->_children.front() != this) {
pairWin->_children.remove(this);
pairWin->_children.insert_at(0, this);
}
}

/*--------------------------------------------------------------------------*/

BlankWindow::BlankWindow(Windows *windows, uint rock) : Window(windows, rock) {
Expand Down
10 changes: 10 additions & 0 deletions engines/glk/windows.h
Expand Up @@ -581,6 +581,16 @@ class Window {
* Returns a pointer to the styles for the window
*/
virtual const WindowStyle *getStyles() const;

/**
* In arbitrary window positioning mode, brings a window to the front of all other windows
*/
void bringToFront();

/**
* In arbitrary window positioning mode, sends a window to the back of all other windows
*/
void sendToBack();
};
typedef Window *winid_t;

Expand Down

0 comments on commit b2f6280

Please sign in to comment.