Added SkinneableTheme class. Thanks to Ilija Melentijevic for the graphics.

This commit is contained in:
David Capello 2009-11-21 20:02:31 +00:00
parent f6821908cc
commit 5d64181f16
15 changed files with 1969 additions and 131 deletions

View File

@ -5,6 +5,11 @@ AUTHORS
David Capello <davidcapello@gmail.com> David Capello <davidcapello@gmail.com>
Programmer, designer, and maintainer. Programmer, designer, and maintainer.
Ilija Melentijevic
New GUI skin (from ASE 0.8).
http://ilkke.blogspot.com/
http://www.pixeljoint.com/p/9270.htm
Trent Gamblin Trent Gamblin
Mac OS X packager. Mac OS X packager.
@ -21,6 +26,7 @@ AUTHORS
Elio Cuevas Gómez Elio Cuevas Gómez
Emmanuel Rousseau (God_Cells) Emmanuel Rousseau (God_Cells)
Hernán Echegoyemberry Hernán Echegoyemberry
Ilija Melentijevic (iLKke)
Jon Rafkind (kazzmir) Jon Rafkind (kazzmir)
Jonathan Taylor Jonathan Taylor
Jorge Ramírez Flores Jorge Ramírez Flores

View File

@ -1,3 +1,8 @@
2009-11-21 David Capello <davidcapello@gmail.com>
* src/modules/skinneable_theme.h (jtheme): Added SkinneableTheme
class. Thanks to Ilija Melentijevic for the graphics.
2009-11-17 David Capello <davidcapello@gmail.com> 2009-11-17 David Capello <davidcapello@gmail.com>
* src/raster/layer.h (Layer, LayerImage, LayerFolder): Converted * src/raster/layer.h (Layer, LayerImage, LayerFolder): Converted

View File

@ -5,8 +5,7 @@ NEWS
0.8 0.8
--- ---
+ Internal refactoring of commands to support record/play macros in + New ASE skin created by Ilija Melentijevic.
the near future.
0.7.2 0.7.2
----- -----

View File

@ -167,6 +167,7 @@ COMMON_SOURCES = \
src/modules/palettes.cpp \ src/modules/palettes.cpp \
src/modules/recent.cpp \ src/modules/recent.cpp \
src/modules/rootmenu.cpp \ src/modules/rootmenu.cpp \
src/modules/skinneable_theme.cpp \
src/modules/tools.cpp \ src/modules/tools.cpp \
src/raster/algo.cpp \ src/raster/algo.cpp \
src/raster/algofill.cpp \ src/raster/algofill.cpp \

View File

