mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 00:47:36 +00:00
Window: Update coding style.
This commit is contained in:
parent
9dd29f9aa9
commit
e655aebd70
6 changed files with 23 additions and 40 deletions
|
@ -63,8 +63,8 @@ int Process::gui$create_window(const GUI_CreateWindowParameters* user_params)
|
||||||
if (!window)
|
if (!window)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
window->setTitle(params.title);
|
window->set_title(params.title);
|
||||||
window->setRect(rect);
|
window->set_rect(rect);
|
||||||
|
|
||||||
m_windows.set(window_id, move(window));
|
m_windows.set(window_id, move(window));
|
||||||
dbgprintf("%s<%u> gui$create_window: %d with rect {%d,%d %dx%d}\n", name().characters(), pid(), window_id, rect.x(), rect.y(), rect.width(), rect.height());
|
dbgprintf("%s<%u> gui$create_window: %d with rect {%d,%d %dx%d}\n", name().characters(), pid(), window_id, rect.x(), rect.y(), rect.width(), rect.height());
|
||||||
|
|
|
@ -38,9 +38,9 @@ void Widget::event(Event& event)
|
||||||
case Event::Paint:
|
case Event::Paint:
|
||||||
m_hasPendingPaintEvent = false;
|
m_hasPendingPaintEvent = false;
|
||||||
if (auto* win = window()) {
|
if (auto* win = window()) {
|
||||||
if (win->isBeingDragged())
|
if (win->is_being_dragged())
|
||||||
return;
|
return;
|
||||||
if (!win->isVisible())
|
if (!win->is_visible())
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return paintEvent(static_cast<PaintEvent&>(event));
|
return paintEvent(static_cast<PaintEvent&>(event));
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
#include "WindowManager.h"
|
#include "WindowManager.h"
|
||||||
#include "Event.h"
|
#include "Event.h"
|
||||||
#include "EventLoop.h"
|
#include "EventLoop.h"
|
||||||
#include "Widget.h"
|
|
||||||
#include "Process.h"
|
#include "Process.h"
|
||||||
|
|
||||||
Window::Window(Process& process, int window_id)
|
Window::Window(Process& process, int window_id)
|
||||||
|
@ -17,7 +16,7 @@ Window::~Window()
|
||||||
WindowManager::the().removeWindow(*this);
|
WindowManager::the().removeWindow(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::setTitle(String&& title)
|
void Window::set_title(String&& title)
|
||||||
{
|
{
|
||||||
if (m_title == title)
|
if (m_title == title)
|
||||||
return;
|
return;
|
||||||
|
@ -26,7 +25,7 @@ void Window::setTitle(String&& title)
|
||||||
WindowManager::the().notifyTitleChanged(*this);
|
WindowManager::the().notifyTitleChanged(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::setRect(const Rect& rect)
|
void Window::set_rect(const Rect& rect)
|
||||||
{
|
{
|
||||||
if (m_rect == rect)
|
if (m_rect == rect)
|
||||||
return;
|
return;
|
||||||
|
@ -87,17 +86,7 @@ void Window::event(Event& event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::did_paint()
|
bool Window::is_visible() const
|
||||||
{
|
|
||||||
WindowManager::the().did_paint(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Window::isActive() const
|
|
||||||
{
|
|
||||||
return WindowManager::the().activeWindow() == this;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Window::isVisible() const
|
|
||||||
{
|
{
|
||||||
return WindowManager::the().isVisible(const_cast<Window&>(*this));
|
return WindowManager::the().isVisible(const_cast<Window&>(*this));
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,10 +5,8 @@
|
||||||
#include "GraphicsBitmap.h"
|
#include "GraphicsBitmap.h"
|
||||||
#include <AK/AKString.h>
|
#include <AK/AKString.h>
|
||||||
#include <AK/InlineLinkedList.h>
|
#include <AK/InlineLinkedList.h>
|
||||||
#include <AK/WeakPtr.h>
|
|
||||||
|
|
||||||
class Process;
|
class Process;
|
||||||
class Widget;
|
|
||||||
|
|
||||||
class Window final : public Object, public InlineLinkedListNode<Window> {
|
class Window final : public Object, public InlineLinkedListNode<Window> {
|
||||||
public:
|
public:
|
||||||
|
@ -18,7 +16,7 @@ public:
|
||||||
int window_id() const { return m_window_id; }
|
int window_id() const { return m_window_id; }
|
||||||
|
|
||||||
String title() const { return m_title; }
|
String title() const { return m_title; }
|
||||||
void setTitle(String&&);
|
void set_title(String&&);
|
||||||
|
|
||||||
int x() const { return m_rect.x(); }
|
int x() const { return m_rect.x(); }
|
||||||
int y() const { return m_rect.y(); }
|
int y() const { return m_rect.y(); }
|
||||||
|
@ -26,28 +24,24 @@ public:
|
||||||
int height() const { return m_rect.height(); }
|
int height() const { return m_rect.height(); }
|
||||||
|
|
||||||
const Rect& rect() const { return m_rect; }
|
const Rect& rect() const { return m_rect; }
|
||||||
void setRect(const Rect&);
|
void set_rect(const Rect&);
|
||||||
void setRectWithoutRepaint(const Rect& rect) { m_rect = rect; }
|
void set_rect_without_repaint(const Rect& rect) { m_rect = rect; }
|
||||||
|
|
||||||
Point position() const { return m_rect.location(); }
|
Point position() const { return m_rect.location(); }
|
||||||
void setPosition(const Point& position) { setRect({ position.x(), position.y(), width(), height() }); }
|
void set_position(const Point& position) { set_rect({ position.x(), position.y(), width(), height() }); }
|
||||||
void setPositionWithoutRepaint(const Point& position) { setRectWithoutRepaint({ position.x(), position.y(), width(), height() }); }
|
void set_position_without_repaint(const Point& position) { set_rect_without_repaint({ position.x(), position.y(), width(), height() }); }
|
||||||
|
|
||||||
virtual void event(Event&) override;
|
virtual void event(Event&) override;
|
||||||
|
|
||||||
bool isBeingDragged() const { return m_isBeingDragged; }
|
bool is_being_dragged() const { return m_is_being_dragged; }
|
||||||
void setIsBeingDragged(bool b) { m_isBeingDragged = b; }
|
void set_is_being_dragged(bool b) { m_is_being_dragged = b; }
|
||||||
|
|
||||||
bool isActive() const;
|
bool is_visible() const;
|
||||||
|
|
||||||
bool isVisible() const;
|
|
||||||
|
|
||||||
void close();
|
void close();
|
||||||
|
|
||||||
GraphicsBitmap* backing() { return m_backing.ptr(); }
|
GraphicsBitmap* backing() { return m_backing.ptr(); }
|
||||||
|
|
||||||
void did_paint();
|
|
||||||
|
|
||||||
// For InlineLinkedList.
|
// For InlineLinkedList.
|
||||||
// FIXME: Maybe make a ListHashSet and then WindowManager can just use that.
|
// FIXME: Maybe make a ListHashSet and then WindowManager can just use that.
|
||||||
Window* m_next { nullptr };
|
Window* m_next { nullptr };
|
||||||
|
@ -56,7 +50,7 @@ public:
|
||||||
private:
|
private:
|
||||||
String m_title;
|
String m_title;
|
||||||
Rect m_rect;
|
Rect m_rect;
|
||||||
bool m_isBeingDragged { false };
|
bool m_is_being_dragged { false };
|
||||||
|
|
||||||
RetainPtr<GraphicsBitmap> m_backing;
|
RetainPtr<GraphicsBitmap> m_backing;
|
||||||
Process& m_process;
|
Process& m_process;
|
||||||
|
|
|
@ -210,7 +210,7 @@ void WindowManager::handleTitleBarMouseEvent(Window& window, MouseEvent& event)
|
||||||
m_dragOrigin = event.position();
|
m_dragOrigin = event.position();
|
||||||
m_dragWindowOrigin = window.position();
|
m_dragWindowOrigin = window.position();
|
||||||
m_dragStartRect = outerRectForWindow(window.rect());
|
m_dragStartRect = outerRectForWindow(window.rect());
|
||||||
window.setIsBeingDragged(true);
|
window.set_is_being_dragged(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -222,7 +222,7 @@ void WindowManager::processMouseEvent(MouseEvent& event)
|
||||||
printf("[WM] Finish dragging Window{%p}\n", m_dragWindow.ptr());
|
printf("[WM] Finish dragging Window{%p}\n", m_dragWindow.ptr());
|
||||||
invalidate(m_dragStartRect);
|
invalidate(m_dragStartRect);
|
||||||
invalidate(*m_dragWindow);
|
invalidate(*m_dragWindow);
|
||||||
m_dragWindow->setIsBeingDragged(false);
|
m_dragWindow->set_is_being_dragged(false);
|
||||||
m_dragEndRect = outerRectForWindow(m_dragWindow->rect());
|
m_dragEndRect = outerRectForWindow(m_dragWindow->rect());
|
||||||
m_dragWindow = nullptr;
|
m_dragWindow = nullptr;
|
||||||
return;
|
return;
|
||||||
|
@ -235,7 +235,7 @@ void WindowManager::processMouseEvent(MouseEvent& event)
|
||||||
Point pos = m_dragWindowOrigin;
|
Point pos = m_dragWindowOrigin;
|
||||||
printf("[WM] Dragging [origin: %d,%d] now: %d,%d\n", m_dragOrigin.x(), m_dragOrigin.y(), event.x(), event.y());
|
printf("[WM] Dragging [origin: %d,%d] now: %d,%d\n", m_dragOrigin.x(), m_dragOrigin.y(), event.x(), event.y());
|
||||||
pos.moveBy(event.x() - m_dragOrigin.x(), event.y() - m_dragOrigin.y());
|
pos.moveBy(event.x() - m_dragOrigin.x(), event.y() - m_dragOrigin.y());
|
||||||
m_dragWindow->setPositionWithoutRepaint(pos);
|
m_dragWindow->set_position_without_repaint(pos);
|
||||||
invalidate(outerRectForWindow(old_window_rect));
|
invalidate(outerRectForWindow(old_window_rect));
|
||||||
invalidate(outerRectForWindow(m_dragWindow->rect()));
|
invalidate(outerRectForWindow(m_dragWindow->rect()));
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -19,8 +19,8 @@ int main(int argc, char** argv)
|
||||||
EventLoop loop;
|
EventLoop loop;
|
||||||
|
|
||||||
auto* fontTestWindow = new Window;
|
auto* fontTestWindow = new Window;
|
||||||
fontTestWindow->setTitle("Font test");
|
fontTestWindow->set_title("Font test");
|
||||||
fontTestWindow->setRect({ 140, 100, 300, 80 });
|
fontTestWindow->set_rect({ 140, 100, 300, 80 });
|
||||||
|
|
||||||
auto* fontTestWindowWidget = new Widget;
|
auto* fontTestWindowWidget = new Widget;
|
||||||
fontTestWindow->setMainWidget(fontTestWindowWidget);
|
fontTestWindow->setMainWidget(fontTestWindowWidget);
|
||||||
|
@ -44,8 +44,8 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
{
|
{
|
||||||
auto* widgetTestWindow = new Window;
|
auto* widgetTestWindow = new Window;
|
||||||
widgetTestWindow->setTitle("Widget test");
|
widgetTestWindow->set_title("Widget test");
|
||||||
widgetTestWindow->setRect({ 20, 40, 100, 180 });
|
widgetTestWindow->set_rect({ 20, 40, 100, 180 });
|
||||||
|
|
||||||
auto* widgetTestWindowWidget = new Widget;
|
auto* widgetTestWindowWidget = new Widget;
|
||||||
widgetTestWindowWidget->setWindowRelativeRect({ 0, 0, 100, 100 });
|
widgetTestWindowWidget->setWindowRelativeRect({ 0, 0, 100, 100 });
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue