// Drawing mixins

// generic drawing of more complex things

// provide font size in rem, with px fallback
@mixin fontsize($size: 24, $base: 16) {
  font-size: round($size) + pt;
  //font-size: ($size / $base) * 1rem;
}

// 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*1.5), 0 3px 6px rgba(0,0,0,0.23*1.5);
  }
  @if $level==3 {
    box-shadow: 0 10px 20px rgba(0,0,0,0.19*1.5), 0 6px 6px rgba(0,0,0,0.23*1.5);
  }
  @if $level==4 {
    box-shadow: 0 14px 28px rgba(0,0,0,0.25*1.5), 0 10px 10px rgba(0,0,0,0.22*1.5);
  }
  @if $level==5 {
    box-shadow: 0 19px 38px rgba(0,0,0,0.30*1.5), 0 15px 12px rgba(0,0,0,0.22*1.5);
  }
}

// entries

@mixin entry($t, $fc:$selected_bg_color) {
//
// Entries drawing function
//
// $t: entry type
// $fc: focus color
//
// possible $t values:
// normal, focus, insensitive
//
  @if $t==normal {
    background-color: rgba(0, 0, 0, 0.01);
    border-color: transparent;
    box-shadow: inset 0 -1px if($fc!=$selected_bg_color, $fc, $fill_color);

  }
  @if $t==focus {
    border-color: transparent;
    box-shadow: inset 0 -2px if($fc!=$selected_bg_color, $fc, $selected_bg_color);
  }
  @if $t==hover { }
  @if $t==insensitive {
    color: $insensitive_fg_color;
    border-color: transparent;
    box-shadow: inset 0 -1px if($fc!=$selected_bg_color, $fc, $insensitive_fill_color);
  }
}

// buttons

@mixin button($t, $c:$bg_color, $tc:$fg_color) {
//
// Button drawing function
//
// $t:    button type,
// $c:    base button color for colored* types
// $tc:   optional text color for colored* types
//
// possible $t values:
// normal, hover, active, insensitive, undecorated
//
  @if $t==normal {
  //
  // normal button
  //
    color: if($tc!=$fg_color, $tc, $secondary_fg_color);
    background-color: $c;
    border-color: transparent;
    @include shadow(1);
    text-shadow: none;
    icon-shadow: none;
  }
  @if $t==focus {
  //
  // focused button
  //
    color: $tc;
    text-shadow: none;
    icon-shadow: none;
    border-color: transparent;
    box-shadow: 0 0 transparent;
  //  box-shadow: inset 0px 0px 0px 2px $fill_color;
  }

  @else if $t==hover {
  //
  // hovered button
  //
    color: if($tc!=$fg_color, $tc, $fg_color);
    background-color: $c;
    border-color: transparent;
    @include shadow(2);
    text-shadow: none;
    icon-shadow: none;

  }
  @else if $t==active {
  //
  // pushed button
  //
    color: if($tc!=$fg_color, $tc, $fg_color);
    background-color: mix($tc, $c, 20%);
    border-color: transparent;
    @include shadow(2);
    text-shadow: none;
    icon-shadow: none;
  }
  @else if $t==insensitive {
  //
  // insensitive button
  //
    color: if($tc!=$fg_color, $tc, $insensitive_secondary_fg_color);
    background-color: if($c!=$bg_color, $c, $insensitive_fill_color);
    border-color: transparent;
    box-shadow: 0 0 transparent;
    text-shadow: none;
    icon-shadow: none;
  }
  @if $t==flat-normal {
  //
  // normal flat button
  //
    color: if($tc!=$fg_color, $tc, $secondary_fg_color);
    background-color: transparent;
    border-color: transparent;
    box-shadow: 0 0 transparent;
    text-shadow: none;
    icon-shadow: none;
  }
  @if $t==flat-focus {
  //
  // focused flat button
  //
    color: $tc;
    text-shadow: none;
    icon-shadow: none;
    box-shadow: 0 0 transparent;
  //  box-shadow: inset 0px 0px 0px 2px $fill_color;
  }

  @else if $t==flat-hover {
  //
  // hovered flat button
  //
    color: if($tc!=$fg_color, $tc, $fg_color);
    background-color: if($c!=$bg_color, $c, $semi_fill_color);
    border-color: transparent;
    box-shadow: 0 0 transparent;
    text-shadow: none;
    icon-shadow: none;

  }
  @else if $t==flat-active {
  //
  // pushed flat button
  //
    color: if($tc!=$fg_color, $tc, $fg_color);
    background-color: if($c!=$bg_color, $c, $fill_color);
    border-color: transparent;
    box-shadow: 0 0 transparent;
    text-shadow: none;
    icon-shadow: none;
  }
  @else if $t==flat-insensitive {
  //
  // insensitive flat button
  //
    color: if($tc!=$fg_color, $tc, $insensitive_secondary_fg_color);
    background-color: transparent;
    border-color: transparent;
    box-shadow: 0 0 transparent;
    text-shadow: none;
    icon-shadow: none;
  }
  @else if $t==undecorated {
  //
  // reset
  //
    color: inherit;
    background-color: transparent;
    border-color: transparent;
    box-shadow: 0 0 transparent;
    text-shadow: none;
    icon-shadow: none;
  }
}

