Skip to content

Commit f249134

Browse files
committed
Update fenster integration to use new layouting
1 parent e7d4b42 commit f249134

File tree

5 files changed

+81
-23
lines changed

5 files changed

+81
-23
lines changed

applications/fenster

Submodule fenster updated 47 files

applications/navigator/src/navigator.cpp

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
#include <libfenster/label.hpp>
2929
#include <libfenster/image.hpp>
3030
#include <libfenster/listener/key_listener.hpp>
31+
#include <libfenster/layout/flex_layout_manager.hpp>
32+
#include <libfenster/layout/grid_layout_manager.hpp>
33+
#include <libfenster/layout/flow_layout_manager.hpp>
3134

3235
using namespace fenster;
3336
struct file_entry_t
@@ -68,19 +71,19 @@ int main()
6871
window->setTitle("Navigator");
6972
window->onClose([]() { g_exit(0); });
7073

71-
window->setLayout(FENSTER_LAYOUT_MANAGER_FLEX);
72-
window->setFlexOrientation(false);
74+
auto windowLayout = FlexLayoutManager::create(window);
75+
windowLayout->setHorizontal(false);
7376

7477
Panel* navBar = Panel::create();
75-
navBar->setLayout(FENSTER_LAYOUT_MANAGER_FLEX);
76-
navBar->setLayoutPadding(Insets(5, 5, 5, 5));
77-
navBar->setFlexGap(10);
78+
auto navBarLayout = FlexLayoutManager::create(navBar);
79+
navBarLayout->setPadding(Insets(5, 5, 5, 5));
80+
navBarLayout->setSpace(10);
7881
{
7982
navPrev = Button::create();
8083
navPrev->setStyle(FENSTER_BUTTON_STYLE_GHOST);
8184
navPrev->setTitle("<");
8285
navBar->addChild(navPrev);
83-
navBar->setFlexComponentInfo(navPrev, 0, 1, 50);
86+
navBarLayout->setComponentInfo(navPrev, 0, 1, 50);
8487
navPrev->setActionListener([]()
8588
{
8689
if(historyCurrentPosition > 0)
@@ -95,7 +98,7 @@ int main()
9598
navNext->setStyle(FENSTER_BUTTON_STYLE_GHOST);
9699
navNext->setTitle(">");
97100
navBar->addChild(navNext);
98-
navBar->setFlexComponentInfo(navNext, 0, 1, 50);
101+
navBarLayout->setComponentInfo(navNext, 0, 1, 50);
99102
navNext->setActionListener([]()
100103
{
101104
if(historyCurrentPosition >= 0 && historyCurrentPosition < (int) history.size() - 1)
@@ -108,7 +111,7 @@ int main()
108111

109112
navText = TextField::create();
110113
navBar->addChild(navText);
111-
navBar->setFlexComponentInfo(navText, 1, 1, 0);
114+
navBarLayout->setComponentInfo(navText, 1, 1, 0);
112115
navText->addKeyListener([](KeyEvent& e)
113116
{
114117
// TODO: g_keyboard needs a layout right now, maybe key events should already send ASCII codes:
@@ -124,7 +127,7 @@ int main()
124127
navUp->setTitle("^");
125128
navUp->setStyle(FENSTER_BUTTON_STYLE_GHOST);
126129
navBar->addChild(navUp);
127-
navBar->setFlexComponentInfo(navUp, 0, 1, 50);
130+
navBarLayout->setComponentInfo(navUp, 0, 1, 50);
128131

129132
navUp->setActionListener([]()
130133
{
@@ -135,24 +138,25 @@ int main()
135138
});
136139
}
137140
window->addChild(navBar);
138-
window->setFlexComponentInfo(navBar, 0, 1, 40);
141+
windowLayout->setComponentInfo(navBar, 0, 1, 40);
139142

140143
Panel* centerPanel = Panel::create();
141144
centerPanel->setBackground(_RGB(255, 255, 255));
142-
centerPanel->setLayout(FENSTER_LAYOUT_MANAGER_GRID);
145+
GridLayoutManager::create(centerPanel);
143146
{
144147
scroller = ScrollPane::create();
145148
content = Panel::create();
146-
content->setLayout(FENSTER_LAYOUT_MANAGER_FLOW);
147-
content->setLayoutPadding(Insets(5, 5, 5, 5));
149+
150+
auto contentLayout = FlowLayoutManager::create(content);
151+
contentLayout->setPadding(Insets(5, 5, 5, 5));
148152

149153
scroller->setFixed(true, false);
150154
scroller->setContent(content);
151155

152156
centerPanel->addChild(scroller);
153157
}
154158
window->addChild(centerPanel);
155-
window->setFlexComponentInfo(centerPanel, 1, 1, 0);
159+
windowLayout->setComponentInfo(centerPanel, 1, 1, 0);
156160

157161
window->setVisible(true);
158162
window->onClose([]()

applications/terminal/src/screen/gui/gui_screen.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <cstdio>
2626
#include <cstring>
2727
#include <libfenster/color_argb.hpp>
28+
#include <libfenster/layout/grid_layout_manager.hpp>
2829

2930
void guiScreenBlinkCursorEntry(gui_screen_t* screen);
3031
void guiScreenPaintEntry(gui_screen_t* screen);
@@ -107,7 +108,7 @@ bool gui_screen_t::createUi()
107108
return this;
108109
});
109110

110-
window->setLayout(FENSTER_LAYOUT_MANAGER_GRID);
111+
window->setLayoutManager(GridLayoutManager::create(window));
111112
window->addChild(canvas.component);
112113

113114
Rectangle windowBounds = Rectangle(80, 80, 700, 500);

applications/testprogram/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ fi
77

88
# Build configuration
99
ARTIFACT_NAME="tester.bin"
10-
LDFLAGS="-lps2driver"
10+
LDFLAGS="-lps2driver -lfenster"
1111

1212
# Include application build tasks
1313
. "../applications.sh"

applications/testprogram/src/tester.cpp

Lines changed: 59 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,66 @@
2020

2121
#include "tester.hpp"
2222

23-
#include <assert.h>
24-
#include <ghost.h>
25-
#include <libgen.h>
26-
#include <malloc.h>
27-
#include <stdio.h>
28-
#include <string.h>
23+
#include <libfenster/application.hpp>
24+
#include <libfenster/window.hpp>
25+
#include <libfenster/panel.hpp>
26+
#include <cstdio>
27+
#include <libfenster/checkbox.hpp>
28+
#include <libfenster/label.hpp>
29+
#include <libfenster/layout/stack_layout_manager.hpp>
2930

3031
int main(int argc, char** argv)
3132
{
33+
if(fenster::Application::open() != FENSTER_APPLICATION_STATUS_SUCCESSFUL)
34+
{
35+
printf("Failed to start UI\n");
36+
return -1;
37+
}
38+
39+
auto window = fenster::Window::create();
40+
window->onClose([]()
41+
{
42+
g_exit(0);
43+
});
44+
fenster::StackLayoutManager::create(window);
45+
46+
auto panel = fenster::Panel::create();
47+
panel->setBackground(_RGB(200, 200, 255));
48+
49+
auto stackLayout = fenster::StackLayoutManager::create(panel);
50+
stackLayout->setPadding(fenster::Insets(10, 10, 10, 10));
51+
stackLayout->setSpace(20);
52+
53+
auto testLabel = fenster::Label::create();
54+
testLabel->setTitle("Choose the checkbox to test listener behaviour:");
55+
panel->addChild(testLabel);
56+
57+
auto check = fenster::Checkbox::create();
58+
check->setTitle("Enable other field");
59+
panel->addChild(check);
60+
61+
auto conditionalLabel = fenster::Label::create();
62+
conditionalLabel->setTitle("Conditional label");
63+
conditionalLabel->setVisible(false);
64+
panel->addChild(conditionalLabel);
65+
check->addCheckedListener([conditionalLabel](bool checked)
66+
{
67+
printf("Check state changed to %s\n", checked ? "checked" : "unchecked");
68+
conditionalLabel->setVisible(checked);
69+
});
70+
71+
auto testLabel2 = fenster::Label::create();
72+
testLabel2->setTitle("Very cool.");
73+
panel->addChild(testLabel2);
74+
75+
window->addChild(panel);
76+
77+
window->setTitle("Test window");
78+
window->setBounds(fenster::Rectangle(70, 70, 400, 300));
79+
window->setVisible(true);
80+
81+
for(;;)
82+
{
83+
g_sleep(999999);
84+
}
3285
}

0 commit comments

Comments
 (0)