// Sourced from https://github.com/ndwarshuis/CinnXP

@mixin checkradio() {
  //selection-mode
  @each $s,$as in ('','-selectionmode'),
                    (':hover', '-hover-selectionmode'),
                    (':active', '-active-selectionmode'),
                    (':checked', '-checked-selectionmode'),
                    (':checked:hover', '-checked-hover-selectionmode'),
                    (':checked:active', '-checked-active-selectionmode') {
    .view.content-view.check#{$s}:not(list),
    .content-view .tile check#{$s}:not(list) {
      -gtk-icon-shadow: none;
      -gtk-icon-source: -gtk-scaled(url("assets/checkbox#{$as}.png"));
      background-color: transparent;
      min-width: 41px;
      min-height: 41px;
      background-image: none;
      transition: none;
      box-shadow: none;
      border-width: 0;
    }
  }

  checkbutton.text-button, radiobutton.text-button {
    // this is for a nice focus on check and radios text
    padding: 2px 0;
    outline-offset: 0;

    label:not(:only-child) {
      &:first-child { margin-left: 4px; }
      &:last-child { margin-right: 4px; }
    }
  }

  check,
  radio {
    margin: 0 4px;

    &:only-child { margin: 0; }

    min-height: $check_size;
    min-width: $check_size;
  }

  @each $w,$a in ('check', 'checkbox'),
                 ('radio','radio') {

    //standard checks and radios
    @each $s,$as in ('','-unchecked'),
                    (':hover', '-unchecked-hover'),
                    (':active', '-unchecked-active'),
                    (':disabled','-unchecked-insensitive'),
                    (':indeterminate', '-mixed'),
                    (':indeterminate:hover', '-mixed-hover'),
                    (':indeterminate:selected', '-mixed-active'),
                    (':indeterminate:disabled', '-mixed-insensitive'),
                    (':checked', '-checked'),
                    (':checked:disabled','-checked-insensitive'),
                    (':checked:hover', '-checked-hover'),
                    (':checked:active', '-checked-active') {

      #{$w}#{$s} { -gtk-icon-source: -gtk-scaled(url("assets/#{$a}#{$as}.png")); }

      .view #{$w}#{$s}:selected,
      row:selected #{$w}#{$s} {
        -gtk-icon-source: none;
        background-image: linear-gradient(to bottom, gtkalpha($selected_bg_color, 0.85), gtkalpha($selected_bg_color, 0.85)),
                          url("assets/#{$a}#{$as}.png"); //dirty hack

        &:backdrop { -gtk-icon-source: -gtk-scaled(url("assets/#{$a}#{$as}.png")); }
      }
    }

    //menu
    menu menuitem #{$w} {
      -gtk-icon-shadow: none;

      &:hover, &:disabled, & { -gtk-icon-source: none; }

      &:active,
      &:checked {
        -gtk-icon-source: -gtk-scaled(url("assets/menu-#{$w}-checked.png"));

        &:hover { -gtk-icon-source: -gtk-scaled(url("assets/menu-#{$w}-checked-hover.png")); }

        &:disabled { -gtk-icon-source: -gtk-scaled(url("assets/menu-#{$w}-checked-insensitive.png")); }
      }

      &:indeterminate {
        -gtk-icon-source: -gtk-scaled(url("assets/menu-#{$w}-mixed.png")); 
        
        &:hover { -gtk-icon-source: -gtk-scaled(url("assets/menu-#{$w}-mixed-hover.png")); }

        &:disabled { -gtk-icon-source: -gtk-scaled(url("assets/menu-#{$w}-mixed-insensitive.png")); }
      }
    }
  }
}
