Skip to content

Commit a22774e

Browse files
committed
Taskbar: Start working on a taskbar app.
I originally thought I would do this inside WindowServer, but let's try to make it as a standalone app that communicates with WindowServer instead. That will allow us to use LibGUI. :^)
1 parent 318db1e commit a22774e

31 files changed

+577
-18
lines changed

Applications/Taskbar/About

709 KB
Binary file not shown.

Applications/Taskbar/Makefile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
OBJS = \
2+
TaskbarWindow.o \
3+
TaskbarWidget.o \
4+
main.o
5+
6+
APP = Taskbar
7+
8+
STANDARD_FLAGS = -std=c++17 -Wno-sized-deallocation
9+
WARNING_FLAGS = -Wextra -Wall -Wundef -Wcast-qual -Wwrite-strings -Wimplicit-fallthrough
10+
FLAVOR_FLAGS = -fno-exceptions -fno-rtti
11+
OPTIMIZATION_FLAGS = -Os
12+
INCLUDE_FLAGS = -I../.. -I. -I../../LibC
13+
14+
DEFINES = -DSERENITY -DSANITIZE_PTRS -DUSERLAND
15+
16+
CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(FLAVOR_FLAGS) $(STANDARD_FLAGS) $(INCLUDE_FLAGS) $(DEFINES)
17+
CXX = i686-pc-serenity-g++
18+
LD = i686-pc-serenity-g++
19+
LDFLAGS = -L../../LibC -L../../LibGUI
20+
21+
all: $(APP)
22+
23+
$(APP): $(OBJS)
24+
$(LD) -o $(APP) $(LDFLAGS) $(OBJS) -lgui -lc
25+
26+
.cpp.o:
27+
@echo "CXX $<"; $(CXX) $(CXXFLAGS) -o $@ -c $<
28+
29+
-include $(OBJS:%.o=%.d)
30+
31+
clean:
32+
@echo "CLEAN"; rm -f $(APPS) $(OBJS) *.d
33+

Applications/Taskbar/Taskbar

712 KB
Binary file not shown.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#include "TaskbarWidget.h"
2+
#include <LibGUI/GLabel.h>
3+
#include <LibGUI/GButton.h>
4+
#include <LibGUI/GBoxLayout.h>
5+
#include <LibGUI/GPainter.h>
6+
#include <stdio.h>
7+
8+
TaskbarWidget::TaskbarWidget(GWidget* parent)
9+
: GFrame(parent)
10+
{
11+
set_fill_with_background_color(true);
12+
set_layout(make<GBoxLayout>(Orientation::Vertical));
13+
layout()->set_margins({ 0, 8, 0, 8 });
14+
layout()->set_spacing(8);
15+
16+
set_frame_thickness(1);
17+
set_frame_shape(GFrame::Shape::Panel);
18+
set_frame_shadow(GFrame::Shadow::Raised);
19+
}
20+
21+
TaskbarWidget::~TaskbarWidget()
22+
{
23+
}
24+
25+
void TaskbarWidget::paint_event(GPaintEvent& event)
26+
{
27+
GFrame::paint_event(event);
28+
29+
GPainter painter(*this);
30+
painter.add_clip_rect(event.rect());
31+
}

Applications/Taskbar/TaskbarWidget.d

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
TaskbarWidget.o: TaskbarWidget.cpp TaskbarWidget.h ../../LibGUI/GFrame.h \
2+
../../LibGUI/GWidget.h ../../LibGUI/GElapsedTimer.h ../../LibC/time.h \
3+
../../LibC/sys/cdefs.h ../../LibC/sys/types.h ../../LibC/stdint.h \
4+
../../LibGUI/GEvent.h ../../SharedGraphics/Point.h ../../AK/AKString.h \
5+
../../AK/ByteBuffer.h ../../AK/Types.h ../../AK/StdLibExtras.h \
6+
../../LibC/stdlib.h ../../LibC/stddef.h ../../LibC/string.h \
7+
../../AK/Retainable.h ../../AK/Assertions.h ../../LibC/assert.h \
8+
../../AK/RetainPtr.h ../../AK/Retained.h ../../AK/kmalloc.h \
9+
../../AK/StringImpl.h ../../AK/Traits.h ../../AK/kstdio.h \
10+
../../Kernel/kstdio.h ../../Kernel/kprintf.h ../../AK/HashFunctions.h \
11+
../../AK/Vector.h ../../AK/OwnPtr.h ../../SharedGraphics/Rect.h \
12+
../../SharedGraphics/Size.h ../../AK/WeakPtr.h ../../AK/Weakable.h \
13+
../../Kernel/KeyCode.h ../../LibGUI/GObject.h \
14+
../../SharedGraphics/Color.h ../../SharedGraphics/Font.h \
15+
../../AK/MappedFile.h ../../AK/Badge.h ../../LibGUI/GLabel.h \
16+
../../SharedGraphics/TextAlignment.h ../../LibGUI/GButton.h \
17+
../../SharedGraphics/StylePainter.h ../../AK/Function.h \
18+
../../SharedGraphics/GraphicsBitmap.h ../../LibC/SharedBuffer.h \
19+
../../LibGUI/GBoxLayout.h ../../LibGUI/GLayout.h ../../LibGUI/GMargins.h \
20+
../../LibGUI/GPainter.h ../../SharedGraphics/Painter.h \
21+
../../LibC/stdio.h ../../LibC/stdarg.h ../../LibC/limits.h
22+
23+
TaskbarWidget.h:
24+
25+
../../LibGUI/GFrame.h:
26+
27+
../../LibGUI/GWidget.h:
28+
29+
../../LibGUI/GElapsedTimer.h:
30+
31+
../../LibC/time.h:
32+
33+
../../LibC/sys/cdefs.h:
34+
35+
../../LibC/sys/types.h:
36+
37+
../../LibC/stdint.h:
38+
39+
../../LibGUI/GEvent.h:
40+
41+
../../SharedGraphics/Point.h:
42+
43+
../../AK/AKString.h:
44+
45+
../../AK/ByteBuffer.h:
46+
47+
../../AK/Types.h:
48+
49+
../../AK/StdLibExtras.h:
50+
51+
../../LibC/stdlib.h:
52+
53+
../../LibC/stddef.h:
54+
55+
../../LibC/string.h:
56+
57+
../../AK/Retainable.h:
58+
59+
../../AK/Assertions.h:
60+
61+
../../LibC/assert.h:
62+
63+
../../AK/RetainPtr.h:
64+
65+
../../AK/Retained.h:
66+
67+
../../AK/kmalloc.h:
68+
69+
../../AK/StringImpl.h:
70+
71+
../../AK/Traits.h:
72+
73+
../../AK/kstdio.h:
74+
75+
../../Kernel/kstdio.h:
76+
77+
../../Kernel/kprintf.h:
78+
79+
../../AK/HashFunctions.h:
80+
81+
../../AK/Vector.h:
82+
83+
../../AK/OwnPtr.h:
84+
85+
../../SharedGraphics/Rect.h:
86+
87+
../../SharedGraphics/Size.h:
88+
89+
../../AK/WeakPtr.h:
90+
91+
../../AK/Weakable.h:
92+
93+
../../Kernel/KeyCode.h:
94+
95+
../../LibGUI/GObject.h:
96+
97+
../../SharedGraphics/Color.h:
98+
99+
../../SharedGraphics/Font.h:
100+
101+
../../AK/MappedFile.h:
102+
103+
../../AK/Badge.h:
104+
105+
../../LibGUI/GLabel.h:
106+
107+
../../SharedGraphics/TextAlignment.h:
108+
109+
../../LibGUI/GButton.h:
110+
111+
../../SharedGraphics/StylePainter.h:
112+
113+
../../AK/Function.h:
114+
115+
../../SharedGraphics/GraphicsBitmap.h:
116+
117+
../../LibC/SharedBuffer.h:
118+
119+
../../LibGUI/GBoxLayout.h:
120+
121+
../../LibGUI/GLayout.h:
122+
123+
../../LibGUI/GMargins.h:
124+
125+
../../LibGUI/GPainter.h:
126+
127+
../../SharedGraphics/Painter.h:
128+
129+
../../LibC/stdio.h:
130+
131+
../../LibC/stdarg.h:
132+
133+
../../LibC/limits.h:

