2626#include < cstdio>
2727#include < libfenster/components/checkbox.hpp>
2828#include < libfenster/components/label.hpp>
29- #include < libfenster/layout/stack_layout.hpp>
29+ #include < libfenster/components/text_box.hpp>
30+ #include < libfenster/layout/grid_layout.hpp>
31+ #include < libfenster/layout/flex_layout.hpp>
3032
3133int main (int argc, char ** argv)
3234{
@@ -41,45 +43,50 @@ int main(int argc, char** argv)
4143 {
4244 g_exit (0 );
4345 });
44- fenster::StackLayout ::create (window);
46+ auto flex = fenster::FlexLayout ::create (window);
4547
46- auto panel = fenster::Panel::create ();
47- panel->setBackground (_RGB (200 , 200 , 255 ));
48+ auto textArea = fenster::TextBox::create ();
49+ textArea->setMultiLine (true );
50+ textArea->setTitle (" ..." );
51+ window->addChild (textArea);
52+ flex->setComponentInfo (textArea, 1 , 1 , -1 );
4853
49- auto stackLayout = fenster::StackLayout::create (panel);
50- stackLayout->setPadding (fenster::Insets (10 , 10 , 10 , 10 ));
51- stackLayout->setSpace (20 );
54+ auto lastRead = fenster::Label::create ();
55+ lastRead->setTitle (" Last read: -" );
56+ window->addChild (lastRead);
57+ flex->setComponentInfo (lastRead, 0 ,0 , 50 );
5258
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);
59+ window->setTitle (" Kernel log" );
60+ window->setBounds (fenster::Rectangle (50 , 50 , 600 , 600 ));
61+ window->setVisible (true );
6062
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)
63+ g_fd logPipe = g_open_log_pipe ();
64+ if (logPipe == G_FD_NONE)
6665 {
67- printf ( " Check state changed to %s \n " , checked ? " checked " : " unchecked " );
68- conditionalLabel-> setVisible (checked );
69- });
66+ textArea-> setTitle ( " Failed to open kernel log pipe " );
67+ g_sleep ( 999999999 );
68+ }
7069
71- auto testLabel2 = fenster::Label::create ();
72- testLabel2->setTitle (" Very cool." );
73- panel->addChild (testLabel2);
70+ uint8_t buf[1 ] ={0 };
71+ std::stringstream s;
72+ for (;;)
73+ {
74+ int r = g_read (logPipe, buf, 1 );
75+ if (r == 0 )
76+ {
77+ // Pipe is not blocking in both directions right now...
78+ g_sleep (100 );
79+ continue ;
80+ }
81+ s << (char ) buf[0 ];
7482
75- window-> addChild (panel );
83+ textArea-> setTitle (s. str () );
7684
77- window->setTitle (" Test window" );
78- window->setBounds (fenster::Rectangle (70 , 70 , 400 , 300 ));
79- window->setVisible (true );
85+ if (s.str ().size () > 1000 )
86+ s.str (" " );
8087
81- for (;;)
82- {
83- g_sleep ( 999999 );
88+ std::stringstream out;
89+ out << s. str (). size ();
90+ lastRead-> setTitle (out. str () );
8491 }
8592}
0 commit comments