diff --git a/data/skins/default_skin/sheet.png b/data/skins/default_skin/sheet.png index df4e21f64..27f35ab7f 100644 Binary files a/data/skins/default_skin/sheet.png and b/data/skins/default_skin/sheet.png differ diff --git a/data/skins/default_skin/skin.xml b/data/skins/default_skin/skin.xml index e51a0de98..642f97784 100644 --- a/data/skins/default_skin/skin.xml +++ b/data/skins/default_skin/skin.xml @@ -103,12 +103,9 @@ - - - - + diff --git a/src/modules/gfx.cpp b/src/modules/gfx.cpp index 4e730aa92..8abe0e470 100644 --- a/src/modules/gfx.cpp +++ b/src/modules/gfx.cpp @@ -513,38 +513,15 @@ void draw_color_button(BITMAP* bmp, ji_screen = old_ji_screen; } - // Draw transparent border - set_trans_blender(0, 0, 0, 128); - { - SkinneableTheme* theme = (SkinneableTheme*)ji_get_theme(); - int parts[8] = { - outer_nw ? PART_COLORBAR_BORDER_0_NW: PART_COLORBAR_BORDER_3_NW, - outer_n ? PART_COLORBAR_BORDER_0_N : PART_COLORBAR_BORDER_2_N, - outer_ne ? PART_COLORBAR_BORDER_1_NE: (outer_e ? PART_COLORBAR_BORDER_3_NE: PART_COLORBAR_BORDER_2_NE), - outer_e ? PART_COLORBAR_BORDER_1_E : PART_COLORBAR_BORDER_0_E, - outer_se ? PART_COLORBAR_BORDER_3_SE: (outer_s ? PART_COLORBAR_BORDER_2_SE: (outer_e ? PART_COLORBAR_BORDER_1_SE: PART_COLORBAR_BORDER_0_SE)), - outer_s ? PART_COLORBAR_BORDER_2_S : PART_COLORBAR_BORDER_0_S, - outer_sw ? PART_COLORBAR_BORDER_2_SW: (outer_s ? PART_COLORBAR_BORDER_3_SW: PART_COLORBAR_BORDER_1_SW), - outer_w ? PART_COLORBAR_BORDER_0_W : PART_COLORBAR_BORDER_1_W, - }; - BITMAP* old_ji_screen = ji_screen; // TODO fix this ugly hack - ji_screen = bmp; - theme->draw_trans_bounds0(rc.x, rc.y, rc.x+rc.w-1, rc.y+rc.h-1, parts); - ji_screen = old_ji_screen; - } - set_trans_blender(0, 0, 0, 0); - // Draw hot if (hot) { - set_trans_blender(0, 0, 0, 128); BITMAP* old_ji_screen = ji_screen; // TODO fix this ugly hack ji_screen = bmp; theme->draw_trans_bounds(rc.x, rc.y, rc.x+rc.w-1, rc.y+rc.h-1 - (outer_s ? 1*scale: 0), - PART_COLORBAR_BORDER_FG_NW); + PART_COLORBAR_BORDER_HOTFG_NW); ji_screen = old_ji_screen; - set_trans_blender(0, 0, 0, 0); } } diff --git a/src/modules/skinneable_theme.cpp b/src/modules/skinneable_theme.cpp index 11a6591fa..88a531f91 100644 --- a/src/modules/skinneable_theme.cpp +++ b/src/modules/skinneable_theme.cpp @@ -126,12 +126,9 @@ SkinneableTheme::SkinneableTheme() sheet_mapping["colorbar_1"] = PART_COLORBAR_1_NW; sheet_mapping["colorbar_2"] = PART_COLORBAR_2_NW; sheet_mapping["colorbar_3"] = PART_COLORBAR_3_NW; - sheet_mapping["colorbar_border_0"] = PART_COLORBAR_BORDER_0_NW; - sheet_mapping["colorbar_border_1"] = PART_COLORBAR_BORDER_1_NW; - sheet_mapping["colorbar_border_2"] = PART_COLORBAR_BORDER_2_NW; - sheet_mapping["colorbar_border_3"] = PART_COLORBAR_BORDER_3_NW; sheet_mapping["colorbar_border_fg"] = PART_COLORBAR_BORDER_FG_NW; sheet_mapping["colorbar_border_bg"] = PART_COLORBAR_BORDER_BG_NW; + sheet_mapping["colorbar_border_hotfg"] = PART_COLORBAR_BORDER_HOTFG_NW; reload_skin(); } @@ -234,7 +231,7 @@ void SkinneableTheme::regen() cursors_info[c].focusx = focusx; cursors_info[c].focusy = focusy; - m_cursors[c] = cropPartFromSheet(m_cursors[c], x, y, w, h); + m_cursors[c] = cropPartFromSheet(m_cursors[c], x, y, w, h, true); break; } @@ -314,24 +311,31 @@ void SkinneableTheme::regen() dirs_free(dirs); } -BITMAP* SkinneableTheme::cropPartFromSheet(BITMAP* bmp, int x, int y, int w, int h) +BITMAP* SkinneableTheme::cropPartFromSheet(BITMAP* bmp, int x, int y, int w, int h, bool cursor) { + int colordepth = (cursor ? bitmap_color_depth(screen): 32); + if (bmp && (bmp->w != w || bmp->h != h || - bitmap_color_depth(bmp) != bitmap_color_depth(screen))) { + bitmap_color_depth(bmp) != colordepth)) { destroy_bitmap(bmp); bmp = NULL; } if (!bmp) - bmp = create_bitmap(w, h); + bmp = create_bitmap_ex(colordepth, w, h); - clear_to_color(bmp, bitmap_mask_color(bmp)); + if (cursor) { + clear_to_color(bmp, bitmap_mask_color(bmp)); - set_alpha_blender(); - draw_trans_sprite(bmp, m_sheet_bmp, -x, -y); - set_trans_blender(0, 0, 0, 0); + set_alpha_blender(); + draw_trans_sprite(bmp, m_sheet_bmp, -x, -y); + set_trans_blender(0, 0, 0, 0); + } + else { + blit(m_sheet_bmp, bmp, x, y, 0, 0, w, h); + } return ji_apply_guiscale(bmp); } @@ -717,10 +721,11 @@ void SkinneableTheme::draw_check(JWidget widget, JRect clip) draw_textstring(NULL, -1, bg, false, widget, &text, 0); /* icon */ - draw_sprite(ji_screen, - jwidget_is_selected(widget) ? m_part[PART_CHECK_SELECTED]: - m_part[PART_CHECK_NORMAL], - icon.x1, icon.y1); + set_alpha_blender(); + draw_trans_sprite(ji_screen, + jwidget_is_selected(widget) ? m_part[PART_CHECK_SELECTED]: + m_part[PART_CHECK_NORMAL], + icon.x1, icon.y1); // draw focus if (jwidget_has_focus(widget)) { @@ -915,7 +920,8 @@ void SkinneableTheme::draw_menuitem(JWidget widget, JRect clip) int x = widget->rc->x1+4-icon->w/2; int y = (widget->rc->y1+widget->rc->y2)/2-icon->h/2; - draw_sprite(ji_screen, icon, x, y); + set_alpha_blender(); + draw_trans_sprite(ji_screen, icon, x, y); } /* text */ @@ -1007,10 +1013,11 @@ void SkinneableTheme::draw_radio(JWidget widget, JRect clip) draw_textstring(NULL, -1, bg, false, widget, &text, 0); /* icon */ - draw_sprite(ji_screen, - jwidget_is_selected(widget) ? m_part[PART_RADIO_SELECTED]: - m_part[PART_RADIO_NORMAL], - icon.x1, icon.y1); + set_alpha_blender(); + draw_trans_sprite(ji_screen, + jwidget_is_selected(widget) ? m_part[PART_RADIO_SELECTED]: + m_part[PART_RADIO_NORMAL], + icon.x1, icon.y1); // draw focus if (jwidget_has_focus(widget)) { @@ -1266,7 +1273,8 @@ void SkinneableTheme::draw_combobox_button(JWidget widget, JRect clip) get_button_selected_offset(), get_button_selected_offset()); - draw_sprite(ji_screen, icon_bmp, icon.x1, icon.y1); + set_alpha_blender(); + draw_trans_sprite(ji_screen, icon_bmp, icon.x1, icon.y1); } void SkinneableTheme::draw_textbox(JWidget widget, JRect clip) @@ -1398,7 +1406,8 @@ void SkinneableTheme::draw_frame_button(JWidget widget, JRect clip) else part = PART_WINDOW_CLOSE_BUTTON_NORMAL; - draw_sprite(ji_screen, m_part[part], widget->rc->x1, widget->rc->y1); + set_alpha_blender(); + draw_trans_sprite(ji_screen, m_part[part], widget->rc->x1, widget->rc->y1); } int SkinneableTheme::get_bg_color(JWidget widget) @@ -1568,7 +1577,8 @@ void SkinneableTheme::draw_bounds0(int x1, int y1, int x2, int y2, int parts[8]) int sw = parts[6]; int w = parts[7]; - draw_bounds_template(nw, n, ne, e, se, s, sw, w, draw_sprite); + set_alpha_blender(); + draw_bounds_template(nw, n, ne, e, se, s, sw, w, draw_trans_sprite); } void SkinneableTheme::draw_trans_bounds0(int x1, int y1, int x2, int y2, int parts[8]) @@ -1587,10 +1597,11 @@ void SkinneableTheme::draw_trans_bounds0(int x1, int y1, int x2, int y2, int par void SkinneableTheme::draw_bounds(int x1, int y1, int x2, int y2, int nw, int bg) { + set_alpha_blender(); draw_bounds_template(nw+0, nw+1, nw+2, nw+3, - nw+4, nw+5, nw+6, nw+7, draw_sprite); + nw+4, nw+5, nw+6, nw+7, draw_trans_sprite); - // Background + // Center if (bg >= 0) { x1 += m_part[nw+7]->w; y1 += m_part[nw+1]->h; @@ -1627,14 +1638,23 @@ void SkinneableTheme::draw_hline(int x1, int y1, int x2, int y2, int part) { int x; + set_alpha_blender(); + for (x = x1; x <= x2-m_part[part]->w; x += m_part[part]->w) { - draw_sprite(ji_screen, m_part[part], x, y1); + draw_trans_sprite(ji_screen, m_part[part], x, y1); } - if (x <= x2) - blit(m_part[part], ji_screen, 0, 0, x, y1, x2-x+1, m_part[part]->h); + if (x <= x2) { + int cx1, cy1, cx2, cy2; + get_clip_rect(ji_screen, &cx1, &cy1, &cx2, &cy2); + + if (my_add_clip_rect(ji_screen, x, y1, x2, y1+m_part[part]->h-1)) + draw_trans_sprite(ji_screen, m_part[part], x, y1); + + set_clip_rect(ji_screen, cx1, cy1, cx2, cy2); + } } void SkinneableTheme::draw_bevel_box(int x1, int y1, int x2, int y2, int c1, int c2, int *bevel) diff --git a/src/modules/skinneable_theme.h b/src/modules/skinneable_theme.h index 8adb7976f..1f3f8075f 100644 --- a/src/modules/skinneable_theme.h +++ b/src/modules/skinneable_theme.h @@ -354,42 +354,6 @@ enum { PART_COLORBAR_3_SW, PART_COLORBAR_3_W, - PART_COLORBAR_BORDER_0_NW, - PART_COLORBAR_BORDER_0_N, - PART_COLORBAR_BORDER_0_NE, - PART_COLORBAR_BORDER_0_E, - PART_COLORBAR_BORDER_0_SE, - PART_COLORBAR_BORDER_0_S, - PART_COLORBAR_BORDER_0_SW, - PART_COLORBAR_BORDER_0_W, - - PART_COLORBAR_BORDER_1_NW, - PART_COLORBAR_BORDER_1_N, - PART_COLORBAR_BORDER_1_NE, - PART_COLORBAR_BORDER_1_E, - PART_COLORBAR_BORDER_1_SE, - PART_COLORBAR_BORDER_1_S, - PART_COLORBAR_BORDER_1_SW, - PART_COLORBAR_BORDER_1_W, - - PART_COLORBAR_BORDER_2_NW, - PART_COLORBAR_BORDER_2_N, - PART_COLORBAR_BORDER_2_NE, - PART_COLORBAR_BORDER_2_E, - PART_COLORBAR_BORDER_2_SE, - PART_COLORBAR_BORDER_2_S, - PART_COLORBAR_BORDER_2_SW, - PART_COLORBAR_BORDER_2_W, - - PART_COLORBAR_BORDER_3_NW, - PART_COLORBAR_BORDER_3_N, - PART_COLORBAR_BORDER_3_NE, - PART_COLORBAR_BORDER_3_E, - PART_COLORBAR_BORDER_3_SE, - PART_COLORBAR_BORDER_3_S, - PART_COLORBAR_BORDER_3_SW, - PART_COLORBAR_BORDER_3_W, - PART_COLORBAR_BORDER_FG_NW, PART_COLORBAR_BORDER_FG_N, PART_COLORBAR_BORDER_FG_NE, @@ -408,6 +372,15 @@ enum { PART_COLORBAR_BORDER_BG_SW, PART_COLORBAR_BORDER_BG_W, + PART_COLORBAR_BORDER_HOTFG_NW, + PART_COLORBAR_BORDER_HOTFG_N, + PART_COLORBAR_BORDER_HOTFG_NE, + PART_COLORBAR_BORDER_HOTFG_E, + PART_COLORBAR_BORDER_HOTFG_SE, + PART_COLORBAR_BORDER_HOTFG_S, + PART_COLORBAR_BORDER_HOTFG_SW, + PART_COLORBAR_BORDER_HOTFG_W, + PARTS }; @@ -527,7 +500,7 @@ public: private: - BITMAP* cropPartFromSheet(BITMAP* bmp, int x, int y, int w, int h); + BITMAP* cropPartFromSheet(BITMAP* bmp, int x, int y, int w, int h, bool cursor = false); int get_bg_color(JWidget widget); void draw_textstring(const char *t, int fg_color, int bg_color, bool fill_bg, JWidget widget, const JRect rect, diff --git a/src/widgets/toolbar.cpp b/src/widgets/toolbar.cpp index b74609422..7e65ec319 100644 --- a/src/widgets/toolbar.cpp +++ b/src/widgets/toolbar.cpp @@ -217,10 +217,12 @@ bool ToolBar::msg_proc(JMessage msg) // Draw the tool icon BITMAP* icon = theme->get_toolicon(tool->getId().c_str()); - if (icon) - draw_sprite(doublebuffer, icon, - toolrc.x+toolrc.w/2-icon->w/2, - toolrc.y+toolrc.h/2-icon->h/2); + if (icon) { + set_alpha_blender(); + draw_trans_sprite(doublebuffer, icon, + toolrc.x+toolrc.w/2-icon->w/2, + toolrc.y+toolrc.h/2-icon->h/2); + } } toolrc = getToolGroupBounds(-1); @@ -234,9 +236,10 @@ bool ToolBar::msg_proc(JMessage msg) // Draw the tool icon BITMAP* icon = theme->get_toolicon("configuration"); if (icon) { - draw_sprite(doublebuffer, icon, - toolrc.x+toolrc.w/2-icon->w/2, - toolrc.y+toolrc.h/2-icon->h/2); + set_alpha_blender(); + draw_trans_sprite(doublebuffer, icon, + toolrc.x+toolrc.w/2-icon->w/2, + toolrc.y+toolrc.h/2-icon->h/2); } ji_screen = old_ji_screen; @@ -573,10 +576,12 @@ bool ToolStrip::msg_proc(JMessage msg) // Draw the tool icon BITMAP* icon = theme->get_toolicon(tool->getId().c_str()); - if (icon) - draw_sprite(doublebuffer, icon, - toolrc.x+toolrc.w/2-icon->w/2, - toolrc.y+toolrc.h/2-icon->h/2); + if (icon) { + set_alpha_blender(); + draw_trans_sprite(doublebuffer, icon, + toolrc.x+toolrc.w/2-icon->w/2, + toolrc.y+toolrc.h/2-icon->h/2); + } } }