Applications/Taskbar/TaskbarWidget.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include <LibGUI/GFrame.h>
2+
3+
class TaskbarWidget final : public GFrame {
4+
public:
5+
TaskbarWidget(GWidget* parent = nullptr);
6+
virtual ~TaskbarWidget() override;
7+
8+
virtual const char* class_name() const override { return "TaskbarWidget"; }
9+
10+
private:
11+
virtual void paint_event(GPaintEvent&) override;
12+
13+
};

Applications/Taskbar/TaskbarWidget.o

4.59 KB
Binary file not shown.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include "TaskbarWindow.h"
2+
#include "TaskbarWidget.h"
3+
#include <LibGUI/GWindow.h>
4+
#include <LibGUI/GDesktop.h>
5+
#include <stdio.h>
6+
7+
TaskbarWindow::TaskbarWindow()
8+
{
9+
set_window_type(GWindowType::Taskbar);
10+
set_title("Taskbar");
11+
set_should_exit_event_loop_on_close(true);
12+
13+
on_screen_rect_change(GDesktop::the().rect());
14+
15+
GDesktop::the().on_rect_change = [this] (const Rect& rect) { on_screen_rect_change(rect); };
16+
17+
auto* widget = new TaskbarWidget;
18+
set_main_widget(widget);
19+
}
20+
21+
TaskbarWindow::~TaskbarWindow()
22+
{
23+
}
24+
25+
void TaskbarWindow::on_screen_rect_change(const Rect& rect)
26+
{
27+
Rect new_rect { rect.x(), rect.bottom() - taskbar_height() + 1, rect.width(), taskbar_height() };
28+
set_rect(new_rect);
29+
}

