gtk_editor.hpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #pragma once
  2. #include "lumacs/ui_interface.hpp"
  3. #include "lumacs/gtk_renderer.hpp"
  4. #include "lumacs/window.hpp"
  5. #include "lumacs/editor_core.hpp"
  6. #include "lumacs/face.hpp"
  7. #include "lumacs/gtk_window_controller.hpp" // Include GtkWindowController header
  8. #include <gtkmm.h>
  9. #include <pangomm.h>
  10. #include <memory>
  11. #include <vector>
  12. #include <map>
  13. // Forward declarations
  14. namespace lumacs {
  15. class EditorCore;
  16. class Window;
  17. }
  18. // Custom Gtk::ApplicationWindow to make constructor public
  19. class LumacsWindow : public Gtk::ApplicationWindow {
  20. public:
  21. explicit LumacsWindow(const Glib::RefPtr<Gtk::Application>& application);
  22. };
  23. namespace lumacs {
  24. class GtkEditor : public IEditorView {
  25. public:
  26. GtkEditor();
  27. ~GtkEditor() override;
  28. void init() override;
  29. void run() override;
  30. void handle_editor_event(EditorEvent event) override;
  31. void set_core(EditorCore* core) override;
  32. void queue_redraw_all_windows(Gtk::Widget* widget);
  33. private:
  34. EditorCore* core_;
  35. std::shared_ptr<Window> cached_active_window_;
  36. Glib::RefPtr<Gtk::Application> app_;
  37. Gtk::Window* window_ = nullptr;
  38. Gtk::DrawingArea* drawing_area_ = nullptr;
  39. Gtk::Widget* content_widget_ = nullptr;
  40. bool cursor_visible_ = true;
  41. sigc::connection cursor_timer_connection_;
  42. std::unique_ptr<GtkRenderer> gtk_renderer_;
  43. std::vector<std::shared_ptr<GtkWindowController>> window_controllers_;
  44. protected:
  45. void on_activate();
  46. void on_draw(const Cairo::RefPtr<Cairo::Context>& cr, int width, int height);
  47. bool on_cursor_blink();
  48. void rebuild_layout();
  49. Gtk::Widget* create_widget_for_layout_node(std::shared_ptr<LayoutNode> node);
  50. };
  51. std::unique_ptr<IEditorView> create_gtk_editor();
  52. } // namespace lumacs