summaryrefslogtreecommitdiff
path: root/Libraries/LibGUI
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-02-14 23:02:47 +0100
committerAndreas Kling <kling@serenityos.org>2020-02-14 23:31:18 +0100
commit3fe2640c8c51283cb8c89a948d7221fd79699f3d (patch)
tree28b49ab4ec5e075694c6563ac5f7bb9f083abffa /Libraries/LibGUI
parent184475d45a6f671a40bd7cdd1a21b73bf12c55c7 (diff)
downloadserenity-3fe2640c8c51283cb8c89a948d7221fd79699f3d.zip
LibGfx: Add forward declaration header
This patch adds <LibGfx/Forward.h> with forward declarations for Gfx.
Diffstat (limited to 'Libraries/LibGUI')
-rw-r--r--Libraries/LibGUI/Action.cpp125
-rw-r--r--Libraries/LibGUI/Action.h4
-rw-r--r--Libraries/LibGUI/DragOperation.cpp1
-rw-r--r--Libraries/LibGUI/Menu.cpp6
-rw-r--r--Libraries/LibGUI/Painter.cpp1
-rw-r--r--Libraries/LibGUI/TextEditor.cpp1
-rw-r--r--Libraries/LibGUI/Window.cpp6
-rw-r--r--Libraries/LibGUI/Window.h5
-rw-r--r--Libraries/LibGUI/WindowServerConnection.cpp2
9 files changed, 82 insertions, 69 deletions
diff --git a/Libraries/LibGUI/Action.cpp b/Libraries/LibGUI/Action.cpp
index f0a34fef54..03f136642f 100644
--- a/Libraries/LibGUI/Action.cpp
+++ b/Libraries/LibGUI/Action.cpp
@@ -34,80 +34,80 @@ namespace GUI {
namespace CommonActions {
-NonnullRefPtr<Action> make_open_action(Function<void(Action&)> callback, Core::Object* parent)
-{
- return Action::create("Open...", { Mod_Ctrl, Key_O }, Gfx::Bitmap::load_from_file("/res/icons/16x16/open.png"), move(callback), parent);
-}
+ NonnullRefPtr<Action> make_open_action(Function<void(Action&)> callback, Core::Object* parent)
+ {
+ return Action::create("Open...", { Mod_Ctrl, Key_O }, Gfx::Bitmap::load_from_file("/res/icons/16x16/open.png"), move(callback), parent);
+ }
-NonnullRefPtr<Action> make_move_to_front_action(Function<void(Action&)> callback, Core::Object* parent)
-{
- return Action::create("Move to front", { Mod_Ctrl | Mod_Shift, Key_Up }, Gfx::Bitmap::load_from_file("/res/icons/16x16/move-to-front.png"), move(callback), parent);
-}
+ NonnullRefPtr<Action> make_move_to_front_action(Function<void(Action&)> callback, Core::Object* parent)
+ {
+ return Action::create("Move to front", { Mod_Ctrl | Mod_Shift, Key_Up }, Gfx::Bitmap::load_from_file("/res/icons/16x16/move-to-front.png"), move(callback), parent);
+ }
-NonnullRefPtr<Action> make_move_to_back_action(Function<void(Action&)> callback, Core::Object* parent)
-{
- return Action::create("Move to back", { Mod_Ctrl | Mod_Shift, Key_Down }, Gfx::Bitmap::load_from_file("/res/icons/16x16/move-to-back.png"), move(callback), parent);
-}
+ NonnullRefPtr<Action> make_move_to_back_action(Function<void(Action&)> callback, Core::Object* parent)
+ {
+ return Action::create("Move to back", { Mod_Ctrl | Mod_Shift, Key_Down }, Gfx::Bitmap::load_from_file("/res/icons/16x16/move-to-back.png"), move(callback), parent);
+ }
-NonnullRefPtr<Action> make_undo_action(Function<void(Action&)> callback, Core::Object* parent)
-{
- return Action::create("Undo", { Mod_Ctrl, Key_Z }, Gfx::Bitmap::load_from_file("/res/icons/16x16/undo.png"), move(callback), parent);
-}
+ NonnullRefPtr<Action> make_undo_action(Function<void(Action&)> callback, Core::Object* parent)
+ {
+ return Action::create("Undo", { Mod_Ctrl, Key_Z }, Gfx::Bitmap::load_from_file("/res/icons/16x16/undo.png"), move(callback), parent);
+ }
-NonnullRefPtr<Action> make_redo_action(Function<void(Action&)> callback, Core::Object* parent)
-{
- return Action::create("Redo", { Mod_Ctrl, Key_Y }, Gfx::Bitmap::load_from_file("/res/icons/16x16/redo.png"), move(callback), parent);
-}
+ NonnullRefPtr<Action> make_redo_action(Function<void(Action&)> callback, Core::Object* parent)
+ {
+ return Action::create("Redo", { Mod_Ctrl, Key_Y }, Gfx::Bitmap::load_from_file("/res/icons/16x16/redo.png"), move(callback), parent);
+ }
-NonnullRefPtr<Action> make_delete_action(Function<void(Action&)> callback, Core::Object* parent)
-{
- return Action::create("Delete", { Mod_None, Key_Delete }, Gfx::Bitmap::load_from_file("/res/icons/16x16/delete.png"), move(callback), parent);
-}
+ NonnullRefPtr<Action> make_delete_action(Function<void(Action&)> callback, Core::Object* parent)
+ {
+ return Action::create("Delete", { Mod_None, Key_Delete }, Gfx::Bitmap::load_from_file("/res/icons/16x16/delete.png"), move(callback), parent);
+ }
-NonnullRefPtr<Action> make_cut_action(Function<void(Action&)> callback, Core::Object* parent)
-{
- return Action::create("Cut", { Mod_Ctrl, Key_X }, Gfx::Bitmap::load_from_file("/res/icons/cut16.png"), move(callback), parent);
-}
+ NonnullRefPtr<Action> make_cut_action(Function<void(Action&)> callback, Core::Object* parent)
+ {
+ return Action::create("Cut", { Mod_Ctrl, Key_X }, Gfx::Bitmap::load_from_file("/res/icons/cut16.png"), move(callback), parent);
+ }
-NonnullRefPtr<Action> make_copy_action(Function<void(Action&)> callback, Core::Object* parent)
-{
- return Action::create("Copy", { Mod_Ctrl, Key_C }, Gfx::Bitmap::load_from_file("/res/icons/16x16/edit-copy.png"), move(callback), parent);
-}
+ NonnullRefPtr<Action> make_copy_action(Function<void(Action&)> callback, Core::Object* parent)
+ {
+ return Action::create("Copy", { Mod_Ctrl, Key_C }, Gfx::Bitmap::load_from_file("/res/icons/16x16/edit-copy.png"), move(callback), parent);
+ }
-NonnullRefPtr<Action> make_paste_action(Function<void(Action&)> callback, Core::Object* parent)
-{
- return Action::create("Paste", { Mod_Ctrl, Key_V }, Gfx::Bitmap::load_from_file("/res/icons/paste16.png"), move(callback), parent);
-}
+ NonnullRefPtr<Action> make_paste_action(Function<void(Action&)> callback, Core::Object* parent)
+ {
+ return Action::create("Paste", { Mod_Ctrl, Key_V }, Gfx::Bitmap::load_from_file("/res/icons/paste16.png"), move(callback), parent);
+ }
-NonnullRefPtr<Action> make_fullscreen_action(Function<void(Action&)> callback, Core::Object* parent)
-{
- return Action::create("Fullscreen", { Mod_None, Key_F11 }, move(callback), parent);
-}
+ NonnullRefPtr<Action> make_fullscreen_action(Function<void(Action&)> callback, Core::Object* parent)
+ {
+ return Action::create("Fullscreen", { Mod_None, Key_F11 }, move(callback), parent);
+ }
-NonnullRefPtr<Action> make_quit_action(Function<void(Action&)> callback)
-{
- return Action::create("Quit", { Mod_Alt, Key_F4 }, move(callback));
-}
+ NonnullRefPtr<Action> make_quit_action(Function<void(Action&)> callback)
+ {
+ return Action::create("Quit", { Mod_Alt, Key_F4 }, move(callback));
+ }
-NonnullRefPtr<Action> make_go_back_action(Function<void(Action&)> callback, Core::Object* parent)
-{
- return Action::create("Go back", { Mod_Alt, Key_Left }, Gfx::Bitmap::load_from_file("/res/icons/16x16/go-back.png"), move(callback), parent);
-}
+ NonnullRefPtr<Action> make_go_back_action(Function<void(Action&)> callback, Core::Object* parent)
+ {
+ return Action::create("Go back", { Mod_Alt, Key_Left }, Gfx::Bitmap::load_from_file("/res/icons/16x16/go-back.png"), move(callback), parent);
+ }
-NonnullRefPtr<Action> make_go_forward_action(Function<void(Action&)> callback, Core::Object* parent)
-{
- return Action::create("Go forward", { Mod_Alt, Key_Right }, Gfx::Bitmap::load_from_file("/res/icons/16x16/go-forward.png"), move(callback), parent);
-}
+ NonnullRefPtr<Action> make_go_forward_action(Function<void(Action&)> callback, Core::Object* parent)
+ {
+ return Action::create("Go forward", { Mod_Alt, Key_Right }, Gfx::Bitmap::load_from_file("/res/icons/16x16/go-forward.png"), move(callback), parent);
+ }
-NonnullRefPtr<Action> make_go_home_action(Function<void(Action&)> callback, Core::Object* parent)
-{
- return Action::create("Go home", { Mod_Alt, Key_Home }, Gfx::Bitmap::load_from_file("/res/icons/16x16/go-home.png"), move(callback), parent);
-}
+ NonnullRefPtr<Action> make_go_home_action(Function<void(Action&)> callback, Core::Object* parent)
+ {
+ return Action::create("Go home", { Mod_Alt, Key_Home }, Gfx::Bitmap::load_from_file("/res/icons/16x16/go-home.png"), move(callback), parent);
+ }
-NonnullRefPtr<Action> make_reload_action(Function<void(Action&)> callback, Core::Object* parent)
-{
- return Action::create("Reload", { Mod_Ctrl, Key_R }, Gfx::Bitmap::load_from_file("/res/icons/16x16/reload.png"), move(callback), parent);
-}
+ NonnullRefPtr<Action> make_reload_action(Function<void(Action&)> callback, Core::Object* parent)
+ {
+ return Action::create("Reload", { Mod_Ctrl, Key_R }, Gfx::Bitmap::load_from_file("/res/icons/16x16/reload.png"), move(callback), parent);
+ }
}
@@ -239,4 +239,9 @@ void Action::set_group(Badge<ActionGroup>, ActionGroup* group)
m_action_group = group ? group->make_weak_ptr() : nullptr;
}
+void Action::set_icon(const Gfx::Bitmap* icon)
+{
+ m_icon = icon;
+}
+
}
diff --git a/Libraries/LibGUI/Action.h b/Libraries/LibGUI/Action.h
index d3b7a52ceb..ba1688c0e9 100644
--- a/Libraries/LibGUI/Action.h
+++ b/Libraries/LibGUI/Action.h
@@ -34,7 +34,7 @@
#include <AK/String.h>
#include <AK/WeakPtr.h>
#include <AK/Weakable.h>
-#include <LibGfx/Bitmap.h>
+#include <LibGfx/Forward.h>
#include <LibGUI/Shortcut.h>
#include <LibGUI/Window.h>
@@ -93,7 +93,7 @@ public:
String text() const { return m_text; }
Shortcut shortcut() const { return m_shortcut; }
const Gfx::Bitmap* icon() const { return m_icon.ptr(); }
- void set_icon(const Gfx::Bitmap* icon) { m_icon = icon; }
+ void set_icon(const Gfx::Bitmap*);
const Core::Object* activator() const { return m_activator.ptr(); }
Core::Object* activator() { return m_activator.ptr(); }
diff --git a/Libraries/LibGUI/DragOperation.cpp b/Libraries/LibGUI/DragOperation.cpp
index 81a1a8729d..bd85629126 100644
--- a/Libraries/LibGUI/DragOperation.cpp
+++ b/Libraries/LibGUI/DragOperation.cpp
@@ -25,6 +25,7 @@
*/
#include <AK/Badge.h>
+#include <AK/SharedBuffer.h>
#include <LibGUI/DragOperation.h>
#include <LibGUI/WindowServerConnection.h>
#include <LibGfx/Bitmap.h>
diff --git a/Libraries/LibGUI/Menu.cpp b/Libraries/LibGUI/Menu.cpp
index eefce0c871..cc5455a6b0 100644
--- a/Libraries/LibGUI/Menu.cpp
+++ b/Libraries/LibGUI/Menu.cpp
@@ -25,10 +25,12 @@
*/
#include <AK/HashMap.h>
+#include <AK/SharedBuffer.h>
#include <LibGUI/Action.h>
#include <LibGUI/ActionGroup.h>
#include <LibGUI/Menu.h>
#include <LibGUI/WindowServerConnection.h>
+#include <LibGfx/Bitmap.h>
//#define MENU_DEBUG
@@ -123,12 +125,12 @@ int Menu::realize_menu()
auto& action = *item.action();
int icon_buffer_id = -1;
if (action.icon()) {
- ASSERT(action.icon()->format() == Gfx::Bitmap::Format::RGBA32);
+ ASSERT(action.icon()->format() == Gfx::BitmapFormat::RGBA32);
ASSERT(action.icon()->size() == Gfx::Size(16, 16));
if (action.icon()->shared_buffer_id() == -1) {
auto shared_buffer = SharedBuffer::create_with_size(action.icon()->size_in_bytes());
ASSERT(shared_buffer);
- auto shared_icon = Gfx::Bitmap::create_with_shared_buffer(Gfx::Bitmap::Format::RGBA32, *shared_buffer, action.icon()->size());
+ auto shared_icon = Gfx::Bitmap::create_with_shared_buffer(Gfx::BitmapFormat::RGBA32, *shared_buffer, action.icon()->size());
memcpy(shared_buffer->data(), action.icon()->bits(0), action.icon()->size_in_bytes());
shared_buffer->seal();
shared_buffer->share_with(WindowServerConnection::the().server_pid());
diff --git a/Libraries/LibGUI/Painter.cpp b/Libraries/LibGUI/Painter.cpp
index 0dd3e3fbcb..c0c2720c40 100644
--- a/Libraries/LibGUI/Painter.cpp
+++ b/Libraries/LibGUI/Painter.cpp
@@ -27,6 +27,7 @@
#include <LibGUI/Painter.h>
#include <LibGUI/Widget.h>
#include <LibGUI/Window.h>
+#include <LibGfx/Bitmap.h>
namespace GUI {
Painter::Painter(Gfx::Bitmap& bitmap)
diff --git a/Libraries/LibGUI/TextEditor.cpp b/Libraries/LibGUI/TextEditor.cpp
index 6353357869..ea106cd502 100644
--- a/Libraries/LibGUI/TextEditor.cpp
+++ b/Libraries/LibGUI/TextEditor.cpp
@@ -37,6 +37,7 @@
#include <LibGUI/SyntaxHighlighter.h>
#include <LibGUI/TextEditor.h>
#include <LibGUI/Window.h>
+#include <LibGfx/Bitmap.h>
#include <LibGfx/Palette.h>
#include <ctype.h>
#include <fcntl.h>
diff --git a/Libraries/LibGUI/Window.cpp b/Libraries/LibGUI/Window.cpp
index ca05ff9f17..4222de9ea1 100644
--- a/Libraries/LibGUI/Window.cpp
+++ b/Libraries/LibGUI/Window.cpp
@@ -493,7 +493,7 @@ void Window::flip(const Vector<Gfx::Rect, 32>& dirty_rects)
m_back_bitmap->shared_buffer()->set_volatile();
}
-NonnullRefPtr<Gfx::Bitmap> Window::create_shared_bitmap(Gfx::Bitmap::Format format, const Gfx::Size& size)
+NonnullRefPtr<Gfx::Bitmap> Window::create_shared_bitmap(Gfx::BitmapFormat format, const Gfx::Size& size)
{
ASSERT(WindowServerConnection::the().server_pid());
ASSERT(!size.is_empty());
@@ -507,7 +507,7 @@ NonnullRefPtr<Gfx::Bitmap> Window::create_shared_bitmap(Gfx::Bitmap::Format form
NonnullRefPtr<Gfx::Bitmap> Window::create_backing_bitmap(const Gfx::Size& size)
{
- auto format = m_has_alpha_channel ? Gfx::Bitmap::Format::RGBA32 : Gfx::Bitmap::Format::RGB32;
+ auto format = m_has_alpha_channel ? Gfx::BitmapFormat::RGBA32 : Gfx::BitmapFormat::RGB32;
return create_shared_bitmap(format, size);
}
@@ -526,7 +526,7 @@ void Window::set_icon(const Gfx::Bitmap* icon)
if (m_icon == icon)
return;
- m_icon = create_shared_bitmap(Gfx::Bitmap::Format::RGBA32, icon->size());
+ m_icon = create_shared_bitmap(Gfx::BitmapFormat::RGBA32, icon->size());
{
Painter painter(*m_icon);
painter.blit({ 0, 0 }, *icon, icon->rect());
diff --git a/Libraries/LibGUI/Window.h b/Libraries/LibGUI/Window.h
index 625a02d960..55b2856762 100644
--- a/Libraries/LibGUI/Window.h
+++ b/Libraries/LibGUI/Window.h
@@ -32,7 +32,8 @@
#include <AK/WeakPtr.h>
#include <LibCore/Object.h>
#include <LibGUI/WindowType.h>
-#include <LibGfx/Bitmap.h>
+#include <LibGfx/Color.h>
+#include <LibGfx/Forward.h>
#include <LibGfx/Rect.h>
namespace GUI {
@@ -184,7 +185,7 @@ private:
virtual bool is_window() const override final { return true; }
NonnullRefPtr<Gfx::Bitmap> create_backing_bitmap(const Gfx::Size&);
- NonnullRefPtr<Gfx::Bitmap> create_shared_bitmap(Gfx::Bitmap::Format, const Gfx::Size&);
+ NonnullRefPtr<Gfx::Bitmap> create_shared_bitmap(Gfx::BitmapFormat, const Gfx::Size&);
void set_current_backing_bitmap(Gfx::Bitmap&, bool flush_immediately = false);
void flip(const Vector<Gfx::Rect, 32>& dirty_rects);
diff --git a/Libraries/LibGUI/WindowServerConnection.cpp b/Libraries/LibGUI/WindowServerConnection.cpp
index d1a17570e2..df0dab8df9 100644
--- a/Libraries/LibGUI/WindowServerConnection.cpp
+++ b/Libraries/LibGUI/WindowServerConnection.cpp
@@ -24,6 +24,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <AK/SharedBuffer.h>
#include <LibCore/MimeData.h>
#include <LibGUI/Action.h>
#include <LibGUI/Application.h>
@@ -35,6 +36,7 @@
#include <LibGUI/Widget.h>
#include <LibGUI/Window.h>
#include <LibGUI/WindowServerConnection.h>
+#include <LibGfx/Bitmap.h>
#include <LibGfx/Palette.h>
#include <LibGfx/SystemTheme.h>