1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 14:38:11 +00:00

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. :^)
This commit is contained in:
Andreas Kling 2019-04-03 19:38:44 +02:00
parent 318db1e48e
commit a22774ee3f
31 changed files with 577 additions and 18 deletions

BIN
Applications/Taskbar/About Executable file

Binary file not shown.

View file

@ -0,0 +1,33 @@
OBJS = \
TaskbarWindow.o \
TaskbarWidget.o \
main.o
APP = Taskbar
STANDARD_FLAGS = -std=c++17 -Wno-sized-deallocation
WARNING_FLAGS = -Wextra -Wall -Wundef -Wcast-qual -Wwrite-strings -Wimplicit-fallthrough
FLAVOR_FLAGS = -fno-exceptions -fno-rtti
OPTIMIZATION_FLAGS = -Os
INCLUDE_FLAGS = -I../.. -I. -I../../LibC
DEFINES = -DSERENITY -DSANITIZE_PTRS -DUSERLAND
CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(FLAVOR_FLAGS) $(STANDARD_FLAGS) $(INCLUDE_FLAGS) $(DEFINES)
CXX = i686-pc-serenity-g++
LD = i686-pc-serenity-g++
LDFLAGS = -L../../LibC -L../../LibGUI
all: $(APP)
$(APP): $(OBJS)
$(LD) -o $(APP) $(LDFLAGS) $(OBJS) -lgui -lc
.cpp.o:
@echo "CXX $<"; $(CXX) $(CXXFLAGS) -o $@ -c $<
-include $(OBJS:%.o=%.d)
clean:
@echo "CLEAN"; rm -f $(APPS) $(OBJS) *.d

BIN
Applications/Taskbar/Taskbar Executable file

Binary file not shown.

View file

@ -0,0 +1,31 @@
#include "TaskbarWidget.h"
#include <LibGUI/GLabel.h>
#include <LibGUI/GButton.h>
#include <LibGUI/GBoxLayout.h>
#include <LibGUI/GPainter.h>
#include <stdio.h>
TaskbarWidget::TaskbarWidget(GWidget* parent)
: GFrame(parent)
{
set_fill_with_background_color(true);
set_layout(make<GBoxLayout>(Orientation::Vertical));
layout()->set_margins({ 0, 8, 0, 8 });
layout()->set_spacing(8);
set_frame_thickness(1);
set_frame_shape(GFrame::Shape::Panel);
set_frame_shadow(GFrame::Shadow::Raised);
}
TaskbarWidget::~TaskbarWidget()
{
}
void TaskbarWidget::paint_event(GPaintEvent& event)
{
GFrame::paint_event(event);
GPainter painter(*this);
painter.add_clip_rect(event.rect());
}

View file

