Skip to content

ass::LayoutSpacing#

Controls the gap between elements of the container. Basically acts like a margin, but the gaps appear between views only, not around them.

Header:#include <AUI/ASS/Property/LayoutSpacing.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.

                          b.setText(isRunning ? "Pause" : "Run");
                      };
                      connect(it->clicked, [&] { mCells.isRunning = !mCells.isRunning; });
                  },
            } AUI_WITH_STYLE { LayoutSpacing { 4_dp } },
          },
          Centered {
            _new<CellsView>(aui::ptr::fake_shared(&mCells)) AUI_WITH_STYLE {
                  Expanding(),
                  BackgroundSolid(AColor::BLACK),

examples/app/minesweeper/src/NewGameWindow.cpp

Minesweeper Game - Minesweeper game implementation driven by ass.

        {
          "Mines count:"_as,
          mMines = _new<ANumberPicker>() AUI_LET { it->setMin(8); },
        },
      }) AUI_WITH_STYLE { LayoutSpacing { 4_dp } },
      mDifficultyLabel = _new<ALabel>(),
      Horizontal {
        _new<ASpacerExpanding>(),
        _new<AButton>("Start game") AUI_LET {
                it->setDefault();

examples/app/fractal/src/FractalWindow.cpp

Fractal Example - Fractal viewer application demonstrating usage of custom shaders.

            &ANumberPicker::valueChanged, this, [fractal](int v) { fractal->setIterations(v); }) AUI_LET {
                it->setMax(1000);
                it->setValue(350);
            },
      } AUI_WITH_STYLE { LayoutSpacing { 4_dp } },
    } AUI_WITH_STYLE { LayoutSpacing { 4_dp } });

    fractal->focus();
}

examples/ui/contacts/src/view/ContactDetailsView.cpp

AUI Contacts - Usage of AUI_DECLARATIVE_FOR to make a contacts-like application.

                profilePhoto(mContact),
                Centered::Expanding {
                  presentation(mContact->displayName) AUI_WITH_STYLE { FontSize { 12_pt } },
                },
              } AUI_WITH_STYLE { Margin { 8_dp, {} }, LayoutSpacing { 4_dp } },
              row("Phone", mContact->phone),
              row("Address", mContact->address),
              row("Email", mContact->email),
              row("Homepage", mContact->homepage),
              Horizontal::Expanding {

examples/ui/views/src/ExampleWindow.cpp

Views Example - All-in-one views building example.

                                    }
                                }),
                            _new<ASpacerExpanding>(),
                          } AUI_WITH_STYLE { LayoutSpacing { 4_dp } },
                          AUI_DECLARATIVE_FOR(i, *state->colors, AWordWrappingLayout) {
                              return Horizontal {
                                  _new<ALabel>(i.toString()) AUI_WITH_STYLE {
                                      TextColor { i.readableBlackOrWhite() },
                                  }
                              } AUI_WITH_STYLE {

examples/7guis/crud/src/main.cpp

7GUIs CRUD - Create/Read/Update/Delete example.

                Label { "Filter prefix:" },
                _new<ATextField>() AUI_WITH_STYLE { Expanding(1, 0) } && mFilterPrefix,
              } AUI_WITH_STYLE { LayoutSpacing { 4_dp } },
              AScrollArea::Builder().withExpanding().withContents(
                  AUI_DECLARATIVE_FOR(i, *mUsers | FILTER_VIEW, AVerticalLayout) {
                    auto view = _new<ALabel>();
                    view & i->displayName;
                    connect(mSelectedUser, view, [this, &view = *view, i] {
                        view.setAssName("selected", mSelectedUser == i);
                    });

examples/7guis/counter/src/main.cpp

7GUIs Counter - Simple counter.

        setContents(Centered {
          Horizontal {
            Label { AUI_REACT("Count: {}"_format(mCounter)) },
            Button { Label { "Count" }, [this] { mCounter += 1; } },
          } AUI_WITH_STYLE { LayoutSpacing { 4_dp } },
        });
    }

private:
    AProperty<int> mCounter;

examples/7guis/flight_booker/src/main.cpp

7GUIs Flight Booker - Flight Booker.

                  }
                  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 } },
    });

    window->show();
    return 0;
}

examples/7guis/timer/src/main.cpp

7GUIs Timer - Timer example.

                        it & mElapsedTimeRatio;
                        it->setCustomStyle({ Expanding { 1, 0 } });
                    },
              },
            } AUI_WITH_STYLE { LayoutSpacing { 4_dp } },
            Label { AUI_REACT("{:.1f}s"_format(duration_cast<milliseconds>(*mElapsedTime).count() / 1000.f)) },
            Horizontal {
              Label { "Duration:" },
              Slider {
                .value = AUI_REACT(float(mDuration->count()) / float(MAX_DURATION.count())),

examples/7guis/circle_drawer/src/main.cpp

7GUIs Circle Drawer - Undo, redo, dialog control.

                      },
                },
              },
              _new<CircleDrawArea>(aui::ptr::fake_shared(&mState)),
            } AUI_WITH_STYLE { LayoutSpacing { 4_dp } });
    }

private:
    State mState;

examples/7guis/cells/src/main.cpp

7GUIs Cells - Spreadsheet processor (Excel).

                            }
                        }
                        return views;
                    }())
                    .build() AUI_WITH_STYLE { Expanding(), LayoutSpacing { 1_dp }, MinSize { 80_dp * float(mState->spreadsheet.size().x), {} } });
    }

private:
    _<State> mState;
};

examples/7guis/temperature_converter/src/main.cpp

7GUIs Temperature Converter - Fahrenheit to Celsius and vice versa.

            Label { "°C" },
            Label { "=" } AUI_WITH_STYLE { Margin { {}, 16_dp } },
            myPicker() AUI_LET { biConnect(it->value(), mFahrenheit); },
            Label { "°F" },
          } AUI_WITH_STYLE { LayoutSpacing { 4_dp } },
        });

        connect(mFahrenheit.changed, [&] { mCelsius = (*mFahrenheit - 32.f) * (5.f / 9.f); });
        connect(mCelsius.changed, [&] { mFahrenheit = *mCelsius * (9.f / 5.f) + 32.f; });
    }

examples/app/minesweeper/src/MinesweeperWindow.cpp

Minesweeper Game - Minesweeper game implementation driven by ass.

      },
      _container<AStackedLayout>(
          { // also assign ".frame" ASS class in place
            mGrid = _new<AViewContainer>() << ".frame" }),
    } AUI_WITH_STYLE { LayoutSpacing { 4_dp } });

    beginGame(10, 10, 20);
}

void MinesweeperWindow::openCell(int x, int y, bool doGameLoseIfBomb) {

examples/app/fractal/src/JumpToCoordsWindow.cpp

Fractal Example - Fractal viewer application demonstrating usage of custom shaders.

      _form({
        { "Re="_as, re },
        { "Im="_as, im },
        { "Scale="_as, scale },
      }) AUI_WITH_STYLE { LayoutSpacing { 4_dp } },
      Horizontal {
        SpacerExpanding {},
        _new<AButton>("Jump").connect(
            &AButton::clicked, this,
            [&, fractalView, re, im, scale]() {