Applications/Taskbar/TaskbarWindow.d

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
TaskbarWindow.o: TaskbarWindow.cpp TaskbarWindow.h ../../LibGUI/GWindow.h \
2+
../../LibGUI/GObject.h ../../AK/Vector.h ../../AK/Assertions.h \
3+
../../LibC/assert.h ../../LibC/sys/cdefs.h ../../AK/OwnPtr.h \
4+
../../AK/StdLibExtras.h ../../LibC/stdlib.h ../../LibC/sys/types.h \
5+
../../LibC/stdint.h ../../LibC/stddef.h ../../LibC/string.h \
6+
../../AK/Types.h ../../AK/Traits.h ../../AK/kstdio.h \
7+
../../Kernel/kstdio.h ../../Kernel/kprintf.h ../../AK/HashFunctions.h \
8+
../../AK/kmalloc.h ../../AK/Weakable.h ../../AK/Retainable.h \
9+
../../AK/RetainPtr.h ../../AK/Retained.h ../../SharedGraphics/Rect.h \
10+
../../SharedGraphics/Point.h ../../AK/AKString.h ../../AK/ByteBuffer.h \
11+
../../AK/StringImpl.h ../../SharedGraphics/Size.h \
12+
../../SharedGraphics/GraphicsBitmap.h ../../SharedGraphics/Color.h \
13+
../../AK/MappedFile.h ../../LibC/SharedBuffer.h ../../AK/WeakPtr.h \
14+
../../LibGUI/GWidget.h ../../LibGUI/GElapsedTimer.h ../../LibC/time.h \
15+
../../LibGUI/GEvent.h ../../Kernel/KeyCode.h ../../SharedGraphics/Font.h \
16+
../../AK/Badge.h TaskbarWidget.h ../../LibGUI/GFrame.h \
17+
../../LibGUI/GDesktop.h ../../AK/Function.h ../../LibC/stdio.h \
18+
../../LibC/stdarg.h ../../LibC/limits.h
19+
20+
TaskbarWindow.h:
21+
22+
../../LibGUI/GWindow.h:
23+
24+
../../LibGUI/GObject.h:
25+
26+
../../AK/Vector.h:
27+
28+
../../AK/Assertions.h:
29+
30+
../../LibC/assert.h:
31+
32+
../../LibC/sys/cdefs.h:
33+
34+
../../AK/OwnPtr.h:
35+
36+
../../AK/StdLibExtras.h:
37+
38+
../../LibC/stdlib.h:
39+
40+
../../LibC/sys/types.h:
41+
42+
../../LibC/stdint.h:
43+
44+
../../LibC/stddef.h:
45+
46+
../../LibC/string.h:
47+
48+
../../AK/Types.h:
49+
50+
../../AK/Traits.h:
51+
52+
../../AK/kstdio.h:
53+
54+
../../Kernel/kstdio.h:
55+
56+
../../Kernel/kprintf.h:
57+
58+
../../AK/HashFunctions.h:
59+
60+
../../AK/kmalloc.h:
61+
62+
../../AK/Weakable.h:
63+
64+
../../AK/Retainable.h:
65+
66+
../../AK/RetainPtr.h:
67+
68+
../../AK/Retained.h:
69+
70+
../../SharedGraphics/Rect.h:
71+
72+
../../SharedGraphics/Point.h:
73+
74+
../../AK/AKString.h:
75+
76+
../../AK/ByteBuffer.h:
77+
78+
../../AK/StringImpl.h:
79+
80+
../../SharedGraphics/Size.h:
81+
82+
../../SharedGraphics/GraphicsBitmap.h:
83+
84+
../../SharedGraphics/Color.h:
85+
86+
../../AK/MappedFile.h:
87+
88+
../../LibC/SharedBuffer.h:
89+
90+
../../AK/WeakPtr.h:
91+
92+
../../LibGUI/GWidget.h:
93+
94+
../../LibGUI/GElapsedTimer.h:
95+
96+
../../LibC/time.h:
97+
98+
../../LibGUI/GEvent.h:
99+
100+
../../Kernel/KeyCode.h:
101+
102+
../../SharedGraphics/Font.h:
103+
104+
../../AK/Badge.h:
105+
106+
TaskbarWidget.h:
107+
108+
../../LibGUI/GFrame.h:
109+
110+
../../LibGUI/GDesktop.h:
111+
112+
../../AK/Function.h:
113+
114+
../../LibC/stdio.h:
115+
116+
../../LibC/stdarg.h:
117+
118+
../../LibC/limits.h:

Applications/Taskbar/TaskbarWindow.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include <LibGUI/GWindow.h>
2+
#include <LibGUI/GWidget.h>
3+
4+
class TaskbarWindow final : public GWindow {
5+
public:
6+
TaskbarWindow();
7+
virtual ~TaskbarWindow() override;
8+
9+
int taskbar_height() const { return 20; }
10+
11+
virtual const char* class_name() const override { return "TaskbarWindow"; }
12+
13+
private:
14+
void on_screen_rect_change(const Rect&);
15+
16+
};

Applications/Taskbar/TaskbarWindow.o

4.62 KB
Binary file not shown.

Applications/Taskbar/main.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include <LibGUI/GApplication.h>
2+
#include "TaskbarWindow.h"
3+
4+
int main(int argc, char** argv)
5+
{
6+
GApplication app(argc, argv);
7+
TaskbarWindow window;
8+
window.show();
9+
return app.exec();
10+
}

0 commit comments

Comments
 (0)