Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions aui.core/src/AUI/Common/ASignal.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ class ASignal final : public AAbstractSignal {
return !mOutgoingConnections.empty();
}

[[nodiscard]] const auto& outgoingConnections() const noexcept {
return mOutgoingConnections;
}

[[nodiscard]] bool hasOutgoingConnectionsWith(aui::no_escape<AObjectBase> object) const noexcept override {
return std::any_of(
mOutgoingConnections.begin(), mOutgoingConnections.end(),
Expand Down
6 changes: 6 additions & 0 deletions examples/ui/checkboxes1kk/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
cmake_minimum_required(VERSION 3.10)

get_filename_component(_t ${CMAKE_CURRENT_SOURCE_DIR} NAME)

aui_executable("aui.example.${_t}")
aui_link("aui.example.${_t}" PRIVATE aui::core aui::views)
63 changes: 63 additions & 0 deletions examples/ui/checkboxes1kk/src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* AUI Framework - Declarative UI toolkit for modern C++20
* Copyright (C) 2020-2025 Alex2772 and Contributors
*
* SPDX-License-Identifier: MPL-2.0
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

/// [ScrollArea_example]
#include <range/v3/all.hpp>
#include "AUI/View/AButton.h"
#include "AUI/View/ACheckBox.h"
#include "AUI/View/AForEachUI.h"

#include <AUI/Platform/Entry.h>
#include <AUI/Platform/AWindow.h>
#include <AUI/Util/UIBuildingHelpers.h>
#include "AUI/View/AScrollArea.h"
#include "AUI/View/ATextArea.h"

using namespace ass;
using namespace declarative;

static constexpr auto COUNT = 1'000'000;
static constexpr auto DIV = 1'000;
static const auto INDICES = ranges::views::ints | ranges::view::take(COUNT);

AUI_ENTRY {
auto window = _new<AWindow>("1000000 checkboxes", 300_dp, 300_dp);
struct State {
AProperty<std::vector<bool>> values = std::vector<bool>(COUNT);
ScrollAreaViewport::State scrollAreaState;
APropertyPrecomputed<size_t> observerCount = [&] {
aui::react::DependencyObserverScope::addDependency(scrollAreaState.scroll.changed);
return values.changed.outgoingConnections().size();
};
};
auto state = _new<State>();
window->setContents(Vertical {
ScrollArea {
.state = AUI_PTR_ALIAS(state, scrollAreaState),
.content =
AUI_DECLARATIVE_FOR(row, INDICES | ranges::view::chunk(DIV), AVerticalLayout) {
return Horizontal {
Label { "{}"_format(ranges::front(row) / DIV) } AUI_WITH_STYLE { FixedSize { 50_dp, {} } },
// AUI_DECLARATIVE_FOR(i, row, AHorizontalLayout) {
// return CheckBox {
// .checked = AUI_REACT(state->values->at(i)),
// .onCheckedChange = [state, i](bool v) { state->values.writeScope()->at(i) = v; },
// } AUI_WITH_STYLE { Margin { 2_dp } };
// } AUI_LET { it->setKeyFunction([](int i) { return i; }); },
};
} AUI_LET { it->setKeyFunction([](const auto& row) { return ranges::front(row); }); },
},
Label { AUI_REACT("Observers: {}"_format(state->observerCount)) },
});
window->show();
return 0;
}
/// [ScrollArea_example]
Loading