@ -0,0 +1,133 @@
TaskbarWidget.o: TaskbarWidget.cpp TaskbarWidget.h ../../LibGUI/GFrame.h \
../../LibGUI/GWidget.h ../../LibGUI/GElapsedTimer.h ../../LibC/time.h \
../../LibC/sys/cdefs.h ../../LibC/sys/types.h ../../LibC/stdint.h \
../../LibGUI/GEvent.h ../../SharedGraphics/Point.h ../../AK/AKString.h \
../../AK/ByteBuffer.h ../../AK/Types.h ../../AK/StdLibExtras.h \
../../LibC/stdlib.h ../../LibC/stddef.h ../../LibC/string.h \
../../AK/Retainable.h ../../AK/Assertions.h ../../LibC/assert.h \
../../AK/RetainPtr.h ../../AK/Retained.h ../../AK/kmalloc.h \
../../AK/StringImpl.h ../../AK/Traits.h ../../AK/kstdio.h \
../../Kernel/kstdio.h ../../Kernel/kprintf.h ../../AK/HashFunctions.h \
../../AK/Vector.h ../../AK/OwnPtr.h ../../SharedGraphics/Rect.h \
../../SharedGraphics/Size.h ../../AK/WeakPtr.h ../../AK/Weakable.h \
../../Kernel/KeyCode.h ../../LibGUI/GObject.h \
../../SharedGraphics/Color.h ../../SharedGraphics/Font.h \
../../AK/MappedFile.h ../../AK/Badge.h ../../LibGUI/GLabel.h \
../../SharedGraphics/TextAlignment.h ../../LibGUI/GButton.h \
../../SharedGraphics/StylePainter.h ../../AK/Function.h \
../../SharedGraphics/GraphicsBitmap.h ../../LibC/SharedBuffer.h \
../../LibGUI/GBoxLayout.h ../../LibGUI/GLayout.h ../../LibGUI/GMargins.h \
../../LibGUI/GPainter.h ../../SharedGraphics/Painter.h \
../../LibC/stdio.h ../../LibC/stdarg.h ../../LibC/limits.h
TaskbarWidget.h:
../../LibGUI/GFrame.h:
../../LibGUI/GWidget.h:
../../LibGUI/GElapsedTimer.h:
../../LibC/time.h:
../../LibC/sys/cdefs.h:
../../LibC/sys/types.h:
../../LibC/stdint.h:
../../LibGUI/GEvent.h:
../../SharedGraphics/Point.h:
../../AK/AKString.h:
../../AK/ByteBuffer.h:
../../AK/Types.h:
../../AK/StdLibExtras.h:
../../LibC/stdlib.h:
../../LibC/stddef.h:
../../LibC/string.h:
../../AK/Retainable.h:
../../AK/Assertions.h:
../../LibC/assert.h:
../../AK/RetainPtr.h:
../../AK/Retained.h:
../../AK/kmalloc.h:
../../AK/StringImpl.h:
../../AK/Traits.h:
../../AK/kstdio.h:
../../Kernel/kstdio.h:
../../Kernel/kprintf.h:
../../AK/HashFunctions.h:
../../AK/Vector.h:
../../AK/OwnPtr.h:
../../SharedGraphics/Rect.h:
../../SharedGraphics/Size.h:
../../AK/WeakPtr.h:
../../AK/Weakable.h:
../../Kernel/KeyCode.h:
../../LibGUI/GObject.h:
../../SharedGraphics/Color.h:
../../SharedGraphics/Font.h:
../../AK/MappedFile.h:
../../AK/Badge.h:
../../LibGUI/GLabel.h:
../../SharedGraphics/TextAlignment.h:
../../LibGUI/GButton.h:
../../SharedGraphics/StylePainter.h:
../../AK/Function.h:
../../SharedGraphics/GraphicsBitmap.h:
../../LibC/SharedBuffer.h:
../../LibGUI/GBoxLayout.h:
../../LibGUI/GLayout.h:
../../LibGUI/GMargins.h:
../../LibGUI/GPainter.h:
../../SharedGraphics/Painter.h:
../../LibC/stdio.h:
../../LibC/stdarg.h:
../../LibC/limits.h:

View file

@ -0,0 +1,13 @@
#include <LibGUI/GFrame.h>
class TaskbarWidget final : public GFrame {
public:
TaskbarWidget(GWidget* parent = nullptr);
virtual ~TaskbarWidget() override;
virtual const char* class_name() const override { return "TaskbarWidget"; }
private:
virtual void paint_event(GPaintEvent&) override;
};

Binary file not shown.

View file

@ -0,0 +1,29 @@
#include "TaskbarWindow.h"
#include "TaskbarWidget.h"
#include <LibGUI/GWindow.h>
#include <LibGUI/GDesktop.h>
#include <stdio.h>
TaskbarWindow::TaskbarWindow()
{
set_window_type(GWindowType::Taskbar);
set_title("Taskbar");
set_should_exit_event_loop_on_close(true);
on_screen_rect_change(GDesktop::the().rect());
GDesktop::the().on_rect_change = [this] (const Rect& rect) { on_screen_rect_change(rect); };
auto* widget = new TaskbarWidget;
set_main_widget(widget);
}
TaskbarWindow::~TaskbarWindow()
{
}
void TaskbarWindow::on_screen_rect_change(const Rect& rect)
{
Rect new_rect { rect.x(), rect.bottom() - taskbar_height() + 1, rect.width(), taskbar_height() };
set_rect(new_rect);
}

View file

@ -0,0 +1,118 @@
TaskbarWindow.o: TaskbarWindow.cpp TaskbarWindow.h ../../LibGUI/GWindow.h \
../../LibGUI/GObject.h ../../AK/Vector.h ../../AK/Assertions.h \
../../LibC/assert.h ../../LibC/sys/cdefs.h ../../AK/OwnPtr.h \
../../AK/StdLibExtras.h ../../LibC/stdlib.h ../../LibC/sys/types.h \
../../LibC/stdint.h ../../LibC/stddef.h ../../LibC/string.h \
../../AK/Types.h ../../AK/Traits.h ../../AK/kstdio.h \
../../Kernel/kstdio.h ../../Kernel/kprintf.h ../../AK/HashFunctions.h \
../../AK/kmalloc.h ../../AK/Weakable.h ../../AK/Retainable.h \
../../AK/RetainPtr.h ../../AK/Retained.h ../../SharedGraphics/Rect.h \
../../SharedGraphics/Point.h ../../AK/AKString.h ../../AK/ByteBuffer.h \
../../AK/StringImpl.h ../../SharedGraphics/Size.h \
../../SharedGraphics/GraphicsBitmap.h ../../SharedGraphics/Color.h \
../../AK/MappedFile.h ../../LibC/SharedBuffer.h ../../AK/WeakPtr.h \
../../LibGUI/GWidget.h ../../LibGUI/GElapsedTimer.h ../../LibC/time.h \
../../LibGUI/GEvent.h ../../Kernel/KeyCode.h ../../SharedGraphics/Font.h \
../../AK/Badge.h TaskbarWidget.h ../../LibGUI/GFrame.h \
../../LibGUI/GDesktop.h ../../AK/Function.h ../../LibC/stdio.h \
../../LibC/stdarg.h ../../LibC/limits.h
TaskbarWindow.h:
../../LibGUI/GWindow.h:
../../LibGUI/GObject.h:
../../AK/Vector.h:
../../AK/Assertions.h:
../../LibC/assert.h:
../../LibC/sys/cdefs.h:
../../AK/OwnPtr.h:
../../AK/StdLibExtras.h:
../../LibC/stdlib.h:
../../LibC/sys/types.h:
../../LibC/stdint.h:
../../LibC/stddef.h:
../../LibC/string.h:
../../AK/Types.h:
../../AK/Traits.h:
../../AK/kstdio.h:
../../Kernel/kstdio.h:
../../Kernel/kprintf.h:
../../AK/HashFunctions.h:
../../AK/kmalloc.h:
../../AK/Weakable.h:
../../AK/Retainable.h:
../../AK/RetainPtr.h:
../../AK/Retained.h:
../../SharedGraphics/Rect.h:
../../SharedGraphics/Point.h:
../../AK/AKString.h:
../../AK/ByteBuffer.h:
../../AK/StringImpl.h:
../../SharedGraphics/Size.h:
../../SharedGraphics/GraphicsBitmap.h:
../../SharedGraphics/Color.h:
../../AK/MappedFile.h:
../../LibC/SharedBuffer.h:
../../AK/WeakPtr.h:
../../LibGUI/GWidget.h:
../../LibGUI/GElapsedTimer.h:
../../LibC/time.h:
../../LibGUI/GEvent.h:
../../Kernel/KeyCode.h:
../../SharedGraphics/Font.h:
../../AK/Badge.h:
TaskbarWidget.h:
../../LibGUI/GFrame.h:
../../LibGUI/GDesktop.h:
../../AK/Function.h:
../../LibC/stdio.h:
../../LibC/stdarg.h:
../../LibC/limits.h:

View file

@ -0,0 +1,16 @@
#include <LibGUI/GWindow.h>
#include <LibGUI/GWidget.h>
class TaskbarWindow final : public GWindow {
public:
TaskbarWindow();
virtual ~TaskbarWindow() override;
int taskbar_height() const { return 20; }
virtual const char* class_name() const override { return "TaskbarWindow"; }
private:
void on_screen_rect_change(const Rect&);
};

