1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:07:46 +00:00

LibGUI: Rename GUI::Image => GUI::ImageWidget

"Image" was a bit too vague, "ImageWidget" is obviously a widget of
some sort.
This commit is contained in:
Andreas Kling 2020-07-22 15:29:51 +02:00
parent a92f7aea7a
commit 299824de73
15 changed files with 41 additions and 41 deletions

View file

@ -33,7 +33,7 @@
#include <LibDesktop/Launcher.h> #include <LibDesktop/Launcher.h>
#include <LibGUI/BoxLayout.h> #include <LibGUI/BoxLayout.h>
#include <LibGUI/Button.h> #include <LibGUI/Button.h>
#include <LibGUI/Image.h> #include <LibGUI/ImageWidget.h>
#include <LibGUI/Label.h> #include <LibGUI/Label.h>
#include <LibGUI/MessageBox.h> #include <LibGUI/MessageBox.h>
#include <LibGUI/ProgressBar.h> #include <LibGUI/ProgressBar.h>
@ -74,7 +74,7 @@ DownloadWidget::DownloadWidget(const URL& url)
animation_container.set_preferred_size(0, 32); animation_container.set_preferred_size(0, 32);
auto& animation_layout = animation_container.set_layout<GUI::HorizontalBoxLayout>(); auto& animation_layout = animation_container.set_layout<GUI::HorizontalBoxLayout>();
auto& browser_image = animation_container.add<GUI::Image>(); auto& browser_image = animation_container.add<GUI::ImageWidget>();
browser_image.load_from_file("/res/download-animation.gif"); browser_image.load_from_file("/res/download-animation.gif");
animation_layout.add_spacer(); animation_layout.add_spacer();

View file

@ -69,7 +69,7 @@ PropertiesDialog::PropertiesDialog(GUI::FileSystemModel& model, String path, boo
file_container.layout()->set_spacing(20); file_container.layout()->set_spacing(20);
file_container.set_preferred_size(0, 34); file_container.set_preferred_size(0, 34);
m_icon = file_container.add<GUI::Image>(); m_icon = file_container.add<GUI::ImageWidget>();
m_icon->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); m_icon->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed);
m_icon->set_preferred_size(32, 32); m_icon->set_preferred_size(32, 32);

View file

@ -30,7 +30,7 @@
#include <LibGUI/Button.h> #include <LibGUI/Button.h>
#include <LibGUI/Dialog.h> #include <LibGUI/Dialog.h>
#include <LibGUI/FileSystemModel.h> #include <LibGUI/FileSystemModel.h>
#include <LibGUI/Image.h> #include <LibGUI/ImageWidget.h>
#include <LibGUI/Label.h> #include <LibGUI/Label.h>
#include <LibGUI/TextBox.h> #include <LibGUI/TextBox.h>
@ -87,7 +87,7 @@ private:
GUI::FileSystemModel& m_model; GUI::FileSystemModel& m_model;
RefPtr<GUI::Button> m_apply_button; RefPtr<GUI::Button> m_apply_button;
RefPtr<GUI::TextBox> m_name_box; RefPtr<GUI::TextBox> m_name_box;
RefPtr<GUI::Image> m_icon; RefPtr<GUI::ImageWidget> m_icon;
String m_name; String m_name;
String m_path; String m_path;
mode_t m_mode; mode_t m_mode;

View file

@ -36,7 +36,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/Image.h> #include <LibGUI/ImageWidget.h>
#include <LibGUI/Label.h> #include <LibGUI/Label.h>
#include <LibGUI/MessageBox.h> #include <LibGUI/MessageBox.h>
#include <LibGUI/StackWidget.h> #include <LibGUI/StackWidget.h>
@ -214,7 +214,7 @@ int main(int argc, char** argv)
title_box.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); title_box.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
if (!page.icon.is_empty()) { if (!page.icon.is_empty()) {
auto& icon = title_box.add<GUI::Image>(); auto& icon = title_box.add<GUI::ImageWidget>();
icon.set_preferred_size(16, 16); icon.set_preferred_size(16, 16);
icon.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); icon.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed);
icon.load_from_file(page.icon); icon.load_from_file(page.icon);

View file

