mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-23 17:52:26 -05:00
b0e3f73375
Userspace programs can now open /dev/gui_events and read a stream of GUI_Event structs one at a time. I was stuck on a stupid problem where we'd reenter Scheduler::yield() due to having one of the has_data_available_for_reading() implementations using locks.
61 lines
1.7 KiB
C++
61 lines
1.7 KiB
C++
#include "MsgBox.h"
|
|
#include "Font.h"
|
|
#include "AbstractScreen.h"
|
|
#include "Window.h"
|
|
#include "Label.h"
|
|
#include "Button.h"
|
|
#include "Process.h"
|
|
|
|
#if 0
|
|
void MsgBox(Window* owner, String&& text)
|
|
{
|
|
Font& font = Font::defaultFont();
|
|
auto screenRect = AbstractScreen::the().rect();
|
|
|
|
int textWidth = text.length() * font.glyphWidth() + 8;
|
|
int textHeight = font.glyphHeight() + 8;
|
|
int horizontalPadding = 16;
|
|
int verticalPadding = 16;
|
|
int buttonWidth = 60;
|
|
int buttonHeight = 20;
|
|
int windowWidth = textWidth + horizontalPadding * 2;
|
|
int windowHeight = textHeight + buttonHeight + verticalPadding * 3;
|
|
|
|
Rect windowRect(
|
|
screenRect.center().x() - windowWidth / 2,
|
|
screenRect.center().y() - windowHeight / 2,
|
|
windowWidth,
|
|
windowHeight
|
|
);
|
|
|
|
Rect buttonRect(
|
|
windowWidth / 2 - buttonWidth / 2,
|
|
windowHeight - verticalPadding - buttonHeight,
|
|
buttonWidth,
|
|
buttonHeight
|
|
);
|
|
|
|
auto* window = new Window(*current, current->make_window_id());
|
|
window->setTitle("MsgBox");
|
|
window->setRect(windowRect);
|
|
auto* widget = new Widget;
|
|
widget->setWindowRelativeRect({ 0, 0, windowWidth, windowHeight });
|
|
widget->setFillWithBackgroundColor(true);
|
|
window->setMainWidget(widget);
|
|
auto* label = new Label(widget);
|
|
label->setWindowRelativeRect({
|
|
horizontalPadding,
|
|
verticalPadding,
|
|
textWidth,
|
|
textHeight
|
|
});
|
|
label->setText(move(text));
|
|
auto* button = new Button(widget);
|
|
button->setCaption("OK");
|
|
button->setWindowRelativeRect(buttonRect);
|
|
button->onClick = [] (Button& button) {
|
|
printf("MsgBox button pressed, closing MsgBox :)\n");
|
|
button.window()->close();
|
|
};
|
|
}
|
|
#endif
|