@ -76,6 +76,7 @@ ase_files="config.h \
data/fonts/*.pcx \ data/fonts/*.pcx \
data/jids/*.jid \ data/jids/*.jid \
data/palettes/*.col \ data/palettes/*.col \
data/skins/*.png \
data/tips/*.pcx \ data/tips/*.pcx \
data/tips/tips.en \ data/tips/tips.en \
docs/*.pdf \ docs/*.pdf \
@ -184,6 +185,7 @@ $1/docs/licenses/*.txt"
$1/data/aseicon.* \ $1/data/aseicon.* \
$1/data/fonts/*.pcx \ $1/data/fonts/*.pcx \
$1/data/palettes/*.col \ $1/data/palettes/*.col \
$1/data/skins/*.png \
$1/data/tips/*.pcx \ $1/data/tips/*.pcx \
$1/docs/*.pdf" $1/docs/*.pdf"
} }

View File

@ -541,9 +541,9 @@ void draw_color_button(BITMAP* bmp,
int x1, int y1, int x2, int y2, int x1, int y1, int x2, int y2,
int b0, int b1, int b2, int b3, int b0, int b1, int b2, int b3,
int imgtype, color_t color, int imgtype, color_t color,
bool hot, bool drag) bool hot, bool drag,
int bg)
{ {
int face = ji_color_face();
int fore = ji_color_foreground(); int fore = ji_color_foreground();
draw_color(bmp, x1, y1, x2, y2, imgtype, color); draw_color(bmp, x1, y1, x2, y2, imgtype, color);
@ -571,26 +571,26 @@ void draw_color_button(BITMAP* bmp,
} }
if (b0) { if (b0) {
hline(bmp, x1, y1, x1+1, face); hline(bmp, x1, y1, x1+1, bg);
putpixel(bmp, x1, y1+1, face); putpixel(bmp, x1, y1+1, bg);
putpixel(bmp, x1+1, y1+1, fore); putpixel(bmp, x1+1, y1+1, fore);
} }
if (b1) { if (b1) {
hline(bmp, x2-1, y1, x2, face); hline(bmp, x2-1, y1, x2, bg);
putpixel(bmp, x2, y1+1, face); putpixel(bmp, x2, y1+1, bg);
putpixel(bmp, x2-1, y1+1, fore); putpixel(bmp, x2-1, y1+1, fore);
} }
if (b2) { if (b2) {
putpixel(bmp, x1, y2-1, face); putpixel(bmp, x1, y2-1, bg);
hline(bmp, x1, y2, x1+1, face); hline(bmp, x1, y2, x1+1, bg);
putpixel(bmp, x1+1, y2-1, fore); putpixel(bmp, x1+1, y2-1, fore);
} }
if (b3) { if (b3) {
putpixel(bmp, x2, y2-1, face); putpixel(bmp, x2, y2-1, bg);
hline(bmp, x2-1, y2, x2, face); hline(bmp, x2-1, y2, x2, bg);
putpixel(bmp, x2-1, y2-1, fore); putpixel(bmp, x2-1, y2-1, fore);
} }

View File

@ -121,7 +121,8 @@ void draw_color_button(BITMAP* bmp,
int x1, int y1, int x2, int y2, int x1, int y1, int x2, int y2,
int b0, int b1, int b2, int b3, int b0, int b1, int b2, int b3,
int imgtype, color_t color, int imgtype, color_t color,
bool hot, bool drag); bool hot, bool drag,
int bg);
void draw_progress_bar(BITMAP* bmp, void draw_progress_bar(BITMAP* bmp,
int x1, int y1, int x2, int y2, int x1, int y1, int x2, int y2,
float progress); float progress);

View File

@ -18,12 +18,12 @@
#include "config.h" #include "config.h"
#include <list>
#include <vector>
#include <cassert>
#include <algorithm> #include <algorithm>
#include <allegro.h> #include <allegro.h>
#include <allegro/internal/aintern.h> #include <allegro/internal/aintern.h>
#include <cassert>
#include <list>
#include <vector>
#ifdef ALLEGRO_WINDOWS #ifdef ALLEGRO_WINDOWS
#include <winalleg.h> #include <winalleg.h>
@ -32,7 +32,6 @@
#include "jinete/jinete.h" #include "jinete/jinete.h"
#include "jinete/jintern.h" #include "jinete/jintern.h"
#include "ui_context.h"
#include "commands/command.h" #include "commands/command.h"
#include "commands/commands.h" #include "commands/commands.h"
#include "commands/params.h" #include "commands/params.h"
@ -49,12 +48,14 @@
#include "modules/gui.h" #include "modules/gui.h"
#include "modules/palettes.h" #include "modules/palettes.h"
#include "modules/rootmenu.h" #include "modules/rootmenu.h"
#include "modules/skinneable_theme.h"
#include "modules/tools.h" #include "modules/tools.h"
#include "raster/sprite.h" #include "raster/sprite.h"
#include "sprite_wrappers.h"
#include "ui_context.h"
#include "util/recscr.h" #include "util/recscr.h"
#include "widgets/editor.h" #include "widgets/editor.h"
#include "widgets/statebar.h" #include "widgets/statebar.h"
#include "sprite_wrappers.h"
#define REBUILD_RECENT_LIST 2 #define REBUILD_RECENT_LIST 2
#define REFRESH_FULL_SCREEN 4 #define REFRESH_FULL_SCREEN 4
@ -128,6 +129,7 @@ struct Monitor
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
static JWidget manager = NULL; static JWidget manager = NULL;
static JTheme ase_theme = NULL;
static int monitor_timer = -1; static int monitor_timer = -1;
static MonitorList* monitors = NULL; static MonitorList* monitors = NULL;
@ -281,7 +283,7 @@ int init_module_gui()
jwidget_add_hook(manager, JI_WIDGET, manager_msg_proc, NULL); jwidget_add_hook(manager, JI_WIDGET, manager_msg_proc, NULL);
/* setup the standard jinete theme for widgets */ /* setup the standard jinete theme for widgets */
ji_set_standard_theme(); ji_set_theme(ase_theme = new SkinneableTheme());
/* set hook to translate strings */ /* set hook to translate strings */
ji_set_translation_hook(msgids_get); ji_set_translation_hook(msgids_get);
@ -348,6 +350,8 @@ void exit_module_gui()
icon_buttons = NULL; icon_buttons = NULL;
jmanager_free(manager); jmanager_free(manager);
ji_set_theme(NULL);
delete ase_theme;
remove_keyboard(); remove_keyboard();
remove_mouse(); remove_mouse();

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,345 @@
/* ASE - Allegro Sprite Editor
* Copyright (C) 2001-2009 David Capello
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef MODULES_SKINNEABLE_THEME_H_INCLUDED
#define MODULES_SKINNEABLE_THEME_H_INCLUDED
#include <allegro/color.h>
#include "jinete/jtheme.h"
enum {
PART_CURSOR_NORMAL,
PART_CURSOR_NORMAL_ADD,
PART_CURSOR_FORBIDDEN,
PART_CURSOR_HAND,
PART_CURSOR_SCROLL,
PART_CURSOR_MOVE,
PART_CURSOR_SIZE_TL,
PART_CURSOR_SIZE_T,
PART_CURSOR_SIZE_TR,
PART_CURSOR_SIZE_L,
PART_CURSOR_SIZE_R,
PART_CURSOR_SIZE_BL,
PART_CURSOR_SIZE_B,
PART_CURSOR_SIZE_BR,
PART_CURSOR_EYEDROPPER,
PART_RADIO_NORMAL,
PART_RADIO_SELECTED,
PART_RADIO_DISABLED,
PART_CHECK_NORMAL,
PART_CHECK_SELECTED,
PART_CHECK_DISABLED,
PART_CHECK_FOCUS_NW,
PART_CHECK_FOCUS_N,
PART_CHECK_FOCUS_NE,
PART_CHECK_FOCUS_E,
PART_CHECK_FOCUS_SE,
PART_CHECK_FOCUS_S,
PART_CHECK_FOCUS_SW,
PART_CHECK_FOCUS_W,
PART_RADIO_FOCUS_NW,
PART_RADIO_FOCUS_N,
PART_RADIO_FOCUS_NE,
PART_RADIO_FOCUS_E,
PART_RADIO_FOCUS_SE,
PART_RADIO_FOCUS_S,
PART_RADIO_FOCUS_SW,
PART_RADIO_FOCUS_W,
PART_BUTTON_NORMAL_NW,
PART_BUTTON_NORMAL_N,
PART_BUTTON_NORMAL_NE,
PART_BUTTON_NORMAL_E,
PART_BUTTON_NORMAL_SE,
PART_BUTTON_NORMAL_S,
PART_BUTTON_NORMAL_SW,
PART_BUTTON_NORMAL_W,
PART_BUTTON_HOT_NW,
PART_BUTTON_HOT_N,
PART_BUTTON_HOT_NE,
PART_BUTTON_HOT_E,
PART_BUTTON_HOT_SE,
PART_BUTTON_HOT_S,
PART_BUTTON_HOT_SW,
PART_BUTTON_HOT_W,
PART_BUTTON_FOCUSED_NW,
PART_BUTTON_FOCUSED_N,
PART_BUTTON_FOCUSED_NE,
PART_BUTTON_FOCUSED_E,
PART_BUTTON_FOCUSED_SE,
PART_BUTTON_FOCUSED_S,
PART_BUTTON_FOCUSED_SW,
PART_BUTTON_FOCUSED_W,
PART_BUTTON_SELECTED_NW,
PART_BUTTON_SELECTED_N,
PART_BUTTON_SELECTED_NE,
PART_BUTTON_SELECTED_E,
PART_BUTTON_SELECTED_SE,
PART_BUTTON_SELECTED_S,
PART_BUTTON_SELECTED_SW,
PART_BUTTON_SELECTED_W,
PART_SUNKEN_NORMAL_NW,
PART_SUNKEN_NORMAL_N,
PART_SUNKEN_NORMAL_NE,
PART_SUNKEN_NORMAL_E,
PART_SUNKEN_NORMAL_SE,
PART_SUNKEN_NORMAL_S,
PART_SUNKEN_NORMAL_SW,
PART_SUNKEN_NORMAL_W,
PART_SUNKEN_FOCUSED_NW,
PART_SUNKEN_FOCUSED_N,
PART_SUNKEN_FOCUSED_NE,
PART_SUNKEN_FOCUSED_E,
PART_SUNKEN_FOCUSED_SE,
PART_SUNKEN_FOCUSED_S,
PART_SUNKEN_FOCUSED_SW,
PART_SUNKEN_FOCUSED_W,
PART_WINDOW_NW,
PART_WINDOW_N,
PART_WINDOW_NE,
PART_WINDOW_E,
PART_WINDOW_SE,
PART_WINDOW_S,
PART_WINDOW_SW,
PART_WINDOW_W,
PART_MENU_NW,
PART_MENU_N,
PART_MENU_NE,
PART_MENU_E,
PART_MENU_SE,
PART_MENU_S,
PART_MENU_SW,
PART_MENU_W,
PART_WINDOW_CLOSE_BUTTON_NORMAL,
PART_WINDOW_CLOSE_BUTTON_HOT,
PART_WINDOW_CLOSE_BUTTON_SELECTED,
PART_SLIDER_FULL_NW,
PART_SLIDER_FULL_N,
PART_SLIDER_FULL_NE,
PART_SLIDER_FULL_E,
PART_SLIDER_FULL_SE,
PART_SLIDER_FULL_S,
PART_SLIDER_FULL_SW,
PART_SLIDER_FULL_W,
PART_SLIDER_EMPTY_NW,
PART_SLIDER_EMPTY_N,
PART_SLIDER_EMPTY_NE,
PART_SLIDER_EMPTY_E,
PART_SLIDER_EMPTY_SE,
PART_SLIDER_EMPTY_S,
PART_SLIDER_EMPTY_SW,
PART_SLIDER_EMPTY_W,
PART_SLIDER_FULL_FOCUSED_NW,
PART_SLIDER_FULL_FOCUSED_N,
PART_SLIDER_FULL_FOCUSED_NE,
PART_SLIDER_FULL_FOCUSED_E,
PART_SLIDER_FULL_FOCUSED_SE,
PART_SLIDER_FULL_FOCUSED_S,
PART_SLIDER_FULL_FOCUSED_SW,
PART_SLIDER_FULL_FOCUSED_W,
PART_SLIDER_EMPTY_FOCUSED_NW,
PART_SLIDER_EMPTY_FOCUSED_N,
PART_SLIDER_EMPTY_FOCUSED_NE,
PART_SLIDER_EMPTY_FOCUSED_E,
PART_SLIDER_EMPTY_FOCUSED_SE,
PART_SLIDER_EMPTY_FOCUSED_S,
PART_SLIDER_EMPTY_FOCUSED_SW,
PART_SLIDER_EMPTY_FOCUSED_W,
PART_SEPARATOR,
PART_TAB_NORMAL_NW,
PART_TAB_NORMAL_N,
PART_TAB_NORMAL_NE,
PART_TAB_NORMAL_E,
PART_TAB_NORMAL_SE,
PART_TAB_NORMAL_S,
PART_TAB_NORMAL_SW,
PART_TAB_NORMAL_W,
PART_TAB_SELECTED_NW,
PART_TAB_SELECTED_N,
PART_TAB_SELECTED_NE,
PART_TAB_SELECTED_E,
PART_TAB_SELECTED_SE,
PART_TAB_SELECTED_S,
PART_TAB_SELECTED_SW,
PART_TAB_SELECTED_W,
PART_TAB_BOTTOM_SELECTED_NW,
PART_TAB_BOTTOM_SELECTED_N,
PART_TAB_BOTTOM_SELECTED_NE,
PART_TAB_BOTTOM_SELECTED_E,
PART_TAB_BOTTOM_SELECTED_SE,
PART_TAB_BOTTOM_SELECTED_S,
PART_TAB_BOTTOM_SELECTED_SW,
PART_TAB_BOTTOM_SELECTED_W,
PART_TAB_BOTTOM_NORMAL,
PART_TAB_FILLER,
PART_TAB_FILLER_SEPARATOR,
PART_EDITOR_NORMAL_NW,
PART_EDITOR_NORMAL_N,
PART_EDITOR_NORMAL_NE,
PART_EDITOR_NORMAL_E,
PART_EDITOR_NORMAL_SE,
PART_EDITOR_NORMAL_S,
PART_EDITOR_NORMAL_SW,
PART_EDITOR_NORMAL_W,
PART_EDITOR_SELECTED_NW,
PART_EDITOR_SELECTED_N,
PART_EDITOR_SELECTED_NE,
PART_EDITOR_SELECTED_E,
PART_EDITOR_SELECTED_SE,
PART_EDITOR_SELECTED_S,
PART_EDITOR_SELECTED_SW,
PART_EDITOR_SELECTED_W,
PARTS
};
class SkinneableTheme : public jtheme
{
BITMAP* m_sheet_bmp;
BITMAP* m_part[PARTS];
public:
SkinneableTheme();
~SkinneableTheme();
void regen();
BITMAP* set_cursor(int type, int* focus_x, int* focus_y);
void init_widget(JWidget widget);
JRegion get_window_mask(JWidget widget);
void map_decorative_widget(JWidget widget);
int color_foreground();
int color_disabled();
int color_face();
int color_hotface();
int color_selected();
int color_background();
void draw_box(JWidget widget, JRect clip);
void draw_button(JWidget widget, JRect clip);
void draw_check(JWidget widget, JRect clip);
void draw_entry(JWidget widget, JRect clip);
void draw_grid(JWidget widget, JRect clip);
void draw_label(JWidget widget, JRect clip);
void draw_listbox(JWidget widget, JRect clip);
void draw_listitem(JWidget widget, JRect clip);
void draw_menu(JWidget widget, JRect clip);
void draw_menuitem(JWidget widget, JRect clip);
void draw_panel(JWidget widget, JRect clip);
void draw_radio(JWidget widget, JRect clip);
void draw_separator(JWidget widget, JRect clip);
void draw_slider(JWidget widget, JRect clip);
void draw_textbox(JWidget widget, JRect clip);
void draw_view(JWidget widget, JRect clip);
void draw_view_scrollbar(JWidget widget, JRect clip);
void draw_view_viewport(JWidget widget, JRect clip);
void draw_window(JWidget widget, JRect clip);
void draw_window_button(JWidget widget, JRect clip);
int get_button_normal_text_color() const { return makecol(0, 0, 0); }
int get_button_normal_face_color() const { return makecol(198, 198, 198); }
int get_button_hot_text_color() const { return makecol(0, 0, 0); }
int get_button_hot_face_color() const { return makecol(255, 255, 255); }
int get_button_selected_text_color() const { return makecol(255, 255, 255); }
int get_button_selected_face_color() const { return makecol(124, 144, 159); }
int get_button_selected_offset() const { return 0; }
int get_check_hot_face_color() const { return makecol(255, 235, 182); }
int get_check_focus_face_color() const { return makecol(198, 198, 198); }
int get_radio_hot_face_color() const { return makecol(255, 235, 182); }
int get_radio_focus_face_color() const { return makecol(198, 198, 198); }
int get_menuitem_normal_text_color() const { return makecol(0, 0, 0); }
int get_menuitem_normal_face_color() const { return makecol(211, 203, 190); }
int get_menuitem_hot_text_color() const { return makecol(0, 0, 0); }
int get_menuitem_hot_face_color() const { return makecol(255, 235, 182); }
int get_menuitem_highlight_text_color() const { return makecol(255, 255, 255); }
int get_menuitem_highlight_face_color() const { return makecol(124, 144, 159); }
int get_window_face_color() const { return makecol(211, 203, 190); }
int get_window_titlebar_text_color() const { return makecol(255, 255, 255); }
int get_window_titlebar_face_color() const { return makecol(124, 144, 159); }
int get_editor_face_color() const { return makecol(101, 85, 97); }
int get_editor_sprite_border() const { return makecol(0, 0, 0); }
int get_editor_sprite_bottom_edge() const { return makecol(65, 65, 44); }
int get_listitem_normal_text_color() const { return makecol(0, 0, 0); }
int get_listitem_normal_face_color() const { return makecol(255, 255, 255); }
int get_listitem_selected_text_color() const { return makecol(255, 255, 255); }
int get_listitem_selected_face_color() const { return makecol(255, 85, 85); }
int get_slider_empty_text_color() const { return makecol(0, 0, 0); }
int get_slider_empty_face_color() const { return makecol(174, 203, 223); }
int get_slider_full_text_color() const { return makecol(255, 255, 255); }
int get_slider_full_face_color() const { return makecol(125, 146, 158); }
int get_tab_selected_text_color() const { return makecol(255, 255, 255); }
int get_tab_selected_face_color() const { return makecol(125, 146, 158); }
int get_tab_normal_text_color() const { return makecol(0, 0, 0); }
int get_tab_normal_face_color() const { return makecol(199, 199, 199); }
int get_panel_face_color() const { return makecol(125, 146, 158); }
BITMAP* get_part(int part_i) const { return m_part[part_i]; }
// helper functions to draw parts
void draw_bounds(int x1, int y1, int x2, int y2, int nw, int bg);
void draw_bounds2(int x1, int y1, int x2, int y2, int x_mid, int nw1, int nw2, int bg1, int bg2);
void draw_hline(int x1, int y1, int x2, int y2, int part);
private:
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,
int selected_offset);
void draw_entry_cursor(JWidget widget, int x, int y);
void draw_bevel_box(int x1, int y1, int x2, int y2, int c1, int c2, int *bevel);
void less_bevel(int *bevel);
static bool theme_button_msg_proc(JWidget widget, JMessage msg);
};
#endif

View File

@ -32,6 +32,7 @@
#include "modules/gfx.h" #include "modules/gfx.h"
#include "modules/gui.h" #include "modules/gui.h"
#include "modules/palettes.h" #include "modules/palettes.h"
#include "modules/skinneable_theme.h"
#include "raster/image.h" #include "raster/image.h"
#include "raster/palette.h" #include "raster/palette.h"
#include "raster/sprite.h" #include "raster/sprite.h"
@ -279,11 +280,13 @@ static bool colorbar_msg_proc(JWidget widget, JMessage msg)
return TRUE; return TRUE;
case JM_DRAW: { case JM_DRAW: {
SkinneableTheme* theme = static_cast<SkinneableTheme*>(widget->theme);
BITMAP *doublebuffer = create_bitmap(jrect_w(&msg->draw.rect), BITMAP *doublebuffer = create_bitmap(jrect_w(&msg->draw.rect),
jrect_h(&msg->draw.rect)); jrect_h(&msg->draw.rect));
int imgtype = app_get_current_image_type(); int imgtype = app_get_current_image_type();
int x1, y1, x2, y2, v1, v2; int x1, y1, x2, y2, v1, v2;
int c, h, beg, end; int c, h, beg, end;
int bg = theme->get_panel_face_color();
get_info(widget, &beg, &end); get_info(widget, &beg, &end);
@ -292,7 +295,7 @@ static bool colorbar_msg_proc(JWidget widget, JMessage msg)
x2 = x1 + jrect_w(widget->rc) - 1; x2 = x1 + jrect_w(widget->rc) - 1;
y2 = y1 + jrect_h(widget->rc) - 1; y2 = y1 + jrect_h(widget->rc) - 1;
rectfill(doublebuffer, x1, y1, x2, y2, ji_color_face()); rectfill(doublebuffer, x1, y1, x2, y2, bg);
++x1, ++y1, --x2, --y2; ++x1, ++y1, --x2, --y2;
h = (y2-y1+1-(4+FGBGSIZE*2+4)); h = (y2-y1+1-(4+FGBGSIZE*2+4));
@ -308,7 +311,8 @@ static bool colorbar_msg_proc(JWidget widget, JMessage msg)
(c == colorbar->hot || (c == colorbar->hot ||
c == colorbar->hot_editing), c == colorbar->hot_editing),
(colorbar->hot_drag == c && (colorbar->hot_drag == c &&
colorbar->hot_drag != colorbar->hot_drop)); colorbar->hot_drag != colorbar->hot_drop),
bg);
if (color_equals(colorbar->fgcolor, colorbar->color[c])) { if (color_equals(colorbar->fgcolor, colorbar->color[c])) {
int neg = blackandwhite_neg(color_get_red(imgtype, colorbar->fgcolor), int neg = blackandwhite_neg(color_get_red(imgtype, colorbar->fgcolor),
@ -338,7 +342,7 @@ static bool colorbar_msg_proc(JWidget widget, JMessage msg)
(colorbar->hot == HOTCOLOR_FGCOLOR || (colorbar->hot == HOTCOLOR_FGCOLOR ||
colorbar->hot_editing == HOTCOLOR_FGCOLOR), colorbar->hot_editing == HOTCOLOR_FGCOLOR),
(colorbar->hot_drag == HOTCOLOR_FGCOLOR && (colorbar->hot_drag == HOTCOLOR_FGCOLOR &&
colorbar->hot_drag != colorbar->hot_drop)); colorbar->hot_drag != colorbar->hot_drop), bg);
/* draw background color */ /* draw background color */
v1 = y2-4-FGBGSIZE+1; v1 = y2-4-FGBGSIZE+1;
@ -348,7 +352,8 @@ static bool colorbar_msg_proc(JWidget widget, JMessage msg)
(colorbar->hot == HOTCOLOR_BGCOLOR || (colorbar->hot == HOTCOLOR_BGCOLOR ||
colorbar->hot_editing == HOTCOLOR_BGCOLOR), colorbar->hot_editing == HOTCOLOR_BGCOLOR),
(colorbar->hot_drag == HOTCOLOR_BGCOLOR && (colorbar->hot_drag == HOTCOLOR_BGCOLOR &&
colorbar->hot_drag != colorbar->hot_drop)); colorbar->hot_drag != colorbar->hot_drop),
bg);
blit(doublebuffer, ji_screen, 0, 0, blit(doublebuffer, ji_screen, 0, 0,
msg->draw.rect.x1, msg->draw.rect.x1,

View File

@ -229,7 +229,7 @@ static void colorbutton_draw(JWidget widget)
colorbutton->imgtype, colorbutton->imgtype,
colorbutton->color, colorbutton->color,
jwidget_has_mouse(widget), jwidget_has_mouse(widget),
FALSE); FALSE, ji_color_face());
/* draw text */ /* draw text */
color_to_formalstring(colorbutton->imgtype, color_to_formalstring(colorbutton->imgtype,

View File

@ -35,6 +35,7 @@
#include "modules/editors.h" #include "modules/editors.h"
#include "modules/gfx.h" #include "modules/gfx.h"
#include "modules/gui.h" #include "modules/gui.h"
#include "modules/skinneable_theme.h"
#include "modules/palettes.h" #include "modules/palettes.h"
#include "modules/tools.h" #include "modules/tools.h"
#include "raster/brush.h" #include "raster/brush.h"
@ -80,8 +81,13 @@ static void editor_update_candraw(JWidget widget);
JWidget editor_view_new() JWidget editor_view_new()
{ {
JWidget widget = jview_new(); JWidget widget = jview_new();
SkinneableTheme* theme = static_cast<SkinneableTheme*>(widget->theme);
int l = theme->get_part(PART_EDITOR_SELECTED_W)->w;
int t = theme->get_part(PART_EDITOR_SELECTED_N)->h;
int r = theme->get_part(PART_EDITOR_SELECTED_E)->w;
int b = theme->get_part(PART_EDITOR_SELECTED_S)->h;
jwidget_set_border(widget, 3, 3, 3, 3); jwidget_set_border(widget, l, t, r, b);
jview_without_bars(widget); jview_without_bars(widget);
jwidget_add_hook(widget, JI_WIDGET, editor_view_msg_proc, NULL); jwidget_add_hook(widget, JI_WIDGET, editor_view_msg_proc, NULL);
@ -856,37 +862,12 @@ static bool editor_view_msg_proc(JWidget widget, JMessage msg)
JWidget viewport = jview_get_viewport(widget); JWidget viewport = jview_get_viewport(widget);
JWidget child = reinterpret_cast<JWidget>(jlist_first_data(viewport->children)); JWidget child = reinterpret_cast<JWidget>(jlist_first_data(viewport->children));
JRect pos = jwidget_get_rect(widget); JRect pos = jwidget_get_rect(widget);
int has_focus; SkinneableTheme* theme = static_cast<SkinneableTheme*>(widget->theme);
if (child == current_editor) theme->draw_bounds(pos->x1, pos->y1,
has_focus = TRUE; pos->x2-1, pos->y2-1,
else (child == current_editor) ? PART_EDITOR_SELECTED_NW:
has_focus = FALSE; PART_EDITOR_NORMAL_NW, false);
if (has_focus) {
/* 1st border */
jdraw_rect(pos, ji_color_selected());
/* 2nd border */
jrect_shrink(pos, 1);
jdraw_rect(pos, ji_color_selected());
/* 3rd border */
jrect_shrink(pos, 1);
jdraw_rectedge(pos, ji_color_faceshadow(), ji_color_facelight());
}
else {
/* 1st border */
jdraw_rect(pos, ji_color_face());
/* 2nd border */
jrect_shrink(pos, 1);
jdraw_rect(pos, ji_color_face());
/* 3rd border */
jrect_shrink(pos, 1);
jdraw_rectedge(pos, ji_color_faceshadow(), ji_color_facelight());
}
jrect_free(pos); jrect_free(pos);
} }
@ -921,6 +902,8 @@ static bool editor_msg_proc(JWidget widget, JMessage msg)
break; break;
case JM_DRAW: { case JM_DRAW: {
SkinneableTheme* theme = static_cast<SkinneableTheme*>(widget->theme);
if (editor->old_cursor_thick == 0) { if (editor->old_cursor_thick == 0) {
editor->old_cursor_thick = editor->cursor_thick; editor->old_cursor_thick = editor->cursor_thick;
} }
@ -933,7 +916,7 @@ static bool editor_msg_proc(JWidget widget, JMessage msg)
JWidget view = jwidget_get_view(widget); JWidget view = jwidget_get_view(widget);
JRect vp = jview_get_viewport_position(view); JRect vp = jview_get_viewport_position(view);
jdraw_rectfill(vp, makecol(128, 128, 128)); jdraw_rectfill(vp, theme->get_editor_face_color());
draw_emptyset_symbol(vp, makecol(64, 64, 64)); draw_emptyset_symbol(vp, makecol(64, 64, 64));
jrect_free(vp); jrect_free(vp);
@ -953,14 +936,15 @@ static bool editor_msg_proc(JWidget widget, JMessage msg)
jrectexclude(ji_screen, jrectexclude(ji_screen,
widget->rc->x1, widget->rc->y1, widget->rc->x1, widget->rc->y1,
widget->rc->x2-1, widget->rc->y2-1, widget->rc->x2-1, widget->rc->y2-1,
x1-1, y1-1, x2+1, y2+1, makecol(128, 128, 128)); x1-1, y1-1, x2+1, y2+2, theme->get_editor_face_color());
/* draw the sprite in the editor */ /* draw the sprite in the editor */
editor_draw_sprite(widget, 0, 0, editor_draw_sprite(widget, 0, 0,
editor->sprite->w-1, editor->sprite->h-1); editor->sprite->w-1, editor->sprite->h-1);
/* draw the sprite boundary */ /* draw the sprite boundary */
rect(ji_screen, x1-1, y1-1, x2+1, y2+1, makecol(0, 0, 0)); rect(ji_screen, x1-1, y1-1, x2+1, y2+1, theme->get_editor_sprite_border());
hline(ji_screen, x1-1, y2+2, x2+1, theme->get_editor_sprite_bottom_edge());
/* draw the grid */ /* draw the grid */
if (get_view_grid()) if (get_view_grid())
@ -1233,7 +1217,9 @@ static bool editor_msg_proc(JWidget widget, JMessage msg)
int dz = jmouse_z(1) - jmouse_z(0); int dz = jmouse_z(1) - jmouse_z(0);
/* with the ALT */ /* with the ALT */
if (has_only_shifts(msg, KB_ALT_FLAG)) { if (!(msg->any.shifts & (KB_SHIFT_FLAG |
KB_ALT_FLAG |
KB_CTRL_FLAG))) {
JWidget view = jwidget_get_view(widget); JWidget view = jwidget_get_view(widget);
JRect vp = jview_get_viewport_position(view); JRect vp = jview_get_viewport_position(view);
int x, y, zoom; int x, y, zoom;

View File

@ -26,21 +26,29 @@
#include "modules/gfx.h" #include "modules/gfx.h"
#include "modules/gui.h" #include "modules/gui.h"
#include "modules/skinneable_theme.h"
#include "widgets/tabs.h" #include "widgets/tabs.h"
#define CALC_TAB_WIDTH(widget, tab) \ #define CALC_TAB_WIDTH(widget, tab) \
(4 + text_length(widget->font(), tab->text) + 4) (4 + text_length(widget->font(), tab->text.c_str()) + 4)
#define ARROW_W 12 #define ARROW_W 12
#define HAS_ARROWS ((jwidget_get_parent(tabs->button_left) == widget)) #define HAS_ARROWS ((jwidget_get_parent(tabs->button_left) == widget))
typedef struct Tab struct Tab
{ {
char *text; std::string text;
void *data; void *data;
int width; int width;
} Tab;
Tab(const char* text, void* data)
{
this->text = text;
this->data = data;
this->width = 0;
}
};
typedef struct Tabs typedef struct Tabs
{ {
@ -66,9 +74,6 @@ static void set_scroll_x(JWidget widget, int scroll_x);
static void calculate_hot(JWidget widget); static void calculate_hot(JWidget widget);
static void draw_bevel_box(JRect box, int c1, int c2, int bottom); static void draw_bevel_box(JRect box, int c1, int c2, int bottom);
static Tab *tab_new(const char *text, void *data);
static void tab_free(Tab *tab);
/**************************************************************/ /**************************************************************/
/* Tabs */ /* Tabs */
/**************************************************************/ /**************************************************************/
@ -110,7 +115,7 @@ JWidget tabs_new(void (*select_callback)(JWidget tabs, void *data, int button))
void tabs_append_tab(JWidget widget, const char *text, void *data) void tabs_append_tab(JWidget widget, const char *text, void *data)
{ {
Tabs* tabs = reinterpret_cast<Tabs*>(jwidget_get_data(widget, tabs_type())); Tabs* tabs = reinterpret_cast<Tabs*>(jwidget_get_data(widget, tabs_type()));
Tab *tab = tab_new(text, data); Tab *tab = new Tab(text, data);
tab->width = CALC_TAB_WIDTH(widget, tab); tab->width = CALC_TAB_WIDTH(widget, tab);
jlist_append(tabs->list_of_tabs, tab); jlist_append(tabs->list_of_tabs, tab);
@ -128,7 +133,7 @@ void tabs_remove_tab(JWidget widget, void *data)
if (tab) { if (tab) {
jlist_remove(tabs->list_of_tabs, tab); jlist_remove(tabs->list_of_tabs, tab);
tab_free(tab); delete tab;
/* update scroll (in the same position if we can */ /* update scroll (in the same position if we can */
set_scroll_x(widget, tabs->scroll_x); set_scroll_x(widget, tabs->scroll_x);
@ -143,12 +148,8 @@ void tabs_set_text_for_tab(JWidget widget, const char *text, void *data)
Tab *tab = get_tab_by_data(widget, data); Tab *tab = get_tab_by_data(widget, data);
if (tab) { if (tab) {
/* free old text */
if (tab->text)
jfree(tab->text);
/* change text of the tab */ /* change text of the tab */
tab->text = jstrdup(text); tab->text = text;
tab->width = CALC_TAB_WIDTH(widget, tab); tab->width = CALC_TAB_WIDTH(widget, tab);
/* make it visible (if it's the selected) */ /* make it visible (if it's the selected) */
@ -192,6 +193,7 @@ static int tabs_type()
static bool tabs_msg_proc(JWidget widget, JMessage msg) static bool tabs_msg_proc(JWidget widget, JMessage msg)
{ {
Tabs* tabs = reinterpret_cast<Tabs*>(jwidget_get_data(widget, tabs_type())); Tabs* tabs = reinterpret_cast<Tabs*>(jwidget_get_data(widget, tabs_type()));
SkinneableTheme* theme = static_cast<SkinneableTheme*>(widget->theme);
switch (msg->type) { switch (msg->type) {
@ -199,7 +201,7 @@ static bool tabs_msg_proc(JWidget widget, JMessage msg)
JLink link; JLink link;
JI_LIST_FOR_EACH(tabs->list_of_tabs, link) JI_LIST_FOR_EACH(tabs->list_of_tabs, link)
tab_free(reinterpret_cast<Tab*>(link->data)); delete reinterpret_cast<Tab*>(link->data); // tab
jwidget_free(tabs->button_left); jwidget_free(tabs->button_left);
jwidget_free(tabs->button_right); jwidget_free(tabs->button_right);
@ -212,8 +214,10 @@ static bool tabs_msg_proc(JWidget widget, JMessage msg)
} }
case JM_REQSIZE: case JM_REQSIZE:
msg->reqsize.w = msg->reqsize.w = 0; // msg->reqsize.h = 4 + jwidget_get_text_height(widget) + 5;
msg->reqsize.h = 4 + jwidget_get_text_height(widget) + 5; msg->reqsize.h =
theme->get_part(PART_TAB_FILLER)->h +
theme->get_part(PART_TAB_BOTTOM_NORMAL)->h;
return TRUE; return TRUE;
case JM_SETPOS: case JM_SETPOS:
@ -223,62 +227,67 @@ static bool tabs_msg_proc(JWidget widget, JMessage msg)
case JM_DRAW: { case JM_DRAW: {
JRect rect = jwidget_get_rect(widget); JRect rect = jwidget_get_rect(widget);
JRect box = jrect_new(rect->x1-tabs->scroll_x, rect->y1, 0, rect->y2-1); JRect box = jrect_new(rect->x1-tabs->scroll_x, rect->y1,
rect->x1-tabs->scroll_x+2, rect->y1+theme->get_part(PART_TAB_FILLER)->h);
JLink link; JLink link;
theme->draw_hline(box->x1, box->y1, box->x2-1, box->y2-1, PART_TAB_FILLER);
theme->draw_hline(box->x1, box->y2, box->x2-1, rect->y2-1, PART_TAB_BOTTOM_NORMAL);
box->x1 = box->x2;
/* for each tab */ /* for each tab */
JI_LIST_FOR_EACH(tabs->list_of_tabs, link) { JI_LIST_FOR_EACH(tabs->list_of_tabs, link) {
Tab* tab = reinterpret_cast<Tab*>(link->data); Tab* tab = reinterpret_cast<Tab*>(link->data);
int fg, face, bottom;
box->x2 = box->x1 + tab->width; box->x2 = box->x1 + tab->width;
/* is the tab inside the bounds of the widget? */ /* is the tab inside the bounds of the widget? */
if (box->x1 < rect->x2 && box->x2 > rect->x1) { if (box->x1 < rect->x2 && box->x2 > rect->x1) {
int text_color;
int face_color;
/* selected */ /* selected */
if (tabs->selected == tab) { if (tabs->selected == tab) {
fg = ji_color_background(); text_color = theme->get_tab_selected_text_color();
face = ji_color_selected(); face_color = theme->get_tab_selected_face_color();
bottom = face;
} }
/* non-selected */ /* non-selected */
else { else {
fg = ji_color_foreground(); text_color = theme->get_tab_normal_text_color();
face = tabs->hot == tab ? ji_color_hotface(): face_color = theme->get_tab_normal_face_color();
ji_color_face();
bottom = ji_color_facelight();
} }
hline(ji_screen, box->x1, box->y1, box->x2-1, widget->bg_color()); theme->draw_bounds(box->x1, box->y1, box->x2-1, box->y2-1,
rectfill(ji_screen, box->x1+1, box->y1+1, box->x2-2, box->y2-1, face); (tabs->selected == tab) ? PART_TAB_SELECTED_NW:
hline(ji_screen, box->x1, rect->y2-1, box->x2-1, ji_color_selected()); PART_TAB_NORMAL_NW, face_color);
draw_bevel_box(box, if (tabs->selected == tab)
ji_color_facelight(), theme->draw_bounds(box->x1, box->y2, box->x2-1, rect->y2-1,
ji_color_faceshadow(), PART_TAB_BOTTOM_SELECTED_NW,
bottom); theme->get_tab_selected_face_color());
else
theme->draw_hline(box->x1, box->y2, box->x2-1, rect->y2-1, PART_TAB_BOTTOM_NORMAL);
jdraw_text(widget->font(), tab->text, jdraw_text(widget->font(), tab->text.c_str(),
box->x1+4, box->x1+4,
(box->y1+box->y2)/2-text_height(widget->font())/2, (box->y1+box->y2)/2-text_height(widget->font())/2,
fg, face, FALSE); text_color, face_color, false);
} }
box->x1 = box->x2;
box->x2 = box->x1 + theme->get_part(PART_TAB_FILLER_SEPARATOR)->w;
theme->draw_hline(box->x1, box->y1, box->x2-1, box->y2-1, PART_TAB_FILLER_SEPARATOR);
theme->draw_hline(box->x1, box->y2, box->x2-1, rect->y2-1, PART_TAB_BOTTOM_NORMAL);
box->x1 = box->x2; box->x1 = box->x2;
} }
/* fill the gap to the right-side */ /* fill the gap to the right-side */
if (box->x1 < rect->x2) { if (box->x1 < rect->x2) {
rectfill(ji_screen, box->x1, rect->y1, rect->x2-1, rect->y2-3, theme->draw_hline(box->x1, box->y1, rect->x2-1, box->y2-1, PART_TAB_FILLER);
widget->bg_color()); theme->draw_hline(box->x1, box->y2, rect->x2-1, rect->y2-1, PART_TAB_BOTTOM_NORMAL);
hline(ji_screen, box->x1, rect->y2-2, rect->x2-1, ji_color_facelight());
hline(ji_screen, box->x1, rect->y2-1, rect->x2-1, ji_color_selected());
}
/* draw bottom lines below the arrow-buttons */
if (HAS_ARROWS) {
hline(ji_screen, box->x1, rect->y2-2, rect->x2-1, ji_color_facelight());
hline(ji_screen, box->x1, rect->y2-1, rect->x2-1, ji_color_selected());
} }
jrect_free(rect); jrect_free(rect);
@ -532,27 +541,3 @@ static void draw_bevel_box(JRect box, int c1, int c2, int bottom)
vline(ji_screen, box->x1, box->y1+1, box->y2-2, c1); /* left */ vline(ji_screen, box->x1, box->y1+1, box->y2-2, c1); /* left */
vline(ji_screen, box->x2-1, box->y1+1, box->y2-2, c2); /* right */ vline(ji_screen, box->x2-1, box->y1+1, box->y2-2, c2); /* right */
} }
/**************************************************************/
/* Tab */
/**************************************************************/
static Tab *tab_new(const char *text, void *data)
{
Tab *tab = jnew0(Tab, 1);
if (!tab)
return NULL;
tab->text = jstrdup(text);
tab->data = data;
tab->width = 0;
return tab;
}
static void tab_free(Tab *tab)
{
if (tab->text)
jfree(tab->text);
jfree(tab);
}

View File

@ -32,6 +32,7 @@
#include "commands/command.h" #include "commands/command.h"
#include "modules/gfx.h" #include "modules/gfx.h"
#include "modules/gui.h" #include "modules/gui.h"
#include "modules/skinneable_theme.h"
#include "modules/tools.h" #include "modules/tools.h"
#include "widgets/groupbut.h" #include "widgets/groupbut.h"
#include "widgets/toolbar.h" #include "widgets/toolbar.h"
@ -96,6 +97,9 @@ JWidget toolbar_new()
box->user_data[0] = tools; box->user_data[0] = tools;
SkinneableTheme* theme = static_cast<SkinneableTheme*>(box->theme);
box->bg_color(theme->get_panel_face_color());
return box; return box;
} }