From 4b7bf5b835767013dbb64738958f1d87913051ed Mon Sep 17 00:00:00 2001 From: David Capello Date: Sat, 28 Jun 2014 16:10:39 -0300 Subject: [PATCH] Merge she::Color and ui::Color types in gfx::Color --- src/README.md | 2 +- src/app/color_utils.cpp | 53 ++++++++++--------- src/app/color_utils.h | 8 +-- src/app/modules/gfx.cpp | 18 +++---- src/app/modules/gfx.h | 2 +- src/app/ui/color_bar.cpp | 2 +- src/app/ui/color_button.cpp | 10 ++-- src/app/ui/color_selector.cpp | 4 +- src/app/ui/color_sliders.cpp | 8 +-- src/app/ui/context_bar.cpp | 4 +- src/app/ui/editor/cursor.cpp | 44 ++++++++-------- src/app/ui/editor/editor.cpp | 2 +- src/app/ui/editor/editor.h | 4 +- src/app/ui/editor/editor_view.cpp | 2 +- src/app/ui/editor/transform_handles.cpp | 4 +- src/app/ui/file_list.cpp | 6 +-- src/app/ui/palette_view.cpp | 4 +- src/app/ui/palettes_listbox.cpp | 4 +- src/app/ui/resources_listbox.cpp | 6 +-- src/app/ui/skin/skin_theme.cpp | 67 +++++++++++------------ src/app/ui/skin/skin_theme.h | 22 ++++---- src/app/ui/skin/style.cpp | 8 +-- src/app/ui/skin/style.h | 14 ++--- src/app/ui/skin/style_sheet.cpp | 6 +-- src/app/ui/skin/style_sheet.h | 4 +- src/app/ui/status_bar.cpp | 2 +- src/app/ui/tabs.cpp | 6 +-- src/app/ui/toolbar.cpp | 10 ++-- src/gfx/CMakeLists.txt | 2 +- src/gfx/LICENSE.txt | 2 +- src/gfx/README.md | 2 +- src/{she => gfx}/color.h | 14 ++--- src/she/alleg4/alleg4_surface.h | 48 ++++++++--------- src/she/locked_surface.h | 20 +++---- src/ui/CMakeLists.txt | 1 - src/ui/color.cpp | 27 ---------- src/ui/color.h | 48 ----------------- src/ui/graphics.cpp | 70 ++++++++++--------------- src/ui/graphics.h | 32 +++++------ src/ui/int_entry.cpp | 2 +- src/ui/intern.h | 4 +- src/ui/label.cpp | 4 +- src/ui/label.h | 8 +-- src/ui/textbox.cpp | 4 +- src/ui/theme.cpp | 2 +- src/ui/tooltips.cpp | 2 +- src/ui/ui.h | 1 - src/ui/widget.cpp | 6 +-- src/ui/widget.h | 14 ++--- 49 files changed, 276 insertions(+), 363 deletions(-) rename src/{she => gfx}/color.h (88%) delete mode 100644 src/ui/color.cpp delete mode 100644 src/ui/color.h diff --git a/src/README.md b/src/README.md index a2b6d8eeb..c0567638c 100644 --- a/src/README.md +++ b/src/README.md @@ -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). * [net](net/) (base): Networking library to send HTTP requests. * [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)) ## Level 2 diff --git a/src/app/color_utils.cpp b/src/app/color_utils.cpp index 408aa910c..d60464a96 100644 --- a/src/app/color_utils.cpp +++ b/src/app/color_utils.cpp @@ -32,8 +32,6 @@ #include "raster/palette.h" #include "raster/sprite.h" -using namespace gfx; - // Internal functions namespace { @@ -56,43 +54,45 @@ int get_mask_for_bitmap(int depth) 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) - return ui::rgba(0, 0, 0); + if ((gfx::getr(color)*30+gfx::getg(color)*59+gfx::getb(color)*11)/100 < 128) + return gfx::rgba(0, 0, 0); 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) - return ui::rgba(255, 255, 255); + if ((gfx::getr(color)*30+gfx::getg(color)*59+gfx::getb(color)*11)/100 < 128) + return gfx::rgba(255, 255, 255); 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()) { case app::Color::MaskType: - c = ui::ColorNone; + c = gfx::ColorNone; break; case app::Color::RgbType: case app::Color::HsvType: - c = ui::rgba(color.getRed(), - color.getGreen(), - color.getBlue(), 255); + c = gfx::rgba( + color.getRed(), + color.getGreen(), + color.getBlue(), 255); break; case app::Color::GrayType: - c = ui::rgba(color.getGray(), - color.getGray(), - color.getGray(), 255); + c = gfx::rgba( + color.getGray(), + color.getGray(), + color.getGray(), 255); break; 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()); uint32_t _c = get_current_palette()->getEntry(i); - c = ui::rgba(rgba_getr(_c), - rgba_getg(_c), - rgba_getb(_c), 255); + c = gfx::rgba( + rgba_getr(_c), + rgba_getg(_c), + rgba_getb(_c), 255); break; } @@ -120,10 +121,10 @@ raster::color_t color_utils::color_for_image(const app::Color& color, PixelForma switch (format) { case IMAGE_RGB: - c = rgba(color.getRed(), color.getGreen(), color.getBlue(), 255); + c = raster::rgba(color.getRed(), color.getGreen(), color.getBlue(), 255); break; case IMAGE_GRAYSCALE: - c = graya(color.getGray(), 255); + c = raster::graya(color.getGray(), 255); break; case IMAGE_INDEXED: c = color.getIndex(); @@ -147,10 +148,10 @@ raster::color_t color_utils::color_for_target(const app::Color& color, const Col switch (colorTarget.pixelFormat()) { case IMAGE_RGB: - c = rgba(color.getRed(), color.getGreen(), color.getBlue(), 255); + c = raster::rgba(color.getRed(), color.getGreen(), color.getBlue(), 255); break; case IMAGE_GRAYSCALE: - c = graya(color.getGray(), 255); + c = raster::graya(color.getGray(), 255); break; case IMAGE_INDEXED: if (color.getType() == app::Color::IndexType) { diff --git a/src/app/color_utils.h b/src/app/color_utils.h index 1e49fdcc9..b35f26356 100644 --- a/src/app/color_utils.h +++ b/src/app/color_utils.h @@ -22,9 +22,9 @@ #include "app/color.h" #include "app/color_target.h" +#include "gfx/color.h" #include "raster/color.h" #include "raster/pixel_format.h" -#include "ui/color.h" namespace raster { class Layer; @@ -33,10 +33,10 @@ namespace raster { namespace app { namespace color_utils { - ui::Color blackandwhite(ui::Color color); - ui::Color blackandwhite_neg(ui::Color color); + gfx::Color blackandwhite(gfx::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_layer(const app::Color& color, raster::Layer* layer); raster::color_t color_for_target(const app::Color& color, const ColorTarget& colorTarget); diff --git a/src/app/modules/gfx.cpp b/src/app/modules/gfx.cpp index fdf943655..3f2ef4046 100644 --- a/src/app/modules/gfx.cpp +++ b/src/app/modules/gfx.cpp @@ -23,25 +23,25 @@ #include #include -#include "ui/color.h" +#include "gfx/color.h" #include "ui/intern.h" #include "ui/system.h" #include "ui/theme.h" #include "app/app.h" #include "app/color_utils.h" -#include "app/ui/editor/editor.h" #include "app/console.h" -#include "gfx/point.h" -#include "gfx/rect.h" #include "app/ini_file.h" #include "app/modules/gfx.h" #include "app/modules/gui.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/image.h" #include "raster/palette.h" -#include "app/ui/skin/skin_theme.h" namespace app { @@ -171,8 +171,8 @@ static void rectgrid(ui::Graphics* g, const gfx::Rect& rc, const gfx::Size& tile return; int x, y, u, v; - ui::Color c1 = ui::rgba(128, 128, 128); - ui::Color c2 = ui::rgba(192, 192, 192); + gfx::Color c1 = gfx::rgba(128, 128, 128); + gfx::Color c2 = gfx::rgba(192, 192, 192); u = 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); } else { - g->fillRect(ui::rgba(0, 0, 0), rc); - g->drawLine(ui::rgba(255, 255, 255), + g->fillRect(gfx::rgba(0, 0, 0), rc); + g->drawLine(gfx::rgba(255, 255, 255), gfx::Point(rc.x+rc.w-2, rc.y+1), gfx::Point(rc.x+1, rc.y+rc.h-2)); } diff --git a/src/app/modules/gfx.h b/src/app/modules/gfx.h index 299c06bd6..09528b733 100644 --- a/src/app/modules/gfx.h +++ b/src/app/modules/gfx.h @@ -21,9 +21,9 @@ #pragma once #include "app/color.h" +#include "gfx/color.h" #include "gfx/rect.h" #include "ui/base.h" -#include "ui/color.h" #include "ui/graphics.h" namespace app { diff --git a/src/app/ui/color_bar.cpp b/src/app/ui/color_bar.cpp index 90cf661c9..c3fa7d194 100644 --- a/src/app/ui/color_bar.cpp +++ b/src/app/ui/color_bar.cpp @@ -67,7 +67,7 @@ void ColorBar::ScrollableView::onPaint(ui::PaintEvent& ev) getClientBounds(), hasFocus() ? PART_EDITOR_SELECTED_NW: PART_EDITOR_NORMAL_NW, - ColorNone); + gfx::ColorNone); } ////////////////////////////////////////////////////////////////////// diff --git a/src/app/ui/color_button.cpp b/src/app/ui/color_button.cpp index 9e275755c..467ac76f4 100644 --- a/src/app/ui/color_button.cpp +++ b/src/app/ui/color_button.cpp @@ -179,8 +179,8 @@ void ColorButton::onPaint(PaintEvent& ev) SkinTheme* theme = static_cast(getTheme()); gfx::Rect rc = getClientBounds(); - ui::Color bg = getBgColor(); - if (is_transparent(bg)) + gfx::Color bg = getBgColor(); + if (gfx::is_transparent(bg)) bg = theme->getColor(ThemeColor::Face); g->fillRect(bg, rc); @@ -205,13 +205,13 @@ void ColorButton::onPaint(PaintEvent& ev) setTextQuiet(str.c_str()); - ui::Color textcolor = ui::rgba(255, 255, 255); + gfx::Color textcolor = gfx::rgba(255, 255, 255); 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; getTextIconInfo(NULL, &text); - g->drawUIString(getText(), textcolor, ColorNone, text.getOrigin()); + g->drawUIString(getText(), textcolor, gfx::ColorNone, text.getOrigin()); } void ColorButton::onClick(Event& ev) diff --git a/src/app/ui/color_selector.cpp b/src/app/ui/color_selector.cpp index aa7f53e75..aff74115f 100644 --- a/src/app/ui/color_selector.cpp +++ b/src/app/ui/color_selector.cpp @@ -239,10 +239,10 @@ void ColorSelector::onFixWarningClick(ui::Event& ev) { try { Palette* newPalette = get_current_palette(); // System current pal - color_t newColor = rgba( + color_t newColor = raster::rgba( m_color.getRed(), m_color.getGreen(), - m_color.getBlue()); + m_color.getBlue(), 255); int index = newPalette->findExactMatch( m_color.getRed(), m_color.getGreen(), diff --git a/src/app/ui/color_sliders.cpp b/src/app/ui/color_sliders.cpp index 99e995c4d..4bedbdc60 100644 --- a/src/app/ui/color_sliders.cpp +++ b/src/app/ui/color_sliders.cpp @@ -52,17 +52,17 @@ namespace { } 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) { switch (m_channel) { 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; 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; 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; case ColorSliders::Hue: color = color_utils::color_for_ui(app::Color::fromHsv(360 * x / (rc.w-1), m_color.getSaturation(), m_color.getValue())); diff --git a/src/app/ui/context_bar.cpp b/src/app/ui/context_bar.cpp index a00f552db..f9e998881 100644 --- a/src/app/ui/context_bar.cpp +++ b/src/app/ui/context_bar.cpp @@ -172,7 +172,7 @@ private: PART_BRUSH_LINE); m_brushTypeButton->ItemChange.connect(&BrushTypeField::onBrushTypeChange, this); m_brushTypeButton->setTransparent(true); - m_brushTypeButton->setBgColor(ui::ColorNone); + m_brushTypeButton->setBgColor(gfx::ColorNone); m_popupWindow->addChild(m_brushTypeButton); m_popupWindow->openWindow(); @@ -546,7 +546,7 @@ private: PART_FREEHAND_ALGO_DOTS); m_freehandAlgoButton->ItemChange.connect(&FreehandAlgorithmField::onFreehandAlgoChange, this); 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(1), "Pixel-perfect trace", JI_TOP); diff --git a/src/app/ui/editor/cursor.cpp b/src/app/ui/editor/cursor.cpp index 02e69597b..a2f6513e3 100644 --- a/src/app/ui/editor/cursor.cpp +++ b/src/app/ui/editor/cursor.cpp @@ -77,7 +77,7 @@ enum { static int cursor_type = CURSOR_THINCROSS; static int cursor_negative; -static ui::Color saved_pixel[MAX_SAVED]; +static gfx::Color saved_pixel[MAX_SAVED]; static int saved_pixel_n; // 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 trace_thincross_pixels(ui::Graphics* g, Editor* editor, int x, int y, ui::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_brush_bounds(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, gfx::Color color, int thickness, 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 drawpixel(ui::Graphics* g, int x, int y, ui::Color color); -static void clearpixel(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, gfx::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); @@ -102,7 +102,7 @@ static color_t get_brush_color(Sprite* sprite, Layer* layer); ////////////////////////////////////////////////////////////////////// static app::Color cursor_color; -static ui::Color ui_cursor_color; +static gfx::Color ui_cursor_color; static bool is_cursor_mask; static void update_cursor_color() @@ -338,7 +338,7 @@ void Editor::moveBrushPreview(int x, int y, bool refresh) ScreenGraphics g; 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()) { @@ -387,7 +387,7 @@ void Editor::clearBrushPreview(bool refresh) ScreenGraphics g; 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 @@ -469,7 +469,7 @@ void Editor::forEachBrushPixel( ui::Graphics* g, int screen_x, int screen_y, int sprite_x, int sprite_y, - ui::Color color, + gfx::Color color, Editor::PixelDelegate pixelDelegate) { saved_pixel_n = 0; @@ -492,7 +492,7 @@ void Editor::forEachBrushPixel( // New Thin Cross 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] = { 0, 0, 0, 1, 0, 0, 0, @@ -520,7 +520,7 @@ static void trace_thincross_pixels(ui::Graphics* g, Editor* editor, // Old Thick Cross 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] = { 0, 0, 1, 1, 0, 0, @@ -557,7 +557,7 @@ static void trace_thickcross_pixels(ui::Graphics* g, Editor* editor, struct Data { ui::Graphics* g; - ui::Color color; + gfx::Color color; 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, - 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 }; int c, x1, y1, x2, y2; @@ -613,22 +613,22 @@ static void trace_brush_bounds(ui::Graphics* g, Editor* editor, ////////////////////////////////////////////////////////////////////// // 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))) 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 (cursor_negative) { int c = saved_pixel[saved_pixel_n++]; - int r = getr(c); - int g = getg(c); - int b = getb(c); + int r = gfx::getr(c); + int g = gfx::getg(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 { 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 (clipping_region.contains(gfx::Point(x, y))) diff --git a/src/app/ui/editor/editor.cpp b/src/app/ui/editor/editor.cpp index 23da8b848..55497d2e0 100644 --- a/src/app/ui/editor/editor.cpp +++ b/src/app/ui/editor/editor.cpp @@ -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; // 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 int x1 = spriteBounds.x; diff --git a/src/app/ui/editor/editor.h b/src/app/ui/editor/editor.h index 7bd73c405..371bdb0e2 100644 --- a/src/app/ui/editor/editor.h +++ b/src/app/ui/editor/editor.h @@ -65,7 +65,7 @@ namespace app { class Editor : public ui::Widget, public DocumentSettingsObserver { 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 { kNoneFlag = 0, @@ -216,7 +216,7 @@ namespace app { ui::Graphics* g, int screen_x, int screen_y, int sprite_x, int sprite_y, - ui::Color color, + gfx::Color color, PixelDelegate pixelDelegate); // Draws the specified portion of sprite in the editor. Warning: diff --git a/src/app/ui/editor/editor_view.cpp b/src/app/ui/editor/editor_view.cpp index 952e42b59..3b01ffbcd 100644 --- a/src/app/ui/editor/editor_view.cpp +++ b/src/app/ui/editor/editor_view.cpp @@ -48,7 +48,7 @@ EditorView::EditorView(EditorView::Type type) int b = theme->get_part(PART_EDITOR_SELECTED_S)->height(); setBorder(gfx::Border(l, t, r, b)); - setBgColor(ui::rgba(0, 0, 0)); + setBgColor(gfx::rgba(0, 0, 0)); setupScrollbars(); UIContext::instance()->settings()->addObserver(this); diff --git a/src/app/ui/editor/transform_handles.cpp b/src/app/ui/editor/transform_handles.cpp index 49067930a..fe5340520 100644 --- a/src/app/ui/editor/transform_handles.cpp +++ b/src/app/ui/editor/transform_handles.cpp @@ -130,12 +130,12 @@ void TransformHandles::drawHandles(Editor* editor, const gfx::Transformation& tr y2 = y1 + transform.bounds().h; editor->editorToScreen(x1, y1, &x1, &y1); 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; y1 = transform.pivot().y; 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 diff --git a/src/app/ui/file_list.cpp b/src/app/ui/file_list.cpp index 5b900c465..55d6b5c77 100644 --- a/src/app/ui/file_list.cpp +++ b/src/app/ui/file_list.cpp @@ -309,8 +309,8 @@ void FileList::onPaint(ui::PaintEvent& ev) int th = getTextHeight(); int x, y = bounds.y; int evenRow = 0; - ui::Color bgcolor; - ui::Color fgcolor; + gfx::Color bgcolor; + gfx::Color fgcolor; she::Surface* thumbnail = NULL; int thumbnail_y = 0; @@ -390,7 +390,7 @@ void FileList::onPaint(ui::PaintEvent& ev) y -= getBounds().y; 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)); } } diff --git a/src/app/ui/palette_view.cpp b/src/app/ui/palette_view.cpp index 2c520dae9..fd6a011d7 100644 --- a/src/app/ui/palette_view.cpp +++ b/src/app/ui/palette_view.cpp @@ -283,7 +283,7 @@ void PaletteView::onPaint(ui::PaintEvent& ev) Palette* palette = get_current_palette(); 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; c = 0; @@ -295,7 +295,7 @@ void PaletteView::onPaint(ui::PaintEvent& ev) if (c >= palette->size()) break; - color = ui::rgba( + color = gfx::rgba( rgba_getr(palette->getEntry(c)), rgba_getg(palette->getEntry(c)), rgba_getb(palette->getEntry(c))); diff --git a/src/app/ui/palettes_listbox.cpp b/src/app/ui/palettes_listbox.cpp index 5bbd15197..925c58cdd 100644 --- a/src/app/ui/palettes_listbox.cpp +++ b/src/app/ui/palettes_listbox.cpp @@ -72,7 +72,7 @@ void PalettesListBox::onPaintResource(Graphics* g, const gfx::Rect& bounds, Reso for (int i=0; isize(); ++i) { raster::color_t c = palette->getEntry(i); - g->fillRect(ui::rgba( + g->fillRect(gfx::rgba( raster::rgba_getr(c), raster::rgba_getg(c), raster::rgba_getb(c)), box); @@ -80,7 +80,7 @@ void PalettesListBox::onPaintResource(Graphics* g, const gfx::Rect& bounds, Reso box.x += box.w; } - // g->drawString(getText(), fgcolor, ui::ColorNone, false, + // g->drawString(getText(), fgcolor, gfx::ColorNone, false, // gfx::Point( // bounds.x + jguiscale()*2, // bounds.y + bounds.h/2 - g->measureUIString(getText()).h/2)); diff --git a/src/app/ui/resources_listbox.cpp b/src/app/ui/resources_listbox.cpp index 9c63e4d76..e19377621 100644 --- a/src/app/ui/resources_listbox.cpp +++ b/src/app/ui/resources_listbox.cpp @@ -63,7 +63,7 @@ protected: SkinTheme* theme = static_cast(getTheme()); Graphics* g = ev.getGraphics(); gfx::Rect bounds = getClientBounds(); - ui::Color bgcolor, fgcolor; + gfx::Color bgcolor, fgcolor; if (isSelected()) { bgcolor = theme->getColor(ThemeColor::ListItemSelectedFace); @@ -82,7 +82,7 @@ protected: // for (int i=0; isize(); ++i) { // raster::color_t c = m_resource->getEntry(i); - // g->fillRect(ui::rgba( + // g->fillRect(gfx::rgba( // raster::rgba_getr(c), // raster::rgba_getg(c), // raster::rgba_getb(c)), box); @@ -90,7 +90,7 @@ protected: // box.x += box.w; // } - g->drawString(getText(), fgcolor, ui::ColorNone, + g->drawString(getText(), fgcolor, gfx::ColorNone, gfx::Point( bounds.x + jguiscale()*2, bounds.y + bounds.h/2 - g->measureUIString(getText()).h/2)); diff --git a/src/app/ui/skin/skin_theme.cpp b/src/app/ui/skin/skin_theme.cpp index 6607bcd48..d3992640b 100644 --- a/src/app/ui/skin/skin_theme.cpp +++ b/src/app/ui/skin/skin_theme.cpp @@ -448,9 +448,10 @@ void SkinTheme::onRegenerate() while (xmlColor) { std::string id = xmlColor->Attribute("id"); uint32_t value = strtol(xmlColor->Attribute("value")+1, NULL, 16); - ui::Color color = ui::rgba((value & 0xff0000) >> 16, - (value & 0xff00) >> 8, - (value & 0xff)); + gfx::Color color = gfx::rgba( + (value & 0xff0000) >> 16, + (value & 0xff00) >> 8, + (value & 0xff)); PRINTF("Loading color '%s'...\n", id.c_str()); @@ -944,7 +945,7 @@ void SkinTheme::paintButton(PaintEvent& ev) ButtonBase* widget = static_cast(ev.getSource()); IButtonIcon* iconInterface = widget->getIconInterface(); gfx::Rect box, text, icon; - ui::Color fg, bg; + gfx::Color fg, bg; int part_nw; widget->getTextIconInfo(&box, &text, &icon, @@ -1020,7 +1021,7 @@ void SkinTheme::paintCheckBox(PaintEvent& ev) gfx::Rect bounds = widget->getClientBounds(); IButtonIcon* iconInterface = widget->getIconInterface(); gfx::Rect box, text, icon; - ui::Color bg; + gfx::Color bg; widget->getTextIconInfo(&box, &text, &icon, iconInterface ? iconInterface->getIconAlign(): 0, @@ -1053,7 +1054,7 @@ void SkinTheme::paintCheckBox(PaintEvent& ev) // draw focus 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) @@ -1088,7 +1089,7 @@ void SkinTheme::paintEntry(PaintEvent& ev) if (skinPropery != NULL) isMiniLook = (skinPropery->getLook() == MiniLook); - ui::Color bg = getColor(ThemeColor::Background); + gfx::Color bg = getColor(ThemeColor::Background); draw_bounds_nw(g, bounds, (widget->hasFocus() ? (isMiniLook ? PART_SUNKEN_MINI_FOCUSED_NW: PART_SUNKEN_FOCUSED_NW): @@ -1104,7 +1105,7 @@ void SkinTheme::paintEntry(PaintEvent& ev) // Normal text bg = ColorNone; - ui::Color fg = getColor(ThemeColor::Text); + gfx::Color fg = getColor(ThemeColor::Text); // Selected if ((c >= selbeg) && (c <= selend)) { @@ -1155,8 +1156,8 @@ void SkinTheme::paintLabel(PaintEvent& ev) { Graphics* g = ev.getGraphics(); Label* widget = static_cast(ev.getSource()); - ui::Color bg = BGCOLOR; - ui::Color fg = widget->getTextColor(); + gfx::Color bg = BGCOLOR; + gfx::Color fg = widget->getTextColor(); Rect text, rc = widget->getClientBounds(); if (!is_transparent(bg)) @@ -1173,8 +1174,8 @@ void SkinTheme::paintLinkLabel(PaintEvent& ev) Graphics* g = ev.getGraphics(); Widget* widget = static_cast(ev.getSource()); gfx::Rect bounds = widget->getClientBounds(); - ui::Color fg = getColor(ThemeColor::LinkText); - ui::Color bg = BGCOLOR; + gfx::Color fg = getColor(ThemeColor::LinkText); + gfx::Color bg = BGCOLOR; g->fillRect(bg, bounds); drawTextString(g, NULL, fg, ColorNone, widget, bounds, 0); @@ -1200,7 +1201,7 @@ void SkinTheme::paintListItem(ui::PaintEvent& ev) Widget* widget = static_cast(ev.getSource()); gfx::Rect bounds = widget->getClientBounds(); Graphics* g = ev.getGraphics(); - ui::Color fg, bg; + gfx::Color fg, bg; if (!widget->isEnabled()) { bg = getColor(ThemeColor::Face); @@ -1237,7 +1238,7 @@ void SkinTheme::paintMenuItem(ui::PaintEvent& ev) Graphics* g = ev.getGraphics(); MenuItem* widget = static_cast(ev.getSource()); gfx::Rect bounds = widget->getClientBounds(); - ui::Color fg, bg; + gfx::Color fg, bg; int c, bar; // TODO ASSERT? @@ -1346,7 +1347,7 @@ void SkinTheme::paintRadioButton(PaintEvent& ev) ButtonBase* widget = static_cast(ev.getSource()); gfx::Rect bounds = widget->getClientBounds(); IButtonIcon* iconInterface = widget->getIconInterface(); - ui::Color bg = BGCOLOR; + gfx::Color bg = BGCOLOR; gfx::Rect box, text, icon; widget->getTextIconInfo(&box, &text, &icon, @@ -1374,7 +1375,7 @@ void SkinTheme::paintRadioButton(PaintEvent& ev) // Focus 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) @@ -1417,7 +1418,7 @@ void SkinTheme::paintSlider(PaintEvent& ev) int min, max, value; // Outside borders - ui::Color bgcolor = widget->getBgColor(); + gfx::Color bgcolor = widget->getBgColor(); if (!is_transparent(bgcolor)) g->fillRect(bgcolor, bounds); @@ -1467,7 +1468,7 @@ void SkinTheme::paintSlider(PaintEvent& ev) 3 * 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) rc.shrink(Border(1, 1, 1, 2) * jguiscale()); @@ -1549,7 +1550,7 @@ void SkinTheme::paintComboBoxEntry(ui::PaintEvent& ev) // Outside borders g->fillRect(BGCOLOR, bounds); - ui::Color fg, bg = getColor(ThemeColor::Background); + gfx::Color fg, bg = getColor(ThemeColor::Background); draw_bounds_nw(g, bounds, widget->hasFocus() ? @@ -1609,7 +1610,7 @@ void SkinTheme::paintComboBoxButton(PaintEvent& ev) Graphics* g = ev.getGraphics(); IButtonIcon* iconInterface = widget->getIconInterface(); int part_nw; - ui::Color bg; + gfx::Color bg; if (widget->isSelected()) { bg = getColor(ThemeColor::ButtonSelectedFace); @@ -1659,7 +1660,7 @@ void SkinTheme::paintView(PaintEvent& ev) Graphics* g = ev.getGraphics(); View* widget = static_cast(ev.getSource()); gfx::Rect bounds = widget->getClientBounds(); - ui::Color bg = BGCOLOR; + gfx::Color bg = BGCOLOR; if (!is_transparent(bg)) g->fillRect(bg, bounds); @@ -1709,7 +1710,7 @@ void SkinTheme::paintViewViewport(PaintEvent& ev) { Viewport* widget = static_cast(ev.getSource()); Graphics* g = ev.getGraphics(); - ui::Color bg = BGCOLOR; + gfx::Color bg = BGCOLOR; if (!is_transparent(bg)) g->fillRect(bg, widget->getClientBounds()); @@ -1782,8 +1783,8 @@ void SkinTheme::paintTooltip(PaintEvent& ev) ui::TipWindow* widget = static_cast(ev.getSource()); Graphics* g = ev.getGraphics(); Rect rc = widget->getClientBounds(); - ui::Color fg = getColor(ThemeColor::TooltipText); - ui::Color bg = getColor(ThemeColor::TooltipFace); + gfx::Color fg = getColor(ThemeColor::TooltipText); + gfx::Color bg = getColor(ThemeColor::TooltipFace); int nw = PART_TOOLTIP_NW; int n = PART_TOOLTIP_N; @@ -1841,9 +1842,9 @@ void SkinTheme::paintTooltip(PaintEvent& ev) 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(); if (!is_transparent(c) || widget->getType() == kWindowWidget) @@ -1854,7 +1855,7 @@ ui::Color SkinTheme::getWidgetBgColor(Widget* widget) 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, int selected_offset) { @@ -1911,14 +1912,14 @@ void SkinTheme::drawTextString(Graphics* g, const char *t, ui::Color fg_color, u // Draw white part g->drawUIString(t, getColor(ThemeColor::Background), - ui::ColorNone, + gfx::ColorNone, textrc.getOrigin() + Point(jguiscale(), jguiscale())); } g->drawUIString(t, (!widget->isEnabled() ? getColor(ThemeColor::Disabled): - (ui::geta(fg_color) > 0 ? fg_color : + (gfx::geta(fg_color) > 0 ? fg_color : getColor(ThemeColor::Text))), 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) { - ui::Color color = getColor(ThemeColor::Text); + gfx::Color color = getColor(ThemeColor::Text); int h = widget->getTextHeight(); for (int u=x; u m_part; std::map m_parts_by_id; std::map m_toolicon; - std::map m_colors_by_id; + std::map m_colors_by_id; std::vector m_cursors; - std::vector m_colors; + std::vector m_colors; StyleSheet m_stylesheet; she::Font* m_minifont; }; @@ -229,7 +229,7 @@ namespace app { return static_cast(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(ui::Manager::getDefault()->getTheme())->getColorById(id); } diff --git a/src/app/ui/skin/style.cpp b/src/app/ui/skin/style.cpp index 86ce2948a..eeb39f74a 100644 --- a/src/app/ui/skin/style.cpp +++ b/src/app/ui/skin/style.cpp @@ -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->size() == 1) { - if (!ui::is_transparent(m_color)) + if (!gfx::is_transparent(m_color)) g->fillRect(m_color, bounds); 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); } } - else if (!ui::is_transparent(m_color)) { + else if (!gfx::is_transparent(m_color)) { g->fillRect(m_color, bounds); } } @@ -72,10 +72,10 @@ void TextRule::onPaint(ui::Graphics* g, const gfx::Rect& bounds, const char* tex if (text) { g->drawAlignedUIString(text, - (ui::is_transparent(m_color) ? + (gfx::is_transparent(m_color) ? theme->getColor(ThemeColor::Text): m_color), - ui::ColorNone, + gfx::ColorNone, gfx::Rect(bounds).shrink(m_padding), m_align); } } diff --git a/src/app/ui/skin/style.h b/src/app/ui/skin/style.h index a330e93cf..8aeb76ae3 100644 --- a/src/app/ui/skin/style.h +++ b/src/app/ui/skin/style.h @@ -27,8 +27,8 @@ #include "css/state.h" #include "css/stateful_style.h" #include "gfx/border.h" +#include "gfx/color.h" #include "gfx/fwd.h" -#include "ui/color.h" #include #include @@ -56,26 +56,26 @@ namespace app { class BackgroundRule : public Rule { 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; } protected: void onPaint(ui::Graphics* g, const gfx::Rect& bounds, const char* text) OVERRIDE; private: - ui::Color m_color; + gfx::Color m_color; SkinPartPtr m_part; }; class TextRule : public Rule { public: explicit TextRule() : m_align(0), - m_color(ui::ColorNone) { } + m_color(gfx::ColorNone) { } 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; } protected: @@ -83,7 +83,7 @@ namespace app { private: int m_align; - ui::Color m_color; + gfx::Color m_color; gfx::Border m_padding; }; diff --git a/src/app/ui/skin/style_sheet.cpp b/src/app/ui/skin/style_sheet.cpp index 8fd29f517..3730234ed 100644 --- a/src/app/ui/skin/style_sheet.cpp +++ b/src/app/ui/skin/style_sheet.cpp @@ -113,13 +113,13 @@ SkinPartPtr StyleSheet::convertPart(const css::Value& value) } // 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) { const std::string& color_id = value.string(); 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()); } return color; diff --git a/src/app/ui/skin/style_sheet.h b/src/app/ui/skin/style_sheet.h index 0fc0fa958..f8a235b07 100644 --- a/src/app/ui/skin/style_sheet.h +++ b/src/app/ui/skin/style_sheet.h @@ -23,7 +23,7 @@ #include "app/ui/skin/skin_part.h" #include "css/rule.h" #include "css/state.h" -#include "ui/color.h" +#include "gfx/color.h" #include #include @@ -63,7 +63,7 @@ namespace app { Style* getStyle(const std::string& id); static SkinPartPtr convertPart(const css::Value& value); - static ui::Color convertColor(const css::Value& value); + static gfx::Color convertColor(const css::Value& value); private: typedef std::map StyleMap; diff --git a/src/app/ui/status_bar.cpp b/src/app/ui/status_bar.cpp index 0b46b90f9..7a8082416 100644 --- a/src/app/ui/status_bar.cpp +++ b/src/app/ui/status_bar.cpp @@ -479,7 +479,7 @@ void StatusBar::onPreferredSize(PreferredSizeEvent& ev) void StatusBar::onPaint(ui::PaintEvent& ev) { SkinTheme* theme = static_cast(this->getTheme()); - ui::Color textColor = theme->getColorById(kStatusBarText); + gfx::Color textColor = theme->getColorById(kStatusBarText); Rect rc = getClientBounds(); Graphics* g = ev.getGraphics(); diff --git a/src/app/ui/tabs.cpp b/src/app/ui/tabs.cpp index 1a10e3cc4..d8bc3eb45 100644 --- a/src/app/ui/tabs.cpp +++ b/src/app/ui/tabs.cpp @@ -476,8 +476,8 @@ void Tabs::drawTab(Graphics* g, const gfx::Rect& box, Tab* tab, int y_delta, boo return; SkinTheme* theme = static_cast(this->getTheme()); - ui::Color text_color; - ui::Color face_color; + gfx::Color text_color; + gfx::Color face_color; // 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, face_color); - g->drawString(tab->text, text_color, ColorNone, + g->drawString(tab->text, text_color, gfx::ColorNone, gfx::Point( box.x + 4*jguiscale(), box.y + box.h/2 - getFont()->height()/2+1 + y_delta)); diff --git a/src/app/ui/toolbar.cpp b/src/app/ui/toolbar.cpp index 165de3866..4b541c8d6 100644 --- a/src/app/ui/toolbar.cpp +++ b/src/app/ui/toolbar.cpp @@ -318,8 +318,8 @@ void ToolBar::onPaint(ui::PaintEvent& ev) gfx::Rect bounds = getClientBounds(); Graphics* g = ev.getGraphics(); SkinTheme* theme = static_cast(this->getTheme()); - ui::Color normalFace = theme->getColor(ThemeColor::ButtonNormalFace); - ui::Color hotFace = theme->getColor(ThemeColor::ButtonHotFace); + gfx::Color normalFace = theme->getColor(ThemeColor::ButtonNormalFace); + gfx::Color hotFace = theme->getColor(ThemeColor::ButtonHotFace); ToolBox* toolbox = App::instance()->getToolBox(); ToolGroupList::iterator it = toolbox->begin_group(); int groups = toolbox->getGroupsCount(); @@ -330,7 +330,7 @@ void ToolBar::onPaint(ui::PaintEvent& ev) for (int c=0; cgetSettings()->getCurrentTool() == tool || @@ -467,7 +467,7 @@ void ToolBar::openPopupWindow(int group_index, ToolGroup* tool_group) m_popupWindow->setHotRegion(rgn); m_popupWindow->setTransparent(true); - m_popupWindow->setBgColor(ui::ColorNone); + m_popupWindow->setBgColor(gfx::ColorNone); m_popupWindow->setAutoRemap(false); m_popupWindow->setBounds(rc); toolstrip->setBounds(rc); @@ -741,7 +741,7 @@ void ToolBar::ToolStrip::onPaint(PaintEvent& ev) for (ToolIterator it = toolbox->begin(); it != toolbox->end(); ++it) { Tool* tool = *it; if (tool->getGroup() == m_group) { - ui::Color face; + gfx::Color face; int nw; if (UIContext::instance()->getSettings()->getCurrentTool() == tool || diff --git a/src/gfx/CMakeLists.txt b/src/gfx/CMakeLists.txt index a0319b7cf..954e247c8 100644 --- a/src/gfx/CMakeLists.txt +++ b/src/gfx/CMakeLists.txt @@ -1,5 +1,5 @@ # ASEPRITE -# Copyright (C) 2001-2013 David Capello +# Copyright (C) 2001-2014 David Capello add_library(gfx-lib hsv.cpp diff --git a/src/gfx/LICENSE.txt b/src/gfx/LICENSE.txt index d7ebf2162..220ac0d42 100644 --- a/src/gfx/LICENSE.txt +++ b/src/gfx/LICENSE.txt @@ -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 a copy of this software and associated documentation files (the diff --git a/src/gfx/README.md b/src/gfx/README.md index 9ade24411..17ded9639 100644 --- a/src/gfx/README.md +++ b/src/gfx/README.md @@ -1,4 +1,4 @@ # Aseprite Gfx Library -*Copyright (C) 2001-2013 David Capello* +*Copyright (C) 2001-2014 David Capello* > Distributed under [MIT license](LICENSE.txt) diff --git a/src/she/color.h b/src/gfx/color.h similarity index 88% rename from src/she/color.h rename to src/gfx/color.h index ac1b51f55..f16c39cc2 100644 --- a/src/she/color.h +++ b/src/gfx/color.h @@ -1,14 +1,14 @@ -// SHE library -// Copyright (C) 2012-2014 David Capello +// Aseprite Gfx Library +// Copyright (C) 2001-2014 David Capello // // This file is released under the terms of the MIT license. // Read LICENSE.txt for more information. -#ifndef SHE_COLOR_H_INCLUDED -#define SHE_COLOR_H_INCLUDED +#ifndef GFX_COLOR_H_INCLUDED +#define GFX_COLOR_H_INCLUDED #pragma once -namespace she { +namespace gfx { typedef uint32_t Color; typedef uint8_t ColorComponent; @@ -39,6 +39,6 @@ namespace she { inline bool is_transparent(Color c) { return geta(c) == 0; } -} // namespace she +} // namespace gfx -#endif // SHE_COLOR_H_INCLUDED +#endif // GFX_COLOR_H_INCLUDED diff --git a/src/she/alleg4/alleg4_surface.h b/src/she/alleg4/alleg4_surface.h index 5b8078b46..e546636ce 100644 --- a/src/she/alleg4/alleg4_surface.h +++ b/src/she/alleg4/alleg4_surface.h @@ -20,15 +20,15 @@ namespace she { - inline int to_allegro(Color color) { - if (is_transparent(color)) + inline int to_allegro(int color_depth, gfx::Color color) { + if (gfx::is_transparent(color)) return -1; 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) { - return she::rgba( + inline gfx::Color from_allegro(int color_depth, int color) { + return gfx::rgba( getr_depth(color_depth, color), getg_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( bitmap_color_depth(m_bmp), getpixel(m_bmp, x, y)); } - void putPixel(she::Color color, int x, int y) OVERRIDE { - putpixel(m_bmp, x, y, to_allegro(color)); + void putPixel(gfx::Color color, int x, int y) OVERRIDE { + 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 { - hline(m_bmp, x, y, x+w-1, to_allegro(color)); + void drawHLine(gfx::Color color, int x, int y, int w) OVERRIDE { + 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 { - vline(m_bmp, x, y, y+h-1, to_allegro(color)); + void drawVLine(gfx::Color color, int x, int y, int h) OVERRIDE { + 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 { - line(m_bmp, a.x, a.y, b.x, b.y, to_allegro(color)); + 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(bitmap_color_depth(m_bmp), color)); } - void drawRect(she::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)); + 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(bitmap_color_depth(m_bmp), color)); } - void fillRect(she::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)); + 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(bitmap_color_depth(m_bmp), color)); } 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(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(sheFont->nativeHandle()); allegFont->vtable->render_char(allegFont, chr, - to_allegro(fg), - to_allegro(bg), + to_allegro(bitmap_color_depth(m_bmp), fg), + to_allegro(bitmap_color_depth(m_bmp), bg), 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(sheFont->nativeHandle()); base::utf8_const_iterator it(str.begin()), end(str.end()); int length = 0; - int sysfg = to_allegro(fg); - int sysbg = to_allegro(bg); + int sysfg = to_allegro(bitmap_color_depth(m_bmp), fg); + int sysbg = to_allegro(bitmap_color_depth(m_bmp), bg); while (it != end) { allegFont->vtable->render_char(allegFont, *it, sysfg, sysbg, m_bmp, x, y); diff --git a/src/she/locked_surface.h b/src/she/locked_surface.h index b873543d8..b68ebdeb7 100644 --- a/src/she/locked_surface.h +++ b/src/she/locked_surface.h @@ -8,8 +8,8 @@ #define SHE_LOCKED_SURFACE_H_INCLUDED #pragma once +#include "gfx/color.h" #include "gfx/fwd.h" -#include "she/color.h" #include "she/surface_format.h" #include @@ -27,22 +27,22 @@ namespace she { virtual uint8_t* getData(int x, int y) = 0; virtual void getFormat(SurfaceFormatData* formatData) = 0; - virtual she::Color getPixel(int x, int y) = 0; - virtual void putPixel(she::Color color, int x, int y) = 0; + virtual gfx::Color getPixel(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 drawVLine(she::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 drawHLine(gfx::Color color, int x, int y, int w) = 0; + virtual void drawVLine(gfx::Color color, int x, int y, int h) = 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 fillRect(she::Color color, const gfx::Rect& rc) = 0; + virtual void drawRect(gfx::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 drawSurface(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 drawString(Font* font, she::Color fg, she::Color bg, int x, int y, const std::string& str) = 0; + virtual void drawChar(Font* font, gfx::Color fg, gfx::Color bg, int x, int y, int chr) = 0; + virtual void drawString(Font* font, gfx::Color fg, gfx::Color bg, int x, int y, const std::string& str) = 0; }; } // namespace she diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index 2e89bf72f..8a33a9385 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -7,7 +7,6 @@ add_library(ui-lib box.cpp button.cpp clipboard.cpp - color.cpp combobox.cpp component.cpp cursor.cpp diff --git a/src/ui/color.cpp b/src/ui/color.cpp deleted file mode 100644 index 243f9e443..000000000 --- a/src/ui/color.cpp +++ /dev/null @@ -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 - -namespace ui { - -int to_system(Color color) -{ - if (is_transparent(color)) - return -1; - else - return makecol(getr(color), - getg(color), - getb(color)); -} - -} // namespace ui diff --git a/src/ui/color.h b/src/ui/color.h deleted file mode 100644 index bcc53b470..000000000 --- a/src/ui/color.h +++ /dev/null @@ -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 diff --git a/src/ui/graphics.cpp b/src/ui/graphics.cpp index 10075139e..62a4f0afb 100644 --- a/src/ui/graphics.cpp +++ b/src/ui/graphics.cpp @@ -22,18 +22,6 @@ #include "she/system.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 { 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)); } -ui::Color Graphics::getPixel(int x, int y) +gfx::Color Graphics::getPixel(int x, int y) { 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); - 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); - 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); - 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); - dst->drawLine(to_she(color), + dst->drawLine(color, gfx::Point(m_dx+a.x, m_dy+a.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); - 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); - 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) fillRect(color, *it); } -void Graphics::fillAreaBetweenRects(ui::Color color, +void Graphics::fillAreaBetweenRects(gfx::Color color, const gfx::Rect& outer, const gfx::Rect& inner) { if (!outer.intersects(inner)) @@ -160,19 +148,19 @@ void Graphics::setFont(she::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); - 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); - 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); 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); } } - 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); ++it; } if (underscored_w > 0) { y += m_font->height(); - dst->fillRect(to_she(fg), + dst->fillRect(fg, 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); } @@ -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) { - 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); 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) pt.y = rc.y + rc.h/2 - preSize.h/2; 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)); - if (!is_transparent(bg)) + if (!gfx::is_transparent(bg)) fillAreaBetweenRects(bg, gfx::Rect(rc.x, pt.y, rc.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 - if (draw && !is_transparent(bg)) { + if (draw && !gfx::is_transparent(bg)) { if (pt.y < rc.y+rc.h) fillRect(bg, gfx::Rect(rc.x, pt.y, rc.w, rc.y+rc.h-pt.y)); } diff --git a/src/ui/graphics.h b/src/ui/graphics.h index 9f78b0b31..d0937cd69 100644 --- a/src/ui/graphics.h +++ b/src/ui/graphics.h @@ -8,12 +8,12 @@ #define UI_GRAPHICS_H_INCLUDED #pragma once -#include "base/shared_ptr.h" #include "base/disable_copying.h" +#include "base/shared_ptr.h" +#include "gfx/color.h" #include "gfx/point.h" #include "gfx/rect.h" #include "gfx/size.h" -#include "ui/color.h" #include @@ -45,17 +45,17 @@ namespace ui { void setClipBounds(const gfx::Rect& rc); bool intersectClipRect(const gfx::Rect& rc); - ui::Color getPixel(int x, int y); - void putPixel(ui::Color color, int x, int y); + gfx::Color getPixel(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 drawVLine(ui::Color color, int x, int y, int h); - void drawLine(ui::Color color, const gfx::Point& a, const gfx::Point& b); + void drawHLine(gfx::Color color, int x, int y, int w); + void drawVLine(gfx::Color color, int x, int y, int h); + void drawLine(gfx::Color color, const gfx::Point& a, const gfx::Point& b); - void drawRect(ui::Color color, const gfx::Rect& rc); - void fillRect(ui::Color color, const gfx::Rect& rc); - void fillRegion(ui::Color color, const gfx::Region& rgn); - void fillAreaBetweenRects(ui::Color color, + void drawRect(gfx::Color color, const gfx::Rect& rc); + void fillRect(gfx::Color color, const gfx::Rect& rc); + void fillRegion(gfx::Color color, const gfx::Region& rgn); + void fillAreaBetweenRects(gfx::Color color, const gfx::Rect& outer, const gfx::Rect& inner); void drawSurface(she::Surface* surface, int x, int y); @@ -70,10 +70,10 @@ namespace ui { void setFont(she::Font* font); she::Font* getFont() { return m_font; } - void drawChar(int chr, Color fg, Color bg, int x, int y); - void drawString(const std::string& str, Color fg, Color bg, const gfx::Point& pt); - void drawUIString(const std::string& str, Color fg, Color bg, const gfx::Point& pt); - void drawAlignedUIString(const std::string& str, Color fg, Color bg, const gfx::Rect& rc, int align); + void drawChar(int chr, gfx::Color fg, gfx::Color bg, int x, int y); + void drawString(const std::string& str, gfx::Color fg, gfx::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, gfx::Color fg, gfx::Color bg, const gfx::Rect& rc, int align); gfx::Size measureChar(int chr); gfx::Size measureUIString(const std::string& str); @@ -81,7 +81,7 @@ namespace ui { gfx::Size fitString(const std::string& str, int maxWidth, int align); 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; int m_dx; diff --git a/src/ui/int_entry.cpp b/src/ui/int_entry.cpp index dfe5f25c9..3b2f79197 100644 --- a/src/ui/int_entry.cpp +++ b/src/ui/int_entry.cpp @@ -142,7 +142,7 @@ void IntEntry::openPopup() m_popupWindow = new PopupWindow("", PopupWindow::kCloseOnClickInOtherWindow); m_popupWindow->setAutoRemap(false); m_popupWindow->setTransparent(true); - m_popupWindow->setBgColor(ui::ColorNone); + m_popupWindow->setBgColor(gfx::ColorNone); m_popupWindow->setBounds(rc); m_popupWindow->Close.connect(&IntEntry::onPopupClose, this); diff --git a/src/ui/intern.h b/src/ui/intern.h index 12d282d37..ca682a999 100644 --- a/src/ui/intern.h +++ b/src/ui/intern.h @@ -8,8 +8,8 @@ #define UI_INTERN_H_INCLUDED #pragma once +#include "gfx/color.h" #include "ui/base.h" -#include "ui/color.h" namespace she { class Font; @@ -32,7 +32,7 @@ namespace ui { // theme.cpp 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 diff --git a/src/ui/label.cpp b/src/ui/label.cpp index a00f4b69e..76f4a877a 100644 --- a/src/ui/label.cpp +++ b/src/ui/label.cpp @@ -23,12 +23,12 @@ Label::Label(const std::string& text) initTheme(); } -Color Label::getTextColor() const +gfx::Color Label::getTextColor() const { return m_textColor; } -void Label::setTextColor(Color color) +void Label::setTextColor(gfx::Color color) { m_textColor = color; } diff --git a/src/ui/label.h b/src/ui/label.h index f0da74e28..0c14a9ef8 100644 --- a/src/ui/label.h +++ b/src/ui/label.h @@ -9,7 +9,7 @@ #pragma once #include "base/compiler_specific.h" -#include "ui/color.h" +#include "gfx/color.h" #include "ui/widget.h" namespace ui { @@ -19,15 +19,15 @@ namespace ui { public: Label(const std::string& text); - Color getTextColor() const; - void setTextColor(Color color); + gfx::Color getTextColor() const; + void setTextColor(gfx::Color color); protected: void onPreferredSize(PreferredSizeEvent& ev) OVERRIDE; void onPaint(PaintEvent& ev) OVERRIDE; private: - Color m_textColor; + gfx::Color m_textColor; }; } // namespace ui diff --git a/src/ui/textbox.cpp b/src/ui/textbox.cpp index 82af66cb8..bf72ccfcb 100644 --- a/src/ui/textbox.cpp +++ b/src/ui/textbox.cpp @@ -159,7 +159,7 @@ void TextBox::onPreferredSize(PreferredSizeEvent& ev) //w = widget->border_width.l + widget->border_width.r; //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) { View* view = View::getView(this); @@ -173,7 +173,7 @@ void TextBox::onPreferredSize(PreferredSizeEvent& ev) } w = MAX(min, width); - drawTextBox(NULL, this, &w, &h, ColorNone, ColorNone); + drawTextBox(NULL, this, &w, &h, gfx::ColorNone, gfx::ColorNone); w = min; } diff --git a/src/ui/theme.cpp b/src/ui/theme.cpp index b969ed2bb..d7320b6b2 100644 --- a/src/ui/theme.cpp +++ b/src/ui/theme.cpp @@ -72,7 +72,7 @@ Theme* CurrentTheme::get() } 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); char* text = const_cast(widget->getText().c_str()); diff --git a/src/ui/tooltips.cpp b/src/ui/tooltips.cpp index 362759f6a..afbce5042 100644 --- a/src/ui/tooltips.cpp +++ b/src/ui/tooltips.cpp @@ -229,7 +229,7 @@ void TipWindow::onInitTheme(InitThemeEvent& ev) this->border_width.b = 7 * jguiscale(); // Setup the background color. - setBgColor(ui::rgba(255, 255, 200)); + setBgColor(gfx::rgba(255, 255, 200)); } void TipWindow::onPaint(PaintEvent& ev) diff --git a/src/ui/ui.h b/src/ui/ui.h index c0c9c1d47..a111daa7b 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -14,7 +14,6 @@ #include "ui/box.h" #include "ui/button.h" #include "ui/clipboard.h" -#include "ui/color.h" #include "ui/combobox.h" #include "ui/component.h" #include "ui/cursor.h" diff --git a/src/ui/widget.cpp b/src/ui/widget.cpp index 9e057a2a2..57e0370fd 100644 --- a/src/ui/widget.cpp +++ b/src/ui/widget.cpp @@ -66,7 +66,7 @@ Widget::Widget(WidgetType type) this->m_align = 0; 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[1] = NULL; @@ -171,7 +171,7 @@ void Widget::setFont(she::Font* font) invalidate(); } -void Widget::setBgColor(ui::Color color) +void Widget::setBgColor(gfx::Color color) { m_bgColor = color; onSetBgColor(); @@ -969,7 +969,7 @@ bool Widget::paintEvent(Graphics* graphics) #if _DEBUG // In debug mode we can fill the area with Red so we know if the // we are drawing the parent correctly. - graphics->fillRect(ui::rgba(255, 0, 0), getClientBounds()); + graphics->fillRect(gfx::rgba(255, 0, 0), getClientBounds()); #endif this->flags |= JI_HIDDEN; diff --git a/src/ui/widget.h b/src/ui/widget.h index a2a708aa2..e1af40686 100644 --- a/src/ui/widget.h +++ b/src/ui/widget.h @@ -9,12 +9,12 @@ #pragma once #include "gfx/border.h" +#include "gfx/color.h" #include "gfx/point.h" #include "gfx/rect.h" #include "gfx/region.h" #include "gfx/size.h" #include "ui/base.h" -#include "ui/color.h" #include "ui/component.h" #include "ui/graphics.h" #include "ui/widget_type.h" @@ -149,15 +149,15 @@ namespace ui { void setFont(she::Font* font); // Gets the background color of the widget. - ui::Color getBgColor() const { - if (ui::geta(m_bgColor) == 0 && m_parent) + gfx::Color getBgColor() const { + if (gfx::geta(m_bgColor) == 0 && m_parent) return m_parent->getBgColor(); else return m_bgColor; } // Sets the background color of the widget - void setBgColor(ui::Color color); + void setBgColor(gfx::Color color); Theme* getTheme() const { return m_theme; } void setTheme(Theme* theme); @@ -375,11 +375,11 @@ namespace ui { bool paintEvent(Graphics* graphics); std::string m_id; // Widget's id - Theme* m_theme; // Widget's theme - int m_align; // Widget alignment + Theme* m_theme; // Widget's theme + int m_align; // Widget alignment std::string m_text; // Widget text she::Font* m_font; // Text font type - ui::Color m_bgColor; // Background color + gfx::Color m_bgColor; // Background color gfx::Rect m_bounds; gfx::Region m_updateRegion; // Region to be redrawed. WidgetsList m_children; // Sub-widgets