Skip to content

Commit

Permalink
hideo-base: Match the windows controls order with the platform.
Browse files Browse the repository at this point in the history
  • Loading branch information
sleepy-monax committed Aug 3, 2024
1 parent be76696 commit b9076f2
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 4 deletions.
48 changes: 44 additions & 4 deletions src/apps/hideo-base/scafold.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,78 @@ static Ui::BoxStyle TOOLBAR = {
.backgroundFill = Ui::GRAY900,
};

Ui::Child aboutButton(Mdi::Icon icon, String title) {
Ui::Child aboutButton([[maybe_unused]] Mdi::Icon icon, String title) {
#ifdef __ck_sys_darwin__
return Ui::button(
[title](auto &n) {
Ui::showDialog(n, Kr::aboutDialog(title));
},
Ui::ButtonStyle::subtle(), title
);
#else
return Ui::button(
[title](auto &n) {
Ui::showDialog(n, Kr::aboutDialog(title));
},
Ui::ButtonStyle::subtle(), icon, title
);
#endif
}

Ui::Child controls(TitlebarStyle style) {
#ifdef __ck_sys_darwin__
return Ui::hflow(
12,
4,
Ui::button(
Ui::bindBubble<App::RequestExitEvent>(),
Ui::ButtonStyle::subtle(),
Mdi::CLOSE
),
Ui::button(
Ui::bindBubble<App::RequestMinimizeEvent>(),
Ui::ButtonStyle::subtle(),
Mdi::MINUS
) | Ui::cond(style == TitlebarStyle::DEFAULT),
Ui::button(
Ui::bindBubble<App::RequestMaximizeEvent>(),
Ui::ButtonStyle::subtle(),
Mdi::PLUS
) | Ui::cond(style == TitlebarStyle::DEFAULT)
);
#else
return Ui::hflow(
4,
Ui::button(
Ui::bindBubble<App::RequestMinimizeEvent>(),
Ui::ButtonStyle::subtle(),
Mdi::MINUS
) | Ui::cond(style == TitlebarStyle::DEFAULT),

Ui::button(
Ui::bindBubble<App::RequestMaximizeEvent>(),
Ui::ButtonStyle::subtle(),
Mdi::CROP_SQUARE
) | Ui::cond(style == TitlebarStyle::DEFAULT),

Ui::button(
Ui::bindBubble<App::RequestExitEvent>(),
Ui::ButtonStyle::subtle(),
Mdi::CLOSE
)
);
#endif
}

Ui::Child titlebar(Mdi::Icon icon, String title, TitlebarStyle style) {
#ifdef __ck_sys_darwin__
return Ui::stack(
aboutButton(icon, title) | Ui::center(),
Ui::hflow(
controls(style),
Ui::grow(NONE)
)
) |
Ui::insets(8) |
Ui::dragRegion() | box(TOOLBAR);
#else
return Ui::hflow(
4,
aboutButton(icon, title),
Expand All @@ -56,6 +95,7 @@ Ui::Child titlebar(Mdi::Icon icon, String title, TitlebarStyle style) {
) |
Ui::insets(8) |
Ui::dragRegion() | box(TOOLBAR);
#endif
}

Ui::Child titlebar(Mdi::Icon icon, String title, Ui::Child tabs, TitlebarStyle style) {
Expand Down
1 change: 1 addition & 0 deletions src/impls/impl-darwin/async.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//
#include <impl-posix/fd.h>
#include <impl-posix/utils.h>
#include <karm-base/map.h>
#include <karm-sys/async.h>
#include <karm-sys/time.h>

Expand Down
13 changes: 13 additions & 0 deletions src/libs/karm-ui/layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,19 @@ struct StackLayout : public GroupNode<StackLayout> {
return;
}
}

Math::Vec2i size(Math::Vec2i s, Hint hint) override {
isize w{};
isize h{};

for (auto &child : children()) {
auto childSize = child->size(s, hint);
w = max(w, childSize.x);
h = max(h, childSize.y);
}

return {w, h};
}
};

Child stack(Children children) {
Expand Down

0 comments on commit b9076f2

Please sign in to comment.