mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-09 20:52:54 +00:00
Start bringing up LibGUI properly (formerly Widgets.)
This commit is contained in:
parent
b91479d9b9
commit
8eae89a405
Notes:
sideshowbarker
2024-07-19 16:00:02 +09:00
Author: https://github.com/awesomekling
Commit: 8eae89a405
17 changed files with 258 additions and 33 deletions
|
@ -2,10 +2,51 @@
|
|||
#include "GEvent.h"
|
||||
#include "GEventLoop.h"
|
||||
#include <SharedGraphics/GraphicsBitmap.h>
|
||||
#include <LibC/gui.h>
|
||||
#include <LibC/stdio.h>
|
||||
#include <LibC/stdlib.h>
|
||||
#include <AK/HashMap.h>
|
||||
|
||||
GWindow::GWindow(int window_id)
|
||||
: m_window_id(window_id)
|
||||
static HashMap<int, GWindow*>* s_windows;
|
||||
|
||||
static HashMap<int, GWindow*>& windows()
|
||||
{
|
||||
if (!s_windows)
|
||||
s_windows = new HashMap<int, GWindow*>;
|
||||
return *s_windows;
|
||||
}
|
||||
|
||||
GWindow* GWindow::from_window_id(int window_id)
|
||||
{
|
||||
auto it = windows().find(window_id);
|
||||
if (it != windows().end())
|
||||
return (*it).value;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GWindow::GWindow(GObject* parent)
|
||||
: GObject(parent)
|
||||
{
|
||||
GUI_CreateWindowParameters wparams;
|
||||
wparams.rect = { { 100, 400 }, { 140, 140 } };
|
||||
wparams.background_color = 0xffc0c0;
|
||||
strcpy(wparams.title, "GWindow");
|
||||
m_window_id = gui_create_window(&wparams);
|
||||
if (m_window_id < 0) {
|
||||
perror("gui_create_window");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
GUI_WindowBackingStoreInfo backing;
|
||||
int rc = gui_get_window_backing_store(m_window_id, &backing);
|
||||
if (rc < 0) {
|
||||
perror("gui_get_window_backing_store");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
m_backing = GraphicsBitmap::create_wrapper(backing.size, backing.pixels);
|
||||
|
||||
windows().set(m_window_id, this);
|
||||
}
|
||||
|
||||
GWindow::~GWindow()
|
||||
|
@ -40,3 +81,19 @@ void GWindow::close()
|
|||
{
|
||||
}
|
||||
|
||||
void GWindow::show()
|
||||
{
|
||||
}
|
||||
|
||||
void GWindow::update()
|
||||
{
|
||||
gui_invalidate_window(m_window_id, nullptr);
|
||||
}
|
||||
|
||||
void GWindow::set_main_widget(GWidget* widget)
|
||||
{
|
||||
if (m_main_widget == widget)
|
||||
return;
|
||||
m_main_widget = widget;
|
||||
update();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue