// Drawing mixins

// generic drawing of more complex things

// shadows
@mixin shadow($level) {
  @if $level==1 {
    box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
  }
  @if $level==2 {
    box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
  }
  @if $level==3 {
    box-shadow: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23);
  }
  @if $level==4 {
    box-shadow: 0 14px 28px rgba(0,0,0,0.25), 0 10px 10px rgba(0,0,0,0.22);
  }
  @if $level==5 {
    box-shadow: 0 19px 38px rgba(0,0,0,0.30), 0 15px 12px rgba(0,0,0,0.22);
  }
}

// entries
@mixin entry($t, $fc:$selected_bg_color) {
//
// Entries drawing function
//
// $t: entry type
// $fc: focus color
//
// possible $t values:
// normal, focus, insensitive, backdrop, backdrop-insensitive;
//
  @if $t==normal {
    @include shadow(1);
    background-color: if($fc!=$selected_bg_color, $fc, $base_color);
    color: if($fc!=$selected_bg_color, $selected_fg_color, $fg_color);
  }
  @if $t==focus {
    @include shadow(2);
  }
  @if $t==insensitive {
    background-color: $insensitive_base_color;
    color: $insensitive_fg_color;
  }
  @else if $t==flat {
    border-image: -gtk-gradient(radial,
                                center bottom, 0,
                                center bottom, 0.001,
                                to($fc),
                                to(transparent))
                                0 0 0 / 0 0 0px;
    border-radius: 0;
    box-shadow: inset 0 -1px if($fc!=$selected_bg_color, $fc, $fill_color);
    background-color: transparent;
    color: $fg_color;
  }
  @else if $t==flat-focus {
    border-image: -gtk-gradient(radial,
                                center bottom, 0,
                                center bottom, 0.75,
                                to($fc),
                                to(transparent))
                                0 0 2 / 0 0 2px;
    box-shadow: inset 0 -1px if($fc!=$selected_bg_color, $fc, $fill_color);
  }
  @else if $t==flat-insensitive {
    box-shadow: inset 0 -1px $fill_color;
    background-color: transparent;
    color: $insensitive_fg_color;
  }
  @if $t==backdrop {
    color: $backdrop_fg_color;
  }
  @if $t==backdrop-insensitive {
    color: $backdrop_insensitive_fg_color;
  }
}

// buttons
@mixin button($t, $c:$light_color) {
//
// Button drawing function
//
// $t:    button type,
// $c:    base button color for colored* types
//
// possible $t values:
// normal, hover, active, active-hover, insensitive, insensitive-active,
// backdrop, backdrop-insensitive, undecorated;
//
  @if $t==normal {
    @include shadow(1);
    background-color: $c;
    background-image: -gtk-gradient(radial,
                                    center center, 0,
                                    center center, 0.75,
                                    to(gtkalpha(currentColor,0)),
                                    to(transparent)),
                      linear-gradient(to bottom, gtkalpha(currentColor,0));
    color: if($c!=$light_color, $selected_fg_color, $fg_color);
  }
  @else if $t==flat {
    outline-offset: -2px;
    box-shadow: none;
    background-color: gtkalpha(currentColor,0);
    color: if($c!=$light_color, $c, $fg_color);
  }
  @else if $t==hover {
    @include shadow(2);
    background-image: -gtk-gradient(radial,
                                    center center, 0,
                                    center center, 0.001,
                                    to(gtkalpha(currentColor,0)),
                                    to(transparent)),
                      linear-gradient(to bottom, gtkalpha(currentColor,0));
  }
  @else if $t==flat-hover {
    outline-color: gtkalpha(currentColor, 0.1);
    box-shadow: none;
    background-image: -gtk-gradient(radial,
                                    center center, 0,
                                    center center, 0.001,
                                    to(gtkalpha(currentColor,0)),
                                    to(transparent)),
                      linear-gradient(to bottom, gtkalpha(currentColor,0.1));
  }
  @else if $t==active {
    background-image: -gtk-gradient(radial,
                                    center center, 0,
                                    center center, 0.75,
                                    to($fill_color),
                                    to(transparent)),
                      linear-gradient(to bottom, gtkalpha(currentColor,0));
  }
  @else if $t==flat-active {
    outline-color: gtkalpha(currentColor, 0);
    background-image: -gtk-gradient(radial,
                                    center center, 0,
                                    center center, 0.75,
                                    to(gtkalpha(currentColor,0.2)),
                                    to(transparent)),
                      linear-gradient(to bottom, gtkalpha(currentColor,0.0));
  }
  @else if $t==checked {
    background-color: $selected_bg_color;
    color: $selected_fg_color;
  }
  @else if $t==insensitive-checked {
    background-color: gtkalpha(currentColor,0.08);
    color: $selected_bg_color;
  }
  @else if $t==insensitive {
    box-shadow: none;
    background-color: gtkalpha(currentColor,0.08);
    color: $fg_color;
  //  color: gtkalpha(currentColor,0.4);
    > GtkLabel, GtkImage { color: inherit; }
    > GtkLabel, GtkImage { opacity: 0.4; }
  }
  @else if $t==backdrop {
  //  color: gtkalpha(currentColor,0.8);
    > GtkLabel, GtkImage { opacity: 0.8; }
  }
  @else if $t==backdrop-insensitive {
  //  color: gtkalpha(currentColor,0.8 * 0.4);
    > GtkLabel, GtkImage { color: inherit; }
    > GtkLabel, GtkImage { opacity: 0.8 * 0.4; }
  }
}

