using Gtk 4.0;
using Adw 1;

template $GradiaImageSidebar: Adw.Bin {
  child: Adw.ToolbarView {
    top-bar-style: flat;

    [top]
    Adw.HeaderBar {
      centering-policy: loose;
      show-end-title-buttons: false;
      show-start-title-buttons: true;

      [start]
      Gtk.Button open_image_button {
        icon-name: "document-open-symbolic";
        tooltip-text: _("Open Image");
        action-name: "win.open";
      }

      [start]
      Gtk.Button screenshot_button {
        icon-name: "screenshooter-symbolic";
        tooltip-text: _("Take a Screenshot");
        action-name: "win.screenshot";
      }

      [end]
      Gtk.MenuButton about_menu_button {
        icon-name: "open-menu-symbolic";
        tooltip-text: _("Main Menu");
        menu-model: app_menu;
        primary: true;
      }
    }

    content: ScrolledWindow {
      child: Box {
        orientation: vertical;
        margin-start: 12;
        margin-end: 12;
        margin-top: 12;
        margin-bottom: 12;
        valign: start;
        spacing: 12;

        $GradiaDrawingToolsGroup drawing_tools_group {}

        Adw.PreferencesGroup background_selector_group {}

        Adw.PreferencesGroup image_options_group {
          title: _("Image Options");

          Adw.SpinRow padding_row {
            title: _("_Padding");
            use-underline: true;
            numeric: true;

            adjustment: Gtk.Adjustment padding_adjustment {
              value: 5;
              lower: 0;
              upper: 75;
              step-increment: 5;
              page-increment: 5;
            };
          }

          Adw.SpinRow corner_radius_row {
            title: _("_Corner Radius");
            use-underline: true;
            numeric: true;

            adjustment: Gtk.Adjustment corner_radius_adjustment {
              value: 2;
              lower: 0;
              upper: 50;
              step-increment: 1;
              page-increment: 1;
            };
          }

          $GradiaAspectRatioSelector aspect_ratio_selector {
            ratio-changed => $_on_aspect_ratio_changed();
            use-underline: true;
          }

          Adw.ActionRow shadow_strength_row {
            title: _("_Shadow");
            use-underline: true;
            activatable-widget: shadow_strength_scale;

            [suffix]
            Gtk.Scale shadow_strength_scale {
              digits: 0;
              draw-value: true;
              value-pos: right;
              orientation: horizontal;
              valign: center;
              hexpand: true;

              adjustment: Gtk.Adjustment {
                lower: 0;
                upper: 10;
                step-increment: 1;
              };
            }
          }

          Adw.SwitchRow auto_balance_toggle {
            title: _("_Auto Balance");
            use-underline: true;
            activatable: true;
          }

          Adw.ActionRow rotation_row {
            title: _("_Rotation");
            use-underline: true;

            [suffix]
            Box {
              orientation: horizontal;
              spacing: 10;

              Button rotate_left_button {
                icon-name: "object-rotate-left-symbolic";
                tooltip-text: _("Rotate Anticlockwise");
                valign: center;

                styles [
                  "circular",
                  "rotate",
                ]
              }

              Button rotate_right_button {
                icon-name: "object-rotate-right-symbolic";
                tooltip-text: _("Rotate Clockwise");
                valign: center;

                styles [
                  "circular",
                  "rotate",
                ]
              }
            }
          }
        }

        Adw.PreferencesGroup file_info_group {
          title: _("Current File");

          Adw.ActionRow filename_row {
            title: _("Name");
            subtitle: _("N/A");

            styles [
              "property",
            ]
          }

          Adw.ActionRow location_row {
            title: _("_Location");
            use-underline: true;
            subtitle: _("N/A");
            activatable: true;
            activatable-widget: open_folder_button;

            styles [
              "property",
            ]

            [suffix]
            Button open_folder_button {
              valign: center;
              icon-name: "folder-open-symbolic";
              action-name: "win.open-folder";
              tooltip-text: _("Open Folder");

              styles [
                "flat",
              ]
            }
          }

          Adw.ActionRow processed_size_row {
            title: _("Modified image size");
            subtitle: _("N/A");

            styles [
              "property",
            ]
          }
        }
      };
    };

    [bottom]
    Gtk.Box {
      orientation: horizontal;
      halign: center;
      spacing: 15;
      margin-top: 5;
      margin-bottom: 5;

      Gtk.Button save_button {
        icon-name: "document-save-symbolic";
        tooltip-text: _("Save File");
        action-name: "win.save";

        styles [
          "suggested-action",
          "pill",
        ]
      }

      Gtk.Button copy_button {
        icon-name: "edit-copy-symbolic";
        tooltip-text: _("Copy to Clipboard");
        action-name: "win.copy";

        styles [
          "raised",
          "pill",
        ]
      }

      Gtk.Button share_button {
        icon-name: "share-symbolic";
        tooltip-text: _("Share Image");
        action-name: "win.command";
        width-request: 45;

        styles [
          "raised",
          "circular",
        ]
      }

      styles [
        "toolbar",
      ]
    }
  };
}

menu app_menu {
  section {
    item {
      label: _("_Source Snippets");
      action: "win.create-source-image";
    }

    item {
      label: _("_Delete Taken Screenshot(s)");
      action: "win.delete-screenshots";
    }
  }

  section {
    item {
      label: _("_Preferences");
      action: "win.preferences";
    }

    item {
      label: _("_Keyboard Shortcuts");
      action: "win.shortcuts";
    }

    item {
      label: _("D_onate to Gradia");
      action: "win.donate";
    }

    item {
      label: _("_About Gradia");
      action: "win.about";
    }
  }
}

