mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:17:35 +00:00
Notification: Member-ize updatable components
Changes the necessary widgets to be pointers so we can later change their underlying data.
This commit is contained in:
parent
f2814dd6c1
commit
ef4144c183
2 changed files with 16 additions and 12 deletions
|
@ -30,7 +30,7 @@
|
||||||
#include <LibGUI/BoxLayout.h>
|
#include <LibGUI/BoxLayout.h>
|
||||||
#include <LibGUI/Button.h>
|
#include <LibGUI/Button.h>
|
||||||
#include <LibGUI/Desktop.h>
|
#include <LibGUI/Desktop.h>
|
||||||
#include <LibGUI/ImageWidget.h>
|
#include <LibGUI/Icon.h>
|
||||||
#include <LibGUI/Label.h>
|
#include <LibGUI/Label.h>
|
||||||
#include <LibGUI/Widget.h>
|
#include <LibGUI/Widget.h>
|
||||||
#include <LibGfx/Bitmap.h>
|
#include <LibGfx/Bitmap.h>
|
||||||
|
@ -41,6 +41,7 @@
|
||||||
namespace NotificationServer {
|
namespace NotificationServer {
|
||||||
|
|
||||||
static HashMap<u32, RefPtr<NotificationWindow>> s_windows;
|
static HashMap<u32, RefPtr<NotificationWindow>> s_windows;
|
||||||
|
static const Gfx::Bitmap* default_image = GUI::Icon::default_icon("ladybug").bitmap_for_size(16);
|
||||||
|
|
||||||
void update_notification_window_locations()
|
void update_notification_window_locations()
|
||||||
{
|
{
|
||||||
|
@ -95,23 +96,21 @@ NotificationWindow::NotificationWindow(i32 client_id, const String& text, const
|
||||||
widget.layout()->set_margins({ 8, 8, 8, 8 });
|
widget.layout()->set_margins({ 8, 8, 8, 8 });
|
||||||
widget.layout()->set_spacing(6);
|
widget.layout()->set_spacing(6);
|
||||||
|
|
||||||
if (icon.is_valid()) {
|
m_image = &widget.add<GUI::ImageWidget>();
|
||||||
auto& image = widget.add<GUI::ImageWidget>();
|
m_image->set_bitmap(icon.is_valid() ? icon.bitmap() : default_image);
|
||||||
image.set_bitmap(icon.bitmap());
|
|
||||||
}
|
|
||||||
|
|
||||||
auto& left_container = widget.add<GUI::Widget>();
|
auto& left_container = widget.add<GUI::Widget>();
|
||||||
left_container.set_layout<GUI::VerticalBoxLayout>();
|
left_container.set_layout<GUI::VerticalBoxLayout>();
|
||||||
|
|
||||||
auto& title_label = left_container.add<GUI::Label>(title);
|
m_title_label = &left_container.add<GUI::Label>(title);
|
||||||
title_label.set_font(Gfx::FontDatabase::default_bold_font());
|
m_title_label->set_font(Gfx::FontDatabase::default_bold_font());
|
||||||
title_label.set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
m_title_label->set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
||||||
auto& text_label = left_container.add<GUI::Label>(text);
|
m_text_label = &left_container.add<GUI::Label>(text);
|
||||||
text_label.set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
m_text_label->set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
||||||
|
|
||||||
widget.set_tooltip(text);
|
widget.set_tooltip(text);
|
||||||
title_label.set_tooltip(text);
|
m_title_label->set_tooltip(text);
|
||||||
text_label.set_tooltip(text);
|
m_text_label->set_tooltip(text);
|
||||||
|
|
||||||
auto& right_container = widget.add<GUI::Widget>();
|
auto& right_container = widget.add<GUI::Widget>();
|
||||||
right_container.set_fixed_width(36);
|
right_container.set_fixed_width(36);
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <LibGUI/ImageWidget.h>
|
||||||
#include <LibGUI/Window.h>
|
#include <LibGUI/Window.h>
|
||||||
|
|
||||||
namespace NotificationServer {
|
namespace NotificationServer {
|
||||||
|
@ -46,6 +47,10 @@ private:
|
||||||
|
|
||||||
Gfx::IntRect m_original_rect;
|
Gfx::IntRect m_original_rect;
|
||||||
i32 m_id;
|
i32 m_id;
|
||||||
|
|
||||||
|
GUI::Label* m_text_label;
|
||||||
|
GUI::Label* m_title_label;
|
||||||
|
GUI::ImageWidget* m_image;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue