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/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.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/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/ui/minimal_ui_assets_xmake/src/MainWindow.cpp
Minimal UI Template XMake with Assets - Minimal UI boilerplate template XMake with AUI Assets.
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/counter/src/main.cpp
7GUIs Counter - Simple counter.
examples/7guis/flight_booker/src/main.cpp
7GUIs Flight Booker - Flight Booker.
// Create state instance
_<State> state = _new<State>();
// Create window
auto window = _new<AWindow>("AUI - 7GUIs - Book Flight", 150_dp, 50_dp);
// Set contents
window->setContents(Centered {
Vertical {
_new<ADropdownList>(AListModel<AString>::make({ "one-way flight", "return flight" })) AUI_LET {
examples/7guis/timer/src/main.cpp
7GUIs Timer - Timer example.
examples/7guis/circle_drawer/src/main.cpp
7GUIs Circle Drawer - Undo, redo, dialog control.
{
.name = "Adjust radius...",
.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) },
Slider {
.value = AUI_REACT(circle->radius / MAX_RADIUS),
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/temperature_converter/src/main.cpp
7GUIs Temperature Converter - Fahrenheit to Celsius and vice versa.
examples/app/minesweeper/src/MinesweeperWindow.cpp
Minesweeper Game - Minesweeper game implementation driven by ass.
examples/app/minesweeper/src/NewGameWindow.h
Minesweeper Game - Minesweeper game implementation driven by ass.
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/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/fractal/src/FractalWindow.h
Fractal Example - Fractal viewer application demonstrating usage of custom shaders.
examples/ui/minimal_ui_assets_xmake/src/MainWindow.h
Minimal UI Template XMake with Assets - Minimal UI boilerplate template XMake with AUI Assets.
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#
constructor#
Constructor for custom initialization logic
Please call windowNativePreInit
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/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/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/ui/minimal_ui_assets_xmake/src/MainWindow.cpp
Minimal UI Template XMake with Assets - Minimal UI boilerplate template XMake with AUI Assets.
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/views/src/ExampleWindow.h
Views Example - All-in-one views building example.
#include "AUI/Thread/AAsyncHolder.h"
class API_AUI_AUDIO IAudioPlayer;
class ExampleWindow: public AWindow {
public:
ExampleWindow();
void onDragDrop(const ADragNDrop::DropEvent& event) override;
examples/ui/minimal_ui_xmake/src/MainWindow.cpp
Minimal UI Template XMake - Minimal UI boilerplate template XMake.
examples/7guis/counter/src/main.cpp
7GUIs Counter - Simple counter.
examples/7guis/timer/src/main.cpp
7GUIs Timer - Timer example.
examples/7guis/circle_drawer/src/main.cpp
7GUIs Circle Drawer - Undo, redo, dialog control.
{
.name = "Adjust radius...",
.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) },
Slider {
.value = AUI_REACT(circle->radius / MAX_RADIUS),
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/temperature_converter/src/main.cpp
7GUIs Temperature Converter - Fahrenheit to Celsius and vice versa.
examples/app/minesweeper/src/MinesweeperWindow.cpp
Minesweeper Game - Minesweeper game implementation driven by ass.
examples/app/minesweeper/src/MinesweeperWindow.h
Minesweeper Game - Minesweeper game implementation driven by ass.
examples/app/minesweeper/src/NewGameWindow.h
Minesweeper Game - Minesweeper game implementation driven by ass.
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/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/fractal/src/FractalWindow.h
Fractal Example - Fractal viewer application demonstrating usage of custom shaders.
examples/ui/minimal_ui_assets_xmake/src/MainWindow.h
Minimal UI Template XMake with Assets - Minimal UI boilerplate template XMake with AUI Assets.
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.
.name = "Adjust radius...",
.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) },
Slider {
.value = AUI_REACT(circle->radius / MAX_RADIUS),
.onValueChanged =
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
positionthe 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
positioncoordinates in the space of this windowotherother 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/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/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/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),
} AUI_WITH_STYLE { LayoutSpacing { 4_dp } },
} AUI_WITH_STYLE { LayoutSpacing { 4_dp } });
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/ui/minimal_ui_assets_xmake/src/main.cpp
Minimal UI Template XMake with Assets - Minimal UI boilerplate template XMake with AUI Assets.
#include <AUI/Platform/Entry.h>
#include "MainWindow.h"
AUI_ENTRY {
_new<MainWindow>()->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/counter/src/main.cpp
7GUIs Counter - Simple counter.
};
/// [counter]
AUI_ENTRY {
_new<CounterWindow>()->show();
return 0;
}
examples/7guis/flight_booker/src/main.cpp
7GUIs Flight Booker - Flight Booker.
AString msg = "Departure - {}"_format(formatDate(state->departureDate.parsed->value()));
if (state->isReturnFlight) {
msg += "\nReturn - {}"_format(formatDate(state->returnDate.parsed->value()));
}
AMessageBox::show(window.get(), "You've booked the flight", msg);
},
} AUI_LET { AObject::connect(AUI_REACT(state->isValid()), AUI_SLOT(it)::setEnabled); },
} AUI_WITH_STYLE { LayoutSpacing { 4_dp } },
});
examples/7guis/timer/src/main.cpp
7GUIs Timer - Timer example.
};
/// [example]
AUI_ENTRY {
_new<TimerWindow>()->show();
return 0;
}
examples/7guis/circle_drawer/src/main.cpp
7GUIs Circle Drawer - Undo, redo, dialog control.
examples/7guis/cells/src/main.cpp
7GUIs Cells - Spreadsheet processor (Excel).
}
};
AUI_ENTRY {
_new<CellsWindow>()->show();
return 0;
}
examples/7guis/temperature_converter/src/main.cpp
7GUIs Temperature Converter - Fahrenheit to Celsius and vice versa.
};
/// [window]
AUI_ENTRY {
_new<TemperatureConverterWindow>()->show();
return 0;
}
unmapPosition#
Translates coordinates from the coordinate space of this window to the coordinate space of the monitor.
- Arguments
positioncoordinates 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
viewview to wraptitlewindow titlewidthwindow widthheightwindow heightparentparent windowwswindow style flags- Returns
- created window, AWindow::show() is not called