mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:37:35 +00:00
LibCore: Add CEvent and make LibGUI/GEvent inherit from it.
This commit is contained in:
parent
696ada2810
commit
b8062f69d8
31 changed files with 98 additions and 159 deletions
|
@ -97,7 +97,7 @@ void MemoryStatsWidget::refresh()
|
|||
fclose(fp);
|
||||
}
|
||||
|
||||
void MemoryStatsWidget::timer_event(GTimerEvent&)
|
||||
void MemoryStatsWidget::timer_event(CTimerEvent&)
|
||||
{
|
||||
refresh();
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ public:
|
|||
void refresh();
|
||||
|
||||
private:
|
||||
virtual void timer_event(GTimerEvent&) override;
|
||||
virtual void timer_event(CTimerEvent&) override;
|
||||
virtual void paint_event(GPaintEvent&) override;
|
||||
|
||||
GLabel* m_user_physical_pages_label { nullptr };
|
||||
|
|
|
@ -16,7 +16,7 @@ ProcessTableView::~ProcessTableView()
|
|||
{
|
||||
}
|
||||
|
||||
void ProcessTableView::timer_event(GTimerEvent&)
|
||||
void ProcessTableView::timer_event(CTimerEvent&)
|
||||
{
|
||||
model()->update();
|
||||
}
|
||||
|
|
|
@ -17,6 +17,6 @@ protected:
|
|||
virtual void model_notification(const GModelNotification&) override;
|
||||
|
||||
private:
|
||||
virtual void timer_event(GTimerEvent&) override;
|
||||
virtual void timer_event(CTimerEvent&) override;
|
||||
};
|
||||
|
||||
|
|
|
@ -726,7 +726,7 @@ bool Terminal::Line::has_only_one_background_color() const
|
|||
return true;
|
||||
}
|
||||
|
||||
void Terminal::event(GEvent& event)
|
||||
void Terminal::event(CEvent& event)
|
||||
{
|
||||
if (event.type() == GEvent::WindowBecameActive || event.type() == GEvent::WindowBecameInactive) {
|
||||
m_in_active_window = event.type() == GEvent::WindowBecameActive;
|
||||
|
|
|
@ -25,7 +25,7 @@ public:
|
|||
void apply_size_increments_to_window(GWindow&);
|
||||
|
||||
private:
|
||||
virtual void event(GEvent&) override;
|
||||
virtual void event(CEvent&) override;
|
||||
virtual void paint_event(GPaintEvent&) override;
|
||||
virtual void resize_event(GResizeEvent&) override;
|
||||
virtual void keydown_event(GKeyEvent&) override;
|
||||
|
|
12
LibCore/CEvent.cpp
Normal file
12
LibCore/CEvent.cpp
Normal file
|
@ -0,0 +1,12 @@
|
|||
#include <LibCore/CEvent.h>
|
||||
#include <LibGUI/GObject.h>
|
||||
|
||||
CChildEvent::CChildEvent(Type type, GObject& child)
|
||||
: CEvent(type)
|
||||
, m_child(child.make_weak_ptr())
|
||||
{
|
||||
}
|
||||
|
||||
CChildEvent::~CChildEvent()
|
||||
{
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
OBJS = \
|
||||
CElapsedTimer.o
|
||||
|
||||
LIBS =
|
||||
CElapsedTimer.o \
|
||||
CEvent.o
|
||||
|
||||
LIBRARY = libcore.a
|
||||
STANDARD_FLAGS = -std=c++17 -Wno-sized-deallocation
|
||||
|
|
|
@ -97,13 +97,13 @@ void GButton::mouseup_event(GMouseEvent& event)
|
|||
GWidget::mouseup_event(event);
|
||||
}
|
||||
|
||||
void GButton::enter_event(GEvent&)
|
||||
void GButton::enter_event(CEvent&)
|
||||
{
|
||||
m_hovered = true;
|
||||
update();
|
||||
}
|
||||
|
||||
void GButton::leave_event(GEvent&)
|
||||
void GButton::leave_event(CEvent&)
|
||||
{
|
||||
m_hovered = false;
|
||||
update();
|
||||
|
|
|
@ -42,8 +42,8 @@ private:
|
|||
virtual void mousedown_event(GMouseEvent&) override;
|
||||
virtual void mouseup_event(GMouseEvent&) override;
|
||||
virtual void mousemove_event(GMouseEvent&) override;
|
||||
virtual void enter_event(GEvent&) override;
|
||||
virtual void leave_event(GEvent&) override;
|
||||
virtual void enter_event(CEvent&) override;
|
||||
virtual void leave_event(CEvent&) override;
|
||||
|
||||
String m_caption;
|
||||
RetainPtr<GraphicsBitmap> m_icon;
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
#include <LibGUI/GEvent.h>
|
||||
#include <LibGUI/GObject.h>
|
||||
|
||||
GChildEvent::GChildEvent(Type type, GObject& child)
|
||||
: GEvent(type)
|
||||
, m_child(child.make_weak_ptr())
|
||||
{
|
||||
}
|
||||
|
||||
GChildEvent::~GChildEvent()
|
||||
{
|
||||
}
|
|
@ -1,22 +1,17 @@
|
|||
#pragma once
|
||||
|
||||
#include <LibCore/CEvent.h>
|
||||
#include <SharedGraphics/Point.h>
|
||||
#include <SharedGraphics/Rect.h>
|
||||
#include <AK/AKString.h>
|
||||
#include <AK/Types.h>
|
||||
#include <AK/WeakPtr.h>
|
||||
#include <AK/Function.h>
|
||||
#include <Kernel/KeyCode.h>
|
||||
#include <LibGUI/GWindowType.h>
|
||||
|
||||
class GObject;
|
||||
|
||||
class GEvent {
|
||||
class GEvent : public CEvent{
|
||||
public:
|
||||
enum Type {
|
||||
Invalid = 0,
|
||||
Quit,
|
||||
Show,
|
||||
Show = 1000,
|
||||
Hide,
|
||||
Paint,
|
||||
Resize,
|
||||
|
@ -27,9 +22,6 @@ public:
|
|||
Leave,
|
||||
KeyDown,
|
||||
KeyUp,
|
||||
Timer,
|
||||
DeferredDestroy,
|
||||
DeferredInvoke,
|
||||
WindowEntered,
|
||||
WindowLeft,
|
||||
WindowBecameInactive,
|
||||
|
@ -37,37 +29,17 @@ public:
|
|||
FocusIn,
|
||||
FocusOut,
|
||||
WindowCloseRequest,
|
||||
ChildAdded,
|
||||
ChildRemoved,
|
||||
WM_WindowRemoved,
|
||||
WM_WindowStateChanged,
|
||||
};
|
||||
|
||||
GEvent() { }
|
||||
explicit GEvent(Type type) : m_type(type) { }
|
||||
explicit GEvent(Type type) : CEvent(type) { }
|
||||
virtual ~GEvent() { }
|
||||
|
||||
Type type() const { return m_type; }
|
||||
|
||||
bool is_mouse_event() const { return m_type == MouseMove || m_type == MouseDown || m_type == MouseUp; }
|
||||
bool is_key_event() const { return m_type == KeyUp || m_type == KeyDown; }
|
||||
bool is_paint_event() const { return m_type == Paint; }
|
||||
|
||||
private:
|
||||
Type m_type { Invalid };
|
||||
};
|
||||
|
||||
class GDeferredInvocationEvent : public GEvent {
|
||||
friend class GEventLoop;
|
||||
public:
|
||||
GDeferredInvocationEvent(Function<void(GObject&)> invokee)
|
||||
: GEvent(GEvent::Type::DeferredInvoke)
|
||||
, m_invokee(move(invokee))
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
Function<void(GObject&)> m_invokee;
|
||||
bool is_mouse_event() const { return type() == MouseMove || type() == MouseDown || type() == MouseUp; }
|
||||
bool is_key_event() const { return type() == KeyUp || type() == KeyDown; }
|
||||
bool is_paint_event() const { return type() == Paint; }
|
||||
};
|
||||
|
||||
class GWMEvent : public GEvent {
|
||||
|
@ -121,14 +93,6 @@ private:
|
|||
bool m_minimized;
|
||||
};
|
||||
|
||||
class QuitEvent final : public GEvent {
|
||||
public:
|
||||
QuitEvent()
|
||||
: GEvent(GEvent::Quit)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class GPaintEvent final : public GEvent {
|
||||
public:
|
||||
explicit GPaintEvent(const Rect& rect, const Size& window_size = Size())
|
||||
|
@ -233,26 +197,3 @@ private:
|
|||
GMouseButton m_button { GMouseButton::None };
|
||||
unsigned m_modifiers { 0 };
|
||||
};
|
||||
|
||||
class GTimerEvent final : public GEvent {
|
||||
public:
|
||||
explicit GTimerEvent(int timer_id) : GEvent(GEvent::Timer), m_timer_id(timer_id) { }
|
||||
~GTimerEvent() { }
|
||||
|
||||
int timer_id() const { return m_timer_id; }
|
||||
|
||||
private:
|
||||
int m_timer_id;
|
||||
};
|
||||
|
||||
class GChildEvent final : public GEvent {
|
||||
public:
|
||||
GChildEvent(Type, GObject& child);
|
||||
~GChildEvent();
|
||||
|
||||
GObject* child() { return m_child.ptr(); }
|
||||
const GObject* child() const { return m_child.ptr(); }
|
||||
|
||||
private:
|
||||
WeakPtr<GObject> m_child;
|
||||
};
|
||||
|
|
|
@ -153,15 +153,15 @@ int GEventLoop::exec()
|
|||
#endif
|
||||
if (!receiver) {
|
||||
switch (event.type()) {
|
||||
case GEvent::Quit:
|
||||
case CEvent::Quit:
|
||||
ASSERT_NOT_REACHED();
|
||||
return 0;
|
||||
default:
|
||||
dbgprintf("Event type %u with no receiver :(\n", event.type());
|
||||
}
|
||||
} else if (event.type() == GEvent::Type::DeferredInvoke) {
|
||||
} else if (event.type() == CEvent::Type::DeferredInvoke) {
|
||||
printf("DeferredInvoke: receiver=%s{%p}\n", receiver->class_name(), receiver);
|
||||
static_cast<GDeferredInvocationEvent&>(event).m_invokee(*receiver);
|
||||
static_cast<CDeferredInvocationEvent&>(event).m_invokee(*receiver);
|
||||
} else {
|
||||
receiver->event(event);
|
||||
}
|
||||
|
@ -177,7 +177,7 @@ int GEventLoop::exec()
|
|||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
void GEventLoop::post_event(GObject& receiver, OwnPtr<GEvent>&& event)
|
||||
void GEventLoop::post_event(GObject& receiver, OwnPtr<CEvent>&& event)
|
||||
{
|
||||
#ifdef GEVENTLOOP_DEBUG
|
||||
dbgprintf("GEventLoop::post_event: {%u} << receiver=%p, event=%p\n", m_queued_events.size(), &receiver, event.ptr());
|
||||
|
@ -322,9 +322,9 @@ void GEventLoop::wait_for_event()
|
|||
if (!timer.has_expired())
|
||||
continue;
|
||||
#ifdef GEVENTLOOP_DEBUG
|
||||
dbgprintf("GEventLoop: Timer %d has expired, sending GTimerEvent to %p\n", timer.timer_id, timer.owner);
|
||||
dbgprintf("GEventLoop: Timer %d has expired, sending CTimerEvent to %p\n", timer.timer_id, timer.owner);
|
||||
#endif
|
||||
post_event(*timer.owner, make<GTimerEvent>(timer.timer_id));
|
||||
post_event(*timer.owner, make<CTimerEvent>(timer.timer_id));
|
||||
if (timer.should_reload) {
|
||||
timer.reload();
|
||||
} else {
|
||||
|
|
|
@ -20,7 +20,7 @@ public:
|
|||
|
||||
int exec();
|
||||
|
||||
void post_event(GObject& receiver, OwnPtr<GEvent>&&);
|
||||
void post_event(GObject& receiver, OwnPtr<CEvent>&&);
|
||||
|
||||
static GEventLoop& main();
|
||||
static GEventLoop& current();
|
||||
|
@ -66,7 +66,7 @@ private:
|
|||
|
||||
struct QueuedEvent {
|
||||
WeakPtr<GObject> receiver;
|
||||
OwnPtr<GEvent> event;
|
||||
OwnPtr<CEvent> event;
|
||||
};
|
||||
Vector<QueuedEvent> m_queued_events;
|
||||
|
||||
|
|
|
@ -21,17 +21,17 @@ GObject::~GObject()
|
|||
delete child;
|
||||
}
|
||||
|
||||
void GObject::event(GEvent& event)
|
||||
void GObject::event(CEvent& event)
|
||||
{
|
||||
switch (event.type()) {
|
||||
case GEvent::Timer:
|
||||
return timer_event(static_cast<GTimerEvent&>(event));
|
||||
return timer_event(static_cast<CTimerEvent&>(event));
|
||||
case GEvent::DeferredDestroy:
|
||||
delete this;
|
||||
break;
|
||||
case GEvent::ChildAdded:
|
||||
case GEvent::ChildRemoved:
|
||||
return child_event(static_cast<GChildEvent&>(event));
|
||||
return child_event(static_cast<CChildEvent&>(event));
|
||||
case GEvent::Invalid:
|
||||
ASSERT_NOT_REACHED();
|
||||
break;
|
||||
|
@ -43,7 +43,7 @@ void GObject::event(GEvent& event)
|
|||
void GObject::add_child(GObject& object)
|
||||
{
|
||||
m_children.append(&object);
|
||||
GEventLoop::current().post_event(*this, make<GChildEvent>(GEvent::ChildAdded, object));
|
||||
GEventLoop::current().post_event(*this, make<CChildEvent>(GEvent::ChildAdded, object));
|
||||
}
|
||||
|
||||
void GObject::remove_child(GObject& object)
|
||||
|
@ -51,17 +51,17 @@ void GObject::remove_child(GObject& object)
|
|||
for (ssize_t i = 0; i < m_children.size(); ++i) {
|
||||
if (m_children[i] == &object) {
|
||||
m_children.remove(i);
|
||||
GEventLoop::current().post_event(*this, make<GChildEvent>(GEvent::ChildRemoved, object));
|
||||
GEventLoop::current().post_event(*this, make<CChildEvent>(GEvent::ChildRemoved, object));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GObject::timer_event(GTimerEvent&)
|
||||
void GObject::timer_event(CTimerEvent&)
|
||||
{
|
||||
}
|
||||
|
||||
void GObject::child_event(GChildEvent&)
|
||||
void GObject::child_event(CChildEvent&)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,7 @@ void GObject::stop_timer()
|
|||
|
||||
void GObject::delete_later()
|
||||
{
|
||||
GEventLoop::current().post_event(*this, make<GEvent>(GEvent::DeferredDestroy));
|
||||
GEventLoop::current().post_event(*this, make<CEvent>(CEvent::DeferredDestroy));
|
||||
}
|
||||
|
||||
void GObject::dump_tree(int indent)
|
||||
|
@ -103,5 +103,5 @@ void GObject::dump_tree(int indent)
|
|||
|
||||
void GObject::deferred_invoke(Function<void(GObject&)> invokee)
|
||||
{
|
||||
GEventLoop::current().post_event(*this, make<GDeferredInvocationEvent>(move(invokee)));
|
||||
GEventLoop::current().post_event(*this, make<CDeferredInvocationEvent>(move(invokee)));
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
#include <AK/Vector.h>
|
||||
#include <AK/Weakable.h>
|
||||
|
||||
class GEvent;
|
||||
class GChildEvent;
|
||||
class GTimerEvent;
|
||||
class CEvent;
|
||||
class CChildEvent;
|
||||
class CTimerEvent;
|
||||
|
||||
class GObject : public Weakable<GObject> {
|
||||
public:
|
||||
|
@ -15,7 +15,7 @@ public:
|
|||
|
||||
virtual const char* class_name() const { return "GObject"; }
|
||||
|
||||
virtual void event(GEvent&);
|
||||
virtual void event(CEvent&);
|
||||
|
||||
Vector<GObject*>& children() { return m_children; }
|
||||
|
||||
|
@ -39,8 +39,8 @@ public:
|
|||
virtual bool is_window() const { return false; }
|
||||
|
||||
protected:
|
||||
virtual void timer_event(GTimerEvent&);
|
||||
virtual void child_event(GChildEvent&);
|
||||
virtual void timer_event(CTimerEvent&);
|
||||
virtual void child_event(CChildEvent&);
|
||||
|
||||
private:
|
||||
GObject* m_parent { nullptr };
|
||||
|
|
|
@ -293,7 +293,7 @@ void GScrollBar::mousemove_event(GMouseEvent& event)
|
|||
set_value(new_value);
|
||||
}
|
||||
|
||||
void GScrollBar::leave_event(GEvent&)
|
||||
void GScrollBar::leave_event(CEvent&)
|
||||
{
|
||||
if (m_hovered_component != Component::Invalid) {
|
||||
m_hovered_component = Component::Invalid;
|
||||
|
|
|
@ -39,7 +39,7 @@ private:
|
|||
virtual void mousedown_event(GMouseEvent&) override;
|
||||
virtual void mouseup_event(GMouseEvent&) override;
|
||||
virtual void mousemove_event(GMouseEvent&) override;
|
||||
virtual void leave_event(GEvent&) override;
|
||||
virtual void leave_event(CEvent&) override;
|
||||
|
||||
int button_size() const { return orientation() == Orientation::Vertical ? width() : height(); }
|
||||
Rect up_button_rect() const;
|
||||
|
|
|
@ -16,14 +16,14 @@ GSplitter::~GSplitter()
|
|||
{
|
||||
}
|
||||
|
||||
void GSplitter::enter_event(GEvent&)
|
||||
void GSplitter::enter_event(CEvent&)
|
||||
{
|
||||
set_background_color(Color::from_rgb(0xd6d2ce));
|
||||
window()->set_override_cursor(m_orientation == Orientation::Horizontal ? GStandardCursor::ResizeHorizontal : GStandardCursor::ResizeVertical);
|
||||
update();
|
||||
}
|
||||
|
||||
void GSplitter::leave_event(GEvent&)
|
||||
void GSplitter::leave_event(CEvent&)
|
||||
{
|
||||
set_background_color(Color::LightGray);
|
||||
if (!m_resizing)
|
||||
|
|
|
@ -11,8 +11,8 @@ protected:
|
|||
virtual void mousedown_event(GMouseEvent&) override;
|
||||
virtual void mousemove_event(GMouseEvent&) override;
|
||||
virtual void mouseup_event(GMouseEvent&) override;
|
||||
virtual void enter_event(GEvent&) override;
|
||||
virtual void leave_event(GEvent&) override;
|
||||
virtual void enter_event(CEvent&) override;
|
||||
virtual void leave_event(CEvent&) override;
|
||||
|
||||
private:
|
||||
Orientation m_orientation;
|
||||
|
|
|
@ -31,7 +31,7 @@ void GStackWidget::resize_event(GResizeEvent& event)
|
|||
m_active_widget->set_relative_rect({ { }, event.size() });
|
||||
}
|
||||
|
||||
void GStackWidget::child_event(GChildEvent& event)
|
||||
void GStackWidget::child_event(CChildEvent& event)
|
||||
{
|
||||
if (!event.child() || !event.child()->is_widget())
|
||||
return GWidget::child_event(event);
|
||||
|
|
|
@ -13,7 +13,7 @@ public:
|
|||
virtual const char* class_name() const override { return "GStackWidget"; }
|
||||
|
||||
protected:
|
||||
virtual void child_event(GChildEvent&) override;
|
||||
virtual void child_event(CChildEvent&) override;
|
||||
virtual void resize_event(GResizeEvent&) override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -564,18 +564,18 @@ void GTextEditor::set_cursor(const GTextPosition& position)
|
|||
on_cursor_change();
|
||||
}
|
||||
|
||||
void GTextEditor::focusin_event(GEvent&)
|
||||
void GTextEditor::focusin_event(CEvent&)
|
||||
{
|
||||
update_cursor();
|
||||
start_timer(500);
|
||||
}
|
||||
|
||||
void GTextEditor::focusout_event(GEvent&)
|
||||
void GTextEditor::focusout_event(CEvent&)
|
||||
{
|
||||
stop_timer();
|
||||
}
|
||||
|
||||
void GTextEditor::timer_event(GTimerEvent&)
|
||||
void GTextEditor::timer_event(CTimerEvent&)
|
||||
{
|
||||
m_cursor_state = !m_cursor_state;
|
||||
if (is_focused())
|
||||
|
@ -805,13 +805,13 @@ void GTextEditor::paste()
|
|||
insert_at_cursor_or_replace_selection(paste_text);
|
||||
}
|
||||
|
||||
void GTextEditor::enter_event(GEvent&)
|
||||
void GTextEditor::enter_event(CEvent&)
|
||||
{
|
||||
ASSERT(window());
|
||||
window()->set_override_cursor(GStandardCursor::IBeam);
|
||||
}
|
||||
|
||||
void GTextEditor::leave_event(GEvent&)
|
||||
void GTextEditor::leave_event(CEvent&)
|
||||
{
|
||||
ASSERT(window());
|
||||
window()->set_override_cursor(GStandardCursor::None);
|
||||
|
|
|
@ -108,12 +108,12 @@ private:
|
|||
virtual void mouseup_event(GMouseEvent&) override;
|
||||
virtual void mousemove_event(GMouseEvent&) override;
|
||||
virtual void keydown_event(GKeyEvent&) override;
|
||||
virtual void focusin_event(GEvent&) override;
|
||||
virtual void focusout_event(GEvent&) override;
|
||||
virtual void timer_event(GTimerEvent&) override;
|
||||
virtual void focusin_event(CEvent&) override;
|
||||
virtual void focusout_event(CEvent&) override;
|
||||
virtual void timer_event(CTimerEvent&) override;
|
||||
virtual bool accepts_focus() const override { return true; }
|
||||
virtual void enter_event(GEvent&) override;
|
||||
virtual void leave_event(GEvent&) override;
|
||||
virtual void enter_event(CEvent&) override;
|
||||
virtual void leave_event(CEvent&) override;
|
||||
|
||||
void paint_ruler(Painter&);
|
||||
void update_content_size();
|
||||
|
|
|
@ -30,7 +30,7 @@ void GTimer::stop()
|
|||
m_active = false;
|
||||
}
|
||||
|
||||
void GTimer::timer_event(GTimerEvent&)
|
||||
void GTimer::timer_event(CTimerEvent&)
|
||||
{
|
||||
if (m_single_shot)
|
||||
stop();
|
||||
|
|
|
@ -24,7 +24,7 @@ public:
|
|||
virtual const char* class_name() const override { return "GTimer"; }
|
||||
|
||||
private:
|
||||
virtual void timer_event(GTimerEvent&) override;
|
||||
virtual void timer_event(CTimerEvent&) override;
|
||||
|
||||
bool m_active { false };
|
||||
bool m_single_shot { false };
|
||||
|
|
|
@ -22,7 +22,7 @@ GWidget::~GWidget()
|
|||
{
|
||||
}
|
||||
|
||||
void GWidget::child_event(GChildEvent& event)
|
||||
void GWidget::child_event(CChildEvent& event)
|
||||
{
|
||||
if (event.type() == GEvent::ChildAdded) {
|
||||
if (event.child() && event.child()->is_widget() && layout())
|
||||
|
@ -54,7 +54,7 @@ void GWidget::set_relative_rect(const Rect& rect)
|
|||
update();
|
||||
}
|
||||
|
||||
void GWidget::event(GEvent& event)
|
||||
void GWidget::event(CEvent& event)
|
||||
{
|
||||
switch (event.type()) {
|
||||
case GEvent::Paint:
|
||||
|
@ -178,14 +178,14 @@ void GWidget::handle_mousedown_event(GMouseEvent& event)
|
|||
mousedown_event(event);
|
||||
}
|
||||
|
||||
void GWidget::handle_enter_event(GEvent& event)
|
||||
void GWidget::handle_enter_event(CEvent& event)
|
||||
{
|
||||
if (has_tooltip())
|
||||
GApplication::the().show_tooltip(m_tooltip, screen_relative_rect().center().translated(0, height() / 2));
|
||||
enter_event(event);
|
||||
}
|
||||
|
||||
void GWidget::handle_leave_event(GEvent& event)
|
||||
void GWidget::handle_leave_event(CEvent& event)
|
||||
{
|
||||
GApplication::the().hide_tooltip();
|
||||
leave_event(event);
|
||||
|
@ -235,19 +235,19 @@ void GWidget::mousemove_event(GMouseEvent&)
|
|||
{
|
||||
}
|
||||
|
||||
void GWidget::focusin_event(GEvent&)
|
||||
void GWidget::focusin_event(CEvent&)
|
||||
{
|
||||
}
|
||||
|
||||
void GWidget::focusout_event(GEvent&)
|
||||
void GWidget::focusout_event(CEvent&)
|
||||
{
|
||||
}
|
||||
|
||||
void GWidget::enter_event(GEvent&)
|
||||
void GWidget::enter_event(CEvent&)
|
||||
{
|
||||
}
|
||||
|
||||
void GWidget::leave_event(GEvent&)
|
||||
void GWidget::leave_event(CEvent&)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ public:
|
|||
String tooltip() const { return m_tooltip; }
|
||||
void set_tooltip(const String& tooltip) { m_tooltip = tooltip; }
|
||||
|
||||
virtual void event(GEvent&) override;
|
||||
virtual void event(CEvent&) override;
|
||||
virtual void paint_event(GPaintEvent&);
|
||||
virtual void resize_event(GResizeEvent&);
|
||||
virtual void show_event(GShowEvent&);
|
||||
|
@ -50,11 +50,11 @@ public:
|
|||
virtual void mouseup_event(GMouseEvent&);
|
||||
virtual void click_event(GMouseEvent&);
|
||||
virtual void doubleclick_event(GMouseEvent&);
|
||||
virtual void focusin_event(GEvent&);
|
||||
virtual void focusout_event(GEvent&);
|
||||
virtual void enter_event(GEvent&);
|
||||
virtual void leave_event(GEvent&);
|
||||
virtual void child_event(GChildEvent&) override;
|
||||
virtual void focusin_event(CEvent&);
|
||||
virtual void focusout_event(CEvent&);
|
||||
virtual void enter_event(CEvent&);
|
||||
virtual void leave_event(CEvent&);
|
||||
virtual void child_event(CChildEvent&) override;
|
||||
|
||||
Rect relative_rect() const { return m_relative_rect; }
|
||||
Point relative_position() const { return m_relative_rect.location(); }
|
||||
|
@ -154,8 +154,8 @@ private:
|
|||
void handle_resize_event(GResizeEvent&);
|
||||
void handle_mousedown_event(GMouseEvent&);
|
||||
void handle_mouseup_event(GMouseEvent&);
|
||||
void handle_enter_event(GEvent&);
|
||||
void handle_leave_event(GEvent&);
|
||||
void handle_enter_event(CEvent&);
|
||||
void handle_leave_event(CEvent&);
|
||||
void do_layout();
|
||||
|
||||
GWindow* m_window { nullptr };
|
||||
|
|
|
@ -168,21 +168,21 @@ void GWindow::set_override_cursor(GStandardCursor cursor)
|
|||
GEventLoop::current().post_message_to_server(request);
|
||||
}
|
||||
|
||||
void GWindow::event(GEvent& event)
|
||||
void GWindow::event(CEvent& event)
|
||||
{
|
||||
if (event.is_mouse_event()) {
|
||||
if (event.type() == GEvent::MouseUp || event.type() == GEvent::MouseDown || event.type() == GEvent::MouseMove) {
|
||||
auto& mouse_event = static_cast<GMouseEvent&>(event);
|
||||
if (m_global_cursor_tracking_widget) {
|
||||
auto window_relative_rect = m_global_cursor_tracking_widget->window_relative_rect();
|
||||
Point local_point { mouse_event.x() - window_relative_rect.x(), mouse_event.y() - window_relative_rect.y() };
|
||||
auto local_event = make<GMouseEvent>(event.type(), local_point, mouse_event.buttons(), mouse_event.button(), mouse_event.modifiers());
|
||||
auto local_event = make<GMouseEvent>((GEvent::Type)event.type(), local_point, mouse_event.buttons(), mouse_event.button(), mouse_event.modifiers());
|
||||
m_global_cursor_tracking_widget->event(*local_event);
|
||||
return;
|
||||
}
|
||||
if (m_automatic_cursor_tracking_widget) {
|
||||
auto window_relative_rect = m_automatic_cursor_tracking_widget->window_relative_rect();
|
||||
Point local_point { mouse_event.x() - window_relative_rect.x(), mouse_event.y() - window_relative_rect.y() };
|
||||
auto local_event = make<GMouseEvent>(event.type(), local_point, mouse_event.buttons(), mouse_event.button(), mouse_event.modifiers());
|
||||
auto local_event = make<GMouseEvent>((GEvent::Type)event.type(), local_point, mouse_event.buttons(), mouse_event.button(), mouse_event.modifiers());
|
||||
m_automatic_cursor_tracking_widget->event(*local_event);
|
||||
if (mouse_event.buttons() == 0)
|
||||
m_automatic_cursor_tracking_widget = nullptr;
|
||||
|
@ -192,7 +192,7 @@ void GWindow::event(GEvent& event)
|
|||
return;
|
||||
if (m_main_widget) {
|
||||
auto result = m_main_widget->hit_test(mouse_event.x(), mouse_event.y());
|
||||
auto local_event = make<GMouseEvent>(event.type(), Point { result.localX, result.localY }, mouse_event.buttons(), mouse_event.button(), mouse_event.modifiers());
|
||||
auto local_event = make<GMouseEvent>((GEvent::Type)event.type(), Point { result.localX, result.localY }, mouse_event.buttons(), mouse_event.button(), mouse_event.modifiers());
|
||||
ASSERT(result.widget);
|
||||
set_hovered_widget(result.widget);
|
||||
if (mouse_event.buttons() != 0 && !m_automatic_cursor_tracking_widget)
|
||||
|
@ -203,7 +203,7 @@ void GWindow::event(GEvent& event)
|
|||
return;
|
||||
}
|
||||
|
||||
if (event.is_paint_event()) {
|
||||
if (event.type() == GEvent::Paint) {
|
||||
if (!m_window_id)
|
||||
return;
|
||||
m_pending_paint_event_rects.clear();
|
||||
|
@ -240,7 +240,7 @@ void GWindow::event(GEvent& event)
|
|||
return;
|
||||
}
|
||||
|
||||
if (event.is_key_event()) {
|
||||
if (event.type() == GEvent::KeyUp || event.type() == GEvent::KeyDown) {
|
||||
if (m_focused_widget)
|
||||
return m_focused_widget->event(event);
|
||||
if (m_main_widget)
|
||||
|
|
|
@ -56,7 +56,7 @@ public:
|
|||
void move_to(int x, int y) { move_to({ x, y }); }
|
||||
void move_to(const Point& point) { set_rect({ point, size() }); }
|
||||
|
||||
virtual void event(GEvent&) override;
|
||||
virtual void event(CEvent&) override;
|
||||
|
||||
bool is_visible() const;
|
||||
bool is_active() const { return m_is_active; }
|
||||
|
|
|
@ -40,7 +40,6 @@ LIBGUI_OBJS = \
|
|||
GClipboard.o \
|
||||
GSortingProxyModel.o \
|
||||
GStackWidget.o \
|
||||
GEvent.o \
|
||||
GScrollableWidget.o \
|
||||
GSocket.o \
|
||||
GTCPSocket.o \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue