AWindow#
Represents a window in the underlying windowing system.
Header: | #include <AUI/Platform/AWindow.h> |
CMake: | aui_link(my_target PUBLIC aui::views) |
Examples#
examples/app/fractal/src/JumpToCoordsWindow.cpp
Fractal Example - Fractal viewer application demonstrating usage of custom shaders.
#include <AUI/Platform/AMessageBox.h>
using namespace declarative;
JumpToCoordsWindow::JumpToCoordsWindow(_<FractalView> fractalView, AWindow* parent)
: AWindow("Jump to coords", 854_dp, 500_dp, parent, WindowStyle::NO_RESIZE) {
auto re = _new<ATextField>();
auto im = _new<ATextField>();
auto scale = _new<ATextField>();
examples/app/game_of_life/src/main.cpp
Game of Life - Game of Life implementation that uses advanced large dynamic data rendering techniques such as ITexture, AImage to be GPU friendly. The computation is performed in AThreadPool.
examples/app/minesweeper/src/NewGameWindow.h
Minesweeper Game - Minesweeper game implementation driven by ass.
examples/ui/contacts/src/view/ContactDetailsView.cpp
AUI Contacts - Usage of AUI_DECLARATIVE_FOR to make a contacts-like application.
return;
}
// discard
if (AMessageBox::show(dynamic_cast<AWindow*>(AWindow::current()), "Do you really want to discard?", "This action is irreversible!", AMessageBox::Icon::NONE, AMessageBox::Button::YES_NO) != AMessageBox::ResultButton::YES) {
return;
}
mContact = mOriginalContact;
mEditorMode = false;
}
examples/ui/minimal_ui_xmake/src/MainWindow.cpp
Minimal UI Template XMake - Minimal UI boilerplate template XMake.
examples/7guis/flight_booker/src/main.cpp
7GUIs Flight Booker - Flight Booker.
examples/7guis/cells/src/main.cpp
7GUIs Cells - Spreadsheet processor (Excel).
private:
_<State> mState;
};
class CellsWindow : public AWindow {
public:
CellsWindow() : AWindow("AUI - 7GUIs - Cells", 500_dp, 400_dp) {
setContents(Centered {
AScrollArea::Builder()
.withContents(Horizontal { _new<CellsView>(_new<State>()) })
examples/7guis/circle_drawer/src/main.cpp
7GUIs Circle Drawer - Undo, redo, dialog control.
.onAction =
[this, circle] {
auto radiusPopup = _new<AWindow>(
"", 200_dp, 50_dp, dynamic_cast<AWindow*>(AWindow::current()), WindowStyle::MODAL);
radiusPopup->setContents(Vertical {
Label { "Adjust diameter of circle at {}."_format(circle->position) },
_new<ASlider>() AUI_LET {
it->setValue(circle->radius / MAX_RADIUS);
examples/7guis/temperature_converter/src/main.cpp
7GUIs Temperature Converter - Fahrenheit to Celsius and vice versa.
examples/7guis/counter/src/main.cpp
7GUIs Counter - Simple counter.
#include "AUI/View/ATextField.h"
using namespace declarative;
class CounterWindow: public AWindow {
public:
CounterWindow(): AWindow("AUI - 7GUIs - Counter", 200_dp, 100_dp) {
setContents(Centered {
Horizontal {
_new<ATextField>() AUI_LET {
examples/7guis/timer/src/main.cpp
7GUIs Timer - Timer example.
examples/app/fractal/src/FractalWindow.h
Fractal Example - Fractal viewer application demonstrating usage of custom shaders.
examples/app/fractal/src/JumpToCoordsWindow.h
Fractal Example - Fractal viewer application demonstrating usage of custom shaders.
#include <AUI/Platform/AWindow.h>
#include "FractalView.h"
class JumpToCoordsWindow : public AWindow {
public:
explicit JumpToCoordsWindow(_<FractalView> fractalView, AWindow* parent);
};
examples/app/fractal/src/FractalWindow.cpp
Fractal Example - Fractal viewer application demonstrating usage of custom shaders.
using namespace ass;
using namespace declarative;
FractalWindow::FractalWindow() : AWindow("Mandelbrot set") {
setLayout(std::make_unique<AHorizontalLayout>());
auto centerPosDisplay = _new<ALabel>("-");
{
centerPosDisplay->setCustomStyle({
examples/app/minesweeper/src/NewGameWindow.cpp
Minesweeper Game - Minesweeper game implementation driven by ass.
mDifficultyLabel->setText(text);
}
NewGameWindow::NewGameWindow(MinesweeperWindow* minesweeper)
: AWindow("New game", 100, 100, minesweeper), mMinesweeper(minesweeper) {
setWindowStyle(WindowStyle::MODAL);
setLayout(std::make_unique<AVerticalLayout>());
setContents(Vertical {
_form({
examples/app/minesweeper/src/MinesweeperWindow.cpp
Minesweeper Game - Minesweeper game implementation driven by ass.
#include "NewGameWindow.h"
#include "AUI/Platform/AMessageBox.h"
#include "AUI/Util/ARandom.h"
MinesweeperWindow::MinesweeperWindow() : AWindow("Minesweeper", 100_dp, 100_dp) {
setContents(Vertical {
Horizontal {
Centered::Expanding {
_new<AButton>("New game...").connect(&AButton::clicked, me::newGame),
},
examples/ui/minimal_ui_xmake/src/MainWindow.h
Minimal UI Template XMake - Minimal UI boilerplate template XMake.
Public fields and Signals#
mFocusNextViewOnTab#
bool mFocusNextViewOnTab
defines if the next view must be focused on tab button pressed
maximized#
emits<> maximized
Window is maximized.
minimized#
emits<> minimized
Window is minimized (hidden to the taskbar, iconified).
moving#
emits<glm::vec2> moving
Window is moving.
client area position.
restored#
emits<> restored
Window is restored (shown from the taskbar, deiconified).
Public Methods#
AWindow#
Constructor for custom initialization logic
Please call windowNativePreInit
Examples#
examples/app/fractal/src/JumpToCoordsWindow.cpp
Fractal Example - Fractal viewer application demonstrating usage of custom shaders.
#include <AUI/Platform/AMessageBox.h>
using namespace declarative;
JumpToCoordsWindow::JumpToCoordsWindow(_<FractalView> fractalView, AWindow* parent)
: AWindow("Jump to coords", 854_dp, 500_dp, parent, WindowStyle::NO_RESIZE) {
auto re = _new<ATextField>();
auto im = _new<ATextField>();
auto scale = _new<ATextField>();
examples/app/game_of_life/src/main.cpp
Game of Life - Game of Life implementation that uses advanced large dynamic data rendering techniques such as ITexture, AImage to be GPU friendly. The computation is performed in AThreadPool.
examples/app/minesweeper/src/NewGameWindow.h
Minesweeper Game - Minesweeper game implementation driven by ass.
examples/ui/contacts/src/view/ContactDetailsView.cpp
AUI Contacts - Usage of AUI_DECLARATIVE_FOR to make a contacts-like application.
return;
}
// discard
if (AMessageBox::show(dynamic_cast<AWindow*>(AWindow::current()), "Do you really want to discard?", "This action is irreversible!", AMessageBox::Icon::NONE, AMessageBox::Button::YES_NO) != AMessageBox::ResultButton::YES) {
return;
}
mContact = mOriginalContact;
mEditorMode = false;
}
examples/ui/minimal_ui_xmake/src/MainWindow.cpp
Minimal UI Template XMake - Minimal UI boilerplate template XMake.
examples/7guis/flight_booker/src/main.cpp
7GUIs Flight Booker - Flight Booker.
examples/7guis/cells/src/main.cpp
7GUIs Cells - Spreadsheet processor (Excel).
private:
_<State> mState;
};
class CellsWindow : public AWindow {
public:
CellsWindow() : AWindow("AUI - 7GUIs - Cells", 500_dp, 400_dp) {
setContents(Centered {
AScrollArea::Builder()
.withContents(Horizontal { _new<CellsView>(_new<State>()) })
examples/7guis/circle_drawer/src/main.cpp
7GUIs Circle Drawer - Undo, redo, dialog control.
.onAction =
[this, circle] {
auto radiusPopup = _new<AWindow>(
"", 200_dp, 50_dp, dynamic_cast<AWindow*>(AWindow::current()), WindowStyle::MODAL);
radiusPopup->setContents(Vertical {
Label { "Adjust diameter of circle at {}."_format(circle->position) },
_new<ASlider>() AUI_LET {
it->setValue(circle->radius / MAX_RADIUS);
examples/7guis/temperature_converter/src/main.cpp
7GUIs Temperature Converter - Fahrenheit to Celsius and vice versa.
examples/7guis/counter/src/main.cpp
7GUIs Counter - Simple counter.
#include "AUI/View/ATextField.h"
using namespace declarative;
class CounterWindow: public AWindow {
public:
CounterWindow(): AWindow("AUI - 7GUIs - Counter", 200_dp, 100_dp) {
setContents(Centered {
Horizontal {
_new<ATextField>() AUI_LET {
examples/7guis/timer/src/main.cpp
7GUIs Timer - Timer example.
examples/app/fractal/src/FractalWindow.h
Fractal Example - Fractal viewer application demonstrating usage of custom shaders.
examples/app/fractal/src/JumpToCoordsWindow.h
Fractal Example - Fractal viewer application demonstrating usage of custom shaders.
#include <AUI/Platform/AWindow.h>
#include "FractalView.h"
class JumpToCoordsWindow : public AWindow {
public:
explicit JumpToCoordsWindow(_<FractalView> fractalView, AWindow* parent);
};
examples/app/fractal/src/FractalWindow.cpp
Fractal Example - Fractal viewer application demonstrating usage of custom shaders.
using namespace ass;
using namespace declarative;
FractalWindow::FractalWindow() : AWindow("Mandelbrot set") {
setLayout(std::make_unique<AHorizontalLayout>());
auto centerPosDisplay = _new<ALabel>("-");
{
centerPosDisplay->setCustomStyle({
examples/app/minesweeper/src/NewGameWindow.cpp
Minesweeper Game - Minesweeper game implementation driven by ass.
mDifficultyLabel->setText(text);
}
NewGameWindow::NewGameWindow(MinesweeperWindow* minesweeper)
: AWindow("New game", 100, 100, minesweeper), mMinesweeper(minesweeper) {
setWindowStyle(WindowStyle::MODAL);
setLayout(std::make_unique<AVerticalLayout>());
setContents(Vertical {
_form({
examples/app/minesweeper/src/MinesweeperWindow.cpp
Minesweeper Game - Minesweeper game implementation driven by ass.
#include "NewGameWindow.h"
#include "AUI/Platform/AMessageBox.h"
#include "AUI/Util/ARandom.h"
MinesweeperWindow::MinesweeperWindow() : AWindow("Minesweeper", 100_dp, 100_dp) {
setContents(Vertical {
Horizontal {
Centered::Expanding {
_new<AButton>("New game...").connect(&AButton::clicked, me::newGame),
},
examples/ui/minimal_ui_xmake/src/MainWindow.h
Minimal UI Template XMake - Minimal UI boilerplate template XMake.
allowDragNDrop#
Enables drag-n-drop for this window.
current#
- Returns
- Current window for current thread.
Examples#
examples/app/game_of_life/src/main.cpp
Game of Life - Game of Life implementation that uses advanced large dynamic data rendering techniques such as ITexture, AImage to be GPU friendly. The computation is performed in AThreadPool.
examples/ui/contacts/src/view/ContactDetailsView.cpp
AUI Contacts - Usage of AUI_DECLARATIVE_FOR to make a contacts-like application.
return;
}
// discard
if (AMessageBox::show(dynamic_cast<AWindow*>(AWindow::current()), "Do you really want to discard?", "This action is irreversible!", AMessageBox::Icon::NONE, AMessageBox::Button::YES_NO) != AMessageBox::ResultButton::YES) {
return;
}
mContact = mOriginalContact;
mEditorMode = false;
}
examples/7guis/circle_drawer/src/main.cpp
7GUIs Circle Drawer - Undo, redo, dialog control.
[this, circle] {
auto radiusPopup = _new<AWindow>(
"", 200_dp, 50_dp, dynamic_cast<AWindow*>(AWindow::current()), WindowStyle::MODAL);
radiusPopup->setContents(Vertical {
Label { "Adjust diameter of circle at {}."_format(circle->position) },
_new<ASlider>() AUI_LET {
it->setValue(circle->radius / MAX_RADIUS);
connect(
examples/7guis/cells/src/Spreadsheet.h
7GUIs Cells - Spreadsheet processor (Excel).
isMaximized#
- Returns
- true if window maximized (fullscreen)
isMinimized#
- Returns
- true if window minimized (hidden in taskbar, iconified)
isRedrawWillBeEfficient#
Checks whether last monitor frame is displayed and redraw will be efficient. If some object often updates UI thread for displaying some data it may cause extra CPU and GPU overload. AUI throttles window redraws and FPS does not go above 60 FPS but UI views may also cause extra CPU and GPU overload that does not have visual difference.
- Returns
- true if 16 milliseconds elapsed since last frame
mapPosition#
Translates coordinates from the monitor's coordinate space to the coordinate space of this window.
- Arguments
position
the coordinate in screen space- Returns
- coordinates in the space of this window
mapPositionTo#
glm::ivec2 AWindow::mapPositionTo(const glm::ivec2& position, _<AWindow> other)
Translates coordinates from the coordinate space of this window to the coordinate space of another window.
- Arguments
position
coordinates in the space of this windowother
other window- Returns
- coordinates in the space of the other window
maximize#
Maximizes window (makes window fullscreen)
minimize#
Minimizes window (hide window to the taskbar, iconifies)
moveToCenter#
Moves the window to the center of monitor.
When using in series with setSize(), do the setSize() first, when moveToCenter().
quit#
Removes window from AWindowManager.
restore#
Restores window (shows window from taskbar)
setMobileScreenOrientation#
void AWindow::setMobileScreenOrientation(AScreenOrientation screenOrientation)
Controls mobile device's screen orientation when this window is on the foreground.
Affects only mobile OSes. On window-based interfaces (desktop) does nothing.
show#
Shows the window.
- Behavior under UI tests
- Does not actually shows the window and don't even needed in graphics environment.
Examples#
examples/ui/contacts/src/view/ContactDetailsView.cpp
AUI Contacts - Usage of AUI_DECLARATIVE_FOR to make a contacts-like application.
return;
}
// discard
if (AMessageBox::show(dynamic_cast<AWindow*>(AWindow::current()), "Do you really want to discard?", "This action is irreversible!", AMessageBox::Icon::NONE, AMessageBox::Button::YES_NO) != AMessageBox::ResultButton::YES) {
return;
}
mContact = mOriginalContact;
mEditorMode = false;
}
examples/app/fractal/src/JumpToCoordsWindow.cpp
Fractal Example - Fractal viewer application demonstrating usage of custom shaders.
auto dScale = std::stod((*re->text()).toStdString());
fractalView->setPlotPositionAndScale(glm::dvec2 { dRe, dIm }, dScale);
close();
} catch (...) {
AMessageBox::show(this, "Error", "Please check your values are valid numbers.");
}
}) AUI_LET { it->setDefault(); },
_new<AButton>("Cancel").connect(&AButton::clicked, me::close),
},
});
examples/app/fractal/src/main.cpp
Fractal Example - Fractal viewer application demonstrating usage of custom shaders.
#include <AUI/Platform/Entry.h>
#include "FractalWindow.h"
AUI_ENTRY {
_new<FractalWindow>()->show();
return 0;
}
examples/app/fractal/src/FractalWindow.cpp
Fractal Example - Fractal viewer application demonstrating usage of custom shaders.
},
Vertical {
_new<AButton>("Identity").connect(&AButton::clicked, AUI_SLOT(fractal)::reset),
_new<AButton>("Jump to coords...")
.connect(&AButton::clicked, this, [&, fractal]() { _new<JumpToCoordsWindow>(fractal, this)->show(); }),
_new<ALabel>("Iterations:"),
_new<ANumberPicker>().connect(
&ANumberPicker::valueChanged, this, [fractal](int v) { fractal->setIterations(v); }) AUI_LET {
it->setMax(1000);
it->setValue(350);
examples/app/game_of_life/src/main.cpp
Game of Life - Game of Life implementation that uses advanced large dynamic data rendering techniques such as ITexture, AImage to be GPU friendly. The computation is performed in AThreadPool.
AUI_ENTRY {
auto w = _new<GameOfLifeWindow>();
w->pack();
w->show();
return 0;
}
examples/app/minesweeper/src/MinesweeperWindow.cpp
Minesweeper Game - Minesweeper game implementation driven by ass.
c |= FieldCell::RED_BG;
mReveal = true;
emit customCssPropertyChanged();
redraw();
AMessageBox::show(this, "You lost!", "You lost! Ahahahhaa!");
}
return;
}
c |= FieldCell::OPEN;
mOpenedCells += 1;
examples/app/minesweeper/src/main.cpp
Minesweeper Game - Minesweeper game implementation driven by ass.
#include <AUI/Platform/Entry.h>
#include "MinesweeperWindow.h"
AUI_ENTRY {
_new<MinesweeperWindow>()->show();
return 0;
}
examples/ui/backdrop/src/main.cpp
Backdrop - Backdrop effects demo.
"Анне Павловне, поцеловал ее руку, подставив ей свою надушенную и сияющую лысину, и "
"покойно уселся на диване.") } AUI_WITH_STYLE { MaxSize { 550_dp, {} }, Padding { 16_dp } },
}));
window->show();
return 0;
}
examples/ui/views/tests/LayoutManagerTest.cpp
Views Example - All-in-one views building example.
examples/ui/views/src/main.cpp
Views Example - All-in-one views building example.
#include "ExampleWindow.h"
#include <AUI/Platform/Entry.h>
AUI_ENTRY {
_new<ExampleWindow>()->show();
return 0;
}
examples/ui/minimal_ui_xmake/src/main.cpp
Minimal UI Template XMake - Minimal UI boilerplate template XMake.
#include <AUI/Platform/Entry.h>
#include "MainWindow.h"
AUI_ENTRY {
_new<MainWindow>()->show();
return 0;
};
examples/7guis/flight_booker/src/main.cpp
7GUIs Flight Booker - Flight Booker.
examples/7guis/cells/src/main.cpp
7GUIs Cells - Spreadsheet processor (Excel).
}
};
AUI_ENTRY {
_new<CellsWindow>()->show();
return 0;
}
examples/7guis/circle_drawer/src/main.cpp
7GUIs Circle Drawer - Undo, redo, dialog control.
examples/7guis/temperature_converter/src/main.cpp
7GUIs Temperature Converter - Fahrenheit to Celsius and vice versa.
examples/7guis/counter/src/main.cpp
7GUIs Counter - Simple counter.
examples/7guis/timer/src/main.cpp
7GUIs Timer - Timer example.
void reset() { mStartTime = high_resolution_clock::now(); }
};
AUI_ENTRY {
_new<TimerWindow>()->show();
return 0;
}
unmapPosition#
Translates coordinates from the coordinate space of this window to the coordinate space of the monitor.
- Arguments
position
coordinates in the space of this window- Returns
- the coordinates in space of the monitor
wrapViewToWindow#
static _<AWindow> AWindow::wrapViewToWindow(const _<AView>& view, const AString& title, int width = 854 _dp, int height = 500 _dp, AWindow* parent = nullptr, WindowStyle ws = WindowStyle::DEFAULT)
Wraps your AView to window.
- Arguments
view
view to wraptitle
window titlewidth
window widthheight
window heightparent
parent windowws
window style flags- Returns
- created window, AWindow::show() is not called