Binary file not shown.

View file

@ -0,0 +1,10 @@
#include <LibGUI/GApplication.h>
#include "TaskbarWindow.h"
int main(int argc, char** argv)
{
GApplication app(argc, argv);
TaskbarWindow window;
window.show();
return app.exec();
}

114
Applications/Taskbar/main.d Normal file
View file

@ -0,0 +1,114 @@
main.o: main.cpp ../../LibGUI/GApplication.h ../../AK/Badge.h \
../../AK/OwnPtr.h ../../AK/StdLibExtras.h ../../LibC/stdlib.h \
../../LibC/sys/cdefs.h ../../LibC/sys/types.h ../../LibC/stdint.h \
../../LibC/stddef.h ../../LibC/string.h ../../AK/Types.h \
../../AK/Traits.h ../../AK/kstdio.h ../../Kernel/kstdio.h \
../../Kernel/kprintf.h ../../AK/HashFunctions.h ../../AK/HashMap.h \
../../AK/HashTable.h ../../AK/Assertions.h ../../LibC/assert.h \
../../AK/DoublyLinkedList.h ../../LibGUI/GShortcut.h \
../../Kernel/KeyCode.h ../../AK/AKString.h ../../AK/ByteBuffer.h \
../../AK/Retainable.h ../../AK/RetainPtr.h ../../AK/Retained.h \
../../AK/kmalloc.h ../../AK/StringImpl.h ../../AK/Vector.h \
TaskbarWindow.h ../../LibGUI/GWindow.h ../../LibGUI/GObject.h \
../../AK/Weakable.h ../../SharedGraphics/Rect.h \
../../SharedGraphics/Point.h ../../SharedGraphics/Size.h \
../../SharedGraphics/GraphicsBitmap.h ../../SharedGraphics/Color.h \
../../AK/MappedFile.h ../../LibC/SharedBuffer.h ../../AK/WeakPtr.h \
../../LibGUI/GWidget.h ../../LibGUI/GElapsedTimer.h ../../LibC/time.h \
../../LibGUI/GEvent.h ../../SharedGraphics/Font.h
../../LibGUI/GApplication.h:
../../AK/Badge.h:
../../AK/OwnPtr.h:
../../AK/StdLibExtras.h:
../../LibC/stdlib.h:
../../LibC/sys/cdefs.h:
../../LibC/sys/types.h:
../../LibC/stdint.h:
../../LibC/stddef.h:
../../LibC/string.h:
../../AK/Types.h:
../../AK/Traits.h:
../../AK/kstdio.h:
../../Kernel/kstdio.h:
../../Kernel/kprintf.h:
../../AK/HashFunctions.h:
../../AK/HashMap.h:
../../AK/HashTable.h:
../../AK/Assertions.h:
../../LibC/assert.h:
../../AK/DoublyLinkedList.h:
../../LibGUI/GShortcut.h:
../../Kernel/KeyCode.h:
../../AK/AKString.h:
../../AK/ByteBuffer.h:
../../AK/Retainable.h:
../../AK/RetainPtr.h:
../../AK/Retained.h:
../../AK/kmalloc.h:
../../AK/StringImpl.h:
../../AK/Vector.h:
TaskbarWindow.h:
../../LibGUI/GWindow.h:
../../LibGUI/GObject.h:
../../AK/Weakable.h:
../../SharedGraphics/Rect.h:
../../SharedGraphics/Point.h:
../../SharedGraphics/Size.h:
../../SharedGraphics/GraphicsBitmap.h:
../../SharedGraphics/Color.h:
../../AK/MappedFile.h:
../../LibC/SharedBuffer.h:
../../AK/WeakPtr.h:
../../LibGUI/GWidget.h:
../../LibGUI/GElapsedTimer.h:
../../LibC/time.h:
../../LibGUI/GEvent.h:
../../SharedGraphics/Font.h:

BIN
Applications/Taskbar/main.o Normal file

Binary file not shown.