| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- #pragma once
- #include "lumacs/ui_interface.hpp"
- #include "lumacs/gtk_renderer.hpp"
- #include "lumacs/window.hpp"
- #include "lumacs/editor_core.hpp"
- #include "lumacs/face.hpp"
- #include <gtkmm.h>
- #include <pangomm.h>
- #include <memory>
- #include <vector>
- #include <map>
- // Forward declarations
- namespace lumacs {
- class EditorCore;
- class Window;
- }
- // Custom Gtk::ApplicationWindow to make constructor public
- class LumacsWindow : public Gtk::ApplicationWindow {
- public:
- explicit LumacsWindow(const Glib::RefPtr<Gtk::Application>& application);
- };
- namespace lumacs {
- class GtkEditor : public IEditorView {
- public:
- GtkEditor();
- ~GtkEditor() override;
- void init() override;
- void run() override;
- void handle_editor_event(EditorEvent event) override;
- void set_core(EditorCore* core) override;
- void queue_redraw_all_windows(Gtk::Widget* widget);
- private:
- EditorCore* core_;
- std::shared_ptr<Window> cached_active_window_;
- Glib::RefPtr<Gtk::Application> app_;
- Gtk::Window* window_ = nullptr;
- Gtk::DrawingArea* drawing_area_ = nullptr;
- Gtk::Widget* content_widget_ = nullptr;
-
- bool cursor_visible_ = true;
- sigc::connection cursor_timer_connection_;
- std::unique_ptr<GtkRenderer> gtk_renderer_;
- protected:
- void on_activate();
- void on_draw(const Cairo::RefPtr<Cairo::Context>& cr, int width, int height);
- bool on_cursor_blink();
- void rebuild_layout();
- Gtk::Widget* create_widget_for_layout_node(std::shared_ptr<LayoutNode> node);
-
- // Delegate these to GtkRenderer
- std::optional<Position> resolve_screen_pos(std::shared_ptr<Window> window, double x, double y);
- std::string resolve_key(guint keyval, Gdk::ModifierType state);
- bool on_key_pressed(guint keyval, guint keycode, Gdk::ModifierType state);
- };
- std::unique_ptr<IEditorView> create_gtk_editor();
- } // namespace lumacs
|