@ -39,7 +39,7 @@
#include <LibGUI/FontDatabase.h> #include <LibGUI/FontDatabase.h>
#include <LibGUI/GroupBox.h> #include <LibGUI/GroupBox.h>
#include <LibGUI/Icon.h> #include <LibGUI/Icon.h>
#include <LibGUI/Image.h> #include <LibGUI/ImageWidget.h>
#include <LibGUI/InputBox.h> #include <LibGUI/InputBox.h>
#include <LibGUI/Label.h> #include <LibGUI/Label.h>
#include <LibGUI/ListView.h> #include <LibGUI/ListView.h>
@ -495,11 +495,11 @@ int main(int argc, char** argv)
tab_image.layout()->set_margins({ 8, 8, 8, 8 }); tab_image.layout()->set_margins({ 8, 8, 8, 8 });
tab_image.layout()->set_spacing(8); tab_image.layout()->set_spacing(8);
auto& banner_image = tab_image.add<GUI::Image>(); auto& banner_image = tab_image.add<GUI::ImageWidget>();
banner_image.set_frame_thickness(2); banner_image.set_frame_thickness(2);
banner_image.load_from_file("/res/brand-banner.png"); banner_image.load_from_file("/res/brand-banner.png");
auto& gif_animation_image = tab_image.add<GUI::Image>(); auto& gif_animation_image = tab_image.add<GUI::ImageWidget>();
gif_animation_image.load_from_file("/res/download-animation.gif"); gif_animation_image.load_from_file("/res/download-animation.gif");
auto& tab_cursors = tab_widget.add_tab<GUI::Widget>("Cursors"); auto& tab_cursors = tab_widget.add_tab<GUI::Widget>("Cursors");

View file

@ -31,7 +31,7 @@
#include <LibGUI/Application.h> #include <LibGUI/Application.h>
#include <LibGUI/BoxLayout.h> #include <LibGUI/BoxLayout.h>
#include <LibGUI/Button.h> #include <LibGUI/Button.h>
#include <LibGUI/Image.h> #include <LibGUI/ImageWidget.h>
#include <LibGUI/Label.h> #include <LibGUI/Label.h>
#include <LibGUI/Menu.h> #include <LibGUI/Menu.h>
#include <LibGUI/MenuBar.h> #include <LibGUI/MenuBar.h>
@ -67,7 +67,7 @@ int main(int argc, char** argv)
container.set_preferred_size(0, 36); container.set_preferred_size(0, 36);
container.set_layout<GUI::HorizontalBoxLayout>(); container.set_layout<GUI::HorizontalBoxLayout>();
auto& flag_image = container.add<GUI::Image>(); auto& flag_image = container.add<GUI::ImageWidget>();
flag_image.load_from_file("/res/icons/minesweeper/flag.png"); flag_image.load_from_file("/res/icons/minesweeper/flag.png");
auto& flag_label = container.add<GUI::Label>(); auto& flag_label = container.add<GUI::Label>();
@ -76,7 +76,7 @@ int main(int argc, char** argv)
face_button.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); face_button.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill);
face_button.set_preferred_size(36, 0); face_button.set_preferred_size(36, 0);
auto& time_image = container.add<GUI::Image>(); auto& time_image = container.add<GUI::ImageWidget>();
time_image.load_from_file("/res/icons/minesweeper/timer.png"); time_image.load_from_file("/res/icons/minesweeper/timer.png");
auto& time_label = container.add<GUI::Label>(); auto& time_label = container.add<GUI::Label>();

View file

@ -30,7 +30,7 @@
#include <LibGUI/BoxLayout.h> #include <LibGUI/BoxLayout.h>
#include <LibGUI/Button.h> #include <LibGUI/Button.h>
#include <LibGUI/Label.h> #include <LibGUI/Label.h>
#include <LibGUI/Image.h> #include <LibGUI/ImageWidget.h>
#include <LibGUI/Widget.h> #include <LibGUI/Widget.h>
#include <LibGfx/Font.h> #include <LibGfx/Font.h>
@ -53,7 +53,7 @@ AboutDialog::AboutDialog(const StringView& name, const Gfx::Bitmap* icon, Window
widget.set_layout<VerticalBoxLayout>(); widget.set_layout<VerticalBoxLayout>();
widget.layout()->set_spacing(0); widget.layout()->set_spacing(0);
auto& banner_image = widget.add<GUI::Image>(); auto& banner_image = widget.add<GUI::ImageWidget>();
banner_image.load_from_file("/res/brand-banner.png"); banner_image.load_from_file("/res/brand-banner.png");
auto& content_container = widget.add<Widget>(); auto& content_container = widget.add<Widget>();
@ -72,7 +72,7 @@ AboutDialog::AboutDialog(const StringView& name, const Gfx::Bitmap* icon, Window
icon_wrapper.set_preferred_size(32, 48); icon_wrapper.set_preferred_size(32, 48);
icon_wrapper.set_layout<VerticalBoxLayout>(); icon_wrapper.set_layout<VerticalBoxLayout>();
auto& icon_image = icon_wrapper.add<Image>(); auto& icon_image = icon_wrapper.add<ImageWidget>();
icon_image.set_bitmap(m_icon); icon_image.set_bitmap(m_icon);
} }

View file

@ -29,11 +29,11 @@ set(SOURCES
FontDatabase.cpp FontDatabase.cpp
Frame.cpp Frame.cpp
GroupBox.cpp GroupBox.cpp
Icon.cpp
IconView.cpp
Image.cpp
INILexer.cpp INILexer.cpp
INISyntaxHighlighter.cpp INISyntaxHighlighter.cpp
Icon.cpp
IconView.cpp
ImageWidget.cpp
InputBox.cpp InputBox.cpp
JsonArrayModel.cpp JsonArrayModel.cpp
JSSyntaxHighlighter.cpp JSSyntaxHighlighter.cpp

View file

@ -266,7 +266,7 @@ FilePicker::FilePicker(Window* parent_window, Mode mode, Options options, const
m_preview_container->set_layout<VerticalBoxLayout>(); m_preview_container->set_layout<VerticalBoxLayout>();
m_preview_container->layout()->set_margins({ 8, 8, 8, 8 }); m_preview_container->layout()->set_margins({ 8, 8, 8, 8 });
m_preview_image = m_preview_container->add<Image>(); m_preview_image = m_preview_container->add<ImageWidget>();
m_preview_image->set_should_stretch(true); m_preview_image->set_should_stretch(true);
m_preview_image->set_auto_resize(false); m_preview_image->set_auto_resize(false);
m_preview_image->set_preferred_size(160, 160); m_preview_image->set_preferred_size(160, 160);

View file

@ -30,7 +30,7 @@
#include <AK/Optional.h> #include <AK/Optional.h>
#include <LibCore/StandardPaths.h> #include <LibCore/StandardPaths.h>
#include <LibGUI/Dialog.h> #include <LibGUI/Dialog.h>
#include <LibGUI/Image.h> #include <LibGUI/ImageWidget.h>
#include <LibGUI/Model.h> #include <LibGUI/Model.h>
namespace GUI { namespace GUI {
@ -93,7 +93,7 @@ private:
RefPtr<TextBox> m_filename_textbox; RefPtr<TextBox> m_filename_textbox;
RefPtr<TextBox> m_location_textbox; RefPtr<TextBox> m_location_textbox;
RefPtr<Frame> m_preview_container; RefPtr<Frame> m_preview_container;
RefPtr<Image> m_preview_image; RefPtr<ImageWidget> m_preview_image;
RefPtr<Label> m_preview_name_label; RefPtr<Label> m_preview_name_label;
RefPtr<Label> m_preview_geometry_label; RefPtr<Label> m_preview_geometry_label;
Mode m_mode { Mode::Open }; Mode m_mode { Mode::Open };

View file

@ -24,15 +24,15 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "Image.h"
#include <AK/MappedFile.h> #include <AK/MappedFile.h>
#include <LibGUI/Image.h>
#include <LibGUI/Painter.h> #include <LibGUI/Painter.h>
#include <LibGfx/Bitmap.h> #include <LibGfx/Bitmap.h>
#include <LibGfx/ImageDecoder.h> #include <LibGfx/ImageDecoder.h>
namespace GUI { namespace GUI {
Image::Image(const StringView&) ImageWidget::ImageWidget(const StringView&)
: m_timer(Core::Timer::construct()) : m_timer(Core::Timer::construct())
{ {
@ -43,11 +43,11 @@ Image::Image(const StringView&)
set_auto_resize(true); set_auto_resize(true);
} }
Image::~Image() ImageWidget::~ImageWidget()
{ {
} }
void Image::set_bitmap(const Gfx::Bitmap* bitmap) void ImageWidget::set_bitmap(const Gfx::Bitmap* bitmap)
{ {
if (m_bitmap == bitmap) if (m_bitmap == bitmap)
return; return;
@ -59,7 +59,7 @@ void Image::set_bitmap(const Gfx::Bitmap* bitmap)
update(); update();
} }
void Image::set_auto_resize(bool value) void ImageWidget::set_auto_resize(bool value)
{ {
m_auto_resize = value; m_auto_resize = value;
@ -67,7 +67,7 @@ void Image::set_auto_resize(bool value)
set_preferred_size(m_bitmap->width(), m_bitmap->height()); set_preferred_size(m_bitmap->width(), m_bitmap->height());
} }
void Image::animate() void ImageWidget::animate()
{ {
m_current_frame_index = (m_current_frame_index + 1) % m_image_decoder->frame_count(); m_current_frame_index = (m_current_frame_index + 1) % m_image_decoder->frame_count();
@ -86,7 +86,7 @@ void Image::animate()
} }
} }
void Image::load_from_file(const StringView& path) void ImageWidget::load_from_file(const StringView& path)
{ {
MappedFile mapped_file(path); MappedFile mapped_file(path);
if (!mapped_file.is_valid()) if (!mapped_file.is_valid())
@ -108,13 +108,13 @@ void Image::load_from_file(const StringView& path)
} }
} }
void Image::mousedown_event(GUI::MouseEvent&) void ImageWidget::mousedown_event(GUI::MouseEvent&)
{ {
if (on_click) if (on_click)
on_click(); on_click();
} }
void Image::paint_event(PaintEvent& event) void ImageWidget::paint_event(PaintEvent& event)
{ {
Frame::paint_event(event); Frame::paint_event(event);

View file

@ -31,10 +31,10 @@
namespace GUI { namespace GUI {
class Image : public Frame { class ImageWidget : public Frame {
C_OBJECT(Image) C_OBJECT(ImageWidget)
public: public:
virtual ~Image() override; virtual ~ImageWidget() override;
void set_bitmap(const Gfx::Bitmap*); void set_bitmap(const Gfx::Bitmap*);
Gfx::Bitmap* bitmap() { return m_bitmap.ptr(); } Gfx::Bitmap* bitmap() { return m_bitmap.ptr(); }
@ -51,7 +51,7 @@ public:
Function<void()> on_click; Function<void()> on_click;
protected: protected:
explicit Image(const StringView& text = {}); explicit ImageWidget(const StringView& text = {});
virtual void mousedown_event(GUI::MouseEvent&) override; virtual void mousedown_event(GUI::MouseEvent&) override;
virtual void paint_event(PaintEvent&) override; virtual void paint_event(PaintEvent&) override;

View file

@ -27,7 +27,7 @@
#include <LibGUI/BoxLayout.h> #include <LibGUI/BoxLayout.h>
#include <LibGUI/Button.h> #include <LibGUI/Button.h>
#include <LibGUI/Label.h> #include <LibGUI/Label.h>
#include <LibGUI/Image.h> #include <LibGUI/ImageWidget.h>
#include <LibGUI/MessageBox.h> #include <LibGUI/MessageBox.h>
#include <LibGfx/Font.h> #include <LibGfx/Font.h>
#include <stdio.h> #include <stdio.h>
@ -116,7 +116,7 @@ void MessageBox::build()
message_container.layout()->set_spacing(8); message_container.layout()->set_spacing(8);
if (m_type != Type::None) { if (m_type != Type::None) {
auto& icon_image = message_container.add<Image>(); auto& icon_image = message_container.add<ImageWidget>();
icon_image.set_bitmap(icon()); icon_image.set_bitmap(icon());
if (icon()) if (icon())
icon_width = icon()->width(); icon_width = icon()->width();

View file

@ -26,7 +26,7 @@
#include "ClipboardHistoryModel.h" #include "ClipboardHistoryModel.h"
#include <LibGUI/Application.h> #include <LibGUI/Application.h>
#include <LibGUI/Image.h> #include <LibGUI/ImageWidget.h>
#include <LibGUI/TableView.h> #include <LibGUI/TableView.h>
#include <LibGUI/Window.h> #include <LibGUI/Window.h>
#include <stdio.h> #include <stdio.h>
@ -76,7 +76,7 @@ int main(int argc, char* argv[])
auto applet_window = GUI::Window::construct(); auto applet_window = GUI::Window::construct();
applet_window->set_title("ClipboardHistory"); applet_window->set_title("ClipboardHistory");
applet_window->set_window_type(GUI::WindowType::MenuApplet); applet_window->set_window_type(GUI::WindowType::MenuApplet);
auto& icon = applet_window->set_main_widget<GUI::Image>(); auto& icon = applet_window->set_main_widget<GUI::ImageWidget>();
icon.load_from_file("/res/icons/clipboard.png"); icon.load_from_file("/res/icons/clipboard.png");
icon.set_fill_with_background_color(true); icon.set_fill_with_background_color(true);
icon.on_click = [& main_window = *main_window] { icon.on_click = [& main_window = *main_window] {

View file

@ -30,7 +30,7 @@
#include <LibGUI/Button.h> #include <LibGUI/Button.h>
#include <LibGUI/Desktop.h> #include <LibGUI/Desktop.h>
#include <LibGUI/Label.h> #include <LibGUI/Label.h>
#include <LibGUI/Image.h> #include <LibGUI/ImageWidget.h>
#include <LibGUI/Widget.h> #include <LibGUI/Widget.h>
#include <LibGfx/Bitmap.h> #include <LibGfx/Bitmap.h>
#include <LibGfx/Font.h> #include <LibGfx/Font.h>
@ -91,7 +91,7 @@ NotificationWindow::NotificationWindow(const String& text, const String& title,
widget.layout()->set_spacing(6); widget.layout()->set_spacing(6);
if (icon.is_valid()) { if (icon.is_valid()) {
auto& image = widget.add<GUI::Image>(); auto& image = widget.add<GUI::ImageWidget>();
image.set_bitmap(icon.bitmap()); image.set_bitmap(icon.bitmap());
} }