forked from SerenityOS/serenity
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start working on a simple Launcher app.
Let GButton have an optional icon (GraphicsBitmap) that gets rendered in the middle of the button if present. Also add GraphicsBitmap::load_from_file() which allows mmap'ed RGBA32 files. I wrote a little program to take "raw" files from GIMP and swizzle them into the correct byte order.
- Loading branch information
1 parent
71b9ec1
commit 887b4a7
Showing
29 changed files
with
293 additions
and
11 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
*.o | ||
*.d | ||
FontEditor |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
OBJS = \ | ||
main.o | ||
|
||
APP = Launcher | ||
|
||
ARCH_FLAGS = | ||
STANDARD_FLAGS = -std=c++17 -nostdinc++ -nostdlib -nostdinc | ||
USERLAND_FLAGS = -ffreestanding -fno-stack-protector -fno-ident | ||
WARNING_FLAGS = -Wextra -Wall -Wundef -Wcast-qual -Wwrite-strings | ||
FLAVOR_FLAGS = -march=i386 -mregparm=3 -m32 -fno-exceptions -fno-rtti -fmerge-all-constants -fno-unroll-loops -fno-pie -fno-pic | ||
OPTIMIZATION_FLAGS = -Oz -fno-asynchronous-unwind-tables | ||
INCLUDE_FLAGS = -I.. -I. -I../LibC | ||
|
||
DEFINES = -DSERENITY -DSANITIZE_PTRS -DUSERLAND | ||
|
||
CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(USERLAND_FLAGS) $(FLAVOR_FLAGS) $(ARCH_FLAGS) $(STANDARD_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) | ||
CXX = clang | ||
LD = ld | ||
AR = ar | ||
LDFLAGS = -static --strip-debug -melf_i386 -e _start --gc-sections | ||
|
||
all: $(APP) | ||
|
||
$(APP): $(OBJS) | ||
$(LD) -o $(APP) $(LDFLAGS) $(OBJS) ../LibGUI/LibGUI.a ../LibC/LibC.a | ||
|
||
.cpp.o: | ||
@echo "CXX $<"; $(CXX) $(CXXFLAGS) -o $@ -c $< | ||
|
||
-include $(OBJS:%.o=%.d) | ||
|
||
clean: | ||
@echo "CLEAN"; rm -f $(APPS) $(OBJS) *.d | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#include <SharedGraphics/GraphicsBitmap.h> | ||
#include <LibGUI/GWindow.h> | ||
#include <LibGUI/GWidget.h> | ||
#include <LibGUI/GButton.h> | ||
#include <LibGUI/GEventLoop.h> | ||
#include <signal.h> | ||
#include <unistd.h> | ||
|
||
static GWindow* make_launcher_window(); | ||
|
||
void handle_sigchld(int) | ||
{ | ||
dbgprintf("Launcher(%d) Got SIGCHLD\n", getpid()); | ||
int pid = waitpid(-1, nullptr, 0); | ||
dbgprintf("Launcher(%d) waitpid() returned %d\n", getpid(), pid); | ||
ASSERT(pid > 0); | ||
} | ||
|
||
int main(int, char**) | ||
{ | ||
signal(SIGCHLD, handle_sigchld); | ||
|
||
GEventLoop loop; | ||
|
||
auto* launcher_window = make_launcher_window(); | ||
launcher_window->set_should_exit_app_on_close(true); | ||
launcher_window->show(); | ||
|
||
return loop.exec(); | ||
} | ||
|
||
GWindow* make_launcher_window() | ||
{ | ||
auto* window = new GWindow; | ||
window->set_title("Launcher"); | ||
window->set_rect({ 50, 50, 300, 60 }); | ||
|
||
auto* widget = new GWidget; | ||
window->set_main_widget(widget); | ||
widget->set_relative_rect({ 0, 0, 300, 60 }); | ||
|
||
auto* terminal_button = new GButton(widget); | ||
terminal_button->set_relative_rect({ 5, 5, 50, 50 }); | ||
terminal_button->set_icon(GraphicsBitmap::load_from_file("/res/icons/Terminal.rgb", { 32, 32 })); | ||
|
||
terminal_button->on_click = [] (GButton&) { | ||
pid_t child_pid = fork(); | ||
if (!child_pid) { | ||
execve("/bin/Terminal", nullptr, nullptr); | ||
ASSERT_NOT_REACHED(); | ||
} | ||
}; | ||
|
||
auto* font_editor_button = new GButton(widget); | ||
font_editor_button->set_relative_rect({ 60, 5, 50, 50 }); | ||
font_editor_button->set_icon(GraphicsBitmap::load_from_file("/res/icons/FontEditor.rgb", { 32, 32 })); | ||
|
||
font_editor_button->on_click = [] (GButton&) { | ||
pid_t child_pid = fork(); | ||
if (!child_pid) { | ||
execve("/bin/FontEditor", nullptr, nullptr); | ||
ASSERT_NOT_REACHED(); | ||
} | ||
}; | ||
|
||
auto* guitest_editor_button = new GButton(widget); | ||
guitest_editor_button->set_relative_rect({ 115, 5, 50, 50 }); | ||
guitest_editor_button->set_icon(GraphicsBitmap::load_from_file("/res/icons/generic.rgb", { 32, 32 })); | ||
|
||
guitest_editor_button->on_click = [] (GButton&) { | ||
pid_t child_pid = fork(); | ||
if (!child_pid) { | ||
execve("/bin/guitest", nullptr, nullptr); | ||
ASSERT_NOT_REACHED(); | ||
} | ||
}; | ||
|
||
return window; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.