/* main.h -- main window for atomic orbitals display.  -*- C++ -*-
   Copyright (C) 2025 Gerardo Ballabio

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful, but
   WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>. */

#include <string>
#include <gtkmm.h>
#include <epoxy/gl.h>
#include "orbital.h"
#include "sidebar.h"

#ifndef __MAIN_
#define __MAIN_

class MainWindow : public Gtk::ApplicationWindow
{
private:
  // child widgets
  Gtk::Grid toplevel;
  ; OrbitalArea area;
  ; Gtk::ProgressBar progressbar;
  ; Gtk::Grid grid_sidebar;
  ; ; Gtk::Notebook notebook;
  ; ; ; Gtk::Grid grid_controls;
  ; ; ; ; Gtk::Grid grid_orbital;
  ; ; ; ; ; Gtk::Label label_numbers;
  ; ; ; ; ; Gtk::Grid grid_numbers;
  ; ; ; ; ; ; Gtk::Label label_n, label_l, label_m;
  ; ; ; ; ; ; SidebarSpinButton spin_n, spin_l, spin_m;
  ; ; ; ; ; Gtk::Frame frame_orbital;
  ; ; ; ; ; ; Gtk::Label label_orbital;
  ; ; ; ; Gtk::Grid grid_elements;
  ; ; ; ; ; Gtk::Label label_elements;
  ; ; ; ; ; Gtk::Grid grid_modes;
  ; ; ; ; ; ; SidebarCheckButton check_surfaces;
  ; ; ; ; ; ; SidebarCheckButton check_volume;
  ; ; ; ; ; ; SidebarCheckButton check_electron;
  ; ; ; ; ; ; SidebarCheckButton check_axes;
  ; ; ; ; ; ; SidebarCheckButton check_cube;
  ; ; ; ; ; ; SidebarCheckButton check_bar;
  ; ; ; Gtk::Grid grid_settings;
  ; ; ; ; Gtk::Grid grid_grid;
  ; ; ; ; ; Gtk::Label label_grid;
  ; ; ; ; ; Gtk::Grid grid_size;
  ; ; ; ; ; ; Gtk::Label label_size, label_step1, label_step2;
  ; ; ; ; ; ; SidebarSpinButton spin_size, spin_step1, spin_step2;
  ; ; ; ; Gtk::Grid grid_surfaces;
  ; ; ; ; ; Gtk::Label label_surfaces;
  ; ; ; ; ; Gtk::Grid grid_nsurfaces;
  ; ; ; ; ; ; Gtk::Label label_nsurfaces;
  ; ; ; ; ; ; SidebarSpinButton spin_nsurfaces;
  ; ; ; ; Gtk::Grid grid_animation;
  ; ; ; ; ; Gtk::Label label_animation;
  ; ; ; ; ; Gtk::Grid grid_nelectron;
  ; ; ; ; ; ; Gtk::Label label_nelectron;
  ; ; ; ; ; ; SidebarSpinButton spin_nelectron;
  ; ; ; ; Gtk::Grid grid_threads;
  ; ; ; ; ; Gtk::Label label_threads;
  ; ; ; ; ; Gtk::Grid grid_nthreads;
  ; ; ; ; ; ; Gtk::Label label_nthreads;
  ; ; ; ; ; ; SidebarSpinButton spin_nthreads;
  ; ; ; ; Gtk::Frame frame_fps;
  ; ; ; ; ; Gtk::Label label_fps;
  ; ; Gtk::Grid grid_buttons;
  ; ; ; SidebarButton button_help, button_about, button_close;

  sigc::connection timeout;
  bool working, focus_area;
  double t0;
protected:
  virtual bool on_key_press_event(GdkEventKey *event);
  virtual bool on_timeout();
  virtual void on_hide() { area.hide(); notebook.hide(); }
  virtual void on_area_signal_working(bool working_);
  virtual void on_area_signal_press();
  virtual void on_area_signal_fps(double fps_);
  virtual void on_sidebar_signal_press();
  virtual void on_spin_n_signal_value_changed();
  virtual void on_spin_l_signal_value_changed();
  virtual void on_spin_m_signal_value_changed();
  virtual void on_check_surfaces_signal_toggled();
  virtual void on_check_volume_signal_toggled();
  virtual void on_check_electron_signal_toggled();
  virtual void on_check_axes_signal_toggled();
  virtual void on_check_cube_signal_toggled();
  virtual void on_check_bar_signal_toggled();
  virtual void on_spin_size_signal_value_changed();
  virtual void on_spin_step_signal_value_changed();
  virtual void on_spin_nsurfaces_signal_value_changed();
  virtual void on_spin_nelectron_signal_value_changed();
  virtual void on_spin_nthreads_signal_value_changed();
  virtual void on_button_about();
  virtual void on_button_help();
  std::string big_label();
public:
  MainWindow();

  virtual void on_startup(Glib::RefPtr<Gtk::Application> &app);
};

#endif /* __MAIN_ */
