Esempio n. 1
0
void draw_color_button(BITMAP* bmp,
                       const Rect& rc,
                       bool outer_nw, bool outer_n, bool outer_ne, bool outer_e,
                       bool outer_se, bool outer_s, bool outer_sw, bool outer_w,
                       PixelFormat pixelFormat, const Color& color, bool hot, bool drag)
{
  SkinTheme* theme = (SkinTheme*)CurrentTheme::get();
  int scale = jguiscale();

  // Draw background (the color)
  draw_color(bmp,
             Rect(rc.x+1*jguiscale(),
                  rc.y+1*jguiscale(),
                  rc.w-((outer_e) ? 2*jguiscale(): 1*jguiscale()),
                  rc.h-((outer_s) ? 2*jguiscale(): 1*jguiscale())), pixelFormat, color);

  // Draw opaque border
  {
    int parts[8] = {
      outer_nw ? PART_COLORBAR_0_NW: PART_COLORBAR_3_NW,
      outer_n  ? PART_COLORBAR_0_N : PART_COLORBAR_2_N,
      outer_ne ? PART_COLORBAR_1_NE: (outer_e ? PART_COLORBAR_3_NE: PART_COLORBAR_2_NE),
      outer_e  ? PART_COLORBAR_1_E : PART_COLORBAR_0_E,
      outer_se ? PART_COLORBAR_3_SE: (outer_s ? PART_COLORBAR_2_SE: (outer_e ? PART_COLORBAR_1_SE: PART_COLORBAR_0_SE)),
      outer_s  ? PART_COLORBAR_2_S : PART_COLORBAR_0_S,
      outer_sw ? PART_COLORBAR_2_SW: (outer_s ? PART_COLORBAR_3_SW: PART_COLORBAR_1_SW),
      outer_w  ? PART_COLORBAR_0_W : PART_COLORBAR_1_W,
    };
    theme->draw_bounds_array(bmp, rc.x, rc.y, rc.x+rc.w-1, rc.y+rc.h-1, parts);
  }

  // Draw hot
  if (hot) {
    theme->draw_bounds_nw(bmp,
                          rc.x, rc.y,
                          rc.x+rc.w-1,
                          rc.y+rc.h-1 - (outer_s ? 1*scale: 0),
                          PART_COLORBAR_BORDER_HOTFG_NW);
  }
}
Esempio n. 2
0
void draw_color_button(ui::Graphics* g,
  const Rect& rc, const app::Color& color,
  bool hot, bool drag)
{
  SkinTheme* theme = (SkinTheme*)ui::CurrentTheme::get();
  int scale = ui::guiscale();

  // Draw background (the color)
  draw_color(g,
    Rect(rc.x+1*scale,
      rc.y+1*scale,
      rc.w-2*scale,
      rc.h-2*scale), color);

  // Draw opaque border
  {
    int parts[8] = {
      PART_COLORBAR_0_NW,
      PART_COLORBAR_0_N,
      PART_COLORBAR_1_NE,
      PART_COLORBAR_1_E,
      PART_COLORBAR_3_SE,
      PART_COLORBAR_2_S,
      PART_COLORBAR_2_SW,
      PART_COLORBAR_0_W
    };
    theme->draw_bounds_array(g, rc, parts);
  }

  // Draw hot
  if (hot) {
    theme->draw_bounds_nw(g,
      gfx::Rect(rc.x, rc.y, rc.w, rc.h-1 - 1*scale),
      PART_COLORBAR_BORDER_HOTFG_NW);
  }
}