Merge she::Color and ui::Color types in gfx::Color

This commit is contained in:
David Capello 2014-06-28 16:10:39 -03:00
parent 901b2acc06
commit 4b7bf5b835
49 changed files with 276 additions and 363 deletions

View File

@ -26,7 +26,7 @@ because they don't depend on any other component.
* [doc](doc/) (base, gfx): Document model library (business layer, replacement of `raster` library). * [doc](doc/) (base, gfx): Document model library (business layer, replacement of `raster` library).
* [net](net/) (base): Networking library to send HTTP requests. * [net](net/) (base): Networking library to send HTTP requests.
* [raster](raster/) (base, gfx): Library to handle graphics entities like sprites, images, frames. * [raster](raster/) (base, gfx): Library to handle graphics entities like sprites, images, frames.
* [she](she/) (allegro): A (Work In Progress) wrapper for Allegro library. * [she](she/) (base, gfx, allegro): A wrapper for the Allegro library.
* [webserver](webserver/) (base): HTTP web server (based on [mongoose](https://github.com/valenok/mongoose)) * [webserver](webserver/) (base): HTTP web server (based on [mongoose](https://github.com/valenok/mongoose))
## Level 2 ## Level 2

View File

@ -32,8 +32,6 @@
#include "raster/palette.h" #include "raster/palette.h"
#include "raster/sprite.h" #include "raster/sprite.h"
using namespace gfx;
// Internal functions // Internal functions
namespace { namespace {
@ -56,43 +54,45 @@ int get_mask_for_bitmap(int depth)
namespace app { namespace app {
ui::Color color_utils::blackandwhite(ui::Color color) gfx::Color color_utils::blackandwhite(gfx::Color color)
{ {
if ((ui::getr(color)*30+ui::getg(color)*59+ui::getb(color)*11)/100 < 128) if ((gfx::getr(color)*30+gfx::getg(color)*59+gfx::getb(color)*11)/100 < 128)
return ui::rgba(0, 0, 0); return gfx::rgba(0, 0, 0);
else else
return ui::rgba(255, 255, 255); return gfx::rgba(255, 255, 255);
} }
ui::Color color_utils::blackandwhite_neg(ui::Color color) gfx::Color color_utils::blackandwhite_neg(gfx::Color color)
{ {
if ((ui::getr(color)*30+ui::getg(color)*59+ui::getb(color)*11)/100 < 128) if ((gfx::getr(color)*30+gfx::getg(color)*59+gfx::getb(color)*11)/100 < 128)
return ui::rgba(255, 255, 255); return gfx::rgba(255, 255, 255);
else else
return ui::rgba(0, 0, 0); return gfx::rgba(0, 0, 0);
} }
ui::Color color_utils::color_for_ui(const app::Color& color) gfx::Color color_utils::color_for_ui(const app::Color& color)
{ {
ui::Color c = ui::ColorNone; gfx::Color c = gfx::ColorNone;
switch (color.getType()) { switch (color.getType()) {
case app::Color::MaskType: case app::Color::MaskType:
c = ui::ColorNone; c = gfx::ColorNone;
break; break;
case app::Color::RgbType: case app::Color::RgbType:
case app::Color::HsvType: case app::Color::HsvType:
c = ui::rgba(color.getRed(), c = gfx::rgba(
color.getGreen(), color.getRed(),
color.getBlue(), 255); color.getGreen(),
color.getBlue(), 255);
break; break;
case app::Color::GrayType: case app::Color::GrayType:
c = ui::rgba(color.getGray(), c = gfx::rgba(
color.getGray(), color.getGray(),
color.getGray(), 255); color.getGray(),
color.getGray(), 255);
break; break;
case app::Color::IndexType: { case app::Color::IndexType: {
@ -100,9 +100,10 @@ ui::Color color_utils::color_for_ui(const app::Color& color)
ASSERT(i >= 0 && i < (int)get_current_palette()->size()); ASSERT(i >= 0 && i < (int)get_current_palette()->size());
uint32_t _c = get_current_palette()->getEntry(i); uint32_t _c = get_current_palette()->getEntry(i);
c = ui::rgba(rgba_getr(_c), c = gfx::rgba(
rgba_getg(_c), rgba_getr(_c),
rgba_getb(_c), 255); rgba_getg(_c),
rgba_getb(_c), 255);
break; break;
} }
@ -120,10 +121,10 @@ raster::color_t color_utils::color_for_image(const app::Color& color, PixelForma
switch (format) { switch (format) {
case IMAGE_RGB: case IMAGE_RGB:
c = rgba(color.getRed(), color.getGreen(), color.getBlue(), 255); c = raster::rgba(color.getRed(), color.getGreen(), color.getBlue(), 255);
break; break;
case IMAGE_GRAYSCALE: case IMAGE_GRAYSCALE:
c = graya(color.getGray(), 255); c = raster::graya(color.getGray(), 255);
break; break;
case IMAGE_INDEXED: case IMAGE_INDEXED:
c = color.getIndex(); c = color.getIndex();
@ -147,10 +148,10 @@ raster::color_t color_utils::color_for_target(const app::Color& color, const Col
switch (colorTarget.pixelFormat()) { switch (colorTarget.pixelFormat()) {
case IMAGE_RGB: case IMAGE_RGB:
c = rgba(color.getRed(), color.getGreen(), color.getBlue(), 255); c = raster::rgba(color.getRed(), color.getGreen(), color.getBlue(), 255);
break; break;
case IMAGE_GRAYSCALE: case IMAGE_GRAYSCALE:
c = graya(color.getGray(), 255); c = raster::graya(color.getGray(), 255);
break; break;
case IMAGE_INDEXED: case IMAGE_INDEXED:
if (color.getType() == app::Color::IndexType) { if (color.getType() == app::Color::IndexType) {

View File

@ -22,9 +22,9 @@
#include "app/color.h" #include "app/color.h"
#include "app/color_target.h" #include "app/color_target.h"
#include "gfx/color.h"
#include "raster/color.h" #include "raster/color.h"
#include "raster/pixel_format.h" #include "raster/pixel_format.h"
#include "ui/color.h"
namespace raster { namespace raster {
class Layer; class Layer;
@ -33,10 +33,10 @@ namespace raster {
namespace app { namespace app {
namespace color_utils { namespace color_utils {
ui::Color blackandwhite(ui::Color color); gfx::Color blackandwhite(gfx::Color color);
ui::Color blackandwhite_neg(ui::Color color); gfx::Color blackandwhite_neg(gfx::Color color);
ui::Color color_for_ui(const app::Color& color); gfx::Color color_for_ui(const app::Color& color);
raster::color_t color_for_image(const app::Color& color, raster::PixelFormat format); raster::color_t color_for_image(const app::Color& color, raster::PixelFormat format);
raster::color_t color_for_layer(const app::Color& color, raster::Layer* layer); raster::color_t color_for_layer(const app::Color& color, raster::Layer* layer);
raster::color_t color_for_target(const app::Color& color, const ColorTarget& colorTarget); raster::color_t color_for_target(const app::Color& color, const ColorTarget& colorTarget);

View File

@ -23,25 +23,25 @@
#include <allegro.h> #include <allegro.h>
#include <allegro/internal/aintern.h> #include <allegro/internal/aintern.h>
#include "ui/color.h" #include "gfx/color.h"
#include "ui/intern.h" #include "ui/intern.h"
#include "ui/system.h" #include "ui/system.h"
#include "ui/theme.h" #include "ui/theme.h"
#include "app/app.h" #include "app/app.h"
#include "app/color_utils.h" #include "app/color_utils.h"
#include "app/ui/editor/editor.h"
#include "app/console.h" #include "app/console.h"
#include "gfx/point.h"
#include "gfx/rect.h"
#include "app/ini_file.h" #include "app/ini_file.h"
#include "app/modules/gfx.h" #include "app/modules/gfx.h"
#include "app/modules/gui.h" #include "app/modules/gui.h"
#include "app/modules/palettes.h" #include "app/modules/palettes.h"
#include "app/ui/editor/editor.h"
#include "app/ui/skin/skin_theme.h"
#include "gfx/point.h"
#include "gfx/rect.h"
#include "raster/blend.h" #include "raster/blend.h"
#include "raster/image.h" #include "raster/image.h"
#include "raster/palette.h" #include "raster/palette.h"
#include "app/ui/skin/skin_theme.h"
namespace app { namespace app {
@ -171,8 +171,8 @@ static void rectgrid(ui::Graphics* g, const gfx::Rect& rc, const gfx::Size& tile
return; return;
int x, y, u, v; int x, y, u, v;
ui::Color c1 = ui::rgba(128, 128, 128); gfx::Color c1 = gfx::rgba(128, 128, 128);
ui::Color c2 = ui::rgba(192, 192, 192); gfx::Color c2 = gfx::rgba(192, 192, 192);
u = 0; u = 0;
v = 0; v = 0;
@ -213,8 +213,8 @@ static void draw_color(ui::Graphics* g, const Rect& rc, const app::Color& color)
g->fillRect(color_utils::color_for_ui(color), rc); g->fillRect(color_utils::color_for_ui(color), rc);
} }
else { else {
g->fillRect(ui::rgba(0, 0, 0), rc); g->fillRect(gfx::rgba(0, 0, 0), rc);
g->drawLine(ui::rgba(255, 255, 255), g->drawLine(gfx::rgba(255, 255, 255),
gfx::Point(rc.x+rc.w-2, rc.y+1), gfx::Point(rc.x+rc.w-2, rc.y+1),
gfx::Point(rc.x+1, rc.y+rc.h-2)); gfx::Point(rc.x+1, rc.y+rc.h-2));
} }

View File

@ -21,9 +21,9 @@
#pragma once #pragma once
#include "app/color.h" #include "app/color.h"
#include "gfx/color.h"
#include "gfx/rect.h" #include "gfx/rect.h"
#include "ui/base.h" #include "ui/base.h"
#include "ui/color.h"
#include "ui/graphics.h" #include "ui/graphics.h"
namespace app { namespace app {

View File

@ -67,7 +67,7 @@ void ColorBar::ScrollableView::onPaint(ui::PaintEvent& ev)
getClientBounds(), getClientBounds(),
hasFocus() ? PART_EDITOR_SELECTED_NW: hasFocus() ? PART_EDITOR_SELECTED_NW:
PART_EDITOR_NORMAL_NW, PART_EDITOR_NORMAL_NW,
ColorNone); gfx::ColorNone);
} }
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////

View File

@ -179,8 +179,8 @@ void ColorButton::onPaint(PaintEvent& ev)
SkinTheme* theme = static_cast<SkinTheme*>(getTheme()); SkinTheme* theme = static_cast<SkinTheme*>(getTheme());
gfx::Rect rc = getClientBounds(); gfx::Rect rc = getClientBounds();
ui::Color bg = getBgColor(); gfx::Color bg = getBgColor();
if (is_transparent(bg)) if (gfx::is_transparent(bg))
bg = theme->getColor(ThemeColor::Face); bg = theme->getColor(ThemeColor::Face);
g->fillRect(bg, rc); g->fillRect(bg, rc);
@ -205,13 +205,13 @@ void ColorButton::onPaint(PaintEvent& ev)
setTextQuiet(str.c_str()); setTextQuiet(str.c_str());
ui::Color textcolor = ui::rgba(255, 255, 255); gfx::Color textcolor = gfx::rgba(255, 255, 255);
if (color.isValid()) if (color.isValid())
textcolor = color_utils::blackandwhite_neg(ui::rgba(color.getRed(), color.getGreen(), color.getBlue())); textcolor = color_utils::blackandwhite_neg(gfx::rgba(color.getRed(), color.getGreen(), color.getBlue()));
gfx::Rect text; gfx::Rect text;
getTextIconInfo(NULL, &text); getTextIconInfo(NULL, &text);
g->drawUIString(getText(), textcolor, ColorNone, text.getOrigin()); g->drawUIString(getText(), textcolor, gfx::ColorNone, text.getOrigin());
} }
void ColorButton::onClick(Event& ev) void ColorButton::onClick(Event& ev)

View File

@ -239,10 +239,10 @@ void ColorSelector::onFixWarningClick(ui::Event& ev)
{ {
try { try {
Palette* newPalette = get_current_palette(); // System current pal Palette* newPalette = get_current_palette(); // System current pal
color_t newColor = rgba( color_t newColor = raster::rgba(
m_color.getRed(), m_color.getRed(),
m_color.getGreen(), m_color.getGreen(),
m_color.getBlue()); m_color.getBlue(), 255);
int index = newPalette->findExactMatch( int index = newPalette->findExactMatch(
m_color.getRed(), m_color.getRed(),
m_color.getGreen(), m_color.getGreen(),

View File

@ -52,17 +52,17 @@ namespace {
} }
void paint(Slider* slider, Graphics* g, const gfx::Rect& rc) { void paint(Slider* slider, Graphics* g, const gfx::Rect& rc) {
ui::Color color = ui::ColorNone; gfx::Color color = gfx::ColorNone;
for (int x=0; x < rc.w; ++x) { for (int x=0; x < rc.w; ++x) {
switch (m_channel) { switch (m_channel) {
case ColorSliders::Red: case ColorSliders::Red:
color = ui::rgba(255 * x / (rc.w-1), m_color.getGreen(), m_color.getBlue()); color = gfx::rgba(255 * x / (rc.w-1), m_color.getGreen(), m_color.getBlue());
break; break;
case ColorSliders::Green: case ColorSliders::Green:
color = ui::rgba(m_color.getRed(), 255 * x / (rc.w-1), m_color.getBlue()); color = gfx::rgba(m_color.getRed(), 255 * x / (rc.w-1), m_color.getBlue());
break; break;
case ColorSliders::Blue: case ColorSliders::Blue:
color = ui::rgba(m_color.getRed(), m_color.getGreen(), 255 * x / (rc.w-1)); color = gfx::rgba(m_color.getRed(), m_color.getGreen(), 255 * x / (rc.w-1));
break; break;
case ColorSliders::Hue: case ColorSliders::Hue:
color = color_utils::color_for_ui(app::Color::fromHsv(360 * x / (rc.w-1), m_color.getSaturation(), m_color.getValue())); color = color_utils::color_for_ui(app::Color::fromHsv(360 * x / (rc.w-1), m_color.getSaturation(), m_color.getValue()));

View File

@ -172,7 +172,7 @@ private:
PART_BRUSH_LINE); PART_BRUSH_LINE);
m_brushTypeButton->ItemChange.connect(&BrushTypeField::onBrushTypeChange, this); m_brushTypeButton->ItemChange.connect(&BrushTypeField::onBrushTypeChange, this);
m_brushTypeButton->setTransparent(true); m_brushTypeButton->setTransparent(true);
m_brushTypeButton->setBgColor(ui::ColorNone); m_brushTypeButton->setBgColor(gfx::ColorNone);
m_popupWindow->addChild(m_brushTypeButton); m_popupWindow->addChild(m_brushTypeButton);
m_popupWindow->openWindow(); m_popupWindow->openWindow();
@ -546,7 +546,7 @@ private:
PART_FREEHAND_ALGO_DOTS); PART_FREEHAND_ALGO_DOTS);
m_freehandAlgoButton->ItemChange.connect(&FreehandAlgorithmField::onFreehandAlgoChange, this); m_freehandAlgoButton->ItemChange.connect(&FreehandAlgorithmField::onFreehandAlgoChange, this);
m_freehandAlgoButton->setTransparent(true); m_freehandAlgoButton->setTransparent(true);
m_freehandAlgoButton->setBgColor(ui::ColorNone); m_freehandAlgoButton->setBgColor(gfx::ColorNone);
m_tooltipManager->addTooltipFor(m_freehandAlgoButton->getButtonAt(0), "Normal trace", JI_TOP); m_tooltipManager->addTooltipFor(m_freehandAlgoButton->getButtonAt(0), "Normal trace", JI_TOP);
m_tooltipManager->addTooltipFor(m_freehandAlgoButton->getButtonAt(1), "Pixel-perfect trace", JI_TOP); m_tooltipManager->addTooltipFor(m_freehandAlgoButton->getButtonAt(1), "Pixel-perfect trace", JI_TOP);

View File

@ -77,7 +77,7 @@ enum {
static int cursor_type = CURSOR_THINCROSS; static int cursor_type = CURSOR_THINCROSS;
static int cursor_negative; static int cursor_negative;
static ui::Color saved_pixel[MAX_SAVED]; static gfx::Color saved_pixel[MAX_SAVED];
static int saved_pixel_n; static int saved_pixel_n;
// These clipping regions are shared between all editors, so we cannot // These clipping regions are shared between all editors, so we cannot
@ -87,13 +87,13 @@ static gfx::Region old_clipping_region;
static void generate_cursor_boundaries(); static void generate_cursor_boundaries();
static void trace_thincross_pixels(ui::Graphics* g, Editor* editor, int x, int y, ui::Color color, Editor::PixelDelegate pixel); static void trace_thincross_pixels(ui::Graphics* g, Editor* editor, int x, int y, gfx::Color color, Editor::PixelDelegate pixel);
static void trace_thickcross_pixels(ui::Graphics* g, Editor* editor, int x, int y, ui::Color color, int thickness, Editor::PixelDelegate pixel); static void trace_thickcross_pixels(ui::Graphics* g, Editor* editor, int x, int y, gfx::Color color, int thickness, Editor::PixelDelegate pixel);
static void trace_brush_bounds(ui::Graphics* g, Editor* editor, int x, int y, ui::Color color, Editor::PixelDelegate pixel); static void trace_brush_bounds(ui::Graphics* g, Editor* editor, int x, int y, gfx::Color color, Editor::PixelDelegate pixel);
static void savepixel(ui::Graphics* g, int x, int y, ui::Color color); static void savepixel(ui::Graphics* g, int x, int y, gfx::Color color);
static void drawpixel(ui::Graphics* g, int x, int y, ui::Color color); static void drawpixel(ui::Graphics* g, int x, int y, gfx::Color color);
static void clearpixel(ui::Graphics* g, int x, int y, ui::Color color); static void clearpixel(ui::Graphics* g, int x, int y, gfx::Color color);
static color_t get_brush_color(Sprite* sprite, Layer* layer); static color_t get_brush_color(Sprite* sprite, Layer* layer);
@ -102,7 +102,7 @@ static color_t get_brush_color(Sprite* sprite, Layer* layer);
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
static app::Color cursor_color; static app::Color cursor_color;
static ui::Color ui_cursor_color; static gfx::Color ui_cursor_color;
static bool is_cursor_mask; static bool is_cursor_mask;
static void update_cursor_color() static void update_cursor_color()
@ -338,7 +338,7 @@ void Editor::moveBrushPreview(int x, int y, bool refresh)
ScreenGraphics g; ScreenGraphics g;
SetClip clip(&g, gfx::Rect(0, 0, g.width(), g.height())); SetClip clip(&g, gfx::Rect(0, 0, g.width(), g.height()));
forEachBrushPixel(&g, old_screen_x, old_screen_y, old_x, old_y, ui::ColorNone, clearpixel); forEachBrushPixel(&g, old_screen_x, old_screen_y, old_x, old_y, gfx::ColorNone, clearpixel);
} }
if (cursor_type & CURSOR_THINCROSS && m_state->requireBrushPreview()) { if (cursor_type & CURSOR_THINCROSS && m_state->requireBrushPreview()) {
@ -387,7 +387,7 @@ void Editor::clearBrushPreview(bool refresh)
ScreenGraphics g; ScreenGraphics g;
SetClip clip(&g, gfx::Rect(0, 0, g.width(), g.height())); SetClip clip(&g, gfx::Rect(0, 0, g.width(), g.height()));
forEachBrushPixel(&g, m_cursor_screen_x, m_cursor_screen_y, x, y, ui::ColorNone, clearpixel); forEachBrushPixel(&g, m_cursor_screen_x, m_cursor_screen_y, x, y, gfx::ColorNone, clearpixel);
} }
// Clean pixel/brush preview // Clean pixel/brush preview
@ -469,7 +469,7 @@ void Editor::forEachBrushPixel(
ui::Graphics* g, ui::Graphics* g,
int screen_x, int screen_y, int screen_x, int screen_y,
int sprite_x, int sprite_y, int sprite_x, int sprite_y,
ui::Color color, gfx::Color color,
Editor::PixelDelegate pixelDelegate) Editor::PixelDelegate pixelDelegate)
{ {
saved_pixel_n = 0; saved_pixel_n = 0;
@ -492,7 +492,7 @@ void Editor::forEachBrushPixel(
// New Thin Cross // New Thin Cross
static void trace_thincross_pixels(ui::Graphics* g, Editor* editor, static void trace_thincross_pixels(ui::Graphics* g, Editor* editor,
int x, int y, ui::Color color, Editor::PixelDelegate pixelDelegate) int x, int y, gfx::Color color, Editor::PixelDelegate pixelDelegate)
{ {
static int cursor_cross[7*7] = { static int cursor_cross[7*7] = {
0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
@ -520,7 +520,7 @@ static void trace_thincross_pixels(ui::Graphics* g, Editor* editor,
// Old Thick Cross // Old Thick Cross
static void trace_thickcross_pixels(ui::Graphics* g, Editor* editor, static void trace_thickcross_pixels(ui::Graphics* g, Editor* editor,
int x, int y, ui::Color color, int thickness, Editor::PixelDelegate pixelDelegate) int x, int y, gfx::Color color, int thickness, Editor::PixelDelegate pixelDelegate)
{ {
static int cursor_cross[6*6] = { static int cursor_cross[6*6] = {
0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0,
@ -557,7 +557,7 @@ static void trace_thickcross_pixels(ui::Graphics* g, Editor* editor,
struct Data { struct Data {
ui::Graphics* g; ui::Graphics* g;
ui::Color color; gfx::Color color;
Editor::PixelDelegate pixelDelegate; Editor::PixelDelegate pixelDelegate;
}; };
@ -568,7 +568,7 @@ static void algo_line_proxy(int x, int y, void* _data)
} }
static void trace_brush_bounds(ui::Graphics* g, Editor* editor, static void trace_brush_bounds(ui::Graphics* g, Editor* editor,
int x, int y, ui::Color color, Editor::PixelDelegate pixelDelegate) int x, int y, gfx::Color color, Editor::PixelDelegate pixelDelegate)
{ {
Data data = { g, color, pixelDelegate }; Data data = { g, color, pixelDelegate };
int c, x1, y1, x2, y2; int c, x1, y1, x2, y2;
@ -613,22 +613,22 @@ static void trace_brush_bounds(ui::Graphics* g, Editor* editor,
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// Helpers // Helpers
static void savepixel(ui::Graphics* g, int x, int y, ui::Color color) static void savepixel(ui::Graphics* g, int x, int y, gfx::Color color)
{ {
if (saved_pixel_n < MAX_SAVED && clipping_region.contains(gfx::Point(x, y))) if (saved_pixel_n < MAX_SAVED && clipping_region.contains(gfx::Point(x, y)))
saved_pixel[saved_pixel_n++] = g->getPixel(x, y); saved_pixel[saved_pixel_n++] = g->getPixel(x, y);
} }
static void drawpixel(ui::Graphics* graphics, int x, int y, ui::Color color) static void drawpixel(ui::Graphics* graphics, int x, int y, gfx::Color color)
{ {
if (saved_pixel_n < MAX_SAVED && clipping_region.contains(gfx::Point(x, y))) { if (saved_pixel_n < MAX_SAVED && clipping_region.contains(gfx::Point(x, y))) {
if (cursor_negative) { if (cursor_negative) {
int c = saved_pixel[saved_pixel_n++]; int c = saved_pixel[saved_pixel_n++];
int r = getr(c); int r = gfx::getr(c);
int g = getg(c); int g = gfx::getg(c);
int b = getb(c); int b = gfx::getb(c);
graphics->putPixel(color_utils::blackandwhite_neg(ui::rgba(r, g, b)), x, y); graphics->putPixel(color_utils::blackandwhite_neg(gfx::rgba(r, g, b)), x, y);
} }
else { else {
graphics->putPixel(color, x, y); graphics->putPixel(color, x, y);
@ -636,7 +636,7 @@ static void drawpixel(ui::Graphics* graphics, int x, int y, ui::Color color)
} }
} }
static void clearpixel(ui::Graphics* g, int x, int y, ui::Color color) static void clearpixel(ui::Graphics* g, int x, int y, gfx::Color color)
{ {
if (saved_pixel_n < MAX_SAVED) { if (saved_pixel_n < MAX_SAVED) {
if (clipping_region.contains(gfx::Point(x, y))) if (clipping_region.contains(gfx::Point(x, y)))

View File

@ -639,7 +639,7 @@ void Editor::drawGrid(Graphics* g, const gfx::Rect& spriteBounds, const Rect& gr
while (grid.y-grid.h >= spriteBounds.y) grid.y -= grid.h; while (grid.y-grid.h >= spriteBounds.y) grid.y -= grid.h;
// Get the grid's color // Get the grid's color
ui::Color grid_color = color_utils::color_for_ui(color); gfx::Color grid_color = color_utils::color_for_ui(color);
// Draw horizontal lines // Draw horizontal lines
int x1 = spriteBounds.x; int x1 = spriteBounds.x;

View File

@ -65,7 +65,7 @@ namespace app {
class Editor : public ui::Widget, class Editor : public ui::Widget,
public DocumentSettingsObserver { public DocumentSettingsObserver {
public: public:
typedef void (*PixelDelegate)(ui::Graphics* g, int x, int y, ui::Color color); typedef void (*PixelDelegate)(ui::Graphics* g, int x, int y, gfx::Color color);
enum EditorFlags { enum EditorFlags {
kNoneFlag = 0, kNoneFlag = 0,
@ -216,7 +216,7 @@ namespace app {
ui::Graphics* g, ui::Graphics* g,
int screen_x, int screen_y, int screen_x, int screen_y,
int sprite_x, int sprite_y, int sprite_x, int sprite_y,
ui::Color color, gfx::Color color,
PixelDelegate pixelDelegate); PixelDelegate pixelDelegate);
// Draws the specified portion of sprite in the editor. Warning: // Draws the specified portion of sprite in the editor. Warning:

View File

@ -48,7 +48,7 @@ EditorView::EditorView(EditorView::Type type)
int b = theme->get_part(PART_EDITOR_SELECTED_S)->height(); int b = theme->get_part(PART_EDITOR_SELECTED_S)->height();
setBorder(gfx::Border(l, t, r, b)); setBorder(gfx::Border(l, t, r, b));
setBgColor(ui::rgba(0, 0, 0)); setBgColor(gfx::rgba(0, 0, 0));
setupScrollbars(); setupScrollbars();
UIContext::instance()->settings()->addObserver(this); UIContext::instance()->settings()->addObserver(this);

View File

@ -130,12 +130,12 @@ void TransformHandles::drawHandles(Editor* editor, const gfx::Transformation& tr
y2 = y1 + transform.bounds().h; y2 = y1 + transform.bounds().h;
editor->editorToScreen(x1, y1, &x1, &y1); editor->editorToScreen(x1, y1, &x1, &y1);
editor->editorToScreen(x2, y2, &x2, &y2); editor->editorToScreen(x2, y2, &x2, &y2);
g.drawRect(ui::rgba(255, 0, 0), gfx::Rect(x1, y1, x2-x1+1, y2-y1+1)); g.drawRect(gfx::rgba(255, 0, 0), gfx::Rect(x1, y1, x2-x1+1, y2-y1+1));
x1 = transform.pivot().x; x1 = transform.pivot().x;
y1 = transform.pivot().y; y1 = transform.pivot().y;
editor->editorToScreen(x1, y1, &x1, &y1); editor->editorToScreen(x1, y1, &x1, &y1);
g.drawRect(ui::rgba(255, 0, 0), gfx::Rect(x1-2, y1-2, 5, 5)); g.drawRect(gfx::rgba(255, 0, 0), gfx::Rect(x1-2, y1-2, 5, 5));
} }
// ----------------------------------------------- // -----------------------------------------------
#endif #endif

View File

@ -309,8 +309,8 @@ void FileList::onPaint(ui::PaintEvent& ev)
int th = getTextHeight(); int th = getTextHeight();
int x, y = bounds.y; int x, y = bounds.y;
int evenRow = 0; int evenRow = 0;
ui::Color bgcolor; gfx::Color bgcolor;
ui::Color fgcolor; gfx::Color fgcolor;
she::Surface* thumbnail = NULL; she::Surface* thumbnail = NULL;
int thumbnail_y = 0; int thumbnail_y = 0;
@ -390,7 +390,7 @@ void FileList::onPaint(ui::PaintEvent& ev)
y -= getBounds().y; y -= getBounds().y;
g->blit(thumbnail, 0, 0, x, y, thumbnail->width(), thumbnail->height()); g->blit(thumbnail, 0, 0, x, y, thumbnail->width(), thumbnail->height());
g->drawRect(ui::rgba(0, 0, 0), g->drawRect(gfx::rgba(0, 0, 0),
gfx::Rect(x-1, y-1, thumbnail->width()+1, thumbnail->height()+1)); gfx::Rect(x-1, y-1, thumbnail->width()+1, thumbnail->height()+1));
} }
} }

View File

@ -283,7 +283,7 @@ void PaletteView::onPaint(ui::PaintEvent& ev)
Palette* palette = get_current_palette(); Palette* palette = get_current_palette();
int bordercolor = makecol(255, 255, 255); int bordercolor = makecol(255, 255, 255);
g->fillRect(ui::rgba(0 , 0, 0), bounds); g->fillRect(gfx::rgba(0 , 0, 0), bounds);
y = bounds.y + this->border_width.t; y = bounds.y + this->border_width.t;
c = 0; c = 0;
@ -295,7 +295,7 @@ void PaletteView::onPaint(ui::PaintEvent& ev)
if (c >= palette->size()) if (c >= palette->size())
break; break;
color = ui::rgba( color = gfx::rgba(
rgba_getr(palette->getEntry(c)), rgba_getr(palette->getEntry(c)),
rgba_getg(palette->getEntry(c)), rgba_getg(palette->getEntry(c)),
rgba_getb(palette->getEntry(c))); rgba_getb(palette->getEntry(c)));

View File

@ -72,7 +72,7 @@ void PalettesListBox::onPaintResource(Graphics* g, const gfx::Rect& bounds, Reso
for (int i=0; i<palette->size(); ++i) { for (int i=0; i<palette->size(); ++i) {
raster::color_t c = palette->getEntry(i); raster::color_t c = palette->getEntry(i);
g->fillRect(ui::rgba( g->fillRect(gfx::rgba(
raster::rgba_getr(c), raster::rgba_getr(c),
raster::rgba_getg(c), raster::rgba_getg(c),
raster::rgba_getb(c)), box); raster::rgba_getb(c)), box);
@ -80,7 +80,7 @@ void PalettesListBox::onPaintResource(Graphics* g, const gfx::Rect& bounds, Reso
box.x += box.w; box.x += box.w;
} }
// g->drawString(getText(), fgcolor, ui::ColorNone, false, // g->drawString(getText(), fgcolor, gfx::ColorNone, false,
// gfx::Point( // gfx::Point(
// bounds.x + jguiscale()*2, // bounds.x + jguiscale()*2,
// bounds.y + bounds.h/2 - g->measureUIString(getText()).h/2)); // bounds.y + bounds.h/2 - g->measureUIString(getText()).h/2));

View File

@ -63,7 +63,7 @@ protected:
SkinTheme* theme = static_cast<SkinTheme*>(getTheme()); SkinTheme* theme = static_cast<SkinTheme*>(getTheme());
Graphics* g = ev.getGraphics(); Graphics* g = ev.getGraphics();
gfx::Rect bounds = getClientBounds(); gfx::Rect bounds = getClientBounds();
ui::Color bgcolor, fgcolor; gfx::Color bgcolor, fgcolor;
if (isSelected()) { if (isSelected()) {
bgcolor = theme->getColor(ThemeColor::ListItemSelectedFace); bgcolor = theme->getColor(ThemeColor::ListItemSelectedFace);
@ -82,7 +82,7 @@ protected:
// for (int i=0; i<m_palette->size(); ++i) { // for (int i=0; i<m_palette->size(); ++i) {
// raster::color_t c = m_resource->getEntry(i); // raster::color_t c = m_resource->getEntry(i);
// g->fillRect(ui::rgba( // g->fillRect(gfx::rgba(
// raster::rgba_getr(c), // raster::rgba_getr(c),
// raster::rgba_getg(c), // raster::rgba_getg(c),
// raster::rgba_getb(c)), box); // raster::rgba_getb(c)), box);
@ -90,7 +90,7 @@ protected:
// box.x += box.w; // box.x += box.w;
// } // }
g->drawString(getText(), fgcolor, ui::ColorNone, g->drawString(getText(), fgcolor, gfx::ColorNone,
gfx::Point( gfx::Point(
bounds.x + jguiscale()*2, bounds.x + jguiscale()*2,
bounds.y + bounds.h/2 - g->measureUIString(getText()).h/2)); bounds.y + bounds.h/2 - g->measureUIString(getText()).h/2));

View File

@ -448,9 +448,10 @@ void SkinTheme::onRegenerate()
while (xmlColor) { while (xmlColor) {
std::string id = xmlColor->Attribute("id"); std::string id = xmlColor->Attribute("id");
uint32_t value = strtol(xmlColor->Attribute("value")+1, NULL, 16); uint32_t value = strtol(xmlColor->Attribute("value")+1, NULL, 16);
ui::Color color = ui::rgba((value & 0xff0000) >> 16, gfx::Color color = gfx::rgba(
(value & 0xff00) >> 8, (value & 0xff0000) >> 16,
(value & 0xff)); (value & 0xff00) >> 8,
(value & 0xff));
PRINTF("Loading color '%s'...\n", id.c_str()); PRINTF("Loading color '%s'...\n", id.c_str());
@ -944,7 +945,7 @@ void SkinTheme::paintButton(PaintEvent& ev)
ButtonBase* widget = static_cast<ButtonBase*>(ev.getSource()); ButtonBase* widget = static_cast<ButtonBase*>(ev.getSource());
IButtonIcon* iconInterface = widget->getIconInterface(); IButtonIcon* iconInterface = widget->getIconInterface();
gfx::Rect box, text, icon; gfx::Rect box, text, icon;
ui::Color fg, bg; gfx::Color fg, bg;
int part_nw; int part_nw;
widget->getTextIconInfo(&box, &text, &icon, widget->getTextIconInfo(&box, &text, &icon,
@ -1020,7 +1021,7 @@ void SkinTheme::paintCheckBox(PaintEvent& ev)
gfx::Rect bounds = widget->getClientBounds(); gfx::Rect bounds = widget->getClientBounds();
IButtonIcon* iconInterface = widget->getIconInterface(); IButtonIcon* iconInterface = widget->getIconInterface();
gfx::Rect box, text, icon; gfx::Rect box, text, icon;
ui::Color bg; gfx::Color bg;
widget->getTextIconInfo(&box, &text, &icon, widget->getTextIconInfo(&box, &text, &icon,
iconInterface ? iconInterface->getIconAlign(): 0, iconInterface ? iconInterface->getIconAlign(): 0,
@ -1053,7 +1054,7 @@ void SkinTheme::paintCheckBox(PaintEvent& ev)
// draw focus // draw focus
if (look != WithoutBordersLook && widget->hasFocus()) if (look != WithoutBordersLook && widget->hasFocus())
draw_bounds_nw(g, bounds, PART_CHECK_FOCUS_NW, ui::ColorNone); draw_bounds_nw(g, bounds, PART_CHECK_FOCUS_NW, gfx::ColorNone);
} }
void SkinTheme::paintGrid(PaintEvent& ev) void SkinTheme::paintGrid(PaintEvent& ev)
@ -1088,7 +1089,7 @@ void SkinTheme::paintEntry(PaintEvent& ev)
if (skinPropery != NULL) if (skinPropery != NULL)
isMiniLook = (skinPropery->getLook() == MiniLook); isMiniLook = (skinPropery->getLook() == MiniLook);
ui::Color bg = getColor(ThemeColor::Background); gfx::Color bg = getColor(ThemeColor::Background);
draw_bounds_nw(g, bounds, draw_bounds_nw(g, bounds,
(widget->hasFocus() ? (widget->hasFocus() ?
(isMiniLook ? PART_SUNKEN_MINI_FOCUSED_NW: PART_SUNKEN_FOCUSED_NW): (isMiniLook ? PART_SUNKEN_MINI_FOCUSED_NW: PART_SUNKEN_FOCUSED_NW):
@ -1104,7 +1105,7 @@ void SkinTheme::paintEntry(PaintEvent& ev)
// Normal text // Normal text
bg = ColorNone; bg = ColorNone;
ui::Color fg = getColor(ThemeColor::Text); gfx::Color fg = getColor(ThemeColor::Text);
// Selected // Selected
if ((c >= selbeg) && (c <= selend)) { if ((c >= selbeg) && (c <= selend)) {
@ -1155,8 +1156,8 @@ void SkinTheme::paintLabel(PaintEvent& ev)
{ {
Graphics* g = ev.getGraphics(); Graphics* g = ev.getGraphics();
Label* widget = static_cast<Label*>(ev.getSource()); Label* widget = static_cast<Label*>(ev.getSource());
ui::Color bg = BGCOLOR; gfx::Color bg = BGCOLOR;
ui::Color fg = widget->getTextColor(); gfx::Color fg = widget->getTextColor();
Rect text, rc = widget->getClientBounds(); Rect text, rc = widget->getClientBounds();
if (!is_transparent(bg)) if (!is_transparent(bg))
@ -1173,8 +1174,8 @@ void SkinTheme::paintLinkLabel(PaintEvent& ev)
Graphics* g = ev.getGraphics(); Graphics* g = ev.getGraphics();
Widget* widget = static_cast<Widget*>(ev.getSource()); Widget* widget = static_cast<Widget*>(ev.getSource());
gfx::Rect bounds = widget->getClientBounds(); gfx::Rect bounds = widget->getClientBounds();
ui::Color fg = getColor(ThemeColor::LinkText); gfx::Color fg = getColor(ThemeColor::LinkText);
ui::Color bg = BGCOLOR; gfx::Color bg = BGCOLOR;
g->fillRect(bg, bounds); g->fillRect(bg, bounds);
drawTextString(g, NULL, fg, ColorNone, widget, bounds, 0); drawTextString(g, NULL, fg, ColorNone, widget, bounds, 0);
@ -1200,7 +1201,7 @@ void SkinTheme::paintListItem(ui::PaintEvent& ev)
Widget* widget = static_cast<Widget*>(ev.getSource()); Widget* widget = static_cast<Widget*>(ev.getSource());
gfx::Rect bounds = widget->getClientBounds(); gfx::Rect bounds = widget->getClientBounds();
Graphics* g = ev.getGraphics(); Graphics* g = ev.getGraphics();
ui::Color fg, bg; gfx::Color fg, bg;
if (!widget->isEnabled()) { if (!widget->isEnabled()) {
bg = getColor(ThemeColor::Face); bg = getColor(ThemeColor::Face);
@ -1237,7 +1238,7 @@ void SkinTheme::paintMenuItem(ui::PaintEvent& ev)
Graphics* g = ev.getGraphics(); Graphics* g = ev.getGraphics();
MenuItem* widget = static_cast<MenuItem*>(ev.getSource()); MenuItem* widget = static_cast<MenuItem*>(ev.getSource());
gfx::Rect bounds = widget->getClientBounds(); gfx::Rect bounds = widget->getClientBounds();
ui::Color fg, bg; gfx::Color fg, bg;
int c, bar; int c, bar;
// TODO ASSERT? // TODO ASSERT?
@ -1346,7 +1347,7 @@ void SkinTheme::paintRadioButton(PaintEvent& ev)
ButtonBase* widget = static_cast<ButtonBase*>(ev.getSource()); ButtonBase* widget = static_cast<ButtonBase*>(ev.getSource());
gfx::Rect bounds = widget->getClientBounds(); gfx::Rect bounds = widget->getClientBounds();
IButtonIcon* iconInterface = widget->getIconInterface(); IButtonIcon* iconInterface = widget->getIconInterface();
ui::Color bg = BGCOLOR; gfx::Color bg = BGCOLOR;
gfx::Rect box, text, icon; gfx::Rect box, text, icon;
widget->getTextIconInfo(&box, &text, &icon, widget->getTextIconInfo(&box, &text, &icon,
@ -1374,7 +1375,7 @@ void SkinTheme::paintRadioButton(PaintEvent& ev)
// Focus // Focus
if (widget->hasFocus()) if (widget->hasFocus())
draw_bounds_nw(g, bounds, PART_RADIO_FOCUS_NW, ui::ColorNone); draw_bounds_nw(g, bounds, PART_RADIO_FOCUS_NW, gfx::ColorNone);
} }
void SkinTheme::paintSeparator(ui::PaintEvent& ev) void SkinTheme::paintSeparator(ui::PaintEvent& ev)
@ -1417,7 +1418,7 @@ void SkinTheme::paintSlider(PaintEvent& ev)
int min, max, value; int min, max, value;
// Outside borders // Outside borders
ui::Color bgcolor = widget->getBgColor(); gfx::Color bgcolor = widget->getBgColor();
if (!is_transparent(bgcolor)) if (!is_transparent(bgcolor))
g->fillRect(bgcolor, bounds); g->fillRect(bgcolor, bounds);
@ -1467,7 +1468,7 @@ void SkinTheme::paintSlider(PaintEvent& ev)
3 * jguiscale(), 3 * jguiscale(),
1 * jguiscale())); 1 * jguiscale()));
draw_bounds_nw(g, rc, nw, ui::ColorNone); draw_bounds_nw(g, rc, nw, gfx::ColorNone);
// Draw background (using the customized ISliderBgPainter implementation) // Draw background (using the customized ISliderBgPainter implementation)
rc.shrink(Border(1, 1, 1, 2) * jguiscale()); rc.shrink(Border(1, 1, 1, 2) * jguiscale());
@ -1549,7 +1550,7 @@ void SkinTheme::paintComboBoxEntry(ui::PaintEvent& ev)
// Outside borders // Outside borders
g->fillRect(BGCOLOR, bounds); g->fillRect(BGCOLOR, bounds);
ui::Color fg, bg = getColor(ThemeColor::Background); gfx::Color fg, bg = getColor(ThemeColor::Background);
draw_bounds_nw(g, bounds, draw_bounds_nw(g, bounds,
widget->hasFocus() ? widget->hasFocus() ?
@ -1609,7 +1610,7 @@ void SkinTheme::paintComboBoxButton(PaintEvent& ev)
Graphics* g = ev.getGraphics(); Graphics* g = ev.getGraphics();
IButtonIcon* iconInterface = widget->getIconInterface(); IButtonIcon* iconInterface = widget->getIconInterface();
int part_nw; int part_nw;
ui::Color bg; gfx::Color bg;
if (widget->isSelected()) { if (widget->isSelected()) {
bg = getColor(ThemeColor::ButtonSelectedFace); bg = getColor(ThemeColor::ButtonSelectedFace);
@ -1659,7 +1660,7 @@ void SkinTheme::paintView(PaintEvent& ev)
Graphics* g = ev.getGraphics(); Graphics* g = ev.getGraphics();
View* widget = static_cast<View*>(ev.getSource()); View* widget = static_cast<View*>(ev.getSource());
gfx::Rect bounds = widget->getClientBounds(); gfx::Rect bounds = widget->getClientBounds();
ui::Color bg = BGCOLOR; gfx::Color bg = BGCOLOR;
if (!is_transparent(bg)) if (!is_transparent(bg))
g->fillRect(bg, bounds); g->fillRect(bg, bounds);
@ -1709,7 +1710,7 @@ void SkinTheme::paintViewViewport(PaintEvent& ev)
{ {
Viewport* widget = static_cast<Viewport*>(ev.getSource()); Viewport* widget = static_cast<Viewport*>(ev.getSource());
Graphics* g = ev.getGraphics(); Graphics* g = ev.getGraphics();
ui::Color bg = BGCOLOR; gfx::Color bg = BGCOLOR;
if (!is_transparent(bg)) if (!is_transparent(bg))
g->fillRect(bg, widget->getClientBounds()); g->fillRect(bg, widget->getClientBounds());
@ -1782,8 +1783,8 @@ void SkinTheme::paintTooltip(PaintEvent& ev)
ui::TipWindow* widget = static_cast<ui::TipWindow*>(ev.getSource()); ui::TipWindow* widget = static_cast<ui::TipWindow*>(ev.getSource());
Graphics* g = ev.getGraphics(); Graphics* g = ev.getGraphics();
Rect rc = widget->getClientBounds(); Rect rc = widget->getClientBounds();
ui::Color fg = getColor(ThemeColor::TooltipText); gfx::Color fg = getColor(ThemeColor::TooltipText);
ui::Color bg = getColor(ThemeColor::TooltipFace); gfx::Color bg = getColor(ThemeColor::TooltipFace);
int nw = PART_TOOLTIP_NW; int nw = PART_TOOLTIP_NW;
int n = PART_TOOLTIP_N; int n = PART_TOOLTIP_N;
@ -1841,9 +1842,9 @@ void SkinTheme::paintTooltip(PaintEvent& ev)
g->drawAlignedUIString(widget->getText(), fg, bg, rc, widget->getAlign()); g->drawAlignedUIString(widget->getText(), fg, bg, rc, widget->getAlign());
} }
ui::Color SkinTheme::getWidgetBgColor(Widget* widget) gfx::Color SkinTheme::getWidgetBgColor(Widget* widget)
{ {
ui::Color c = widget->getBgColor(); gfx::Color c = widget->getBgColor();
bool decorative = widget->isDecorative(); bool decorative = widget->isDecorative();
if (!is_transparent(c) || widget->getType() == kWindowWidget) if (!is_transparent(c) || widget->getType() == kWindowWidget)
@ -1854,7 +1855,7 @@ ui::Color SkinTheme::getWidgetBgColor(Widget* widget)
return getColor(ThemeColor::Face); return getColor(ThemeColor::Face);
} }
void SkinTheme::drawTextString(Graphics* g, const char *t, ui::Color fg_color, ui::Color bg_color, void SkinTheme::drawTextString(Graphics* g, const char *t, gfx::Color fg_color, gfx::Color bg_color,
Widget* widget, const Rect& rc, Widget* widget, const Rect& rc,
int selected_offset) int selected_offset)
{ {
@ -1911,14 +1912,14 @@ void SkinTheme::drawTextString(Graphics* g, const char *t, ui::Color fg_color, u
// Draw white part // Draw white part
g->drawUIString(t, g->drawUIString(t,
getColor(ThemeColor::Background), getColor(ThemeColor::Background),
ui::ColorNone, gfx::ColorNone,
textrc.getOrigin() + Point(jguiscale(), jguiscale())); textrc.getOrigin() + Point(jguiscale(), jguiscale()));
} }
g->drawUIString(t, g->drawUIString(t,
(!widget->isEnabled() ? (!widget->isEnabled() ?
getColor(ThemeColor::Disabled): getColor(ThemeColor::Disabled):
(ui::geta(fg_color) > 0 ? fg_color : (gfx::geta(fg_color) > 0 ? fg_color :
getColor(ThemeColor::Text))), getColor(ThemeColor::Text))),
bg_color, textrc.getOrigin()); bg_color, textrc.getOrigin());
} }
@ -1927,7 +1928,7 @@ void SkinTheme::drawTextString(Graphics* g, const char *t, ui::Color fg_color, u
void SkinTheme::drawEntryCaret(ui::Graphics* g, Entry* widget, int x, int y) void SkinTheme::drawEntryCaret(ui::Graphics* g, Entry* widget, int x, int y)
{ {
ui::Color color = getColor(ThemeColor::Text); gfx::Color color = getColor(ThemeColor::Text);
int h = widget->getTextHeight(); int h = widget->getTextHeight();
for (int u=x; u<x+2*jguiscale(); ++u) for (int u=x; u<x+2*jguiscale(); ++u)
@ -2047,7 +2048,7 @@ void SkinTheme::draw_bounds_array(ui::Graphics* g, const gfx::Rect& rc, int part
se, s, sw, w); se, s, sw, w);
} }
void SkinTheme::draw_bounds_nw(Graphics* g, const Rect& rc, int nw, ui::Color bg) void SkinTheme::draw_bounds_nw(Graphics* g, const Rect& rc, int nw, gfx::Color bg)
{ {
draw_bounds_template(g, rc, draw_bounds_template(g, rc,
nw+0, nw+1, nw+2, nw+3, nw+0, nw+1, nw+2, nw+3,
@ -2064,7 +2065,7 @@ void SkinTheme::draw_bounds_nw(Graphics* g, const Rect& rc, int nw, ui::Color bg
} }
} }
void SkinTheme::draw_bounds_nw(ui::Graphics* g, const gfx::Rect& rc, const SkinPartPtr skinPart, ui::Color bg) void SkinTheme::draw_bounds_nw(ui::Graphics* g, const gfx::Rect& rc, const SkinPartPtr skinPart, gfx::Color bg)
{ {
draw_bounds_template(g, rc, skinPart); draw_bounds_template(g, rc, skinPart);
@ -2083,7 +2084,7 @@ void SkinTheme::draw_bounds_nw(ui::Graphics* g, const gfx::Rect& rc, const SkinP
} }
} }
void SkinTheme::draw_bounds_nw2(Graphics* g, const Rect& rc, int x_mid, int nw1, int nw2, ui::Color bg1, ui::Color bg2) void SkinTheme::draw_bounds_nw2(Graphics* g, const Rect& rc, int x_mid, int nw1, int nw2, gfx::Color bg1, gfx::Color bg2)
{ {
Rect rc2(rc.x, rc.y, x_mid-rc.x+1, rc.h); Rect rc2(rc.x, rc.y, x_mid-rc.x+1, rc.h);
{ {

View File

@ -24,8 +24,8 @@
#include "app/ui/skin/skin_parts.h" #include "app/ui/skin/skin_parts.h"
#include "app/ui/skin/style_sheet.h" #include "app/ui/skin/style_sheet.h"
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "gfx/color.h"
#include "gfx/fwd.h" #include "gfx/fwd.h"
#include "ui/color.h"
#include "ui/manager.h" #include "ui/manager.h"
#include "ui/system.h" #include "ui/system.h"
#include "ui/theme.h" #include "ui/theme.h"
@ -118,7 +118,7 @@ namespace app {
SkinTheme(); SkinTheme();
~SkinTheme(); ~SkinTheme();
ui::Color getColor(ThemeColor::Type k) const { gfx::Color getColor(ThemeColor::Type k) const {
return m_colors[k]; return m_colors[k];
} }
@ -167,9 +167,9 @@ namespace app {
// Helper functions to draw bounds/hlines with sheet parts // Helper functions to draw bounds/hlines with sheet parts
void draw_bounds_array(ui::Graphics* g, const gfx::Rect& rc, int parts[8]); void draw_bounds_array(ui::Graphics* g, const gfx::Rect& rc, int parts[8]);
void draw_bounds_nw(ui::Graphics* g, const gfx::Rect& rc, int nw, ui::Color bg = ui::ColorNone); void draw_bounds_nw(ui::Graphics* g, const gfx::Rect& rc, int nw, gfx::Color bg = gfx::ColorNone);
void draw_bounds_nw(ui::Graphics* g, const gfx::Rect& rc, const SkinPartPtr skinPart, ui::Color bg = ui::ColorNone); void draw_bounds_nw(ui::Graphics* g, const gfx::Rect& rc, const SkinPartPtr skinPart, gfx::Color bg = gfx::ColorNone);
void draw_bounds_nw2(ui::Graphics* g, const gfx::Rect& rc, int x_mid, int nw1, int nw2, ui::Color bg1, ui::Color bg2); void draw_bounds_nw2(ui::Graphics* g, const gfx::Rect& rc, int x_mid, int nw1, int nw2, gfx::Color bg1, gfx::Color bg2);
void draw_part_as_hline(ui::Graphics* g, const gfx::Rect& rc, int part); void draw_part_as_hline(ui::Graphics* g, const gfx::Rect& rc, int part);
void draw_part_as_vline(ui::Graphics* g, const gfx::Rect& rc, int part); void draw_part_as_vline(ui::Graphics* g, const gfx::Rect& rc, int part);
void paintProgressBar(ui::Graphics* g, const gfx::Rect& rc, float progress); void paintProgressBar(ui::Graphics* g, const gfx::Rect& rc, float progress);
@ -182,7 +182,7 @@ namespace app {
return m_parts_by_id[id]; return m_parts_by_id[id];
} }
ui::Color getColorById(const std::string& id) { gfx::Color getColorById(const std::string& id) {
return m_colors_by_id[id]; return m_colors_by_id[id];
} }
@ -199,8 +199,8 @@ namespace app {
she::Surface* sw, she::Surface* w); she::Surface* sw, she::Surface* w);
she::Surface* sliceSheet(she::Surface* sur, const gfx::Rect& bounds); she::Surface* sliceSheet(she::Surface* sur, const gfx::Rect& bounds);
ui::Color getWidgetBgColor(ui::Widget* widget); gfx::Color getWidgetBgColor(ui::Widget* widget);
void drawTextString(ui::Graphics* g, const char *t, ui::Color fg_color, ui::Color bg_color, void drawTextString(ui::Graphics* g, const char *t, gfx::Color fg_color, gfx::Color bg_color,
ui::Widget* widget, const gfx::Rect& rc, ui::Widget* widget, const gfx::Rect& rc,
int selected_offset); int selected_offset);
void drawEntryCaret(ui::Graphics* g, ui::Entry* widget, int x, int y); void drawEntryCaret(ui::Graphics* g, ui::Entry* widget, int x, int y);
@ -214,9 +214,9 @@ namespace app {
std::vector<she::Surface*> m_part; std::vector<she::Surface*> m_part;
std::map<std::string, SkinPartPtr> m_parts_by_id; std::map<std::string, SkinPartPtr> m_parts_by_id;
std::map<std::string, she::Surface*> m_toolicon; std::map<std::string, she::Surface*> m_toolicon;
std::map<std::string, ui::Color> m_colors_by_id; std::map<std::string, gfx::Color> m_colors_by_id;
std::vector<ui::Cursor*> m_cursors; std::vector<ui::Cursor*> m_cursors;
std::vector<ui::Color> m_colors; std::vector<gfx::Color> m_colors;
StyleSheet m_stylesheet; StyleSheet m_stylesheet;
she::Font* m_minifont; she::Font* m_minifont;
}; };
@ -229,7 +229,7 @@ namespace app {
return static_cast<SkinTheme*>(ui::Manager::getDefault()->getTheme())->getPartById(id); return static_cast<SkinTheme*>(ui::Manager::getDefault()->getTheme())->getPartById(id);
} }
inline ui::Color get_color_by_id(const std::string& id) { inline gfx::Color get_color_by_id(const std::string& id) {
return static_cast<SkinTheme*>(ui::Manager::getDefault()->getTheme())->getColorById(id); return static_cast<SkinTheme*>(ui::Manager::getDefault()->getTheme())->getColorById(id);
} }

View File

@ -52,7 +52,7 @@ void BackgroundRule::onPaint(ui::Graphics* g, const gfx::Rect& bounds, const cha
if (m_part != NULL && m_part->size() > 0) { if (m_part != NULL && m_part->size() > 0) {
if (m_part->size() == 1) { if (m_part->size() == 1) {
if (!ui::is_transparent(m_color)) if (!gfx::is_transparent(m_color))
g->fillRect(m_color, bounds); g->fillRect(m_color, bounds);
g->drawRgbaSurface(m_part->getBitmap(0), bounds.x, bounds.y); g->drawRgbaSurface(m_part->getBitmap(0), bounds.x, bounds.y);
@ -61,7 +61,7 @@ void BackgroundRule::onPaint(ui::Graphics* g, const gfx::Rect& bounds, const cha
theme->draw_bounds_nw(g, bounds, m_part, m_color); theme->draw_bounds_nw(g, bounds, m_part, m_color);
} }
} }
else if (!ui::is_transparent(m_color)) { else if (!gfx::is_transparent(m_color)) {
g->fillRect(m_color, bounds); g->fillRect(m_color, bounds);
} }
} }
@ -72,10 +72,10 @@ void TextRule::onPaint(ui::Graphics* g, const gfx::Rect& bounds, const char* tex
if (text) { if (text) {
g->drawAlignedUIString(text, g->drawAlignedUIString(text,
(ui::is_transparent(m_color) ? (gfx::is_transparent(m_color) ?
theme->getColor(ThemeColor::Text): theme->getColor(ThemeColor::Text):
m_color), m_color),
ui::ColorNone, gfx::ColorNone,
gfx::Rect(bounds).shrink(m_padding), m_align); gfx::Rect(bounds).shrink(m_padding), m_align);
} }
} }

View File

@ -27,8 +27,8 @@
#include "css/state.h" #include "css/state.h"
#include "css/stateful_style.h" #include "css/stateful_style.h"
#include "gfx/border.h" #include "gfx/border.h"
#include "gfx/color.h"
#include "gfx/fwd.h" #include "gfx/fwd.h"
#include "ui/color.h"
#include <map> #include <map>
#include <string> #include <string>
@ -56,26 +56,26 @@ namespace app {
class BackgroundRule : public Rule { class BackgroundRule : public Rule {
public: public:
BackgroundRule() : m_color(ui::ColorNone) { } BackgroundRule() : m_color(gfx::ColorNone) { }
void setColor(ui::Color color) { m_color = color; } void setColor(gfx::Color color) { m_color = color; }
void setPart(const SkinPartPtr& part) { m_part = part; } void setPart(const SkinPartPtr& part) { m_part = part; }
protected: protected:
void onPaint(ui::Graphics* g, const gfx::Rect& bounds, const char* text) OVERRIDE; void onPaint(ui::Graphics* g, const gfx::Rect& bounds, const char* text) OVERRIDE;
private: private:
ui::Color m_color; gfx::Color m_color;
SkinPartPtr m_part; SkinPartPtr m_part;
}; };
class TextRule : public Rule { class TextRule : public Rule {
public: public:
explicit TextRule() : m_align(0), explicit TextRule() : m_align(0),
m_color(ui::ColorNone) { } m_color(gfx::ColorNone) { }
void setAlign(int align) { m_align = align; } void setAlign(int align) { m_align = align; }
void setColor(ui::Color color) { m_color = color; } void setColor(gfx::Color color) { m_color = color; }
void setPadding(const gfx::Border& padding) { m_padding = padding; } void setPadding(const gfx::Border& padding) { m_padding = padding; }
protected: protected:
@ -83,7 +83,7 @@ namespace app {
private: private:
int m_align; int m_align;
ui::Color m_color; gfx::Color m_color;
gfx::Border m_padding; gfx::Border m_padding;
}; };

View File

@ -113,13 +113,13 @@ SkinPartPtr StyleSheet::convertPart(const css::Value& value)
} }
// static // static
ui::Color StyleSheet::convertColor(const css::Value& value) gfx::Color StyleSheet::convertColor(const css::Value& value)
{ {
ui::Color color = ui::ColorNone; gfx::Color color = gfx::ColorNone;
if (value.type() == css::Value::String) { if (value.type() == css::Value::String) {
const std::string& color_id = value.string(); const std::string& color_id = value.string();
color = get_color_by_id(color_id); color = get_color_by_id(color_id);
if (color == ui::ColorNone) if (color == gfx::ColorNone)
throw base::Exception("Unknown color '%s'\n", color_id.c_str()); throw base::Exception("Unknown color '%s'\n", color_id.c_str());
} }
return color; return color;

View File

@ -23,7 +23,7 @@
#include "app/ui/skin/skin_part.h" #include "app/ui/skin/skin_part.h"
#include "css/rule.h" #include "css/rule.h"
#include "css/state.h" #include "css/state.h"
#include "ui/color.h" #include "gfx/color.h"
#include <map> #include <map>
#include <string> #include <string>
@ -63,7 +63,7 @@ namespace app {
Style* getStyle(const std::string& id); Style* getStyle(const std::string& id);
static SkinPartPtr convertPart(const css::Value& value); static SkinPartPtr convertPart(const css::Value& value);
static ui::Color convertColor(const css::Value& value); static gfx::Color convertColor(const css::Value& value);
private: private:
typedef std::map<std::string, Style*> StyleMap; typedef std::map<std::string, Style*> StyleMap;

View File

@ -479,7 +479,7 @@ void StatusBar::onPreferredSize(PreferredSizeEvent& ev)
void StatusBar::onPaint(ui::PaintEvent& ev) void StatusBar::onPaint(ui::PaintEvent& ev)
{ {
SkinTheme* theme = static_cast<SkinTheme*>(this->getTheme()); SkinTheme* theme = static_cast<SkinTheme*>(this->getTheme());
ui::Color textColor = theme->getColorById(kStatusBarText); gfx::Color textColor = theme->getColorById(kStatusBarText);
Rect rc = getClientBounds(); Rect rc = getClientBounds();
Graphics* g = ev.getGraphics(); Graphics* g = ev.getGraphics();

View File

@ -476,8 +476,8 @@ void Tabs::drawTab(Graphics* g, const gfx::Rect& box, Tab* tab, int y_delta, boo
return; return;
SkinTheme* theme = static_cast<SkinTheme*>(this->getTheme()); SkinTheme* theme = static_cast<SkinTheme*>(this->getTheme());
ui::Color text_color; gfx::Color text_color;
ui::Color face_color; gfx::Color face_color;
// Selected // Selected
if (selected) { if (selected) {
@ -497,7 +497,7 @@ void Tabs::drawTab(Graphics* g, const gfx::Rect& box, Tab* tab, int y_delta, boo
PART_TAB_NORMAL_NW, PART_TAB_NORMAL_NW,
face_color); face_color);
g->drawString(tab->text, text_color, ColorNone, g->drawString(tab->text, text_color, gfx::ColorNone,
gfx::Point( gfx::Point(
box.x + 4*jguiscale(), box.x + 4*jguiscale(),
box.y + box.h/2 - getFont()->height()/2+1 + y_delta)); box.y + box.h/2 - getFont()->height()/2+1 + y_delta));

View File

@ -318,8 +318,8 @@ void ToolBar::onPaint(ui::PaintEvent& ev)
gfx::Rect bounds = getClientBounds(); gfx::Rect bounds = getClientBounds();
Graphics* g = ev.getGraphics(); Graphics* g = ev.getGraphics();
SkinTheme* theme = static_cast<SkinTheme*>(this->getTheme()); SkinTheme* theme = static_cast<SkinTheme*>(this->getTheme());
ui::Color normalFace = theme->getColor(ThemeColor::ButtonNormalFace); gfx::Color normalFace = theme->getColor(ThemeColor::ButtonNormalFace);
ui::Color hotFace = theme->getColor(ThemeColor::ButtonHotFace); gfx::Color hotFace = theme->getColor(ThemeColor::ButtonHotFace);
ToolBox* toolbox = App::instance()->getToolBox(); ToolBox* toolbox = App::instance()->getToolBox();
ToolGroupList::iterator it = toolbox->begin_group(); ToolGroupList::iterator it = toolbox->begin_group();
int groups = toolbox->getGroupsCount(); int groups = toolbox->getGroupsCount();
@ -330,7 +330,7 @@ void ToolBar::onPaint(ui::PaintEvent& ev)
for (int c=0; c<groups; ++c, ++it) { for (int c=0; c<groups; ++c, ++it) {
ToolGroup* tool_group = *it; ToolGroup* tool_group = *it;
Tool* tool = m_selectedInGroup[tool_group]; Tool* tool = m_selectedInGroup[tool_group];
ui::Color face; gfx::Color face;
int nw; int nw;
if (UIContext::instance()->getSettings()->getCurrentTool() == tool || if (UIContext::instance()->getSettings()->getCurrentTool() == tool ||
@ -467,7 +467,7 @@ void ToolBar::openPopupWindow(int group_index, ToolGroup* tool_group)
m_popupWindow->setHotRegion(rgn); m_popupWindow->setHotRegion(rgn);
m_popupWindow->setTransparent(true); m_popupWindow->setTransparent(true);
m_popupWindow->setBgColor(ui::ColorNone); m_popupWindow->setBgColor(gfx::ColorNone);
m_popupWindow->setAutoRemap(false); m_popupWindow->setAutoRemap(false);
m_popupWindow->setBounds(rc); m_popupWindow->setBounds(rc);
toolstrip->setBounds(rc); toolstrip->setBounds(rc);
@ -741,7 +741,7 @@ void ToolBar::ToolStrip::onPaint(PaintEvent& ev)
for (ToolIterator it = toolbox->begin(); it != toolbox->end(); ++it) { for (ToolIterator it = toolbox->begin(); it != toolbox->end(); ++it) {
Tool* tool = *it; Tool* tool = *it;
if (tool->getGroup() == m_group) { if (tool->getGroup() == m_group) {
ui::Color face; gfx::Color face;
int nw; int nw;
if (UIContext::instance()->getSettings()->getCurrentTool() == tool || if (UIContext::instance()->getSettings()->getCurrentTool() == tool ||

View File

@ -1,5 +1,5 @@
# ASEPRITE # ASEPRITE
# Copyright (C) 2001-2013 David Capello # Copyright (C) 2001-2014 David Capello
add_library(gfx-lib add_library(gfx-lib
hsv.cpp hsv.cpp

View File

@ -1,4 +1,4 @@
Copyright (c) 2001-2013 David Capello Copyright (c) 2001-2014 David Capello
Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the a copy of this software and associated documentation files (the

View File

@ -1,4 +1,4 @@
# Aseprite Gfx Library # Aseprite Gfx Library
*Copyright (C) 2001-2013 David Capello* *Copyright (C) 2001-2014 David Capello*
> Distributed under [MIT license](LICENSE.txt) > Distributed under [MIT license](LICENSE.txt)

View File

@ -1,14 +1,14 @@
// SHE library // Aseprite Gfx Library
// Copyright (C) 2012-2014 David Capello // Copyright (C) 2001-2014 David Capello
// //
// This file is released under the terms of the MIT license. // This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information. // Read LICENSE.txt for more information.
#ifndef SHE_COLOR_H_INCLUDED #ifndef GFX_COLOR_H_INCLUDED
#define SHE_COLOR_H_INCLUDED #define GFX_COLOR_H_INCLUDED
#pragma once #pragma once
namespace she { namespace gfx {
typedef uint32_t Color; typedef uint32_t Color;
typedef uint8_t ColorComponent; typedef uint8_t ColorComponent;
@ -39,6 +39,6 @@ namespace she {
inline bool is_transparent(Color c) { return geta(c) == 0; } inline bool is_transparent(Color c) { return geta(c) == 0; }
} // namespace she } // namespace gfx
#endif // SHE_COLOR_H_INCLUDED #endif // GFX_COLOR_H_INCLUDED

View File

@ -20,15 +20,15 @@
namespace she { namespace she {
inline int to_allegro(Color color) { inline int to_allegro(int color_depth, gfx::Color color) {
if (is_transparent(color)) if (gfx::is_transparent(color))
return -1; return -1;
else else
return makecol(getr(color), getg(color), getb(color)); return makecol_depth(color_depth, gfx::getr(color), gfx::getg(color), gfx::getb(color));
} }
inline Color from_allegro(int color_depth, int color) { inline gfx::Color from_allegro(int color_depth, int color) {
return she::rgba( return gfx::rgba(
getr_depth(color_depth, color), getr_depth(color_depth, color),
getg_depth(color_depth, color), getg_depth(color_depth, color),
getb_depth(color_depth, color)); getb_depth(color_depth, color));
@ -219,34 +219,34 @@ namespace she {
} }
} }
she::Color getPixel(int x, int y) OVERRIDE { gfx::Color getPixel(int x, int y) OVERRIDE {
return from_allegro( return from_allegro(
bitmap_color_depth(m_bmp), bitmap_color_depth(m_bmp),
getpixel(m_bmp, x, y)); getpixel(m_bmp, x, y));
} }
void putPixel(she::Color color, int x, int y) OVERRIDE { void putPixel(gfx::Color color, int x, int y) OVERRIDE {
putpixel(m_bmp, x, y, to_allegro(color)); putpixel(m_bmp, x, y, to_allegro(bitmap_color_depth(m_bmp), color));
} }
void drawHLine(she::Color color, int x, int y, int w) OVERRIDE { void drawHLine(gfx::Color color, int x, int y, int w) OVERRIDE {
hline(m_bmp, x, y, x+w-1, to_allegro(color)); hline(m_bmp, x, y, x+w-1, to_allegro(bitmap_color_depth(m_bmp), color));
} }
void drawVLine(she::Color color, int x, int y, int h) OVERRIDE { void drawVLine(gfx::Color color, int x, int y, int h) OVERRIDE {
vline(m_bmp, x, y, y+h-1, to_allegro(color)); vline(m_bmp, x, y, y+h-1, to_allegro(bitmap_color_depth(m_bmp), color));
} }
void drawLine(she::Color color, const gfx::Point& a, const gfx::Point& b) OVERRIDE { void drawLine(gfx::Color color, const gfx::Point& a, const gfx::Point& b) OVERRIDE {
line(m_bmp, a.x, a.y, b.x, b.y, to_allegro(color)); line(m_bmp, a.x, a.y, b.x, b.y, to_allegro(bitmap_color_depth(m_bmp), color));
} }
void drawRect(she::Color color, const gfx::Rect& rc) OVERRIDE { void drawRect(gfx::Color color, const gfx::Rect& rc) OVERRIDE {
rect(m_bmp, rc.x, rc.y, rc.x+rc.w-1, rc.y+rc.h-1, to_allegro(color)); rect(m_bmp, rc.x, rc.y, rc.x+rc.w-1, rc.y+rc.h-1, to_allegro(bitmap_color_depth(m_bmp), color));
} }
void fillRect(she::Color color, const gfx::Rect& rc) OVERRIDE { void fillRect(gfx::Color color, const gfx::Rect& rc) OVERRIDE {
rectfill(m_bmp, rc.x, rc.y, rc.x+rc.w-1, rc.y+rc.h-1, to_allegro(color)); rectfill(m_bmp, rc.x, rc.y, rc.x+rc.w-1, rc.y+rc.h-1, to_allegro(bitmap_color_depth(m_bmp), color));
} }
void blitTo(LockedSurface* dest, int srcx, int srcy, int dstx, int dsty, int width, int height) const OVERRIDE { void blitTo(LockedSurface* dest, int srcx, int srcy, int dstx, int dsty, int width, int height) const OVERRIDE {
@ -270,21 +270,21 @@ namespace she {
draw_trans_sprite(m_bmp, static_cast<const Alleg4Surface*>(src)->m_bmp, dstx, dsty); draw_trans_sprite(m_bmp, static_cast<const Alleg4Surface*>(src)->m_bmp, dstx, dsty);
} }
void drawChar(Font* sheFont, she::Color fg, she::Color bg, int x, int y, int chr) OVERRIDE { void drawChar(Font* sheFont, gfx::Color fg, gfx::Color bg, int x, int y, int chr) OVERRIDE {
FONT* allegFont = reinterpret_cast<FONT*>(sheFont->nativeHandle()); FONT* allegFont = reinterpret_cast<FONT*>(sheFont->nativeHandle());
allegFont->vtable->render_char(allegFont, chr, allegFont->vtable->render_char(allegFont, chr,
to_allegro(fg), to_allegro(bitmap_color_depth(m_bmp), fg),
to_allegro(bg), to_allegro(bitmap_color_depth(m_bmp), bg),
m_bmp, x, y); m_bmp, x, y);
} }
void drawString(Font* sheFont, she::Color fg, she::Color bg, int x, int y, const std::string& str) OVERRIDE { void drawString(Font* sheFont, gfx::Color fg, gfx::Color bg, int x, int y, const std::string& str) OVERRIDE {
FONT* allegFont = reinterpret_cast<FONT*>(sheFont->nativeHandle()); FONT* allegFont = reinterpret_cast<FONT*>(sheFont->nativeHandle());
base::utf8_const_iterator it(str.begin()), end(str.end()); base::utf8_const_iterator it(str.begin()), end(str.end());
int length = 0; int length = 0;
int sysfg = to_allegro(fg); int sysfg = to_allegro(bitmap_color_depth(m_bmp), fg);
int sysbg = to_allegro(bg); int sysbg = to_allegro(bitmap_color_depth(m_bmp), bg);
while (it != end) { while (it != end) {
allegFont->vtable->render_char(allegFont, *it, sysfg, sysbg, m_bmp, x, y); allegFont->vtable->render_char(allegFont, *it, sysfg, sysbg, m_bmp, x, y);

View File

@ -8,8 +8,8 @@
#define SHE_LOCKED_SURFACE_H_INCLUDED #define SHE_LOCKED_SURFACE_H_INCLUDED
#pragma once #pragma once
#include "gfx/color.h"
#include "gfx/fwd.h" #include "gfx/fwd.h"
#include "she/color.h"
#include "she/surface_format.h" #include "she/surface_format.h"
#include <string> #include <string>
@ -27,22 +27,22 @@ namespace she {
virtual uint8_t* getData(int x, int y) = 0; virtual uint8_t* getData(int x, int y) = 0;
virtual void getFormat(SurfaceFormatData* formatData) = 0; virtual void getFormat(SurfaceFormatData* formatData) = 0;
virtual she::Color getPixel(int x, int y) = 0; virtual gfx::Color getPixel(int x, int y) = 0;
virtual void putPixel(she::Color color, int x, int y) = 0; virtual void putPixel(gfx::Color color, int x, int y) = 0;
virtual void drawHLine(she::Color color, int x, int y, int w) = 0; virtual void drawHLine(gfx::Color color, int x, int y, int w) = 0;
virtual void drawVLine(she::Color color, int x, int y, int h) = 0; virtual void drawVLine(gfx::Color color, int x, int y, int h) = 0;
virtual void drawLine(she::Color color, const gfx::Point& a, const gfx::Point& b) = 0; virtual void drawLine(gfx::Color color, const gfx::Point& a, const gfx::Point& b) = 0;
virtual void drawRect(she::Color color, const gfx::Rect& rc) = 0; virtual void drawRect(gfx::Color color, const gfx::Rect& rc) = 0;
virtual void fillRect(she::Color color, const gfx::Rect& rc) = 0; virtual void fillRect(gfx::Color color, const gfx::Rect& rc) = 0;
virtual void blitTo(LockedSurface* dest, int srcx, int srcy, int dstx, int dsty, int width, int height) const = 0; virtual void blitTo(LockedSurface* dest, int srcx, int srcy, int dstx, int dsty, int width, int height) const = 0;
virtual void drawSurface(const LockedSurface* src, int dstx, int dsty) = 0; virtual void drawSurface(const LockedSurface* src, int dstx, int dsty) = 0;
virtual void drawRgbaSurface(const LockedSurface* src, int dstx, int dsty) = 0; virtual void drawRgbaSurface(const LockedSurface* src, int dstx, int dsty) = 0;
virtual void drawChar(Font* font, she::Color fg, she::Color bg, int x, int y, int chr) = 0; virtual void drawChar(Font* font, gfx::Color fg, gfx::Color bg, int x, int y, int chr) = 0;
virtual void drawString(Font* font, she::Color fg, she::Color bg, int x, int y, const std::string& str) = 0; virtual void drawString(Font* font, gfx::Color fg, gfx::Color bg, int x, int y, const std::string& str) = 0;
}; };
} // namespace she } // namespace she

View File

@ -7,7 +7,6 @@ add_library(ui-lib
box.cpp box.cpp
button.cpp button.cpp
clipboard.cpp clipboard.cpp
color.cpp
combobox.cpp combobox.cpp
component.cpp component.cpp
cursor.cpp cursor.cpp

View File

@ -1,27 +0,0 @@
// Aseprite UI Library
// Copyright (C) 2001-2013 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "ui/color.h"
#include <allegro.h>
namespace ui {
int to_system(Color color)
{
if (is_transparent(color))
return -1;
else
return makecol(getr(color),
getg(color),
getb(color));
}
} // namespace ui

View File

@ -1,48 +0,0 @@
// Aseprite UI Library
// Copyright (C) 2001-2013 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
#ifndef UI_COLOR_H_INCLUDED
#define UI_COLOR_H_INCLUDED
#pragma once
#include "she/color.h"
namespace ui {
typedef uint32_t Color;
typedef uint8_t ColorComponent;
static const int ColorRShift = 0;
static const int ColorGShift = 8;
static const int ColorBShift = 16;
static const int ColorAShift = 24;
static const Color ColorNone = Color(0);
inline Color rgba(ColorComponent r, ColorComponent g, ColorComponent b, ColorComponent a = 255) {
return Color((r << ColorRShift) |
(g << ColorGShift) |
(b << ColorBShift) |
(a << ColorAShift));
}
inline ColorComponent getr(Color c) { return (c >> ColorRShift) & 0xff; }
inline ColorComponent getg(Color c) { return (c >> ColorGShift) & 0xff; }
inline ColorComponent getb(Color c) { return (c >> ColorBShift) & 0xff; }
inline ColorComponent geta(Color c) { return (c >> ColorAShift) & 0xff; }
inline Color setr(Color c, ColorComponent v) { return Color((c & ~ColorRShift) | (v << ColorRShift)); }
inline Color setg(Color c, ColorComponent v) { return Color((c & ~ColorGShift) | (v << ColorGShift)); }
inline Color setb(Color c, ColorComponent v) { return Color((c & ~ColorBShift) | (v << ColorBShift)); }
inline Color seta(Color c, ColorComponent v) { return Color((c & ~ColorAShift) | (v << ColorAShift)); }
inline bool is_transparent(Color c) { return geta(c) == 0; }
int to_system(Color color);
} // namespace ui
#endif // UI_COLOR_H_INCLUDED

View File

@ -22,18 +22,6 @@
#include "she/system.h" #include "she/system.h"
#include "ui/theme.h" #include "ui/theme.h"
namespace {
inline she::Color to_she(ui::Color color) {
return (she::Color)color;
}
inline ui::Color from_she(she::Color color) {
return (ui::Color)color;
}
}
namespace ui { namespace ui {
Graphics::Graphics(she::Surface* surface, int dx, int dy) Graphics::Graphics(she::Surface* surface, int dx, int dy)
@ -72,57 +60,57 @@ bool Graphics::intersectClipRect(const gfx::Rect& rc)
return m_surface->intersectClipRect(gfx::Rect(rc).offset(m_dx, m_dy)); return m_surface->intersectClipRect(gfx::Rect(rc).offset(m_dx, m_dy));
} }
ui::Color Graphics::getPixel(int x, int y) gfx::Color Graphics::getPixel(int x, int y)
{ {
she::ScopedSurfaceLock dst(m_surface); she::ScopedSurfaceLock dst(m_surface);
return from_she(dst->getPixel(m_dx+x, m_dy+y)); return dst->getPixel(m_dx+x, m_dy+y);
} }
void Graphics::putPixel(ui::Color color, int x, int y) void Graphics::putPixel(gfx::Color color, int x, int y)
{ {
she::ScopedSurfaceLock dst(m_surface); she::ScopedSurfaceLock dst(m_surface);
dst->putPixel(to_she(color), m_dx+x, m_dy+y); dst->putPixel(color, m_dx+x, m_dy+y);
} }
void Graphics::drawHLine(ui::Color color, int x, int y, int w) void Graphics::drawHLine(gfx::Color color, int x, int y, int w)
{ {
she::ScopedSurfaceLock dst(m_surface); she::ScopedSurfaceLock dst(m_surface);
dst->drawHLine(to_she(color), m_dx+x, m_dy+y, w); dst->drawHLine(color, m_dx+x, m_dy+y, w);
} }
void Graphics::drawVLine(ui::Color color, int x, int y, int h) void Graphics::drawVLine(gfx::Color color, int x, int y, int h)
{ {
she::ScopedSurfaceLock dst(m_surface); she::ScopedSurfaceLock dst(m_surface);
dst->drawVLine(to_she(color), m_dx+x, m_dy+y, h); dst->drawVLine(color, m_dx+x, m_dy+y, h);
} }
void Graphics::drawLine(ui::Color color, const gfx::Point& a, const gfx::Point& b) void Graphics::drawLine(gfx::Color color, const gfx::Point& a, const gfx::Point& b)
{ {
she::ScopedSurfaceLock dst(m_surface); she::ScopedSurfaceLock dst(m_surface);
dst->drawLine(to_she(color), dst->drawLine(color,
gfx::Point(m_dx+a.x, m_dy+a.y), gfx::Point(m_dx+a.x, m_dy+a.y),
gfx::Point(m_dx+b.x, m_dy+b.y)); gfx::Point(m_dx+b.x, m_dy+b.y));
} }
void Graphics::drawRect(ui::Color color, const gfx::Rect& rc) void Graphics::drawRect(gfx::Color color, const gfx::Rect& rc)
{ {
she::ScopedSurfaceLock dst(m_surface); she::ScopedSurfaceLock dst(m_surface);
dst->drawRect(to_she(color), gfx::Rect(rc).offset(m_dx, m_dy)); dst->drawRect(color, gfx::Rect(rc).offset(m_dx, m_dy));
} }
void Graphics::fillRect(ui::Color color, const gfx::Rect& rc) void Graphics::fillRect(gfx::Color color, const gfx::Rect& rc)
{ {
she::ScopedSurfaceLock dst(m_surface); she::ScopedSurfaceLock dst(m_surface);
dst->fillRect(to_she(color), gfx::Rect(rc).offset(m_dx, m_dy)); dst->fillRect(color, gfx::Rect(rc).offset(m_dx, m_dy));
} }
void Graphics::fillRegion(ui::Color color, const gfx::Region& rgn) void Graphics::fillRegion(gfx::Color color, const gfx::Region& rgn)
{ {
for (gfx::Region::iterator it=rgn.begin(), end=rgn.end(); it!=end; ++it) for (gfx::Region::iterator it=rgn.begin(), end=rgn.end(); it!=end; ++it)
fillRect(color, *it); fillRect(color, *it);
} }
void Graphics::fillAreaBetweenRects(ui::Color color, void Graphics::fillAreaBetweenRects(gfx::Color color,
const gfx::Rect& outer, const gfx::Rect& inner) const gfx::Rect& outer, const gfx::Rect& inner)
{ {
if (!outer.intersects(inner)) if (!outer.intersects(inner))
@ -160,19 +148,19 @@ void Graphics::setFont(she::Font* font)
m_font = font; m_font = font;
} }
void Graphics::drawChar(int chr, Color fg, Color bg, int x, int y) void Graphics::drawChar(int chr, gfx::Color fg, gfx::Color bg, int x, int y)
{ {
she::ScopedSurfaceLock dst(m_surface); she::ScopedSurfaceLock dst(m_surface);
dst->drawChar(m_font, to_she(fg), to_she(bg), m_dx+x, m_dy+y, chr); dst->drawChar(m_font, fg, bg, m_dx+x, m_dy+y, chr);
} }
void Graphics::drawString(const std::string& str, Color fg, Color bg, const gfx::Point& pt) void Graphics::drawString(const std::string& str, gfx::Color fg, gfx::Color bg, const gfx::Point& pt)
{ {
she::ScopedSurfaceLock dst(m_surface); she::ScopedSurfaceLock dst(m_surface);
dst->drawString(m_font, to_she(fg), to_she(bg), m_dx+pt.x, m_dy+pt.y, str); dst->drawString(m_font, fg, bg, m_dx+pt.x, m_dy+pt.y, str);
} }
void Graphics::drawUIString(const std::string& str, Color fg, Color bg, const gfx::Point& pt) void Graphics::drawUIString(const std::string& str, gfx::Color fg, gfx::Color bg, const gfx::Point& pt)
{ {
she::ScopedSurfaceLock dst(m_surface); she::ScopedSurfaceLock dst(m_surface);
base::utf8_const_iterator it(str.begin()), end(str.end()); base::utf8_const_iterator it(str.begin()), end(str.end());
@ -190,19 +178,19 @@ void Graphics::drawUIString(const std::string& str, Color fg, Color bg, const gf
underscored_w = m_font->charWidth(*it); underscored_w = m_font->charWidth(*it);
} }
} }
dst->drawChar(m_font, to_she(fg), to_she(bg), x, y, *it); dst->drawChar(m_font, fg, bg, x, y, *it);
x += m_font->charWidth(*it); x += m_font->charWidth(*it);
++it; ++it;
} }
if (underscored_w > 0) { if (underscored_w > 0) {
y += m_font->height(); y += m_font->height();
dst->fillRect(to_she(fg), dst->fillRect(fg,
gfx::Rect(underscored_x, y, underscored_w, jguiscale())); gfx::Rect(underscored_x, y, underscored_w, jguiscale()));
} }
} }
void Graphics::drawAlignedUIString(const std::string& str, Color fg, Color bg, const gfx::Rect& rc, int align) void Graphics::drawAlignedUIString(const std::string& str, gfx::Color fg, gfx::Color bg, const gfx::Rect& rc, int align)
{ {
doUIStringAlgorithm(str, fg, bg, rc, align, true); doUIStringAlgorithm(str, fg, bg, rc, align, true);
} }
@ -240,15 +228,15 @@ int Graphics::measureUIStringLength(const std::string& str, she::Font* font)
gfx::Size Graphics::fitString(const std::string& str, int maxWidth, int align) gfx::Size Graphics::fitString(const std::string& str, int maxWidth, int align)
{ {
return doUIStringAlgorithm(str, ColorNone, ColorNone, gfx::Rect(0, 0, maxWidth, 0), align, false); return doUIStringAlgorithm(str, gfx::ColorNone, gfx::ColorNone, gfx::Rect(0, 0, maxWidth, 0), align, false);
} }
gfx::Size Graphics::doUIStringAlgorithm(const std::string& str, Color fg, Color bg, const gfx::Rect& rc, int align, bool draw) gfx::Size Graphics::doUIStringAlgorithm(const std::string& str, gfx::Color fg, gfx::Color bg, const gfx::Rect& rc, int align, bool draw)
{ {
gfx::Point pt(0, rc.y); gfx::Point pt(0, rc.y);
if ((align & (JI_MIDDLE | JI_BOTTOM)) != 0) { if ((align & (JI_MIDDLE | JI_BOTTOM)) != 0) {
gfx::Size preSize = doUIStringAlgorithm(str, ColorNone, ColorNone, rc, 0, false); gfx::Size preSize = doUIStringAlgorithm(str, gfx::ColorNone, gfx::ColorNone, rc, 0, false);
if (align & JI_MIDDLE) if (align & JI_MIDDLE)
pt.y = rc.y + rc.h/2 - preSize.h/2; pt.y = rc.y + rc.h/2 - preSize.h/2;
else if (align & JI_BOTTOM) else if (align & JI_BOTTOM)
@ -318,7 +306,7 @@ gfx::Size Graphics::doUIStringAlgorithm(const std::string& str, Color fg, Color
drawString(line, fg, bg, gfx::Point(xout, pt.y)); drawString(line, fg, bg, gfx::Point(xout, pt.y));
if (!is_transparent(bg)) if (!gfx::is_transparent(bg))
fillAreaBetweenRects(bg, fillAreaBetweenRects(bg,
gfx::Rect(rc.x, pt.y, rc.w, lineSize.h), gfx::Rect(rc.x, pt.y, rc.w, lineSize.h),
gfx::Rect(xout, pt.y, lineSize.w, lineSize.h)); gfx::Rect(xout, pt.y, lineSize.w, lineSize.h));
@ -330,7 +318,7 @@ gfx::Size Graphics::doUIStringAlgorithm(const std::string& str, Color fg, Color
} }
// Fill bottom area // Fill bottom area
if (draw && !is_transparent(bg)) { if (draw && !gfx::is_transparent(bg)) {
if (pt.y < rc.y+rc.h) if (pt.y < rc.y+rc.h)
fillRect(bg, gfx::Rect(rc.x, pt.y, rc.w, rc.y+rc.h-pt.y)); fillRect(bg, gfx::Rect(rc.x, pt.y, rc.w, rc.y+rc.h-pt.y));
} }

View File

@ -8,12 +8,12 @@
#define UI_GRAPHICS_H_INCLUDED #define UI_GRAPHICS_H_INCLUDED
#pragma once #pragma once
#include "base/shared_ptr.h"
#include "base/disable_copying.h" #include "base/disable_copying.h"
#include "base/shared_ptr.h"
#include "gfx/color.h"
#include "gfx/point.h" #include "gfx/point.h"
#include "gfx/rect.h" #include "gfx/rect.h"
#include "gfx/size.h" #include "gfx/size.h"
#include "ui/color.h"
#include <string> #include <string>
@ -45,17 +45,17 @@ namespace ui {
void setClipBounds(const gfx::Rect& rc); void setClipBounds(const gfx::Rect& rc);
bool intersectClipRect(const gfx::Rect& rc); bool intersectClipRect(const gfx::Rect& rc);
ui::Color getPixel(int x, int y); gfx::Color getPixel(int x, int y);
void putPixel(ui::Color color, int x, int y); void putPixel(gfx::Color color, int x, int y);
void drawHLine(ui::Color color, int x, int y, int w); void drawHLine(gfx::Color color, int x, int y, int w);
void drawVLine(ui::Color color, int x, int y, int h); void drawVLine(gfx::Color color, int x, int y, int h);
void drawLine(ui::Color color, const gfx::Point& a, const gfx::Point& b); void drawLine(gfx::Color color, const gfx::Point& a, const gfx::Point& b);
void drawRect(ui::Color color, const gfx::Rect& rc); void drawRect(gfx::Color color, const gfx::Rect& rc);
void fillRect(ui::Color color, const gfx::Rect& rc); void fillRect(gfx::Color color, const gfx::Rect& rc);
void fillRegion(ui::Color color, const gfx::Region& rgn); void fillRegion(gfx::Color color, const gfx::Region& rgn);
void fillAreaBetweenRects(ui::Color color, void fillAreaBetweenRects(gfx::Color color,
const gfx::Rect& outer, const gfx::Rect& inner); const gfx::Rect& outer, const gfx::Rect& inner);
void drawSurface(she::Surface* surface, int x, int y); void drawSurface(she::Surface* surface, int x, int y);
@ -70,10 +70,10 @@ namespace ui {
void setFont(she::Font* font); void setFont(she::Font* font);
she::Font* getFont() { return m_font; } she::Font* getFont() { return m_font; }
void drawChar(int chr, Color fg, Color bg, int x, int y); void drawChar(int chr, gfx::Color fg, gfx::Color bg, int x, int y);
void drawString(const std::string& str, Color fg, Color bg, const gfx::Point& pt); void drawString(const std::string& str, gfx::Color fg, gfx::Color bg, const gfx::Point& pt);
void drawUIString(const std::string& str, Color fg, Color bg, const gfx::Point& pt); void drawUIString(const std::string& str, gfx::Color fg, gfx::Color bg, const gfx::Point& pt);
void drawAlignedUIString(const std::string& str, Color fg, Color bg, const gfx::Rect& rc, int align); void drawAlignedUIString(const std::string& str, gfx::Color fg, gfx::Color bg, const gfx::Rect& rc, int align);
gfx::Size measureChar(int chr); gfx::Size measureChar(int chr);
gfx::Size measureUIString(const std::string& str); gfx::Size measureUIString(const std::string& str);
@ -81,7 +81,7 @@ namespace ui {
gfx::Size fitString(const std::string& str, int maxWidth, int align); gfx::Size fitString(const std::string& str, int maxWidth, int align);
private: private:
gfx::Size doUIStringAlgorithm(const std::string& str, Color fg, Color bg, const gfx::Rect& rc, int align, bool draw); gfx::Size doUIStringAlgorithm(const std::string& str, gfx::Color fg, gfx::Color bg, const gfx::Rect& rc, int align, bool draw);
she::Surface* m_surface; she::Surface* m_surface;
int m_dx; int m_dx;

View File

@ -142,7 +142,7 @@ void IntEntry::openPopup()
m_popupWindow = new PopupWindow("", PopupWindow::kCloseOnClickInOtherWindow); m_popupWindow = new PopupWindow("", PopupWindow::kCloseOnClickInOtherWindow);
m_popupWindow->setAutoRemap(false); m_popupWindow->setAutoRemap(false);
m_popupWindow->setTransparent(true); m_popupWindow->setTransparent(true);
m_popupWindow->setBgColor(ui::ColorNone); m_popupWindow->setBgColor(gfx::ColorNone);
m_popupWindow->setBounds(rc); m_popupWindow->setBounds(rc);
m_popupWindow->Close.connect(&IntEntry::onPopupClose, this); m_popupWindow->Close.connect(&IntEntry::onPopupClose, this);

View File

@ -8,8 +8,8 @@
#define UI_INTERN_H_INCLUDED #define UI_INTERN_H_INCLUDED
#pragma once #pragma once
#include "gfx/color.h"
#include "ui/base.h" #include "ui/base.h"
#include "ui/color.h"
namespace she { namespace she {
class Font; class Font;
@ -32,7 +32,7 @@ namespace ui {
// theme.cpp // theme.cpp
void drawTextBox(Graphics* g, Widget* textbox, void drawTextBox(Graphics* g, Widget* textbox,
int* w, int* h, ui::Color bg, ui::Color fg); int* w, int* h, gfx::Color bg, gfx::Color fg);
} // namespace ui } // namespace ui

View File

@ -23,12 +23,12 @@ Label::Label(const std::string& text)
initTheme(); initTheme();
} }
Color Label::getTextColor() const gfx::Color Label::getTextColor() const
{ {
return m_textColor; return m_textColor;
} }
void Label::setTextColor(Color color) void Label::setTextColor(gfx::Color color)
{ {
m_textColor = color; m_textColor = color;
} }

View File

@ -9,7 +9,7 @@
#pragma once #pragma once
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "ui/color.h" #include "gfx/color.h"
#include "ui/widget.h" #include "ui/widget.h"
namespace ui { namespace ui {
@ -19,15 +19,15 @@ namespace ui {
public: public:
Label(const std::string& text); Label(const std::string& text);
Color getTextColor() const; gfx::Color getTextColor() const;
void setTextColor(Color color); void setTextColor(gfx::Color color);
protected: protected:
void onPreferredSize(PreferredSizeEvent& ev) OVERRIDE; void onPreferredSize(PreferredSizeEvent& ev) OVERRIDE;
void onPaint(PaintEvent& ev) OVERRIDE; void onPaint(PaintEvent& ev) OVERRIDE;
private: private:
Color m_textColor; gfx::Color m_textColor;
}; };
} // namespace ui } // namespace ui

View File

@ -159,7 +159,7 @@ void TextBox::onPreferredSize(PreferredSizeEvent& ev)
//w = widget->border_width.l + widget->border_width.r; //w = widget->border_width.l + widget->border_width.r;
//h = widget->border_width.t + widget->border_width.b; //h = widget->border_width.t + widget->border_width.b;
drawTextBox(NULL, this, &w, &h, ColorNone, ColorNone); drawTextBox(NULL, this, &w, &h, gfx::ColorNone, gfx::ColorNone);
if (this->getAlign() & JI_WORDWRAP) { if (this->getAlign() & JI_WORDWRAP) {
View* view = View::getView(this); View* view = View::getView(this);
@ -173,7 +173,7 @@ void TextBox::onPreferredSize(PreferredSizeEvent& ev)
} }
w = MAX(min, width); w = MAX(min, width);
drawTextBox(NULL, this, &w, &h, ColorNone, ColorNone); drawTextBox(NULL, this, &w, &h, gfx::ColorNone, gfx::ColorNone);
w = min; w = min;
} }

View File

@ -72,7 +72,7 @@ Theme* CurrentTheme::get()
} }
void drawTextBox(Graphics* g, Widget* widget, void drawTextBox(Graphics* g, Widget* widget,
int* w, int* h, Color bg, Color fg) int* w, int* h, gfx::Color bg, gfx::Color fg)
{ {
View* view = View::getView(widget); View* view = View::getView(widget);
char* text = const_cast<char*>(widget->getText().c_str()); char* text = const_cast<char*>(widget->getText().c_str());

View File

@ -229,7 +229,7 @@ void TipWindow::onInitTheme(InitThemeEvent& ev)
this->border_width.b = 7 * jguiscale(); this->border_width.b = 7 * jguiscale();
// Setup the background color. // Setup the background color.
setBgColor(ui::rgba(255, 255, 200)); setBgColor(gfx::rgba(255, 255, 200));
} }
void TipWindow::onPaint(PaintEvent& ev) void TipWindow::onPaint(PaintEvent& ev)

View File

@ -14,7 +14,6 @@
#include "ui/box.h" #include "ui/box.h"
#include "ui/button.h" #include "ui/button.h"
#include "ui/clipboard.h" #include "ui/clipboard.h"
#include "ui/color.h"
#include "ui/combobox.h" #include "ui/combobox.h"
#include "ui/component.h" #include "ui/component.h"
#include "ui/cursor.h" #include "ui/cursor.h"

View File

@ -66,7 +66,7 @@ Widget::Widget(WidgetType type)
this->m_align = 0; this->m_align = 0;
this->m_font = (this->m_theme ? this->m_theme->default_font: NULL); this->m_font = (this->m_theme ? this->m_theme->default_font: NULL);
this->m_bgColor = ui::ColorNone; this->m_bgColor = gfx::ColorNone;
this->theme_data[0] = NULL; this->theme_data[0] = NULL;
this->theme_data[1] = NULL; this->theme_data[1] = NULL;
@ -171,7 +171,7 @@ void Widget::setFont(she::Font* font)
invalidate(); invalidate();
} }
void Widget::setBgColor(ui::Color color) void Widget::setBgColor(gfx::Color color)
{ {
m_bgColor = color; m_bgColor = color;
onSetBgColor(); onSetBgColor();
@ -969,7 +969,7 @@ bool Widget::paintEvent(Graphics* graphics)
#if _DEBUG #if _DEBUG
// In debug mode we can fill the area with Red so we know if the // In debug mode we can fill the area with Red so we know if the
// we are drawing the parent correctly. // we are drawing the parent correctly.
graphics->fillRect(ui::rgba(255, 0, 0), getClientBounds()); graphics->fillRect(gfx::rgba(255, 0, 0), getClientBounds());
#endif #endif
this->flags |= JI_HIDDEN; this->flags |= JI_HIDDEN;

View File

@ -9,12 +9,12 @@
#pragma once #pragma once
#include "gfx/border.h" #include "gfx/border.h"
#include "gfx/color.h"
#include "gfx/point.h" #include "gfx/point.h"
#include "gfx/rect.h" #include "gfx/rect.h"
#include "gfx/region.h" #include "gfx/region.h"
#include "gfx/size.h" #include "gfx/size.h"
#include "ui/base.h" #include "ui/base.h"
#include "ui/color.h"
#include "ui/component.h" #include "ui/component.h"
#include "ui/graphics.h" #include "ui/graphics.h"
#include "ui/widget_type.h" #include "ui/widget_type.h"
@ -149,15 +149,15 @@ namespace ui {
void setFont(she::Font* font); void setFont(she::Font* font);
// Gets the background color of the widget. // Gets the background color of the widget.
ui::Color getBgColor() const { gfx::Color getBgColor() const {
if (ui::geta(m_bgColor) == 0 && m_parent) if (gfx::geta(m_bgColor) == 0 && m_parent)
return m_parent->getBgColor(); return m_parent->getBgColor();
else else
return m_bgColor; return m_bgColor;
} }
// Sets the background color of the widget // Sets the background color of the widget
void setBgColor(ui::Color color); void setBgColor(gfx::Color color);
Theme* getTheme() const { return m_theme; } Theme* getTheme() const { return m_theme; }
void setTheme(Theme* theme); void setTheme(Theme* theme);
@ -375,11 +375,11 @@ namespace ui {
bool paintEvent(Graphics* graphics); bool paintEvent(Graphics* graphics);
std::string m_id; // Widget's id std::string m_id; // Widget's id
Theme* m_theme; // Widget's theme Theme* m_theme; // Widget's theme
int m_align; // Widget alignment int m_align; // Widget alignment
std::string m_text; // Widget text std::string m_text; // Widget text
she::Font* m_font; // Text font type she::Font* m_font; // Text font type
ui::Color m_bgColor; // Background color gfx::Color m_bgColor; // Background color
gfx::Rect m_bounds; gfx::Rect m_bounds;
gfx::Region m_updateRegion; // Region to be redrawed. gfx::Region m_updateRegion; // Region to be redrawed.
WidgetsList m_children; // Sub-widgets WidgetsList m_children; // Sub-widgets