Window: Update coding style.

This commit is contained in:
Andreas Kling 2019-01-16 13:49:44 +01:00
parent 9dd29f9aa9
commit e655aebd70
Notes: sideshowbarker 2024-07-19 16:01:32 +09:00
6 changed files with 23 additions and 40 deletions

View file

@ -63,8 +63,8 @@ int Process::gui$create_window(const GUI_CreateWindowParameters* user_params)
if (!window)
return -ENOMEM;
window->setTitle(params.title);
window->setRect(rect);
window->set_title(params.title);
window->set_rect(rect);
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());

View file

@ -38,9 +38,9 @@ void Widget::event(Event& event)
case Event::Paint:
m_hasPendingPaintEvent = false;
if (auto* win = window()) {
if (win->isBeingDragged())
if (win->is_being_dragged())
return;
if (!win->isVisible())
if (!win->is_visible())
return;
}
return paintEvent(static_cast<PaintEvent&>(event));

View file

@ -2,7 +2,6 @@
#include "WindowManager.h"
#include "Event.h"
#include "EventLoop.h"
#include "Widget.h"
#include "Process.h"
Window::Window(Process& process, int window_id)
@ -17,7 +16,7 @@ Window::~Window()
WindowManager::the().removeWindow(*this);
}
void Window::setTitle(String&& title)
void Window::set_title(String&& title)
{
if (m_title == title)
return;
@ -26,7 +25,7 @@ void Window::setTitle(String&& title)
WindowManager::the().notifyTitleChanged(*this);
}
void Window::setRect(const Rect& rect)
void Window::set_rect(const Rect& rect)
{
if (m_rect == rect)
return;
@ -87,17 +86,7 @@ void Window::event(Event& event)
}
}
void Window::did_paint()
{
WindowManager::the().did_paint(*this);
}
bool Window::isActive() const
{
return WindowManager::the().activeWindow() == this;
}
bool Window::isVisible() const
bool Window::is_visible() const
{
return WindowManager::the().isVisible(const_cast<Window&>(*this));
}

View file

@ -5,10 +5,8 @@
#include "GraphicsBitmap.h"
#include <AK/AKString.h>
#include <AK/InlineLinkedList.h>
#include <AK/WeakPtr.h>
class Process;
class Widget;
class Window final : public Object, public InlineLinkedListNode<Window> {
public:
@ -18,7 +16,7 @@ public:
int window_id() const { return m_window_id; }
String title() const { return m_title; }
void setTitle(String&&);
void set_title(String&&);
int x() const { return m_rect.x(); }
int y() const { return m_rect.y(); }
@ -26,28 +24,24 @@ public:
int height() const { return m_rect.height(); }
const Rect& rect() const { return m_rect; }
void setRect(const Rect&);
void setRectWithoutRepaint(const Rect& rect) { m_rect = rect; }
void set_rect(const Rect&);
void set_rect_without_repaint(const Rect& rect) { m_rect = rect; }
Point position() const { return m_rect.location(); }
void setPosition(const Point& position) { setRect({ position.x(), position.y(), width(), height() }); }
void setPositionWithoutRepaint(const Point& position) { setRectWithoutRepaint({ position.x(), position.y(), width(), height() }); }
void set_position(const Point& position) { set_rect({ 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;
bool isBeingDragged() const { return m_isBeingDragged; }
void setIsBeingDragged(bool b) { m_isBeingDragged = b; }
bool is_being_dragged() const { return m_is_being_dragged; }
void set_is_being_dragged(bool b) { m_is_being_dragged = b; }
bool isActive() const;
bool isVisible() const;
bool is_visible() const;
void close();
GraphicsBitmap* backing() { return m_backing.ptr(); }
void did_paint();
// For InlineLinkedList.
// FIXME: Maybe make a ListHashSet and then WindowManager can just use that.
Window* m_next { nullptr };
@ -56,7 +50,7 @@ public:
private:
String m_title;
Rect m_rect;
bool m_isBeingDragged { false };
bool m_is_being_dragged { false };
RetainPtr<GraphicsBitmap> m_backing;
Process& m_process;

View file

@ -210,7 +210,7 @@ void WindowManager::handleTitleBarMouseEvent(Window& window, MouseEvent& event)
m_dragOrigin = event.position();
m_dragWindowOrigin = window.position();
m_dragStartRect = outerRectForWindow(window.rect());
window.setIsBeingDragged(true);
window.set_is_being_dragged(true);
return;
}
}
@ -222,7 +222,7 @@ void WindowManager::processMouseEvent(MouseEvent& event)
printf("[WM] Finish dragging Window{%p}\n", m_dragWindow.ptr());
invalidate(m_dragStartRect);
invalidate(*m_dragWindow);
m_dragWindow->setIsBeingDragged(false);
m_dragWindow->set_is_being_dragged(false);
m_dragEndRect = outerRectForWindow(m_dragWindow->rect());
m_dragWindow = nullptr;
return;
@ -235,7 +235,7 @@ void WindowManager::processMouseEvent(MouseEvent& event)
Point pos = m_dragWindowOrigin;
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());
m_dragWindow->setPositionWithoutRepaint(pos);
m_dragWindow->set_position_without_repaint(pos);
invalidate(outerRectForWindow(old_window_rect));
invalidate(outerRectForWindow(m_dragWindow->rect()));
return;

View file

@ -19,8 +19,8 @@ int main(int argc, char** argv)
EventLoop loop;
auto* fontTestWindow = new Window;
fontTestWindow->setTitle("Font test");
fontTestWindow->setRect({ 140, 100, 300, 80 });
fontTestWindow->set_title("Font test");
fontTestWindow->set_rect({ 140, 100, 300, 80 });
auto* fontTestWindowWidget = new Widget;
fontTestWindow->setMainWidget(fontTestWindowWidget);
@ -44,8 +44,8 @@ int main(int argc, char** argv)
{
auto* widgetTestWindow = new Window;
widgetTestWindow->setTitle("Widget test");
widgetTestWindow->setRect({ 20, 40, 100, 180 });
widgetTestWindow->set_title("Widget test");
widgetTestWindow->set_rect({ 20, 40, 100, 180 });
auto* widgetTestWindowWidget = new Widget;
widgetTestWindowWidget->setWindowRelativeRect({ 0, 0, 100, 100 });