mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-30 04:20:23 +00:00
Add ui::Color and ThemeColor, move Color to app::Color
Now colors are customizable from skin.xml file.
This commit is contained in:
parent
9ba5ef44ca
commit
a517deee0d
@ -3,6 +3,66 @@
|
||||
author="Ilija Melentijevic & David Capello"
|
||||
url="http://ilkke.blogspot.com/">
|
||||
|
||||
<colors>
|
||||
<color id="text" value="#000000" />
|
||||
<color id="disabled" value="#968275" />
|
||||
<color id="face" value="#d3cbbe" />
|
||||
<color id="hot_face" value="#faf0e6" />
|
||||
<color id="selected" value="#2c4c91" />
|
||||
<color id="background" value="#ffffff" />
|
||||
<color id="desktop" value="#968275" />
|
||||
<color id="textbox_text" value="#000000" />
|
||||
<color id="textbox_face" value="#ffffff" />
|
||||
<color id="link_text" value="#0000ff" />
|
||||
<color id="button_normal_text" value="#000000" />
|
||||
<color id="button_normal_face" value="#c6c6c6" />
|
||||
<color id="button_hot_text" value="#000000" />
|
||||
<color id="button_hot_face" value="#ffffff" />
|
||||
<color id="button_selected_text" value="#ffffff" />
|
||||
<color id="button_selected_face" value="#7c909f" />
|
||||
<color id="check_hot_face" value="#ffebb6" />
|
||||
<color id="check_focus_face" value="#c6c6c6" />
|
||||
<color id="radio_hot_face" value="#ffebb6" />
|
||||
<color id="radio_focus_face" value="#c6c6c6" />
|
||||
<color id="menuitem_normal_text" value="#000000" />
|
||||
<color id="menuitem_normal_face" value="#d3cbbe" />
|
||||
<color id="menuitem_hot_text" value="#000000" />
|
||||
<color id="menuitem_hot_face" value="#ffebb6" />
|
||||
<color id="menuitem_highlight_text" value="#ffffff" />
|
||||
<color id="menuitem_highlight_face" value="#7c909f" />
|
||||
<color id="window_face" value="#d3cbbe" />
|
||||
<color id="window_titlebar_text" value="#ffffff" />
|
||||
<color id="window_titlebar_face" value="#7c909f" />
|
||||
<color id="editor_face" value="#655561" />
|
||||
<color id="editor_sprite_border" value="#000000" />
|
||||
<color id="editor_sprite_bottom_border" value="#41412c" />
|
||||
<color id="listitem_normal_text" value="#000000" />
|
||||
<color id="listitem_normal_face" value="#ffffff" />
|
||||
<color id="listitem_selected_text" value="#ffffff" />
|
||||
<color id="listitem_selected_face" value="#ff5555" />
|
||||
<color id="slider_empty_text" value="#000000" />
|
||||
<color id="slider_empty_face" value="#aecbdf" />
|
||||
<color id="slider_full_text" value="#ffffff" />
|
||||
<color id="slider_full_face" value="#7d929e" />
|
||||
<color id="tab_normal_text" value="#000000" />
|
||||
<color id="tab_normal_face" value="#c6c6c6" />
|
||||
<color id="tab_selected_text" value="#ffffff" />
|
||||
<color id="tab_selected_face" value="#7d929e" />
|
||||
<color id="splitter_normal_face" value="#7d929e" />
|
||||
<color id="scrollbar_bg_face" value="#7d929e" />
|
||||
<color id="scrollbar_thumb_face" value="#c6c6c6" />
|
||||
<color id="popup_window_border" value="#000000" />
|
||||
<color id="tooltip_text" value="#000000" />
|
||||
<color id="tooltip_face" value="#ffff7d" />
|
||||
<color id="filelist_even_row_text" value="#000000" />
|
||||
<color id="filelist_even_row_face" value="#f0f0f0" />
|
||||
<color id="filelist_odd_row_text" value="#000000" />
|
||||
<color id="filelist_odd_row_face" value="#ffffff" />
|
||||
<color id="filelist_selected_row_text" value="#ffffff" />
|
||||
<color id="filelist_selected_row_face" value="#2c4c91" />
|
||||
<color id="filelist_disabled_row_text" value="#ffc8c8" />
|
||||
</colors>
|
||||
|
||||
<cursors>
|
||||
<cursor id="normal" x="80" y="0" w="16" h="16" focusx="0" focusy="0" />
|
||||
<cursor id="normal_add" x="80" y="16" w="16" h="16" focusx="0" focusy="0" />
|
||||
|
@ -346,7 +346,7 @@ void app_default_statusbar_message()
|
||||
int app_get_color_to_clear_layer(Layer* layer)
|
||||
{
|
||||
/* all transparent layers are cleared with the mask color */
|
||||
Color color = Color::fromMask();
|
||||
app::Color color = app::Color::fromMask();
|
||||
|
||||
/* the `Background' is erased with the `Background Color' */
|
||||
if (layer != NULL && layer->is_background())
|
||||
|
@ -33,6 +33,8 @@
|
||||
|
||||
using namespace gfx;
|
||||
|
||||
namespace app {
|
||||
|
||||
// static
|
||||
Color Color::fromMask()
|
||||
{
|
||||
@ -615,3 +617,5 @@ int Color::getIndex() const
|
||||
ASSERT(false);
|
||||
return -1;
|
||||
}
|
||||
|
||||
} // namespace app
|
||||
|
@ -26,6 +26,8 @@
|
||||
class Image;
|
||||
class Layer;
|
||||
|
||||
namespace app {
|
||||
|
||||
class Color {
|
||||
public:
|
||||
enum Type {
|
||||
@ -97,4 +99,6 @@ private:
|
||||
} m_value;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -52,45 +52,86 @@ int get_mask_for_bitmap(int depth)
|
||||
|
||||
}
|
||||
|
||||
int color_utils::blackandwhite(int r, int g, int b)
|
||||
ui::Color color_utils::blackandwhite(ui::Color color)
|
||||
{
|
||||
return (r*30+g*59+b*11)/100 < 128 ?
|
||||
makecol(0, 0, 0):
|
||||
makecol(255, 255, 255);
|
||||
if ((ui::getr(color)*30+ui::getg(color)*59+ui::getb(color)*11)/100 < 128)
|
||||
return ui::rgba(0, 0, 0);
|
||||
else
|
||||
return ui::rgba(255, 255, 255);
|
||||
}
|
||||
|
||||
int color_utils::blackandwhite_neg(int r, int g, int b)
|
||||
ui::Color color_utils::blackandwhite_neg(ui::Color color)
|
||||
{
|
||||
return (r*30+g*59+b*11)/100 < 128 ?
|
||||
makecol(255, 255, 255):
|
||||
makecol(0, 0, 0);
|
||||
if ((ui::getr(color)*30+ui::getg(color)*59+ui::getb(color)*11)/100 < 128)
|
||||
return ui::rgba(255, 255, 255);
|
||||
else
|
||||
return ui::rgba(0, 0, 0);
|
||||
}
|
||||
|
||||
int color_utils::color_for_allegro(const Color& color, int depth)
|
||||
ui::Color color_utils::color_for_ui(const app::Color& color)
|
||||
{
|
||||
ui::Color c = ui::ColorNone;
|
||||
|
||||
switch (color.getType()) {
|
||||
|
||||
case app::Color::MaskType:
|
||||
c = ui::ColorNone;
|
||||
break;
|
||||
|
||||
case app::Color::RgbType:
|
||||
case app::Color::HsvType:
|
||||
c = ui::rgba(color.getRed(),
|
||||
color.getGreen(),
|
||||
color.getBlue(), 255);
|
||||
break;
|
||||
|
||||
case app::Color::GrayType:
|
||||
c = ui::rgba(color.getGray(),
|
||||
color.getGray(),
|
||||
color.getGray(), 255);
|
||||
break;
|
||||
|
||||
case app::Color::IndexType: {
|
||||
int i = color.getIndex();
|
||||
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);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
int color_utils::color_for_allegro(const app::Color& color, int depth)
|
||||
{
|
||||
int c = -1;
|
||||
|
||||
switch (color.getType()) {
|
||||
|
||||
case Color::MaskType:
|
||||
case app::Color::MaskType:
|
||||
c = get_mask_for_bitmap(depth);
|
||||
break;
|
||||
|
||||
case Color::RgbType:
|
||||
case Color::HsvType:
|
||||
case app::Color::RgbType:
|
||||
case app::Color::HsvType:
|
||||
c = makeacol_depth(depth,
|
||||
color.getRed(),
|
||||
color.getGreen(),
|
||||
color.getBlue(), 255);
|
||||
break;
|
||||
|
||||
case Color::GrayType:
|
||||
case app::Color::GrayType:
|
||||
c = color.getGray();
|
||||
if (depth != 8)
|
||||
c = makeacol_depth(depth, c, c, c, 255);
|
||||
break;
|
||||
|
||||
case Color::IndexType:
|
||||
case app::Color::IndexType:
|
||||
c = color.getIndex();
|
||||
if (depth != 8) {
|
||||
ASSERT(c >= 0 && c < (int)get_current_palette()->size());
|
||||
@ -108,9 +149,9 @@ int color_utils::color_for_allegro(const Color& color, int depth)
|
||||
return c;
|
||||
}
|
||||
|
||||
int color_utils::color_for_image(const Color& color, PixelFormat format)
|
||||
int color_utils::color_for_image(const app::Color& color, PixelFormat format)
|
||||
{
|
||||
if (color.getType() == Color::MaskType)
|
||||
if (color.getType() == app::Color::MaskType)
|
||||
return 0;
|
||||
|
||||
int c = -1;
|
||||
@ -123,7 +164,7 @@ int color_utils::color_for_image(const Color& color, PixelFormat format)
|
||||
c = _graya(color.getGray(), 255);
|
||||
break;
|
||||
case IMAGE_INDEXED:
|
||||
if (color.getType() == Color::IndexType)
|
||||
if (color.getType() == app::Color::IndexType)
|
||||
c = color.getIndex();
|
||||
else
|
||||
c = get_current_palette()->findBestfit(color.getRed(), color.getGreen(), color.getBlue());
|
||||
@ -133,11 +174,11 @@ int color_utils::color_for_image(const Color& color, PixelFormat format)
|
||||
return c;
|
||||
}
|
||||
|
||||
int color_utils::color_for_layer(const Color& color, Layer* layer)
|
||||
int color_utils::color_for_layer(const app::Color& color, Layer* layer)
|
||||
{
|
||||
int pixel_color;
|
||||
|
||||
if (color.getType() == Color::MaskType) {
|
||||
if (color.getType() == app::Color::MaskType) {
|
||||
pixel_color = layer->getSprite()->getTransparentColor();
|
||||
}
|
||||
else {
|
||||
|
@ -21,17 +21,19 @@
|
||||
|
||||
#include "app/color.h"
|
||||
#include "raster/pixel_format.h"
|
||||
#include "ui/color.h"
|
||||
|
||||
class Layer;
|
||||
|
||||
namespace color_utils {
|
||||
|
||||
int blackandwhite(int r, int g, int b);
|
||||
int blackandwhite_neg(int r, int g, int b);
|
||||
ui::Color blackandwhite(ui::Color color);
|
||||
ui::Color blackandwhite_neg(ui::Color color);
|
||||
|
||||
int color_for_allegro(const Color& color, int depth);
|
||||
int color_for_image(const Color& color, PixelFormat format);
|
||||
int color_for_layer(const Color& color, Layer* layer);
|
||||
ui::Color color_for_ui(const app::Color& color);
|
||||
int color_for_allegro(const app::Color& color, int depth);
|
||||
int color_for_image(const app::Color& color, PixelFormat format);
|
||||
int color_for_layer(const app::Color& color, Layer* layer);
|
||||
|
||||
int fixup_color_for_layer(Layer* layer, int color);
|
||||
int fixup_color_for_background(PixelFormat format, int color);
|
||||
|
@ -71,30 +71,30 @@ void ChangeColorCommand::onLoadParams(Params* params)
|
||||
void ChangeColorCommand::onExecute(Context* context)
|
||||
{
|
||||
ColorBar* colorbar = ColorBar::instance();
|
||||
Color color = m_background ? colorbar->getBgColor():
|
||||
colorbar->getFgColor();
|
||||
app::Color color = m_background ? colorbar->getBgColor():
|
||||
colorbar->getFgColor();
|
||||
|
||||
switch (m_change) {
|
||||
case None:
|
||||
// do nothing
|
||||
break;
|
||||
case IncrementIndex:
|
||||
if (color.getType() == Color::IndexType) {
|
||||
if (color.getType() == app::Color::IndexType) {
|
||||
int index = color.getIndex();
|
||||
if (index < 255) // TODO use sprite palette limit
|
||||
color = Color::fromIndex(index+1);
|
||||
color = app::Color::fromIndex(index+1);
|
||||
}
|
||||
else
|
||||
color = Color::fromIndex(0);
|
||||
color = app::Color::fromIndex(0);
|
||||
break;
|
||||
case DecrementIndex:
|
||||
if (color.getType() == Color::IndexType) {
|
||||
if (color.getType() == app::Color::IndexType) {
|
||||
int index = color.getIndex();
|
||||
if (index > 0)
|
||||
color = Color::fromIndex(index-1);
|
||||
color = app::Color::fromIndex(index-1);
|
||||
}
|
||||
else
|
||||
color = Color::fromIndex(0);
|
||||
color = app::Color::fromIndex(0);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -83,8 +83,8 @@ void EyedropperCommand::onExecute(Context* context)
|
||||
editor->screenToEditor(jmouse_x(0), jmouse_y(0), &x, &y);
|
||||
|
||||
// get the color from the image
|
||||
Color color = Color::fromImage(sprite->getPixelFormat(),
|
||||
sprite->getPixel(x, y));
|
||||
app::Color color = app::Color::fromImage(sprite->getPixelFormat(),
|
||||
sprite->getPixel(x, y));
|
||||
|
||||
// TODO replace the color in the "context", not directly from the color-bar
|
||||
|
||||
|
@ -74,11 +74,11 @@ void NewFileCommand::onExecute(Context* context)
|
||||
PixelFormat format;
|
||||
int w, h, bg, ncolors;
|
||||
char buf[1024];
|
||||
Color bg_table[] = {
|
||||
Color::fromMask(),
|
||||
Color::fromRgb(0, 0, 0),
|
||||
Color::fromRgb(255, 255, 255),
|
||||
Color::fromRgb(255, 0, 255),
|
||||
app::Color bg_table[] = {
|
||||
app::Color::fromMask(),
|
||||
app::Color::fromRgb(0, 0, 0),
|
||||
app::Color::fromRgb(255, 255, 255),
|
||||
app::Color::fromRgb(255, 0, 255),
|
||||
ColorBar::instance()->getBgColor()
|
||||
};
|
||||
|
||||
@ -147,7 +147,7 @@ void NewFileCommand::onExecute(Context* context)
|
||||
ncolors = MID(2, ncolors, 256);
|
||||
|
||||
// Select the color
|
||||
Color color = Color::fromMask();
|
||||
app::Color color = app::Color::fromMask();
|
||||
|
||||
if (bg >= 0 && bg <= 4) {
|
||||
color = bg_table[bg];
|
||||
@ -177,7 +177,7 @@ void NewFileCommand::onExecute(Context* context)
|
||||
|
||||
// If the background color isn't transparent, we have to
|
||||
// convert the `Layer 1' in a `Background'
|
||||
if (color.getType() != Color::MaskType) {
|
||||
if (color.getType() != app::Color::MaskType) {
|
||||
Sprite* sprite = document->getSprite();
|
||||
|
||||
ASSERT(sprite->getCurrentLayer() && sprite->getCurrentLayer()->is_image());
|
||||
|
@ -177,8 +177,8 @@ void OptionsCommand::onResetCheckedBg()
|
||||
// Default values
|
||||
m_checked_bg->setSelectedItem((int)RenderEngine::CHECKED_BG_16X16);
|
||||
m_checked_bg_zoom->setSelected(true);
|
||||
m_checked_bg_color1->setColor(Color::fromRgb(128, 128, 128));
|
||||
m_checked_bg_color2->setColor(Color::fromRgb(192, 192, 192));
|
||||
m_checked_bg_color1->setColor(app::Color::fromRgb(128, 128, 128));
|
||||
m_checked_bg_color2->setColor(app::Color::fromRgb(192, 192, 192));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
@ -69,16 +69,16 @@ public:
|
||||
PaletteEntryEditor();
|
||||
~PaletteEntryEditor();
|
||||
|
||||
void setColor(const Color& color);
|
||||
void setColor(const app::Color& color);
|
||||
|
||||
protected:
|
||||
bool onProcessMessage(Message* msg) OVERRIDE;
|
||||
|
||||
void onExit();
|
||||
void onCloseWindow();
|
||||
void onFgBgColorChange(const Color& color);
|
||||
void onFgBgColorChange(const app::Color& color);
|
||||
void onColorSlidersChange(ColorSlidersChangeEvent& ev);
|
||||
void onColorHexEntryChange(const Color& color);
|
||||
void onColorHexEntryChange(const app::Color& color);
|
||||
void onColorTypeButtonClick(Event& ev);
|
||||
void onMoreOptionsClick(Event& ev);
|
||||
void onCopyColorsClick(Event& ev);
|
||||
@ -89,9 +89,9 @@ protected:
|
||||
void onQuantizeClick(Event& ev);
|
||||
|
||||
private:
|
||||
void selectColorType(Color::Type type);
|
||||
void setPaletteEntry(const Color& color);
|
||||
void setPaletteEntryChannel(const Color& color, ColorSliders::Channel channel);
|
||||
void selectColorType(app::Color::Type type);
|
||||
void setPaletteEntry(const app::Color& color);
|
||||
void setPaletteEntryChannel(const app::Color& color, ColorSliders::Channel channel);
|
||||
void setNewPalette(Palette* palette, const char* operationName);
|
||||
void updateCurrentSpritePalette(const char* operationName);
|
||||
void updateColorBar();
|
||||
@ -231,7 +231,7 @@ void PaletteEditorCommand::onExecute(Context* context)
|
||||
|
||||
// Show the specified target color
|
||||
{
|
||||
Color color =
|
||||
app::Color color =
|
||||
(m_background ? context->getSettings()->getBgColor():
|
||||
context->getSettings()->getFgColor());
|
||||
|
||||
@ -329,7 +329,7 @@ PaletteEntryEditor::PaletteEntryEditor()
|
||||
m_hsvSliders.ColorChange.connect(&PaletteEntryEditor::onColorSlidersChange, this);
|
||||
m_hexColorEntry.ColorChange.connect(&PaletteEntryEditor::onColorHexEntryChange, this);
|
||||
|
||||
selectColorType(Color::RgbType);
|
||||
selectColorType(app::Color::RgbType);
|
||||
|
||||
// We hook fg/bg color changes (by eyedropper mainly) to update the selected entry color
|
||||
ColorBar::instance()->FgColorChange.connect(&PaletteEntryEditor::onFgBgColorChange, this);
|
||||
@ -353,7 +353,7 @@ PaletteEntryEditor::~PaletteEntryEditor()
|
||||
App::instance()->PaletteChange.disconnect(m_palChangeSlot);
|
||||
}
|
||||
|
||||
void PaletteEntryEditor::setColor(const Color& color)
|
||||
void PaletteEntryEditor::setColor(const app::Color& color)
|
||||
{
|
||||
m_rgbSliders.setColor(color);
|
||||
m_hsvSliders.setColor(color);
|
||||
@ -443,9 +443,9 @@ void PaletteEntryEditor::onCloseWindow()
|
||||
ColorBar::instance()->setPaletteEditorButtonState(false);
|
||||
}
|
||||
|
||||
void PaletteEntryEditor::onFgBgColorChange(const Color& color)
|
||||
void PaletteEntryEditor::onFgBgColorChange(const app::Color& color)
|
||||
{
|
||||
if (color.isValid() && color.getType() == Color::IndexType) {
|
||||
if (color.isValid() && color.getType() == app::Color::IndexType) {
|
||||
setColor(color);
|
||||
}
|
||||
}
|
||||
@ -458,7 +458,7 @@ void PaletteEntryEditor::onColorSlidersChange(ColorSlidersChangeEvent& ev)
|
||||
updateColorBar();
|
||||
}
|
||||
|
||||
void PaletteEntryEditor::onColorHexEntryChange(const Color& color)
|
||||
void PaletteEntryEditor::onColorHexEntryChange(const app::Color& color)
|
||||
{
|
||||
// Disable updating the hex entry so we don't override what the user
|
||||
// is writting in the text field.
|
||||
@ -476,8 +476,8 @@ void PaletteEntryEditor::onColorTypeButtonClick(Event& ev)
|
||||
{
|
||||
RadioButton* source = static_cast<RadioButton*>(ev.getSource());
|
||||
|
||||
if (source == &m_rgbButton) selectColorType(Color::RgbType);
|
||||
else if (source == &m_hsvButton) selectColorType(Color::HsvType);
|
||||
if (source == &m_rgbButton) selectColorType(app::Color::RgbType);
|
||||
else if (source == &m_hsvButton) selectColorType(app::Color::HsvType);
|
||||
}
|
||||
|
||||
void PaletteEntryEditor::onMoreOptionsClick(Event& ev)
|
||||
@ -660,7 +660,7 @@ void PaletteEntryEditor::onQuantizeClick(Event& ev)
|
||||
delete palette;
|
||||
}
|
||||
|
||||
void PaletteEntryEditor::setPaletteEntry(const Color& color)
|
||||
void PaletteEntryEditor::setPaletteEntry(const app::Color& color)
|
||||
{
|
||||
PaletteView* palView = ColorBar::instance()->getPaletteView();
|
||||
PaletteView::SelectedEntries entries;
|
||||
@ -677,7 +677,7 @@ void PaletteEntryEditor::setPaletteEntry(const Color& color)
|
||||
}
|
||||
}
|
||||
|
||||
void PaletteEntryEditor::setPaletteEntryChannel(const Color& color, ColorSliders::Channel channel)
|
||||
void PaletteEntryEditor::setPaletteEntryChannel(const app::Color& color, ColorSliders::Channel channel)
|
||||
{
|
||||
PaletteView* palView = ColorBar::instance()->getPaletteView();
|
||||
PaletteView::SelectedEntries entries;
|
||||
@ -701,7 +701,7 @@ void PaletteEntryEditor::setPaletteEntryChannel(const Color& color, ColorSliders
|
||||
|
||||
switch (color.getType()) {
|
||||
|
||||
case Color::RgbType:
|
||||
case app::Color::RgbType:
|
||||
// Modify one entry
|
||||
if (begSel == endSel) {
|
||||
r = color.getRed();
|
||||
@ -724,7 +724,7 @@ void PaletteEntryEditor::setPaletteEntryChannel(const Color& color, ColorSliders
|
||||
}
|
||||
break;
|
||||
|
||||
case Color::HsvType:
|
||||
case app::Color::HsvType:
|
||||
{
|
||||
Hsv hsv;
|
||||
|
||||
@ -767,14 +767,14 @@ void PaletteEntryEditor::setPaletteEntryChannel(const Color& color, ColorSliders
|
||||
}
|
||||
}
|
||||
|
||||
void PaletteEntryEditor::selectColorType(Color::Type type)
|
||||
void PaletteEntryEditor::selectColorType(app::Color::Type type)
|
||||
{
|
||||
m_rgbSliders.setVisible(type == Color::RgbType);
|
||||
m_hsvSliders.setVisible(type == Color::HsvType);
|
||||
m_rgbSliders.setVisible(type == app::Color::RgbType);
|
||||
m_hsvSliders.setVisible(type == app::Color::HsvType);
|
||||
|
||||
switch (type) {
|
||||
case Color::RgbType: m_rgbButton.setSelected(true); break;
|
||||
case Color::HsvType: m_hsvButton.setSelected(true); break;
|
||||
case app::Color::RgbType: m_rgbButton.setSelected(true); break;
|
||||
case app::Color::HsvType: m_hsvButton.setSelected(true); break;
|
||||
}
|
||||
|
||||
m_vbox.layout();
|
||||
@ -860,7 +860,7 @@ void PaletteEntryEditor::onPalChange()
|
||||
PaletteView* palette_editor = ColorBar::instance()->getPaletteView();
|
||||
int index = palette_editor->getSelectedEntry();
|
||||
if (index >= 0)
|
||||
setColor(Color::fromIndex(index));
|
||||
setColor(app::Color::fromIndex(index));
|
||||
|
||||
// Redraw the window
|
||||
invalidate();
|
||||
|
@ -121,7 +121,7 @@ void SpritePropertiesCommand::onExecute(Context* context)
|
||||
frames->setTextf("%d", (int)sprite->getTotalFrames());
|
||||
|
||||
if (sprite->getPixelFormat() == IMAGE_INDEXED) {
|
||||
color_button = new ColorButton(Color::fromIndex(sprite->getTransparentColor()),
|
||||
color_button = new ColorButton(app::Color::fromIndex(sprite->getTransparentColor()),
|
||||
IMAGE_INDEXED);
|
||||
|
||||
box_transparent->addChild(color_button);
|
||||
|
@ -44,8 +44,8 @@ SwitchColorsCommand::SwitchColorsCommand()
|
||||
void SwitchColorsCommand::onExecute(Context* context)
|
||||
{
|
||||
ColorBar* colorbar = ColorBar::instance();
|
||||
Color fg = colorbar->getFgColor();
|
||||
Color bg = colorbar->getBgColor();
|
||||
app::Color fg = colorbar->getFgColor();
|
||||
app::Color bg = colorbar->getBgColor();
|
||||
|
||||
colorbar->setFgColor(bg);
|
||||
colorbar->setBgColor(fg);
|
||||
|
@ -49,22 +49,22 @@ class ReplaceColorFilterWrapper : public ReplaceColorFilter
|
||||
public:
|
||||
ReplaceColorFilterWrapper(Layer* layer) : m_layer(layer) { }
|
||||
|
||||
void setFrom(const Color& from) {
|
||||
void setFrom(const app::Color& from) {
|
||||
m_from = from;
|
||||
ReplaceColorFilter::setFrom(color_utils::color_for_layer(from, m_layer));
|
||||
}
|
||||
void setTo(const Color& to) {
|
||||
void setTo(const app::Color& to) {
|
||||
m_to = to;
|
||||
ReplaceColorFilter::setTo(color_utils::color_for_layer(to, m_layer));
|
||||
}
|
||||
|
||||
Color getFrom() const { return m_from; }
|
||||
Color getTo() const { return m_to; }
|
||||
app::Color getFrom() const { return m_from; }
|
||||
app::Color getTo() const { return m_to; }
|
||||
|
||||
private:
|
||||
Layer* m_layer;
|
||||
Color m_from;
|
||||
Color m_to;
|
||||
app::Color m_from;
|
||||
app::Color m_to;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
@ -95,13 +95,13 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
void onFromChange(const Color& color)
|
||||
void onFromChange(const app::Color& color)
|
||||
{
|
||||
m_filter.setFrom(color);
|
||||
restartPreview();
|
||||
}
|
||||
|
||||
void onToChange(const Color& color)
|
||||
void onToChange(const app::Color& color)
|
||||
{
|
||||
m_filter.setTo(color);
|
||||
restartPreview();
|
||||
|
@ -886,6 +886,7 @@ void AnimationEditor::drawHeader(JRect clip)
|
||||
|
||||
void AnimationEditor::drawHeaderFrame(JRect clip, FrameNumber frame)
|
||||
{
|
||||
SkinTheme* theme = static_cast<SkinTheme*>(getTheme());
|
||||
bool is_hot = (m_hot_part == A_PART_HEADER_FRAME &&
|
||||
m_hot_frame == frame);
|
||||
bool is_clk = (m_clk_part == A_PART_HEADER_FRAME &&
|
||||
@ -920,16 +921,19 @@ void AnimationEditor::drawHeaderFrame(JRect clip, FrameNumber frame)
|
||||
// user can move frames.
|
||||
if (is_hot && !is_clk &&
|
||||
m_clk_part == A_PART_HEADER_FRAME) {
|
||||
rectfill(ji_screen, x1+1, y1+1, x1+4, y2-1, ji_color_selected());
|
||||
rectfill(ji_screen, x1+1, y1+1, x1+4, y2-1,
|
||||
to_system(theme->getColor(ThemeColor::Selected)));
|
||||
}
|
||||
|
||||
// Padding in the right side.
|
||||
if (frame == m_sprite->getTotalFrames()-1) {
|
||||
if (x2+1 <= this->rc->x2-1) {
|
||||
// Right side.
|
||||
vline(ji_screen, x2+1, y1, y2, ji_color_foreground());
|
||||
vline(ji_screen, x2+1, y1, y2,
|
||||
to_system(theme->getColor(ThemeColor::Text)));
|
||||
if (x2+2 <= this->rc->x2-1)
|
||||
rectfill(ji_screen, x2+2, y1, this->rc->x2-1, y2, ji_color_face());
|
||||
rectfill(ji_screen, x2+2, y1, this->rc->x2-1, y2,
|
||||
to_system(theme->getColor(ThemeColor::Face)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -941,23 +945,20 @@ void AnimationEditor::drawHeaderPart(JRect clip, int x1, int y1, int x2, int y2,
|
||||
const char *line1, int align1,
|
||||
const char *line2, int align2)
|
||||
{
|
||||
int x, fg, face, facelight, faceshadow;
|
||||
SkinTheme* theme = static_cast<SkinTheme*>(getTheme());
|
||||
ui::Color fg, face;
|
||||
int x;
|
||||
|
||||
if ((x2 < clip->x1) || (x1 >= clip->x2) ||
|
||||
(y2 < clip->y1) || (y1 >= clip->y2))
|
||||
return;
|
||||
|
||||
fg = !is_hot && is_clk ? ji_color_background(): ji_color_foreground();
|
||||
face = is_hot ? ji_color_hotface(): (is_clk ? ji_color_selected():
|
||||
ji_color_face());
|
||||
facelight = is_hot && is_clk ? ji_color_faceshadow(): ji_color_facelight();
|
||||
faceshadow = is_hot && is_clk ? ji_color_facelight(): ji_color_faceshadow();
|
||||
|
||||
// Draw the border of this text.
|
||||
jrectedge(ji_screen, x1, y1, x2, y2, facelight, faceshadow);
|
||||
fg = theme->getColor(!is_hot && is_clk ? ThemeColor::Background: ThemeColor::Text);
|
||||
face = theme->getColor(is_hot ? ThemeColor::HotFace: (is_clk ? ThemeColor::Selected:
|
||||
ThemeColor::Face));
|
||||
|
||||
// Fill the background of the part.
|
||||
rectfill(ji_screen, x1+1, y1+1, x2-1, y2-1, face);
|
||||
rectfill(ji_screen, x1, y1, x2, y2, to_system(face));
|
||||
|
||||
// Draw the text inside this header.
|
||||
if (line1 != NULL) {
|
||||
@ -988,6 +989,7 @@ void AnimationEditor::drawHeaderPart(JRect clip, int x1, int y1, int x2, int y2,
|
||||
|
||||
void AnimationEditor::drawSeparator(JRect clip)
|
||||
{
|
||||
SkinTheme* theme = static_cast<SkinTheme*>(getTheme());
|
||||
bool is_hot = (m_hot_part == A_PART_SEPARATOR);
|
||||
int x1, y1, x2, y2;
|
||||
|
||||
@ -1000,8 +1002,9 @@ void AnimationEditor::drawSeparator(JRect clip)
|
||||
(y2 < clip->y1) || (y1 >= clip->y2))
|
||||
return;
|
||||
|
||||
vline(ji_screen, x1, y1, y2, is_hot ? ji_color_selected():
|
||||
ji_color_foreground());
|
||||
vline(ji_screen, x1, y1, y2,
|
||||
to_system(is_hot ? theme->getColor(ThemeColor::Selected):
|
||||
theme->getColor(ThemeColor::Text)));
|
||||
}
|
||||
|
||||
void AnimationEditor::drawLayer(JRect clip, int layer_index)
|
||||
@ -1011,11 +1014,11 @@ void AnimationEditor::drawLayer(JRect clip, int layer_index)
|
||||
bool selected_layer = (layer == m_sprite->getCurrentLayer());
|
||||
bool is_hot = (m_hot_part == A_PART_LAYER && m_hot_layer == layer_index);
|
||||
bool is_clk = (m_clk_part == A_PART_LAYER && m_clk_layer == layer_index);
|
||||
int bg = selected_layer ?
|
||||
ji_color_selected(): (is_hot ? ji_color_hotface():
|
||||
(is_clk ? ji_color_selected():
|
||||
ji_color_face()));
|
||||
int fg = selected_layer ? ji_color_background(): ji_color_foreground();
|
||||
ui::Color bg = theme->getColor(selected_layer ? ThemeColor::Selected:
|
||||
(is_hot ? ThemeColor::HotFace:
|
||||
(is_clk ? ThemeColor::Selected:
|
||||
ThemeColor::Face)));
|
||||
ui::Color fg = theme->getColor(selected_layer ? ThemeColor::Background: ThemeColor::Text);
|
||||
BITMAP* icon1 = theme->get_part(layer->is_readable() ? PART_LAYER_VISIBLE: PART_LAYER_HIDDEN);
|
||||
BITMAP* icon2 = theme->get_part(layer->is_writable() ? PART_LAYER_EDITABLE: PART_LAYER_LOCKED);
|
||||
BITMAP* icon1_selected = theme->get_part(layer->is_readable() ? PART_LAYER_VISIBLE_SELECTED: PART_LAYER_HIDDEN_SELECTED);
|
||||
@ -1038,21 +1041,17 @@ void AnimationEditor::drawLayer(JRect clip, int layer_index)
|
||||
this->rc->x1 + m_separator_x - 1,
|
||||
this->rc->y2-1);
|
||||
|
||||
if (is_hot) {
|
||||
jrectedge(ji_screen, x1, y1, x2, y2-1, ji_color_facelight(), ji_color_faceshadow());
|
||||
rectfill(ji_screen, x1+1, y1+1, x2-1, y2-2, bg);
|
||||
}
|
||||
else {
|
||||
rectfill(ji_screen, x1, y1, x2, y2-1, bg);
|
||||
}
|
||||
hline(ji_screen, x1, y2, x2, ji_color_foreground());
|
||||
rectfill(ji_screen, x1, y1, x2, y2-1, to_system(bg));
|
||||
hline(ji_screen, x1, y2, x2,
|
||||
to_system(theme->getColor(ThemeColor::Text)));
|
||||
|
||||
// If this layer wasn't clicked but there are another layer clicked,
|
||||
// we have to draw some indicators to show that the user can move
|
||||
// layers.
|
||||
if (is_hot && !is_clk &&
|
||||
m_clk_part == A_PART_LAYER) {
|
||||
rectfill(ji_screen, x1+1, y1+1, x2-1, y1+5, ji_color_selected());
|
||||
rectfill(ji_screen, x1+1, y1+1, x2-1, y1+5,
|
||||
to_system(theme->getColor(ThemeColor::Selected)));
|
||||
}
|
||||
|
||||
// u = the position where to put the next element (like eye-icon,
|
||||
@ -1098,7 +1097,7 @@ void AnimationEditor::drawLayer(JRect clip, int layer_index)
|
||||
u,
|
||||
y_mid - ji_font_get_size(this->getFont())/2 + ji_font_get_size(this->getFont()) + 1,
|
||||
u + text_length(this->getFont(), layer->getName().c_str()),
|
||||
fg);
|
||||
to_system(fg));
|
||||
}
|
||||
|
||||
set_clip_rect(ji_screen, cx1, cy1, cx2, cy2);
|
||||
@ -1117,12 +1116,12 @@ void AnimationEditor::drawLayerPadding()
|
||||
|
||||
// Padding in the bottom side.
|
||||
if (y2+1 <= this->rc->y2-1) {
|
||||
rectfill(ji_screen, x1, y2+1, x2, this->rc->y2-1,
|
||||
theme->get_editor_face_color());
|
||||
ui::Color color = theme->getColor(ThemeColor::EditorFace);
|
||||
rectfill(ji_screen, x1, y2+1, x2, this->rc->y2-1, to_system(color));
|
||||
rectfill(ji_screen,
|
||||
x2+1+m_separator_w, y2+1,
|
||||
this->rc->x2-1, this->rc->y2-1,
|
||||
theme->get_editor_face_color());
|
||||
to_system(color));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1137,8 +1136,7 @@ void AnimationEditor::drawCel(JRect clip, int layer_index, FrameNumber frame, Ce
|
||||
bool is_clk = (m_clk_part == A_PART_CEL &&
|
||||
m_clk_layer == layer_index &&
|
||||
m_clk_frame == frame);
|
||||
int bg = is_hot ? ji_color_hotface():
|
||||
ji_color_face();
|
||||
ui::Color bg = theme->getColor(is_hot ? ThemeColor::HotFace: ThemeColor::Face);
|
||||
int x1, y1, x2, y2;
|
||||
int cx1, cy1, cx2, cy2;
|
||||
BITMAP *thumbnail;
|
||||
@ -1163,25 +1161,13 @@ void AnimationEditor::drawCel(JRect clip, int layer_index, FrameNumber frame, Ce
|
||||
// Draw the box for the cel.
|
||||
if (selected_layer && frame == m_sprite->getCurrentFrame()) {
|
||||
// Current cel.
|
||||
if (is_hot)
|
||||
jrectedge(ji_screen, x1, y1, x2, y2-1,
|
||||
ji_color_facelight(), ji_color_faceshadow());
|
||||
else
|
||||
rect(ji_screen, x1, y1, x2, y2-1, ji_color_selected());
|
||||
rect(ji_screen, x1+1, y1+1, x2-1, y2-2, ji_color_selected());
|
||||
rect(ji_screen, x1+2, y1+2, x2-2, y2-3, bg);
|
||||
rect(ji_screen, x1, y1, x2, y2-1, to_system(theme->getColor(ThemeColor::Selected)));
|
||||
rect(ji_screen, x1+1, y1+1, x2-1, y2-2, to_system(bg));
|
||||
}
|
||||
else {
|
||||
if (is_hot) {
|
||||
jrectedge(ji_screen, x1, y1, x2, y2-1,
|
||||
ji_color_facelight(), ji_color_faceshadow());
|
||||
rectfill(ji_screen, x1+1, y1+1, x2-1, y2-2, bg);
|
||||
}
|
||||
else {
|
||||
rectfill(ji_screen, x1, y1, x2, y2-1, bg);
|
||||
}
|
||||
rectfill(ji_screen, x1, y1, x2, y2-1, to_system(bg));
|
||||
}
|
||||
hline(ji_screen, x1, y2, x2, ji_color_foreground());
|
||||
hline(ji_screen, x1, y2, x2, to_system(theme->getColor(ThemeColor::Text)));
|
||||
|
||||
// Empty cel?.
|
||||
if (cel == NULL ||
|
||||
@ -1189,7 +1175,7 @@ void AnimationEditor::drawCel(JRect clip, int layer_index, FrameNumber frame, Ce
|
||||
m_sprite->getStock()->getImage(cel->getImage()) == NULL) {
|
||||
|
||||
jdraw_rectfill(thumbnail_rect, bg);
|
||||
draw_emptyset_symbol(ji_screen, thumbnail_rect, ji_color_disabled());
|
||||
draw_emptyset_symbol(ji_screen, thumbnail_rect, theme->getColor(ThemeColor::Disabled));
|
||||
}
|
||||
else {
|
||||
thumbnail = generate_thumbnail(layer, cel, m_sprite);
|
||||
@ -1205,27 +1191,29 @@ void AnimationEditor::drawCel(JRect clip, int layer_index, FrameNumber frame, Ce
|
||||
// some indicators to show that the user can move cels.
|
||||
if (is_hot && !is_clk &&
|
||||
m_clk_part == A_PART_CEL) {
|
||||
rectfill(ji_screen, x1+1, y1+1, x1+FRMSIZE/3, y1+4, ji_color_selected());
|
||||
rectfill(ji_screen, x1+1, y1+5, x1+4, y1+FRMSIZE/3, ji_color_selected());
|
||||
int color = to_system(theme->getColor(ThemeColor::Selected));
|
||||
|
||||
rectfill(ji_screen, x2-FRMSIZE/3, y1+1, x2-1, y1+4, ji_color_selected());
|
||||
rectfill(ji_screen, x2-4, y1+5, x2-1, y1+FRMSIZE/3, ji_color_selected());
|
||||
rectfill(ji_screen, x1+1, y1+1, x1+FRMSIZE/3, y1+4, color);
|
||||
rectfill(ji_screen, x1+1, y1+5, x1+4, y1+FRMSIZE/3, color);
|
||||
|
||||
rectfill(ji_screen, x1+1, y2-4, x1+FRMSIZE/3, y2-1, ji_color_selected());
|
||||
rectfill(ji_screen, x1+1, y2-FRMSIZE/3, x1+4, y2-5, ji_color_selected());
|
||||
rectfill(ji_screen, x2-FRMSIZE/3, y1+1, x2-1, y1+4, color);
|
||||
rectfill(ji_screen, x2-4, y1+5, x2-1, y1+FRMSIZE/3, color);
|
||||
|
||||
rectfill(ji_screen, x2-FRMSIZE/3, y2-4, x2-1, y2-1, ji_color_selected());
|
||||
rectfill(ji_screen, x2-4, y2-FRMSIZE/3, x2-1, y2-5, ji_color_selected());
|
||||
rectfill(ji_screen, x1+1, y2-4, x1+FRMSIZE/3, y2-1, color);
|
||||
rectfill(ji_screen, x1+1, y2-FRMSIZE/3, x1+4, y2-5, color);
|
||||
|
||||
rectfill(ji_screen, x2-FRMSIZE/3, y2-4, x2-1, y2-1, color);
|
||||
rectfill(ji_screen, x2-4, y2-FRMSIZE/3, x2-1, y2-5, color);
|
||||
}
|
||||
|
||||
// Padding in the right side.
|
||||
if (frame == m_sprite->getTotalFrames()-1) {
|
||||
if (x2+1 <= this->rc->x2-1) {
|
||||
// Right side.
|
||||
vline(ji_screen, x2+1, y1, y2, ji_color_foreground());
|
||||
vline(ji_screen, x2+1, y1, y2, to_system(theme->getColor(ThemeColor::Text)));
|
||||
if (x2+2 <= this->rc->x2-1)
|
||||
rectfill(ji_screen, x2+2, y1, this->rc->x2-1, y2,
|
||||
theme->get_editor_face_color());
|
||||
to_system(theme->getColor(ThemeColor::EditorFace)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1479,18 +1467,14 @@ int AnimationEditor::getLayerIndex(const Layer* layer)
|
||||
static void icon_rect(BITMAP* icon_normal, BITMAP* icon_selected, int x1, int y1, int x2, int y2,
|
||||
bool is_selected, bool is_hot, bool is_clk)
|
||||
{
|
||||
SkinTheme* theme = static_cast<SkinTheme*>(ui::CurrentTheme::get());
|
||||
int icon_x = x1+ICONBORDER;
|
||||
int icon_y = (y1+y2)/2-icon_normal->h/2;
|
||||
int facelight = is_hot && is_clk ? ji_color_faceshadow(): ji_color_facelight();
|
||||
int faceshadow = is_hot && is_clk ? ji_color_facelight(): ji_color_faceshadow();
|
||||
|
||||
if (is_hot) {
|
||||
jrectedge(ji_screen, x1, y1, x2, y2, facelight, faceshadow);
|
||||
|
||||
if (!is_selected)
|
||||
rectfill(ji_screen,
|
||||
x1+1, y1+1, x2-1, y2-1,
|
||||
ji_color_hotface());
|
||||
if (is_hot && !is_selected) {
|
||||
rectfill(ji_screen,
|
||||
x1, y1, x2, y2,
|
||||
to_system(theme->getColor(ThemeColor::HotFace)));
|
||||
}
|
||||
|
||||
set_alpha_blender();
|
||||
|
@ -100,12 +100,12 @@ void set_config_rect(const char *section, const char *name, const Rect& rect)
|
||||
set_config_string(section, name, buf);
|
||||
}
|
||||
|
||||
Color get_config_color(const char *section, const char *name, const Color& value)
|
||||
app::Color get_config_color(const char *section, const char *name, const app::Color& value)
|
||||
{
|
||||
return Color::fromString(get_config_string(section, name, value.toString().c_str()));
|
||||
return app::Color::fromString(get_config_string(section, name, value.toString().c_str()));
|
||||
}
|
||||
|
||||
void set_config_color(const char *section, const char *name, const Color& value)
|
||||
void set_config_color(const char *section, const char *name, const app::Color& value)
|
||||
{
|
||||
set_config_string(section, name, value.toString().c_str());
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ void set_config_bool(const char *section, const char *name, bool value);
|
||||
gfx::Rect get_config_rect(const char *section, const char *name, const gfx::Rect& rect);
|
||||
void set_config_rect(const char *section, const char *name, const gfx::Rect& rect);
|
||||
|
||||
Color get_config_color(const char *section, const char *name, const Color& value);
|
||||
void set_config_color(const char *section, const char *name, const Color& value);
|
||||
app::Color get_config_color(const char *section, const char *name, const app::Color& value);
|
||||
void set_config_color(const char *section, const char *name, const app::Color& value);
|
||||
|
||||
#endif
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <allegro.h>
|
||||
#include <allegro/internal/aintern.h>
|
||||
|
||||
#include "ui/color.h"
|
||||
#include "ui/intern.h"
|
||||
#include "ui/rect.h"
|
||||
#include "ui/system.h"
|
||||
@ -160,24 +161,6 @@ void dotted_mode(int offset)
|
||||
drawing_mode(DRAW_MODE_COPY_PATTERN, pattern, 0, 0);
|
||||
}
|
||||
|
||||
void simple_dotted_mode(BITMAP* bmp, int fg, int bg)
|
||||
{
|
||||
static BITMAP* pattern = NULL;
|
||||
|
||||
if (pattern && bitmap_color_depth(pattern) != bitmap_color_depth(bmp))
|
||||
destroy_bitmap(pattern);
|
||||
|
||||
pattern = create_bitmap_ex(bitmap_color_depth(bmp), 2, 2);
|
||||
clear_bitmap(pattern);
|
||||
|
||||
putpixel(pattern, 0, 0, fg);
|
||||
putpixel(pattern, 0, 1, bg);
|
||||
putpixel(pattern, 1, 0, bg);
|
||||
putpixel(pattern, 1, 1, fg);
|
||||
|
||||
drawing_mode(DRAW_MODE_COPY_PATTERN, pattern, 0, 0);
|
||||
}
|
||||
|
||||
/**********************************************************************/
|
||||
/* Rectangle Tracker (Save/Restore rectangles from/to the screen) */
|
||||
|
||||
@ -305,13 +288,6 @@ void bevel_box(BITMAP* bmp, int x1, int y1, int x2, int y2, int c1, int c2, int
|
||||
line(bmp, x2-bevel, y2, x2, y2-bevel, c2); /* bottom-right */
|
||||
}
|
||||
|
||||
void rectdotted(BITMAP* bmp, int x1, int y1, int x2, int y2, int fg, int bg)
|
||||
{
|
||||
simple_dotted_mode(bmp, fg, bg);
|
||||
rect(bmp, x1, y1, x2, y2, 0);
|
||||
solid_mode();
|
||||
}
|
||||
|
||||
void rectgrid(BITMAP* bmp, int x1, int y1, int x2, int y2, int w, int h)
|
||||
{
|
||||
if (w < 1 || h < 1)
|
||||
@ -346,28 +322,28 @@ void rectgrid(BITMAP* bmp, int x1, int y1, int x2, int y2, int w, int h)
|
||||
/**********************************************************************/
|
||||
/* Specials */
|
||||
|
||||
void draw_emptyset_symbol(BITMAP* bmp, const Rect& rc, int color)
|
||||
void draw_emptyset_symbol(BITMAP* bmp, const Rect& rc, ui::Color color)
|
||||
{
|
||||
Point center = rc.getCenter();
|
||||
int size = MIN(rc.w, rc.h) - 8;
|
||||
size = MID(4, size, 64);
|
||||
|
||||
circle(bmp, center.x, center.y, size*4/10, color);
|
||||
circle(bmp, center.x, center.y, size*4/10, ui::to_system(color));
|
||||
line(bmp,
|
||||
center.x-size/2, center.y+size/2,
|
||||
center.x+size/2, center.y-size/2, color);
|
||||
center.x+size/2, center.y-size/2, ui::to_system(color));
|
||||
}
|
||||
|
||||
void draw_color(BITMAP* bmp, const Rect& rc, PixelFormat pixelFormat, const Color& color)
|
||||
void draw_color(BITMAP* bmp, const Rect& rc, PixelFormat pixelFormat, const app::Color& color)
|
||||
{
|
||||
Color::Type type = color.getType();
|
||||
app::Color::Type type = color.getType();
|
||||
BITMAP* graph;
|
||||
|
||||
if (type == Color::MaskType) {
|
||||
if (type == app::Color::MaskType) {
|
||||
rectgrid(bmp, rc.x, rc.y, rc.x+rc.w-1, rc.y+rc.h-1, rc.w/4, rc.h/2);
|
||||
return;
|
||||
}
|
||||
else if (type == Color::IndexType) {
|
||||
else if (type == app::Color::IndexType) {
|
||||
int index = color.getIndex();
|
||||
|
||||
if (index >= 0 && index < get_current_palette()->size()) {
|
||||
@ -385,7 +361,7 @@ void draw_color(BITMAP* bmp, const Rect& rc, PixelFormat pixelFormat, const Colo
|
||||
|
||||
case IMAGE_INDEXED:
|
||||
rectfill(bmp, rc.x, rc.y, rc.x+rc.w-1, rc.y+rc.h-1,
|
||||
color_utils::color_for_allegro(Color::fromIndex(color_utils::color_for_image(color, pixelFormat)),
|
||||
color_utils::color_for_allegro(app::Color::fromIndex(color_utils::color_for_image(color, pixelFormat)),
|
||||
bitmap_color_depth(bmp)));
|
||||
break;
|
||||
|
||||
@ -396,9 +372,9 @@ void draw_color(BITMAP* bmp, const Rect& rc, PixelFormat pixelFormat, const Colo
|
||||
|
||||
{
|
||||
int rgb_bitmap_color = color_utils::color_for_image(color, pixelFormat);
|
||||
Color color2 = Color::fromRgb(_rgba_getr(rgb_bitmap_color),
|
||||
_rgba_getg(rgb_bitmap_color),
|
||||
_rgba_getb(rgb_bitmap_color));
|
||||
app::Color color2 = app::Color::fromRgb(_rgba_getr(rgb_bitmap_color),
|
||||
_rgba_getg(rgb_bitmap_color),
|
||||
_rgba_getb(rgb_bitmap_color));
|
||||
rectfill(graph, 0, 0, rc.w-1, rc.h-1,
|
||||
color_utils::color_for_allegro(color2, 32));
|
||||
}
|
||||
@ -415,7 +391,7 @@ void draw_color(BITMAP* bmp, const Rect& rc, PixelFormat pixelFormat, const Colo
|
||||
|
||||
{
|
||||
int gray_bitmap_color = color_utils::color_for_image(color, pixelFormat);
|
||||
Color color2 = Color::fromGray(_graya_getv(gray_bitmap_color));
|
||||
app::Color color2 = app::Color::fromGray(_graya_getv(gray_bitmap_color));
|
||||
rectfill(graph, 0, 0, rc.w-1, rc.h-1,
|
||||
color_utils::color_for_allegro(color2, 32));
|
||||
}
|
||||
@ -431,7 +407,7 @@ void draw_color_button(BITMAP* bmp,
|
||||
const Rect& rc,
|
||||
bool outer_nw, bool outer_n, bool outer_ne, bool outer_e,
|
||||
bool outer_se, bool outer_s, bool outer_sw, bool outer_w,
|
||||
PixelFormat pixelFormat, const Color& color, bool hot, bool drag)
|
||||
PixelFormat pixelFormat, const app::Color& color, bool hot, bool drag)
|
||||
{
|
||||
SkinTheme* theme = (SkinTheme*)ui::CurrentTheme::get();
|
||||
int scale = ui::jguiscale();
|
||||
@ -472,17 +448,20 @@ void draw_progress_bar(BITMAP* bmp,
|
||||
int x1, int y1, int x2, int y2,
|
||||
float progress)
|
||||
{
|
||||
SkinTheme* theme = (SkinTheme*)ui::CurrentTheme::get();
|
||||
int w = x2 - x1 + 1;
|
||||
int u = (int)((float)(w-2)*progress);
|
||||
u = MID(0, u, w-2);
|
||||
|
||||
rect(bmp, x1, y1, x2, y2, ui::ji_color_foreground());
|
||||
rect(bmp, x1, y1, x2, y2, ui::to_system(theme->getColor(ThemeColor::Text)));
|
||||
|
||||
if (u > 0)
|
||||
rectfill(bmp, x1+1, y1+1, x1+u, y2-1, ui::ji_color_selected());
|
||||
rectfill(bmp, x1+1, y1+1, x1+u, y2-1,
|
||||
ui::to_system(theme->getColor(ThemeColor::Selected)));
|
||||
|
||||
if (1+u < w-2)
|
||||
rectfill(bmp, x1+u+1, y1+1, x2-1, y2-1, ui::ji_color_background());
|
||||
rectfill(bmp, x1+u+1, y1+1, x2-1, y2-1,
|
||||
ui::to_system(theme->getColor(ThemeColor::Background)));
|
||||
}
|
||||
|
||||
/************************************************************************/
|
||||
|
@ -22,39 +22,28 @@
|
||||
#include "app/color.h"
|
||||
#include "gfx/rect.h"
|
||||
#include "ui/base.h"
|
||||
#include "ui/color.h"
|
||||
|
||||
struct FONT;
|
||||
struct BITMAP;
|
||||
|
||||
#define COLOR_SHADE(color, r, g, b) \
|
||||
makecol(MID(getr(color)+r, 0, 255), \
|
||||
MID(getg(color)+g, 0, 255), \
|
||||
MID(getb(color)+b, 0, 255))
|
||||
|
||||
#define COLOR_INTERP(color1, color2, step, max) \
|
||||
makecol(getr(color1)+(getr(color2)-getr(color1))*step/max, \
|
||||
getg(color1)+(getg(color2)-getg(color1))*step/max, \
|
||||
getb(color1)+(getb(color2)-getb(color1))*step/max)
|
||||
|
||||
typedef struct RectTracker RectTracker;
|
||||
|
||||
void dotted_mode(int offset);
|
||||
void simple_dotted_mode(BITMAP* bmp, int fg, int bg);
|
||||
|
||||
RectTracker *rect_tracker_new(BITMAP* bmp, int x1, int y1, int x2, int y2);
|
||||
void rect_tracker_free(RectTracker *tracker);
|
||||
RectTracker* rect_tracker_new(BITMAP* bmp, int x1, int y1, int x2, int y2);
|
||||
void rect_tracker_free(RectTracker* tracker);
|
||||
|
||||
void bevel_box(BITMAP* bmp, int x1, int y1, int x2, int y2, int c1, int c2, int bevel);
|
||||
void rectdotted(BITMAP* bmp, int x1, int y1, int x2, int y2, int fg, int bg);
|
||||
void bevel_box(BITMAP* bmp, int x1, int y1, int x2, int y2, ui::Color c1, ui::Color c2, int bevel);
|
||||
void rectgrid(BITMAP* bmp, int x1, int y1, int x2, int y2, int w, int h);
|
||||
|
||||
void draw_emptyset_symbol(BITMAP* bmp, const gfx::Rect& rc, int color);
|
||||
void draw_color(BITMAP* bmp, const gfx::Rect& rc, PixelFormat pixelFormat, const Color& color);
|
||||
void draw_emptyset_symbol(BITMAP* bmp, const gfx::Rect& rc, ui::Color color);
|
||||
void draw_color(BITMAP* bmp, const gfx::Rect& rc, PixelFormat pixelFormat, const app::Color& color);
|
||||
void draw_color_button(BITMAP* bmp,
|
||||
const gfx::Rect& rc,
|
||||
bool outer_nw, bool outer_n, bool outer_ne, bool outer_e,
|
||||
bool outer_se, bool outer_s, bool outer_sw, bool outer_w,
|
||||
PixelFormat pixelFormat, const Color& color,
|
||||
PixelFormat pixelFormat, const app::Color& color,
|
||||
bool hot, bool drag);
|
||||
void draw_progress_bar(BITMAP* bmp,
|
||||
int x1, int y1, int x2, int y2,
|
||||
|
@ -44,22 +44,22 @@ public:
|
||||
virtual bool getSnapToGrid() = 0;
|
||||
virtual bool getGridVisible() = 0;
|
||||
virtual gfx::Rect getGridBounds() = 0;
|
||||
virtual Color getGridColor() = 0;
|
||||
virtual app::Color getGridColor() = 0;
|
||||
|
||||
virtual void setSnapToGrid(bool state) = 0;
|
||||
virtual void setGridVisible(bool state) = 0;
|
||||
virtual void setGridBounds(const gfx::Rect& rect) = 0;
|
||||
virtual void setGridColor(const Color& color) = 0;
|
||||
virtual void setGridColor(const app::Color& color) = 0;
|
||||
|
||||
virtual void snapToGrid(gfx::Point& point, SnapBehavior snapBehavior) const = 0;
|
||||
|
||||
// Pixel grid
|
||||
|
||||
virtual bool getPixelGridVisible() = 0;
|
||||
virtual Color getPixelGridColor() = 0;
|
||||
virtual app::Color getPixelGridColor() = 0;
|
||||
|
||||
virtual void setPixelGridVisible(bool state) = 0;
|
||||
virtual void setPixelGridColor(const Color& color) = 0;
|
||||
virtual void setPixelGridColor(const app::Color& color) = 0;
|
||||
|
||||
// Onionskin settings
|
||||
|
||||
|
@ -38,12 +38,12 @@ public:
|
||||
|
||||
// General settings
|
||||
|
||||
virtual Color getFgColor() = 0;
|
||||
virtual Color getBgColor() = 0;
|
||||
virtual app::Color getFgColor() = 0;
|
||||
virtual app::Color getBgColor() = 0;
|
||||
virtual tools::Tool* getCurrentTool() = 0;
|
||||
|
||||
virtual void setFgColor(const Color& color) = 0;
|
||||
virtual void setBgColor(const Color& color) = 0;
|
||||
virtual void setFgColor(const app::Color& color) = 0;
|
||||
virtual void setBgColor(const app::Color& color) = 0;
|
||||
virtual void setCurrentTool(tools::Tool* tool) = 0;
|
||||
|
||||
// Returns the specific settings for the given document. If the
|
||||
|
@ -47,8 +47,8 @@ public:
|
||||
, m_snapToGrid(get_config_bool("Grid", "SnapTo", false))
|
||||
, m_gridVisible(get_config_bool("Grid", "Visible", false))
|
||||
, m_gridBounds(get_config_rect("Grid", "Bounds", Rect(0, 0, 16, 16)))
|
||||
, m_gridColor(get_config_color("Grid", "Color", Color::fromRgb(0, 0, 255)))
|
||||
, m_pixelGridColor(get_config_color("PixelGrid", "Color", Color::fromRgb(200, 200, 200)))
|
||||
, m_gridColor(get_config_color("Grid", "Color", app::Color::fromRgb(0, 0, 255)))
|
||||
, m_pixelGridColor(get_config_color("PixelGrid", "Color", app::Color::fromRgb(200, 200, 200)))
|
||||
, m_pixelGridVisible(get_config_bool("PixelGrid", "Visible", false))
|
||||
{
|
||||
m_tiledMode = (TiledMode)MID(0, (int)m_tiledMode, (int)TILED_BOTH);
|
||||
@ -81,22 +81,22 @@ public:
|
||||
virtual bool getSnapToGrid() OVERRIDE;
|
||||
virtual bool getGridVisible() OVERRIDE;
|
||||
virtual gfx::Rect getGridBounds() OVERRIDE;
|
||||
virtual Color getGridColor() OVERRIDE;
|
||||
virtual app::Color getGridColor() OVERRIDE;
|
||||
|
||||
virtual void setSnapToGrid(bool state) OVERRIDE;
|
||||
virtual void setGridVisible(bool state) OVERRIDE;
|
||||
virtual void setGridBounds(const gfx::Rect& rect) OVERRIDE;
|
||||
virtual void setGridColor(const Color& color) OVERRIDE;
|
||||
virtual void setGridColor(const app::Color& color) OVERRIDE;
|
||||
|
||||
virtual void snapToGrid(gfx::Point& point, SnapBehavior snapBehavior) const OVERRIDE;
|
||||
|
||||
// Pixel grid
|
||||
|
||||
virtual bool getPixelGridVisible() OVERRIDE;
|
||||
virtual Color getPixelGridColor() OVERRIDE;
|
||||
virtual app::Color getPixelGridColor() OVERRIDE;
|
||||
|
||||
virtual void setPixelGridVisible(bool state) OVERRIDE;
|
||||
virtual void setPixelGridColor(const Color& color) OVERRIDE;
|
||||
virtual void setPixelGridColor(const app::Color& color) OVERRIDE;
|
||||
|
||||
// Onionskin settings
|
||||
|
||||
@ -122,9 +122,9 @@ private:
|
||||
bool m_snapToGrid;
|
||||
bool m_gridVisible;
|
||||
gfx::Rect m_gridBounds;
|
||||
Color m_gridColor;
|
||||
app::Color m_gridColor;
|
||||
bool m_pixelGridVisible;
|
||||
Color m_pixelGridColor;
|
||||
app::Color m_pixelGridColor;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
@ -149,12 +149,12 @@ UISettingsImpl::~UISettingsImpl()
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// General settings
|
||||
|
||||
Color UISettingsImpl::getFgColor()
|
||||
app::Color UISettingsImpl::getFgColor()
|
||||
{
|
||||
return ColorBar::instance()->getFgColor();
|
||||
}
|
||||
|
||||
Color UISettingsImpl::getBgColor()
|
||||
app::Color UISettingsImpl::getBgColor()
|
||||
{
|
||||
return ColorBar::instance()->getBgColor();
|
||||
}
|
||||
@ -167,12 +167,12 @@ tools::Tool* UISettingsImpl::getCurrentTool()
|
||||
return m_currentTool;
|
||||
}
|
||||
|
||||
void UISettingsImpl::setFgColor(const Color& color)
|
||||
void UISettingsImpl::setFgColor(const app::Color& color)
|
||||
{
|
||||
ColorBar::instance()->setFgColor(color);
|
||||
}
|
||||
|
||||
void UISettingsImpl::setBgColor(const Color& color)
|
||||
void UISettingsImpl::setBgColor(const app::Color& color)
|
||||
{
|
||||
ColorBar::instance()->setFgColor(color);
|
||||
}
|
||||
@ -224,7 +224,7 @@ Rect UIDocumentSettingsImpl::getGridBounds()
|
||||
return m_gridBounds;
|
||||
}
|
||||
|
||||
Color UIDocumentSettingsImpl::getGridColor()
|
||||
app::Color UIDocumentSettingsImpl::getGridColor()
|
||||
{
|
||||
return m_gridColor;
|
||||
}
|
||||
@ -244,7 +244,7 @@ void UIDocumentSettingsImpl::setGridBounds(const Rect& rect)
|
||||
m_gridBounds = rect;
|
||||
}
|
||||
|
||||
void UIDocumentSettingsImpl::setGridColor(const Color& color)
|
||||
void UIDocumentSettingsImpl::setGridColor(const app::Color& color)
|
||||
{
|
||||
m_gridColor = color;
|
||||
}
|
||||
@ -271,7 +271,7 @@ bool UIDocumentSettingsImpl::getPixelGridVisible()
|
||||
return m_pixelGridVisible;
|
||||
}
|
||||
|
||||
Color UIDocumentSettingsImpl::getPixelGridColor()
|
||||
app::Color UIDocumentSettingsImpl::getPixelGridColor()
|
||||
{
|
||||
return m_pixelGridColor;
|
||||
}
|
||||
@ -281,7 +281,7 @@ void UIDocumentSettingsImpl::setPixelGridVisible(bool state)
|
||||
m_pixelGridVisible = state;
|
||||
}
|
||||
|
||||
void UIDocumentSettingsImpl::setPixelGridColor(const Color& color)
|
||||
void UIDocumentSettingsImpl::setPixelGridColor(const app::Color& color)
|
||||
{
|
||||
m_pixelGridColor = color;
|
||||
}
|
||||
|
@ -32,12 +32,12 @@ public:
|
||||
|
||||
// General settings
|
||||
|
||||
Color getFgColor() OVERRIDE;
|
||||
Color getBgColor() OVERRIDE;
|
||||
app::Color getFgColor() OVERRIDE;
|
||||
app::Color getBgColor() OVERRIDE;
|
||||
tools::Tool* getCurrentTool() OVERRIDE;
|
||||
|
||||
void setFgColor(const Color& color) OVERRIDE;
|
||||
void setBgColor(const Color& color) OVERRIDE;
|
||||
void setFgColor(const app::Color& color) OVERRIDE;
|
||||
void setBgColor(const app::Color& color) OVERRIDE;
|
||||
void setCurrentTool(tools::Tool* tool) OVERRIDE;
|
||||
|
||||
// Document settings
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -21,6 +21,7 @@
|
||||
|
||||
#include "gfx/rect.h"
|
||||
#include "skin/skin_parts.h"
|
||||
#include "ui/color.h"
|
||||
#include "ui/rect.h"
|
||||
#include "ui/system.h"
|
||||
#include "ui/theme.h"
|
||||
@ -35,23 +36,83 @@ namespace ui {
|
||||
class IButtonIcon;
|
||||
}
|
||||
|
||||
namespace ThemeColor {
|
||||
enum Type {
|
||||
Text,
|
||||
Disabled,
|
||||
Face,
|
||||
HotFace,
|
||||
Selected,
|
||||
Background,
|
||||
Desktop,
|
||||
TextBoxText,
|
||||
TextBoxFace,
|
||||
LinkText,
|
||||
ButtonNormalText,
|
||||
ButtonNormalFace,
|
||||
ButtonHotText,
|
||||
ButtonHotFace,
|
||||
ButtonSelectedText,
|
||||
ButtonSelectedFace,
|
||||
CheckHotFace,
|
||||
CheckFocusFace,
|
||||
RadioHotFace,
|
||||
RadioFocusFace,
|
||||
MenuItemNormalText,
|
||||
MenuItemNormalFace,
|
||||
MenuItemHotText,
|
||||
MenuItemHotFace,
|
||||
MenuItemHighlightText,
|
||||
MenuItemHighlightFace,
|
||||
WindowFace,
|
||||
WindowTitlebarText,
|
||||
WindowTitlebarFace,
|
||||
EditorFace,
|
||||
EditorSpriteBorder,
|
||||
EditorSpriteBottomBorder,
|
||||
ListItemNormalText,
|
||||
ListItemNormalFace,
|
||||
ListItemSelectedText,
|
||||
ListItemSelectedFace,
|
||||
SliderEmptyText,
|
||||
SliderEmptyFace,
|
||||
SliderFullText,
|
||||
SliderFullFace,
|
||||
TabNormalText,
|
||||
TabNormalFace,
|
||||
TabSelectedText,
|
||||
TabSelectedFace,
|
||||
SplitterNormalFace,
|
||||
ScrollBarBgFace,
|
||||
ScrollBarThumbFace,
|
||||
PopupWindowBorder,
|
||||
TooltipText,
|
||||
TooltipFace,
|
||||
FileListEvenRowText,
|
||||
FileListEvenRowFace,
|
||||
FileListOddRowText,
|
||||
FileListOddRowFace,
|
||||
FileListSelectedRowText,
|
||||
FileListSelectedRowFace,
|
||||
FileListDisabledRowText,
|
||||
MaxColors
|
||||
};
|
||||
}
|
||||
|
||||
// This is the GUI theme used by ASEPRITE (which use images from data/skins
|
||||
// directory).
|
||||
class SkinTheme : public ui::Theme
|
||||
{
|
||||
std::string m_selected_skin;
|
||||
BITMAP* m_sheet_bmp;
|
||||
BITMAP* m_part[PARTS];
|
||||
std::map<std::string, BITMAP*> m_toolicon;
|
||||
std::vector<ui::Cursor*> m_cursors;
|
||||
FONT* m_minifont;
|
||||
|
||||
public:
|
||||
static const char* kThemeCloseButtonId;
|
||||
|
||||
SkinTheme();
|
||||
~SkinTheme();
|
||||
|
||||
ui::Color getColor(ThemeColor::Type k) const {
|
||||
return m_colors[k];
|
||||
}
|
||||
|
||||
FONT* getMiniFont() const { return m_minifont; }
|
||||
|
||||
void reload_skin();
|
||||
@ -62,13 +123,7 @@ public:
|
||||
ui::JRegion get_window_mask(ui::Widget* widget);
|
||||
void map_decorative_widget(ui::Widget* widget);
|
||||
|
||||
int color_foreground();
|
||||
int color_disabled();
|
||||
int color_face();
|
||||
int color_hotface();
|
||||
int color_selected();
|
||||
int color_background();
|
||||
|
||||
void paintDesktop(ui::PaintEvent& ev);
|
||||
void paintBox(ui::PaintEvent& ev);
|
||||
void paintButton(ui::PaintEvent& ev);
|
||||
void paintCheckBox(ui::PaintEvent& ev);
|
||||
@ -87,80 +142,33 @@ public:
|
||||
void draw_combobox_entry(ui::Entry* widget, ui::JRect clip);
|
||||
void paintComboBoxButton(ui::PaintEvent& ev);
|
||||
void draw_textbox(ui::Widget* widget, ui::JRect clip);
|
||||
void draw_view(ui::Widget* widget, ui::JRect clip);
|
||||
void draw_view_scrollbar(ui::Widget* widget, ui::JRect clip);
|
||||
void draw_view_viewport(ui::Widget* widget, ui::JRect clip);
|
||||
void paintView(ui::PaintEvent& ev);
|
||||
void paintViewScrollbar(ui::PaintEvent& ev);
|
||||
void paintViewViewport(ui::PaintEvent& ev);
|
||||
void paintWindow(ui::PaintEvent& ev);
|
||||
void paintPopupWindow(ui::PaintEvent& ev);
|
||||
void drawWindowButton(ui::ButtonBase* widget, ui::JRect clip);
|
||||
void paintTooltip(ui::PaintEvent& ev);
|
||||
|
||||
int get_button_normal_text_color() const { return makecol(0, 0, 0); }
|
||||
int get_button_normal_face_color() const { return makecol(198, 198, 198); }
|
||||
int get_button_hot_text_color() const { return makecol(0, 0, 0); }
|
||||
int get_button_hot_face_color() const { return makecol(255, 255, 255); }
|
||||
int get_button_selected_text_color() const { return makecol(255, 255, 255); }
|
||||
int get_button_selected_face_color() const { return makecol(124, 144, 159); }
|
||||
int get_button_selected_offset() const { return 0; }
|
||||
|
||||
int get_check_hot_face_color() const { return makecol(255, 235, 182); }
|
||||
int get_check_focus_face_color() const { return makecol(198, 198, 198); }
|
||||
|
||||
int get_radio_hot_face_color() const { return makecol(255, 235, 182); }
|
||||
int get_radio_focus_face_color() const { return makecol(198, 198, 198); }
|
||||
|
||||
int get_menuitem_normal_text_color() const { return makecol(0, 0, 0); }
|
||||
int get_menuitem_normal_face_color() const { return makecol(211, 203, 190); }
|
||||
int get_menuitem_hot_text_color() const { return makecol(0, 0, 0); }
|
||||
int get_menuitem_hot_face_color() const { return makecol(255, 235, 182); }
|
||||
int get_menuitem_highlight_text_color() const { return makecol(255, 255, 255); }
|
||||
int get_menuitem_highlight_face_color() const { return makecol(124, 144, 159); }
|
||||
|
||||
int get_window_face_color() const { return makecol(211, 203, 190); }
|
||||
int get_window_titlebar_text_color() const { return makecol(255, 255, 255); }
|
||||
int get_window_titlebar_face_color() const { return makecol(124, 144, 159); }
|
||||
|
||||
int get_editor_face_color() const { return makecol(101, 85, 97); }
|
||||
int get_editor_sprite_border() const { return makecol(0, 0, 0); }
|
||||
int get_editor_sprite_bottom_edge() const { return makecol(65, 65, 44); }
|
||||
|
||||
int get_listitem_normal_text_color() const { return makecol(0, 0, 0); }
|
||||
int get_listitem_normal_face_color() const { return makecol(255, 255, 255); }
|
||||
int get_listitem_selected_text_color() const { return makecol(255, 255, 255); }
|
||||
int get_listitem_selected_face_color() const { return makecol(255, 85, 85); }
|
||||
|
||||
int get_slider_empty_text_color() const { return makecol(0, 0, 0); }
|
||||
int get_slider_empty_face_color() const { return makecol(174, 203, 223); }
|
||||
int get_slider_full_text_color() const { return makecol(255, 255, 255); }
|
||||
int get_slider_full_face_color() const { return makecol(125, 146, 158); }
|
||||
|
||||
int get_tab_selected_text_color() const { return makecol(255, 255, 255); }
|
||||
int get_tab_selected_face_color() const { return makecol(125, 146, 158); }
|
||||
int get_tab_normal_text_color() const { return makecol(0, 0, 0); }
|
||||
int get_tab_normal_face_color() const { return makecol(199, 199, 199); }
|
||||
|
||||
int get_splitter_normal_face_color() const { return makecol(125, 146, 158); }
|
||||
|
||||
int get_scrollbar_bg_face_color() const { return makecol(125, 146, 158); }
|
||||
int get_scrollbar_thumb_face_color() const { return makecol(199, 199, 199); }
|
||||
int get_button_selected_offset() const { return 0; } // TODO Configurable in xml
|
||||
|
||||
BITMAP* get_part(int part_i) const { return m_part[part_i]; }
|
||||
BITMAP* get_toolicon(const char* tool_id) const;
|
||||
|
||||
// helper functions to draw bounds/hlines with sheet parts
|
||||
void draw_bounds_array(BITMAP* bmp, int x1, int y1, int x2, int y2, int parts[8]);
|
||||
void draw_bounds_nw(BITMAP* bmp, int x1, int y1, int x2, int y2, int nw, int bg = -1);
|
||||
void draw_bounds_nw(ui::Graphics* g, const gfx::Rect& rc, int nw, int bg = -1);
|
||||
void draw_bounds_nw2(ui::Graphics* g, const gfx::Rect& rc, int x_mid, int nw1, int nw2, int bg1, int bg2);
|
||||
void draw_bounds_nw(BITMAP* bmp, int x1, int y1, int x2, int y2, int nw, ui::Color bg = ui::ColorNone);
|
||||
void draw_bounds_nw(ui::Graphics* g, const gfx::Rect& rc, int nw, ui::Color bg = ui::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_part_as_hline(BITMAP* bmp, int x1, int y1, int x2, int y2, int part);
|
||||
void draw_part_as_vline(BITMAP* bmp, int x1, int y1, int x2, int y2, int part);
|
||||
|
||||
// Wrapper to use the new "Rect" class (x, y, w, h)
|
||||
void draw_bounds_nw(BITMAP* bmp, const gfx::Rect& rc, int nw, int bg) {
|
||||
void draw_bounds_nw(BITMAP* bmp, const gfx::Rect& rc, int nw, ui::Color bg) {
|
||||
draw_bounds_nw(bmp, rc.x, rc.y, rc.x+rc.w-1, rc.y+rc.h-1, nw, bg);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
void onRegenerate();
|
||||
|
||||
private:
|
||||
@ -170,11 +178,11 @@ private:
|
||||
int nw, int n, int ne, int e, int se, int s, int sw, int w);
|
||||
|
||||
BITMAP* cropPartFromSheet(BITMAP* bmp, int x, int y, int w, int h);
|
||||
int get_bg_color(ui::Widget* widget);
|
||||
void draw_textstring(const char *t, int fg_color, int bg_color,
|
||||
ui::Color getWidgetBgColor(ui::Widget* widget);
|
||||
void draw_textstring(const char *t, ui::Color fg_color, ui::Color bg_color,
|
||||
bool fill_bg, ui::Widget* widget, const ui::JRect rect,
|
||||
int selected_offset);
|
||||
void draw_textstring(ui::Graphics* g, const char *t, int fg_color, int bg_color,
|
||||
void draw_textstring(ui::Graphics* g, const char *t, ui::Color fg_color, ui::Color bg_color,
|
||||
bool fill_bg, ui::Widget* widget, const gfx::Rect& rc,
|
||||
int selected_offset);
|
||||
void draw_entry_caret(ui::Entry* widget, int x, int y);
|
||||
@ -185,6 +193,13 @@ private:
|
||||
|
||||
static FONT* loadFont(const char* userFont, const std::string& path);
|
||||
|
||||
std::string m_selected_skin;
|
||||
BITMAP* m_sheet_bmp;
|
||||
BITMAP* m_part[PARTS];
|
||||
std::map<std::string, BITMAP*> m_toolicon;
|
||||
std::vector<ui::Cursor*> m_cursors;
|
||||
std::vector<ui::Color> m_colors;
|
||||
FONT* m_minifont;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -7,6 +7,7 @@ add_library(ui-lib
|
||||
box.cpp
|
||||
button.cpp
|
||||
clipboard.cpp
|
||||
color.cpp
|
||||
combobox.cpp
|
||||
component.cpp
|
||||
cursor.cpp
|
||||
|
25
src/ui/color.cpp
Normal file
25
src/ui/color.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
// ASEPRITE gui library
|
||||
// Copyright (C) 2001-2012 David Capello
|
||||
//
|
||||
// This source file is distributed under a BSD-like license, please
|
||||
// read LICENSE.txt for more information.
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#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
|
45
src/ui/color.h
Normal file
45
src/ui/color.h
Normal file
@ -0,0 +1,45 @@
|
||||
// ASEPRITE gui library
|
||||
// Copyright (C) 2001-2012 David Capello
|
||||
//
|
||||
// This source file is distributed under a BSD-like license, please
|
||||
// read LICENSE.txt for more information.
|
||||
|
||||
#ifndef UI_COLOR_H_INCLUDED
|
||||
#define UI_COLOR_H_INCLUDED
|
||||
|
||||
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
|
@ -23,25 +23,25 @@ using namespace gfx;
|
||||
/* TODO optional anti-aliased textout */
|
||||
#define SETUP_ANTIALISING(f, bg, fill_bg) \
|
||||
ji_font_set_aa_mode(f, fill_bg || \
|
||||
bitmap_color_depth(ji_screen) == 8 ? bg: -1)
|
||||
bitmap_color_depth(ji_screen) == 8 ? to_system(bg): -1)
|
||||
|
||||
namespace ui {
|
||||
|
||||
void jrectedge(BITMAP *bmp, int x1, int y1, int x2, int y2,
|
||||
int c1, int c2)
|
||||
ui::Color c1, ui::Color c2)
|
||||
{
|
||||
hline(bmp, x1, y1, x2-1, c1);
|
||||
hline(bmp, x1+1, y2, x2, c2);
|
||||
vline(bmp, x1, y1+1, y2, c1);
|
||||
vline(bmp, x2, y1, y2-1, c2);
|
||||
hline(bmp, x1, y1, x2-1, to_system(c1));
|
||||
hline(bmp, x1+1, y2, x2, to_system(c2));
|
||||
vline(bmp, x1, y1+1, y2, to_system(c1));
|
||||
vline(bmp, x2, y1, y2-1, to_system(c2));
|
||||
}
|
||||
|
||||
void jrectexclude(BITMAP *bmp, int x1, int y1, int x2, int y2,
|
||||
int ex1, int ey1, int ex2, int ey2, int color)
|
||||
int ex1, int ey1, int ex2, int ey2, ui::Color color)
|
||||
{
|
||||
if ((ex1 > x2) || (ex2 < x1) ||
|
||||
(ey1 > y2) || (ey2 < y1))
|
||||
rectfill(bmp, x1, y1, x2, y2, color);
|
||||
rectfill(bmp, x1, y1, x2, y2, to_system(color));
|
||||
else {
|
||||
int my1, my2;
|
||||
|
||||
@ -50,88 +50,43 @@ void jrectexclude(BITMAP *bmp, int x1, int y1, int x2, int y2,
|
||||
|
||||
// top
|
||||
if (y1 < ey1)
|
||||
rectfill(bmp, x1, y1, x2, ey1-1, color);
|
||||
rectfill(bmp, x1, y1, x2, ey1-1, to_system(color));
|
||||
|
||||
// left
|
||||
if (x1 < ex1)
|
||||
rectfill(bmp, x1, my1, ex1-1, my2, color);
|
||||
rectfill(bmp, x1, my1, ex1-1, my2, to_system(color));
|
||||
|
||||
// right
|
||||
if (x2 > ex2)
|
||||
rectfill(bmp, ex2+1, my1, x2, my2, color);
|
||||
rectfill(bmp, ex2+1, my1, x2, my2, to_system(color));
|
||||
|
||||
// bottom
|
||||
if (y2 > ey2)
|
||||
rectfill(bmp, x1, ey2+1, x2, y2, color);
|
||||
rectfill(bmp, x1, ey2+1, x2, y2, to_system(color));
|
||||
}
|
||||
}
|
||||
|
||||
void jrectshade(BITMAP *bmp, int x1, int y1, int x2, int y2,
|
||||
int c1, int c2, int align)
|
||||
void jdraw_rect(const JRect r, ui::Color color)
|
||||
{
|
||||
register int c;
|
||||
int r[2], g[2], b[2];
|
||||
|
||||
r[0] = getr(c1);
|
||||
g[0] = getg(c1);
|
||||
b[0] = getb(c1);
|
||||
|
||||
r[1] = getr(c2);
|
||||
g[1] = getg(c2);
|
||||
b[1] = getb(c2);
|
||||
|
||||
if (align & JI_VERTICAL) {
|
||||
if (y1 == y2)
|
||||
hline(bmp, x1, y1, x2, c1);
|
||||
else
|
||||
for (c=y1; c<=y2; c++)
|
||||
hline(bmp,
|
||||
x1, c, x2,
|
||||
makecol((r[0] + (r[1] - r[0]) * (c - y1) / (y2 - y1)),
|
||||
(g[0] + (g[1] - g[0]) * (c - y1) / (y2 - y1)),
|
||||
(b[0] + (b[1] - b[0]) * (c - y1) / (y2 - y1))));
|
||||
}
|
||||
else if (align & JI_HORIZONTAL) {
|
||||
if (x1 == x2)
|
||||
vline(ji_screen, x1, y1, y2, c1);
|
||||
else
|
||||
for (c=x1; c<=x2; c++)
|
||||
vline(ji_screen,
|
||||
c, y1, y2,
|
||||
makecol((r[0] + (r[1] - r[0]) * (c - x1) / (x2 - x1)),
|
||||
(g[0] + (g[1] - g[0]) * (c - x1) / (x2 - x1)),
|
||||
(b[0] + (b[1] - b[0]) * (c - x1) / (x2 - x1))));
|
||||
}
|
||||
rect(ji_screen, r->x1, r->y1, r->x2-1, r->y2-1, to_system(color));
|
||||
}
|
||||
|
||||
void jdraw_rect(const JRect r, int color)
|
||||
void jdraw_rectfill(const JRect r, ui::Color color)
|
||||
{
|
||||
rect(ji_screen, r->x1, r->y1, r->x2-1, r->y2-1, color);
|
||||
rectfill(ji_screen, r->x1, r->y1, r->x2-1, r->y2-1, to_system(color));
|
||||
}
|
||||
|
||||
void jdraw_rectfill(const JRect r, int color)
|
||||
void jdraw_rectfill(const Rect& r, ui::Color color)
|
||||
{
|
||||
rectfill(ji_screen, r->x1, r->y1, r->x2-1, r->y2-1, color);
|
||||
rectfill(ji_screen, r.x, r.y, r.x+r.w-1, r.y+r.h-1, to_system(color));
|
||||
}
|
||||
|
||||
void jdraw_rectfill(const Rect& r, int color)
|
||||
{
|
||||
rectfill(ji_screen, r.x, r.y, r.x+r.w-1, r.y+r.h-1, color);
|
||||
}
|
||||
|
||||
void jdraw_rectedge(const JRect r, int c1, int c2)
|
||||
void jdraw_rectedge(const JRect r, ui::Color c1, ui::Color c2)
|
||||
{
|
||||
jrectedge(ji_screen, r->x1, r->y1, r->x2-1, r->y2-1, c1, c2);
|
||||
}
|
||||
|
||||
void jdraw_rectshade(const JRect rect, int c1, int c2, int align)
|
||||
{
|
||||
jrectshade(ji_screen,
|
||||
rect->x1, rect->y1,
|
||||
rect->x2-1, rect->y2-1, c1, c2, align);
|
||||
}
|
||||
|
||||
void jdraw_rectexclude(const JRect rc, const JRect exclude, int color)
|
||||
void jdraw_rectexclude(const JRect rc, const JRect exclude, ui::Color color)
|
||||
{
|
||||
jrectexclude(ji_screen,
|
||||
rc->x1, rc->y1,
|
||||
@ -140,15 +95,16 @@ void jdraw_rectexclude(const JRect rc, const JRect exclude, int color)
|
||||
exclude->x2-1, exclude->y2-1, color);
|
||||
}
|
||||
|
||||
void jdraw_char(FONT* f, int chr, int x, int y, int fg, int bg, bool fill_bg)
|
||||
void jdraw_char(FONT* f, int chr, int x, int y, ui::Color fg, ui::Color bg, bool fill_bg)
|
||||
{
|
||||
SETUP_ANTIALISING(f, bg, fill_bg);
|
||||
|
||||
f->vtable->render_char(f, chr, fg, fill_bg ? bg: -1, ji_screen, x, y);
|
||||
f->vtable->render_char(f, chr, to_system(fg),
|
||||
fill_bg ? to_system(bg): -1, ji_screen, x, y);
|
||||
}
|
||||
|
||||
void jdraw_text(BITMAP* bmp, FONT* font, const char *s, int x, int y,
|
||||
int fg_color, int bg_color, bool fill_bg, int underline_height)
|
||||
ui::Color fg_color, ui::Color bg_color, bool fill_bg, int underline_height)
|
||||
{
|
||||
// original code from allegro/src/guiproc.c
|
||||
char tmp[1024];
|
||||
@ -181,7 +137,7 @@ void jdraw_text(BITMAP* bmp, FONT* font, const char *s, int x, int y,
|
||||
|
||||
SETUP_ANTIALISING(font, bg_color, fill_bg);
|
||||
|
||||
textout_ex(bmp, font, tmp, x, y, fg_color, (fill_bg ? bg_color: -1));
|
||||
textout_ex(bmp, font, tmp, x, y, to_system(fg_color), (fill_bg ? to_system(bg_color): -1));
|
||||
|
||||
if (hline_pos >= 0) {
|
||||
c = ugetat(tmp, hline_pos);
|
||||
@ -194,7 +150,7 @@ void jdraw_text(BITMAP* bmp, FONT* font, const char *s, int x, int y,
|
||||
rectfill(bmp, x+hline_pos,
|
||||
y+text_height(font),
|
||||
x+hline_pos+c-1,
|
||||
y+text_height(font)+underline_height-1, fg_color);
|
||||
y+text_height(font)+underline_height-1, to_system(fg_color));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,38 +9,28 @@
|
||||
|
||||
#include "gfx/rect.h"
|
||||
#include "ui/base.h"
|
||||
|
||||
#define JI_COLOR_SHADE(color, r, g, b) \
|
||||
makecol(MID(0, getr(color)+(r), 255), \
|
||||
MID(0, getg(color)+(g), 255), \
|
||||
MID(0, getb(color)+(b), 255))
|
||||
|
||||
#define JI_COLOR_INTERP(c1, c2, step, max) \
|
||||
makecol(getr(c1)+(getr(c2)-getr(c1)) * step / max, \
|
||||
getg(c1)+(getg(c2)-getg(c1)) * step / max, \
|
||||
getb(c1)+(getb(c2)-getb(c1)) * step / max)
|
||||
#include "ui/color.h"
|
||||
|
||||
struct FONT;
|
||||
struct BITMAP;
|
||||
|
||||
// TODO all these functions are deprecated and must be replaced by Graphics methods.
|
||||
|
||||
namespace ui {
|
||||
|
||||
void jrectedge(struct BITMAP *bmp, int x1, int y1, int x2, int y2,
|
||||
int c1, int c2);
|
||||
ui::Color c1, ui::Color c2);
|
||||
void jrectexclude(struct BITMAP *bmp, int x1, int y1, int x2, int y2,
|
||||
int ex1, int ey1, int ex2, int ey2, int color);
|
||||
void jrectshade(struct BITMAP *bmp, int x1, int y1, int x2, int y2,
|
||||
int c1, int c2, int align);
|
||||
int ex1, int ey1, int ex2, int ey2, ui::Color color);
|
||||
|
||||
void jdraw_rect(const JRect rect, int color);
|
||||
void jdraw_rectfill(const JRect rect, int color);
|
||||
void jdraw_rectfill(const gfx::Rect& rect, int color);
|
||||
void jdraw_rectedge(const JRect rect, int c1, int c2);
|
||||
void jdraw_rectshade(const JRect rect, int c1, int c2, int align);
|
||||
void jdraw_rectexclude(const JRect rc, const JRect exclude, int color);
|
||||
void jdraw_rect(const JRect rect, ui::Color color);
|
||||
void jdraw_rectfill(const JRect rect, ui::Color color);
|
||||
void jdraw_rectfill(const gfx::Rect& rect, ui::Color color);
|
||||
void jdraw_rectedge(const JRect rect, ui::Color c1, ui::Color c2);
|
||||
void jdraw_rectexclude(const JRect rc, const JRect exclude, ui::Color color);
|
||||
|
||||
void jdraw_char(FONT* f, int chr, int x, int y, int fg, int bg, bool fill_bg);
|
||||
void jdraw_text(BITMAP* bmp, FONT* f, const char* text, int x, int y, int fg, int bg, bool fill_bg, int underline_height = 1);
|
||||
void jdraw_char(FONT* f, int chr, int x, int y, ui::Color fg, ui::Color bg, bool fill_bg);
|
||||
void jdraw_text(BITMAP* bmp, FONT* f, const char* text, int x, int y, ui::Color fg, ui::Color bg, bool fill_bg, int underline_height = 1);
|
||||
|
||||
void jdraw_inverted_sprite(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
|
||||
|
||||
|
@ -29,11 +29,6 @@ Graphics::~Graphics()
|
||||
{
|
||||
}
|
||||
|
||||
int Graphics::getBitsPerPixel() const
|
||||
{
|
||||
return bitmap_color_depth(m_bmp);
|
||||
}
|
||||
|
||||
gfx::Rect Graphics::getClipBounds() const
|
||||
{
|
||||
return gfx::Rect(m_bmp->cl-m_dx,
|
||||
@ -63,30 +58,38 @@ bool Graphics::intersectClipRect(const gfx::Rect& rc)
|
||||
m_bmp->ct < m_bmp->cb);
|
||||
}
|
||||
|
||||
void Graphics::drawVLine(int color, int x, int y, int h)
|
||||
void Graphics::drawHLine(ui::Color color, int x, int y, int w)
|
||||
{
|
||||
hline(m_bmp,
|
||||
m_dx+x,
|
||||
m_dy+y,
|
||||
m_dx+x+w-1, to_system(color));
|
||||
}
|
||||
|
||||
void Graphics::drawVLine(ui::Color color, int x, int y, int h)
|
||||
{
|
||||
vline(m_bmp,
|
||||
m_dx+x,
|
||||
m_dy+y,
|
||||
m_dy+y+h-1, color);
|
||||
m_dy+y+h-1, to_system(color));
|
||||
}
|
||||
|
||||
void Graphics::drawRect(int color, const gfx::Rect& rc)
|
||||
void Graphics::drawRect(ui::Color color, const gfx::Rect& rc)
|
||||
{
|
||||
rect(m_bmp,
|
||||
m_dx+rc.x,
|
||||
m_dy+rc.y,
|
||||
m_dx+rc.x+rc.w-1,
|
||||
m_dy+rc.y+rc.h-1, color);
|
||||
m_dy+rc.y+rc.h-1, to_system(color));
|
||||
}
|
||||
|
||||
void Graphics::fillRect(int color, const gfx::Rect& rc)
|
||||
void Graphics::fillRect(ui::Color color, const gfx::Rect& rc)
|
||||
{
|
||||
rectfill(m_bmp,
|
||||
m_dx+rc.x,
|
||||
m_dy+rc.y,
|
||||
m_dx+rc.x+rc.w-1,
|
||||
m_dy+rc.y+rc.h-1, color);
|
||||
m_dy+rc.y+rc.h-1, to_system(color));
|
||||
}
|
||||
|
||||
void Graphics::drawBitmap(BITMAP* sprite, int x, int y)
|
||||
@ -115,15 +118,15 @@ FONT* Graphics::getFont()
|
||||
return m_currentFont;
|
||||
}
|
||||
|
||||
void Graphics::drawString(const std::string& str, int fg_color, int bg_color, bool fill_bg, const gfx::Point& pt)
|
||||
void Graphics::drawString(const std::string& str, Color fg, Color bg, bool fillbg, const gfx::Point& pt)
|
||||
{
|
||||
jdraw_text(m_bmp, m_currentFont, str.c_str(), m_dx+pt.x, m_dy+pt.y,
|
||||
fg_color, bg_color, fill_bg, 1 * jguiscale());
|
||||
fg, bg, fillbg, 1 * jguiscale());
|
||||
}
|
||||
|
||||
void Graphics::drawString(const std::string& str, int fg_color, int bg_color, const gfx::Rect& rc, int align)
|
||||
void Graphics::drawString(const std::string& str, Color fg, Color bg, const gfx::Rect& rc, int align)
|
||||
{
|
||||
drawStringAlgorithm(str, fg_color, bg_color, rc, align, true);
|
||||
drawStringAlgorithm(str, fg, bg, rc, align, true);
|
||||
}
|
||||
|
||||
gfx::Size Graphics::measureString(const std::string& str)
|
||||
@ -134,10 +137,10 @@ gfx::Size Graphics::measureString(const std::string& str)
|
||||
|
||||
gfx::Size Graphics::fitString(const std::string& str, int maxWidth, int align)
|
||||
{
|
||||
return drawStringAlgorithm(str, 0, 0, gfx::Rect(0, 0, maxWidth, 0), align, false);
|
||||
return drawStringAlgorithm(str, ColorNone, ColorNone, gfx::Rect(0, 0, maxWidth, 0), align, false);
|
||||
}
|
||||
|
||||
gfx::Size Graphics::drawStringAlgorithm(const std::string& str, int fg_color, int bg_color, const gfx::Rect& rc, int align, bool draw)
|
||||
gfx::Size Graphics::drawStringAlgorithm(const std::string& str, Color fg, Color bg, const gfx::Rect& rc, int align, bool draw)
|
||||
{
|
||||
gfx::Size calculatedSize(0, 0);
|
||||
size_t beg, end, new_word_beg, old_end;
|
||||
@ -200,12 +203,12 @@ gfx::Size Graphics::drawStringAlgorithm(const std::string& str, int fg_color, in
|
||||
else
|
||||
xout = pt.x;
|
||||
|
||||
ji_font_set_aa_mode(m_currentFont, bg_color);
|
||||
textout_ex(m_bmp, m_currentFont, line.c_str(), m_dx+xout, m_dy+pt.y, fg_color, bg_color);
|
||||
ji_font_set_aa_mode(m_currentFont, to_system(bg));
|
||||
textout_ex(m_bmp, m_currentFont, line.c_str(), m_dx+xout, m_dy+pt.y, to_system(fg), to_system(bg));
|
||||
|
||||
jrectexclude(m_bmp,
|
||||
m_dx+rc.x, m_dy+pt.y, m_dx+rc.x+rc.w-1, m_dy+pt.y+lineSize.h-1,
|
||||
m_dx+xout, m_dy+pt.y, m_dx+xout+lineSize.w-1, m_dy+pt.y+lineSize.h-1, bg_color);
|
||||
m_dx+xout, m_dy+pt.y, m_dx+xout+lineSize.w-1, m_dy+pt.y+lineSize.h-1, bg);
|
||||
}
|
||||
|
||||
pt.y += lineSize.h;
|
||||
@ -217,7 +220,7 @@ gfx::Size Graphics::drawStringAlgorithm(const std::string& str, int fg_color, in
|
||||
// Fill bottom area
|
||||
if (draw) {
|
||||
if (pt.y < rc.y+rc.h)
|
||||
fillRect(bg_color, 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));
|
||||
}
|
||||
|
||||
return calculatedSize;
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "gfx/point.h"
|
||||
#include "gfx/rect.h"
|
||||
#include "gfx/size.h"
|
||||
#include "ui/color.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
@ -25,16 +26,15 @@ namespace ui {
|
||||
Graphics(BITMAP* bmp, int dx, int dy);
|
||||
~Graphics();
|
||||
|
||||
int getBitsPerPixel() const;
|
||||
|
||||
gfx::Rect getClipBounds() const;
|
||||
void setClipBounds(const gfx::Rect& rc);
|
||||
bool intersectClipRect(const gfx::Rect& rc);
|
||||
|
||||
void drawVLine(int color, int x, int y, int h);
|
||||
void drawHLine(ui::Color color, int x, int y, int w);
|
||||
void drawVLine(ui::Color color, int x, int y, int h);
|
||||
|
||||
void drawRect(int color, const gfx::Rect& rc);
|
||||
void fillRect(int color, const gfx::Rect& rc);
|
||||
void drawRect(ui::Color color, const gfx::Rect& rc);
|
||||
void fillRect(ui::Color color, const gfx::Rect& rc);
|
||||
|
||||
void drawBitmap(BITMAP* sprite, int x, int y);
|
||||
void drawAlphaBitmap(BITMAP* sprite, int x, int y);
|
||||
@ -48,14 +48,14 @@ namespace ui {
|
||||
void setFont(FONT* font);
|
||||
FONT* getFont();
|
||||
|
||||
void drawString(const std::string& str, int fg_color, int bg_color, bool fillbg, const gfx::Point& pt);
|
||||
void drawString(const std::string& str, int fg_color, int bg_color, const gfx::Rect& rc, int align);
|
||||
void drawString(const std::string& str, Color fg, Color bg, bool fillbg, const gfx::Point& pt);
|
||||
void drawString(const std::string& str, Color fg, Color bg, const gfx::Rect& rc, int align);
|
||||
|
||||
gfx::Size measureString(const std::string& str);
|
||||
gfx::Size fitString(const std::string& str, int maxWidth, int align);
|
||||
|
||||
private:
|
||||
gfx::Size drawStringAlgorithm(const std::string& str, int fg_color, int bg_color, const gfx::Rect& rc, int align, bool draw);
|
||||
gfx::Size drawStringAlgorithm(const std::string& str, Color fg, Color bg, const gfx::Rect& rc, int align, bool draw);
|
||||
|
||||
BITMAP* m_bmp;
|
||||
int m_dx;
|
||||
|
@ -13,6 +13,7 @@
|
||||
#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"
|
||||
|
@ -42,8 +42,7 @@ void ImageView::onPaint(PaintEvent& ev)
|
||||
jwidget_get_texticon_info(this, &box, &text, &icon,
|
||||
getAlign(), m_bmp->w, m_bmp->h);
|
||||
|
||||
jdraw_rectexclude(rc, &icon,
|
||||
jwidget_get_bg_color(this));
|
||||
jdraw_rectexclude(rc, &icon, getBgColor());
|
||||
|
||||
blit(m_bmp, ji_screen, 0, 0,
|
||||
icon.x1, icon.y1, jrect_w(&icon), jrect_h(&icon));
|
||||
|
@ -8,6 +8,7 @@
|
||||
#define UI_INTERN_H_INCLUDED
|
||||
|
||||
#include "ui/base.h"
|
||||
#include "ui/color.h"
|
||||
|
||||
struct FONT;
|
||||
struct BITMAP;
|
||||
@ -35,10 +36,10 @@ namespace ui {
|
||||
// theme.cpp
|
||||
|
||||
void _ji_theme_draw_sprite_color(BITMAP *bmp, BITMAP *sprite,
|
||||
int x, int y, int color);
|
||||
int x, int y, ui::Color color);
|
||||
|
||||
void _ji_theme_textbox_draw(BITMAP *bmp, Widget* textbox,
|
||||
int *w, int *h, int bg, int fg);
|
||||
int *w, int *h, ui::Color bg, ui::Color fg);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// jfontbmp.c
|
||||
|
@ -19,16 +19,14 @@ Label::Label(const char *text)
|
||||
setAlign(JI_LEFT | JI_MIDDLE);
|
||||
setText(text);
|
||||
initTheme();
|
||||
|
||||
m_textColor = ji_color_foreground();
|
||||
}
|
||||
|
||||
int Label::getTextColor() const
|
||||
Color Label::getTextColor() const
|
||||
{
|
||||
return m_textColor;
|
||||
}
|
||||
|
||||
void Label::setTextColor(int color)
|
||||
void Label::setTextColor(Color color)
|
||||
{
|
||||
m_textColor = color;
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
#define UI_LABEL_H_INCLUDED
|
||||
|
||||
#include "base/compiler_specific.h"
|
||||
#include "ui/color.h"
|
||||
#include "ui/widget.h"
|
||||
|
||||
namespace ui {
|
||||
@ -17,15 +18,15 @@ namespace ui {
|
||||
public:
|
||||
Label(const char *text);
|
||||
|
||||
int getTextColor() const;
|
||||
void setTextColor(int color);
|
||||
Color getTextColor() const;
|
||||
void setTextColor(Color color);
|
||||
|
||||
protected:
|
||||
void onPreferredSize(PreferredSizeEvent& ev) OVERRIDE;
|
||||
void onPaint(PaintEvent& ev) OVERRIDE;
|
||||
|
||||
private:
|
||||
int m_textColor;
|
||||
Color m_textColor;
|
||||
};
|
||||
|
||||
} // namespace ui
|
||||
|
@ -892,10 +892,6 @@ bool Manager::onProcessMessage(Message* msg)
|
||||
layoutManager(&msg->setpos.rect);
|
||||
return true;
|
||||
|
||||
case JM_DRAW:
|
||||
jdraw_rectfill(&msg->draw.rect, getTheme()->desktop_color);
|
||||
return true;
|
||||
|
||||
case JM_KEYPRESSED:
|
||||
case JM_KEYRELEASED: {
|
||||
msg->key.propagate_to_children = true;
|
||||
@ -928,6 +924,11 @@ bool Manager::onProcessMessage(Message* msg)
|
||||
return Widget::onProcessMessage(msg);
|
||||
}
|
||||
|
||||
void Manager::onPaint(PaintEvent& ev)
|
||||
{
|
||||
getTheme()->paintDesktop(ev);
|
||||
}
|
||||
|
||||
void Manager::onBroadcastMouseMessage(WidgetsList& targets)
|
||||
{
|
||||
// Ask to the first window in the "children" list to know how to
|
||||
@ -1087,8 +1088,6 @@ void Manager::pumpQueue()
|
||||
msg->draw.rect.x2-1, msg->draw.rect.y2-1);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
/* rectfill(ji_screen, 0, 0, JI_SCREEN_W-1, JI_SCREEN_H-1, makecol(255, 0, 0)); */
|
||||
/* vsync(); vsync(); vsync(); vsync(); */
|
||||
|
||||
dirty_display_flag = true;
|
||||
}
|
||||
|
@ -73,6 +73,7 @@ namespace ui {
|
||||
|
||||
protected:
|
||||
bool onProcessMessage(Message* msg) OVERRIDE;
|
||||
void onPaint(PaintEvent& ev) OVERRIDE;
|
||||
void onPreferredSize(PreferredSizeEvent& ev) OVERRIDE;
|
||||
void onBroadcastMouseMessage(WidgetsList& targets) OVERRIDE;
|
||||
virtual LayoutIO* onGetLayoutIO();
|
||||
|
@ -12,8 +12,8 @@
|
||||
#include "ui/graphics.h"
|
||||
#include "ui/gui.h"
|
||||
#include "ui/intern.h"
|
||||
#include "ui/paint_event.h"
|
||||
#include "ui/preferred_size_event.h"
|
||||
#include "ui/theme.h"
|
||||
|
||||
using namespace gfx;
|
||||
|
||||
@ -171,16 +171,7 @@ void PopupWindow::onPreferredSize(PreferredSizeEvent& ev)
|
||||
|
||||
void PopupWindow::onPaint(PaintEvent& ev)
|
||||
{
|
||||
Graphics* g = ev.getGraphics();
|
||||
gfx::Rect pos = getClientBounds();
|
||||
|
||||
g->drawRect(makecol(0, 0, 0), pos);
|
||||
pos.shrink(1);
|
||||
|
||||
g->fillRect(this->getBgColor(), pos);
|
||||
pos.shrink(getBorder());
|
||||
|
||||
g->drawString(getText(), ji_color_foreground(), this->getBgColor(), pos, getAlign());
|
||||
getTheme()->paintPopupWindow(ev);
|
||||
}
|
||||
|
||||
void PopupWindow::onInitTheme(InitThemeEvent& ev)
|
||||
|
@ -4,6 +4,8 @@
|
||||
// This source file is distributed under a BSD-like license, please
|
||||
// read LICENSE.txt for more information.
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "ui/preferred_size_event.h"
|
||||
#include "ui/widget.h"
|
||||
|
||||
|
@ -163,15 +163,16 @@ bool ScrollBar::onProcessMessage(Message* msg)
|
||||
// TODO add something to avoid this (theme specific stuff)
|
||||
invalidate();
|
||||
break;
|
||||
|
||||
case JM_DRAW:
|
||||
getTheme()->draw_view_scrollbar(this, &msg->draw.rect);
|
||||
return true;
|
||||
}
|
||||
|
||||
return Widget::onProcessMessage(msg);
|
||||
}
|
||||
|
||||
void ScrollBar::onPaint(PaintEvent& ev)
|
||||
{
|
||||
getTheme()->paintViewScrollbar(ev);
|
||||
}
|
||||
|
||||
void ScrollBar::getScrollBarInfo(int *_pos, int *_len, int *_bar_size, int *_viewport_size)
|
||||
{
|
||||
View* view = static_cast<View*>(getParent());
|
||||
|
@ -29,6 +29,7 @@ namespace ui {
|
||||
protected:
|
||||
// Events
|
||||
bool onProcessMessage(Message* msg) OVERRIDE;
|
||||
void onPaint(PaintEvent& ev) OVERRIDE;
|
||||
|
||||
private:
|
||||
void getScrollBarInfo(int* _pos, int* _len, int* _bar_size, int* _viewport_size);
|
||||
|
@ -156,7 +156,7 @@ void TextBox::onPreferredSize(PreferredSizeEvent& ev)
|
||||
//w = widget->border_width.l + widget->border_width.r;
|
||||
//h = widget->border_width.t + widget->border_width.b;
|
||||
|
||||
_ji_theme_textbox_draw(NULL, this, &w, &h, 0, 0);
|
||||
_ji_theme_textbox_draw(NULL, this, &w, &h, ColorNone, ColorNone);
|
||||
|
||||
if (this->getAlign() & JI_WORDWRAP) {
|
||||
View* view = View::getView(this);
|
||||
@ -170,7 +170,7 @@ void TextBox::onPreferredSize(PreferredSizeEvent& ev)
|
||||
}
|
||||
|
||||
w = MAX(min, width);
|
||||
_ji_theme_textbox_draw(NULL, this, &w, &h, 0, 0);
|
||||
_ji_theme_textbox_draw(NULL, this, &w, &h, ColorNone, ColorNone);
|
||||
|
||||
w = min;
|
||||
}
|
||||
|
@ -25,16 +25,13 @@ namespace ui {
|
||||
|
||||
static Theme* current_theme = NULL;
|
||||
|
||||
static void draw_text(BITMAP *bmp, FONT *f, const char *text, int x, int y,
|
||||
int fg_color, int bg_color, bool fill_bg);
|
||||
static void draw_text(BITMAP *bmp, FONT *f, const char* text, int x, int y,
|
||||
ui::Color fg_color, ui::Color bg_color, bool fill_bg);
|
||||
|
||||
Theme::Theme()
|
||||
{
|
||||
this->name = "Theme";
|
||||
this->default_font = font; // Default Allegro font
|
||||
this->desktop_color = 0;
|
||||
this->textbox_fg_color = 0;
|
||||
this->textbox_bg_color = 0;
|
||||
this->scrollbar_size = 0;
|
||||
this->guiscale = 1;
|
||||
}
|
||||
@ -78,52 +75,6 @@ Theme* CurrentTheme::get()
|
||||
return current_theme;
|
||||
}
|
||||
|
||||
int ji_color_foreground()
|
||||
{
|
||||
return current_theme->color_foreground();
|
||||
}
|
||||
|
||||
int ji_color_disabled()
|
||||
{
|
||||
return current_theme->color_disabled();
|
||||
}
|
||||
|
||||
int ji_color_face()
|
||||
{
|
||||
return current_theme->color_face();
|
||||
}
|
||||
|
||||
int ji_color_facelight()
|
||||
{
|
||||
register int c = ji_color_face();
|
||||
return makecol(MIN(getr(c)+64, 255),
|
||||
MIN(getg(c)+64, 255),
|
||||
MIN(getb(c)+64, 255));
|
||||
}
|
||||
|
||||
int ji_color_faceshadow()
|
||||
{
|
||||
register int c = ji_color_face();
|
||||
return makecol(MAX(getr(c)-64, 0),
|
||||
MAX(getg(c)-64, 0),
|
||||
MAX(getb(c)-64, 0));
|
||||
}
|
||||
|
||||
int ji_color_hotface()
|
||||
{
|
||||
return current_theme->color_hotface();
|
||||
}
|
||||
|
||||
int ji_color_selected()
|
||||
{
|
||||
return current_theme->color_selected();
|
||||
}
|
||||
|
||||
int ji_color_background()
|
||||
{
|
||||
return current_theme->color_background();
|
||||
}
|
||||
|
||||
BITMAP* ji_apply_guiscale(BITMAP* original)
|
||||
{
|
||||
int scale = jguiscale();
|
||||
@ -155,7 +106,7 @@ void _ji_theme_draw_sprite_color(BITMAP *bmp, BITMAP *sprite,
|
||||
}
|
||||
|
||||
void _ji_theme_textbox_draw(BITMAP *bmp, Widget* widget,
|
||||
int *w, int *h, int bg, int fg)
|
||||
int *w, int *h, ui::Color bg, ui::Color fg)
|
||||
{
|
||||
View* view = View::getView(widget);
|
||||
char *text = (char*)widget->getText(); // TODO warning: removing const modifier
|
||||
@ -306,20 +257,19 @@ void _ji_theme_textbox_draw(BITMAP *bmp, Widget* widget,
|
||||
if (w) *w += widget->border_width.l + widget->border_width.r;
|
||||
if (h) *h += widget->border_width.t + widget->border_width.b;
|
||||
|
||||
/* fill bottom area */
|
||||
// Fill bottom area
|
||||
if (bmp) {
|
||||
if (y <= y2)
|
||||
rectfill(bmp, x1, y, x2, y2, bg);
|
||||
rectfill(bmp, x1, y, x2, y2, to_system(bg));
|
||||
}
|
||||
}
|
||||
|
||||
static void draw_text(BITMAP *bmp, FONT *f, const char *text, int x, int y,
|
||||
int fg_color, int bg_color, bool fill_bg)
|
||||
ui::Color fg_color, ui::Color bg_color, bool fill_bg)
|
||||
{
|
||||
/* TODO optional anti-aliased textout */
|
||||
ji_font_set_aa_mode(f, bg_color);
|
||||
textout_ex(bmp, f, text, x, y, fg_color, (fill_bg ? bg_color: -1));
|
||||
/* TODO */
|
||||
// TODO Optional anti-aliased textout
|
||||
ji_font_set_aa_mode(f, to_system(bg_color));
|
||||
textout_ex(bmp, f, text, x, y, to_system(fg_color), (fill_bg ? to_system(bg_color): -1));
|
||||
}
|
||||
|
||||
} // namespace ui
|
||||
|
@ -28,9 +28,6 @@ namespace ui {
|
||||
public:
|
||||
const char* name;
|
||||
struct FONT* default_font;
|
||||
int desktop_color;
|
||||
int textbox_fg_color;
|
||||
int textbox_bg_color;
|
||||
int scrollbar_size;
|
||||
int guiscale;
|
||||
|
||||
@ -44,13 +41,7 @@ namespace ui {
|
||||
virtual ui::JRegion get_window_mask(ui::Widget* widget) = 0;
|
||||
virtual void map_decorative_widget(ui::Widget* widget) = 0;
|
||||
|
||||
virtual int color_foreground() = 0;
|
||||
virtual int color_disabled() = 0;
|
||||
virtual int color_face() = 0;
|
||||
virtual int color_hotface() = 0;
|
||||
virtual int color_selected() = 0;
|
||||
virtual int color_background() = 0;
|
||||
|
||||
virtual void paintDesktop(PaintEvent& ev) = 0;
|
||||
virtual void paintBox(PaintEvent& ev) = 0;
|
||||
virtual void paintButton(PaintEvent& ev) = 0;
|
||||
virtual void paintCheckBox(PaintEvent& ev) = 0;
|
||||
@ -69,15 +60,15 @@ namespace ui {
|
||||
virtual void draw_combobox_entry(Entry* widget, JRect clip) = 0;
|
||||
virtual void paintComboBoxButton(PaintEvent& ev) = 0;
|
||||
virtual void draw_textbox(Widget* widget, JRect clip) = 0;
|
||||
virtual void draw_view(Widget* widget, JRect clip) = 0;
|
||||
virtual void draw_view_scrollbar(Widget* widget, JRect clip) = 0;
|
||||
virtual void draw_view_viewport(Widget* widget, JRect clip) = 0;
|
||||
virtual void paintView(PaintEvent& ev) = 0;
|
||||
virtual void paintViewScrollbar(PaintEvent& ev) = 0;
|
||||
virtual void paintViewViewport(PaintEvent& ev) = 0;
|
||||
virtual void paintWindow(PaintEvent& ev) = 0;
|
||||
virtual void paintPopupWindow(PaintEvent& ev) = 0;
|
||||
virtual void paintTooltip(PaintEvent& ev) = 0;
|
||||
|
||||
protected:
|
||||
virtual void onRegenerate() = 0;
|
||||
|
||||
};
|
||||
|
||||
namespace CurrentTheme
|
||||
@ -86,15 +77,6 @@ namespace ui {
|
||||
Theme* get();
|
||||
}
|
||||
|
||||
int ji_color_foreground();
|
||||
int ji_color_disabled();
|
||||
int ji_color_face();
|
||||
int ji_color_facelight();
|
||||
int ji_color_faceshadow();
|
||||
int ji_color_hotface();
|
||||
int ji_color_selected();
|
||||
int ji_color_background();
|
||||
|
||||
BITMAP* ji_apply_guiscale(BITMAP* original);
|
||||
|
||||
// This value is a factor to multiply every screen size/coordinate.
|
||||
|
@ -308,7 +308,7 @@ void TipWindow::onInitTheme(InitThemeEvent& ev)
|
||||
this->border_width.b = 7 * jguiscale();
|
||||
|
||||
// Setup the background color.
|
||||
setBgColor(makecol(255, 255, 200));
|
||||
setBgColor(ui::rgba(255, 255, 200));
|
||||
}
|
||||
|
||||
void TipWindow::onPaint(PaintEvent& ev)
|
||||
|
@ -245,10 +245,6 @@ bool View::onProcessMessage(Message* msg)
|
||||
updateView();
|
||||
return true;
|
||||
|
||||
case JM_DRAW:
|
||||
getTheme()->draw_view(this, &msg->draw.rect);
|
||||
return true;
|
||||
|
||||
case JM_FOCUSENTER:
|
||||
case JM_FOCUSLEAVE:
|
||||
// TODO This is theme specific stuff
|
||||
@ -272,6 +268,11 @@ void View::onPreferredSize(PreferredSizeEvent& ev)
|
||||
ev.setPreferredSize(viewSize);
|
||||
}
|
||||
|
||||
void View::onPaint(PaintEvent& ev)
|
||||
{
|
||||
getTheme()->paintView(ev);
|
||||
}
|
||||
|
||||
// static
|
||||
void View::displaceWidgets(Widget* widget, int x, int y)
|
||||
{
|
||||
|
@ -50,6 +50,7 @@ protected:
|
||||
// Events
|
||||
bool onProcessMessage(Message* msg) OVERRIDE;
|
||||
void onPreferredSize(PreferredSizeEvent& ev) OVERRIDE;
|
||||
void onPaint(PaintEvent& ev) OVERRIDE;
|
||||
|
||||
private:
|
||||
static void displaceWidgets(Widget* widget, int x, int y);
|
||||
|
@ -31,10 +31,6 @@ bool Viewport::onProcessMessage(Message* msg)
|
||||
case JM_SETPOS:
|
||||
set_position(&msg->setpos.rect);
|
||||
return true;
|
||||
|
||||
case JM_DRAW:
|
||||
getTheme()->draw_view_viewport(this, &msg->draw.rect);
|
||||
return true;
|
||||
}
|
||||
|
||||
return Widget::onProcessMessage(msg);
|
||||
@ -46,6 +42,11 @@ void Viewport::onPreferredSize(PreferredSizeEvent& ev)
|
||||
this->border_width.t + 1 + this->border_width.b));
|
||||
}
|
||||
|
||||
void Viewport::onPaint(PaintEvent& ev)
|
||||
{
|
||||
getTheme()->paintViewViewport(ev);
|
||||
}
|
||||
|
||||
Size Viewport::calculateNeededSize()
|
||||
{
|
||||
Size maxSize(0, 0);
|
||||
|
@ -23,6 +23,7 @@ namespace ui {
|
||||
// Events
|
||||
bool onProcessMessage(Message* msg) OVERRIDE;
|
||||
void onPreferredSize(PreferredSizeEvent& ev) OVERRIDE;
|
||||
void onPaint(PaintEvent& ev) OVERRIDE;
|
||||
|
||||
private:
|
||||
void set_position(JRect rect);
|
||||
|
@ -61,7 +61,7 @@ Widget::Widget(int type)
|
||||
this->m_align = 0;
|
||||
this->m_text = "";
|
||||
this->m_font = this->m_theme ? this->m_theme->default_font: NULL;
|
||||
this->m_bg_color = -1;
|
||||
this->m_bgColor = ui::ColorNone;
|
||||
|
||||
this->m_update_region = jregion_new(NULL, 0);
|
||||
|
||||
@ -749,13 +749,6 @@ JRegion jwidget_get_drawable_region(Widget* widget, int flags)
|
||||
return region;
|
||||
}
|
||||
|
||||
int jwidget_get_bg_color(Widget* widget)
|
||||
{
|
||||
ASSERT_VALID_WIDGET(widget);
|
||||
|
||||
return widget->getBgColor();
|
||||
}
|
||||
|
||||
int jwidget_get_text_length(const Widget* widget)
|
||||
{
|
||||
#if 1
|
||||
@ -938,13 +931,6 @@ void jwidget_set_max_size(Widget* widget, int w, int h)
|
||||
widget->max_h = h;
|
||||
}
|
||||
|
||||
void jwidget_set_bg_color(Widget* widget, int color)
|
||||
{
|
||||
ASSERT_VALID_WIDGET(widget);
|
||||
|
||||
widget->setBgColor(color);
|
||||
}
|
||||
|
||||
void Widget::flushRedraw()
|
||||
{
|
||||
std::queue<Widget*> processing;
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "gfx/rect.h"
|
||||
#include "gfx/size.h"
|
||||
#include "ui/base.h"
|
||||
#include "ui/color.h"
|
||||
#include "ui/component.h"
|
||||
#include "ui/rect.h"
|
||||
#include "ui/widgets_list.h"
|
||||
@ -43,7 +44,6 @@ namespace ui {
|
||||
JRect jwidget_get_child_rect(Widget* widget);
|
||||
JRegion jwidget_get_region(Widget* widget);
|
||||
JRegion jwidget_get_drawable_region(Widget* widget, int flags);
|
||||
int jwidget_get_bg_color(Widget* widget);
|
||||
int jwidget_get_text_length(const Widget* widget);
|
||||
int jwidget_get_text_height(const Widget* widget);
|
||||
void jwidget_get_texticon_info(Widget* widget,
|
||||
@ -56,7 +56,6 @@ namespace ui {
|
||||
void jwidget_set_rect(Widget* widget, JRect rect);
|
||||
void jwidget_set_min_size(Widget* widget, int w, int h);
|
||||
void jwidget_set_max_size(Widget* widget, int w, int h);
|
||||
void jwidget_set_bg_color(Widget* widget, int color);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -78,17 +77,6 @@ namespace ui {
|
||||
int min_w, min_h;
|
||||
int max_w, max_h;
|
||||
|
||||
private:
|
||||
std::string m_id; // Widget's id
|
||||
Theme* m_theme; // Widget's theme
|
||||
int m_align; // Widget alignment
|
||||
std::string m_text; // Widget text
|
||||
struct FONT *m_font; // Text font type
|
||||
int m_bg_color; // Background color
|
||||
JRegion m_update_region; // Region to be redrawed.
|
||||
WidgetsList m_children; // Sub-widgets
|
||||
Widget* m_parent; // Who is the parent?
|
||||
|
||||
public:
|
||||
// Extra data for the theme
|
||||
void *theme_data[4];
|
||||
@ -174,16 +162,16 @@ namespace ui {
|
||||
void setFont(FONT* font);
|
||||
|
||||
// Gets the background color of the widget.
|
||||
int getBgColor() const {
|
||||
if (m_bg_color < 0 && m_parent)
|
||||
ui::Color getBgColor() const {
|
||||
if (ui::geta(m_bgColor) == 0 && m_parent)
|
||||
return m_parent->getBgColor();
|
||||
else
|
||||
return m_bg_color;
|
||||
return m_bgColor;
|
||||
}
|
||||
|
||||
// Sets the background color of the widget
|
||||
void setBgColor(int bg_color) {
|
||||
m_bg_color = bg_color;
|
||||
void setBgColor(ui::Color bg_color) {
|
||||
m_bgColor = bg_color;
|
||||
}
|
||||
|
||||
Theme* getTheme() const { return m_theme; }
|
||||
@ -338,6 +326,15 @@ namespace ui {
|
||||
virtual void onSetText();
|
||||
|
||||
private:
|
||||
std::string m_id; // Widget's id
|
||||
Theme* m_theme; // Widget's theme
|
||||
int m_align; // Widget alignment
|
||||
std::string m_text; // Widget text
|
||||
struct FONT *m_font; // Text font type
|
||||
ui::Color m_bgColor; // Background color
|
||||
JRegion m_update_region; // Region to be redrawed.
|
||||
WidgetsList m_children; // Sub-widgets
|
||||
Widget* m_parent; // Who is the parent?
|
||||
gfx::Size* m_preferredSize;
|
||||
bool m_doubleBuffered : 1;
|
||||
};
|
||||
|
@ -280,8 +280,8 @@ done_with_blit:;
|
||||
|
||||
static RenderEngine::CheckedBgType checked_bg_type;
|
||||
static bool checked_bg_zoom;
|
||||
static Color checked_bg_color1;
|
||||
static Color checked_bg_color2;
|
||||
static app::Color checked_bg_color1;
|
||||
static app::Color checked_bg_color2;
|
||||
|
||||
static int global_opacity = 255;
|
||||
static Layer *selected_layer = NULL;
|
||||
@ -293,8 +293,8 @@ void RenderEngine::loadConfig()
|
||||
checked_bg_type = (CheckedBgType)get_config_int("Options", "CheckedBgType",
|
||||
(int)RenderEngine::CHECKED_BG_16X16);
|
||||
checked_bg_zoom = get_config_bool("Options", "CheckedBgZoom", true);
|
||||
checked_bg_color1 = get_config_color("Options", "CheckedBgColor1", Color::fromRgb(128, 128, 128));
|
||||
checked_bg_color2 = get_config_color("Options", "CheckedBgColor2", Color::fromRgb(192, 192, 192));
|
||||
checked_bg_color1 = get_config_color("Options", "CheckedBgColor1", app::Color::fromRgb(128, 128, 128));
|
||||
checked_bg_color2 = get_config_color("Options", "CheckedBgColor2", app::Color::fromRgb(192, 192, 192));
|
||||
}
|
||||
|
||||
// static
|
||||
@ -324,26 +324,26 @@ void RenderEngine::setCheckedBgZoom(bool state)
|
||||
}
|
||||
|
||||
// static
|
||||
Color RenderEngine::getCheckedBgColor1()
|
||||
app::Color RenderEngine::getCheckedBgColor1()
|
||||
{
|
||||
return checked_bg_color1;
|
||||
}
|
||||
|
||||
// static
|
||||
void RenderEngine::setCheckedBgColor1(const Color& color)
|
||||
void RenderEngine::setCheckedBgColor1(const app::Color& color)
|
||||
{
|
||||
checked_bg_color1 = color;
|
||||
set_config_color("Options", "CheckedBgColor1", color);
|
||||
}
|
||||
|
||||
// static
|
||||
Color RenderEngine::getCheckedBgColor2()
|
||||
app::Color RenderEngine::getCheckedBgColor2()
|
||||
{
|
||||
return checked_bg_color2;
|
||||
}
|
||||
|
||||
// static
|
||||
void RenderEngine::setCheckedBgColor2(const Color& color)
|
||||
void RenderEngine::setCheckedBgColor2(const app::Color& color)
|
||||
{
|
||||
checked_bg_color2 = color;
|
||||
set_config_color("Options", "CheckedBgColor2", color);
|
||||
|
@ -45,10 +45,10 @@ public:
|
||||
static void setCheckedBgType(CheckedBgType type);
|
||||
static bool getCheckedBgZoom();
|
||||
static void setCheckedBgZoom(bool state);
|
||||
static Color getCheckedBgColor1();
|
||||
static void setCheckedBgColor1(const Color& color);
|
||||
static Color getCheckedBgColor2();
|
||||
static void setCheckedBgColor2(const Color& color);
|
||||
static app::Color getCheckedBgColor1();
|
||||
static void setCheckedBgColor1(const app::Color& color);
|
||||
static app::Color getCheckedBgColor2();
|
||||
static void setCheckedBgColor2(const app::Color& color);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Preview image
|
||||
|
@ -61,7 +61,8 @@ bool ColorBar::ScrollableView::onProcessMessage(Message* msg)
|
||||
rc->x1, rc->y1,
|
||||
rc->x2-1, rc->y2-1,
|
||||
hasFocus() ? PART_EDITOR_SELECTED_NW:
|
||||
PART_EDITOR_NORMAL_NW, false);
|
||||
PART_EDITOR_NORMAL_NW,
|
||||
ColorNone);
|
||||
}
|
||||
return true;
|
||||
|
||||
@ -78,8 +79,8 @@ ColorBar::ColorBar(int align)
|
||||
: Box(align)
|
||||
, m_paletteButton("Edit Palette", JI_BUTTON)
|
||||
, m_paletteView(false)
|
||||
, m_fgColor(Color::fromIndex(15), IMAGE_INDEXED)
|
||||
, m_bgColor(Color::fromIndex(0), IMAGE_INDEXED)
|
||||
, m_fgColor(app::Color::fromIndex(15), IMAGE_INDEXED)
|
||||
, m_bgColor(app::Color::fromIndex(0), IMAGE_INDEXED)
|
||||
, m_lock(false)
|
||||
{
|
||||
m_instance = this;
|
||||
@ -127,8 +128,8 @@ ColorBar::ColorBar(int align)
|
||||
setFgColor(get_config_color("ColorBar", "FG", getFgColor()));
|
||||
|
||||
// Change color-bar background color (not ColorBar::setBgColor)
|
||||
Widget::setBgColor(((SkinTheme*)getTheme())->get_tab_selected_face_color());
|
||||
m_paletteView.setBgColor(((SkinTheme*)getTheme())->get_tab_selected_face_color());
|
||||
Widget::setBgColor(((SkinTheme*)getTheme())->getColor(ThemeColor::TabSelectedFace));
|
||||
m_paletteView.setBgColor(((SkinTheme*)getTheme())->getColor(ThemeColor::TabSelectedFace));
|
||||
|
||||
// Change labels foreground color
|
||||
setup_mini_look(&m_paletteButton);
|
||||
@ -152,23 +153,23 @@ void ColorBar::setPixelFormat(PixelFormat pixelFormat)
|
||||
m_bgColor.setPixelFormat(pixelFormat);
|
||||
}
|
||||
|
||||
Color ColorBar::getFgColor()
|
||||
app::Color ColorBar::getFgColor()
|
||||
{
|
||||
return m_fgColor.getColor();
|
||||
}
|
||||
|
||||
Color ColorBar::getBgColor()
|
||||
app::Color ColorBar::getBgColor()
|
||||
{
|
||||
return m_bgColor.getColor();
|
||||
}
|
||||
|
||||
void ColorBar::setFgColor(const Color& color)
|
||||
void ColorBar::setFgColor(const app::Color& color)
|
||||
{
|
||||
m_fgColor.setColor(color);
|
||||
FgColorChange(color);
|
||||
}
|
||||
|
||||
void ColorBar::setBgColor(const Color& color)
|
||||
void ColorBar::setBgColor(const app::Color& color)
|
||||
{
|
||||
m_bgColor.setColor(color);
|
||||
BgColorChange(color);
|
||||
@ -198,7 +199,7 @@ void ColorBar::onPaletteIndexChange(int index)
|
||||
{
|
||||
m_lock = true;
|
||||
|
||||
Color color = Color::fromIndex(index);
|
||||
app::Color color = app::Color::fromIndex(index);
|
||||
|
||||
if (jmouse_b(0) & 2) // TODO create a PaletteChangeEvent and take left/right mouse button from there
|
||||
setBgColor(color);
|
||||
@ -208,7 +209,7 @@ void ColorBar::onPaletteIndexChange(int index)
|
||||
m_lock = false;
|
||||
}
|
||||
|
||||
void ColorBar::onFgColorButtonChange(const Color& color)
|
||||
void ColorBar::onFgColorButtonChange(const app::Color& color)
|
||||
{
|
||||
if (!m_lock)
|
||||
m_paletteView.clearSelection();
|
||||
@ -217,7 +218,7 @@ void ColorBar::onFgColorButtonChange(const Color& color)
|
||||
onColorButtonChange(color);
|
||||
}
|
||||
|
||||
void ColorBar::onBgColorButtonChange(const Color& color)
|
||||
void ColorBar::onBgColorButtonChange(const app::Color& color)
|
||||
{
|
||||
if (!m_lock)
|
||||
m_paletteView.clearSelection();
|
||||
@ -226,8 +227,8 @@ void ColorBar::onBgColorButtonChange(const Color& color)
|
||||
onColorButtonChange(color);
|
||||
}
|
||||
|
||||
void ColorBar::onColorButtonChange(const Color& color)
|
||||
void ColorBar::onColorButtonChange(const app::Color& color)
|
||||
{
|
||||
if (color.getType() == Color::IndexType)
|
||||
if (color.getType() == app::Color::IndexType)
|
||||
m_paletteView.selectColor(color.getIndex());
|
||||
}
|
||||
|
@ -43,10 +43,10 @@ public:
|
||||
|
||||
void setPixelFormat(PixelFormat pixelFormat);
|
||||
|
||||
Color getFgColor();
|
||||
Color getBgColor();
|
||||
void setFgColor(const Color& color);
|
||||
void setBgColor(const Color& color);
|
||||
app::Color getFgColor();
|
||||
app::Color getBgColor();
|
||||
void setFgColor(const app::Color& color);
|
||||
void setBgColor(const app::Color& color);
|
||||
|
||||
PaletteView* getPaletteView();
|
||||
|
||||
@ -55,15 +55,15 @@ public:
|
||||
void setPaletteEditorButtonState(bool state);
|
||||
|
||||
// Signals
|
||||
Signal1<void, const Color&> FgColorChange;
|
||||
Signal1<void, const Color&> BgColorChange;
|
||||
Signal1<void, const app::Color&> FgColorChange;
|
||||
Signal1<void, const app::Color&> BgColorChange;
|
||||
|
||||
protected:
|
||||
void onPaletteButtonClick();
|
||||
void onPaletteIndexChange(int index);
|
||||
void onFgColorButtonChange(const Color& color);
|
||||
void onBgColorButtonChange(const Color& color);
|
||||
void onColorButtonChange(const Color& color);
|
||||
void onFgColorButtonChange(const app::Color& color);
|
||||
void onBgColorButtonChange(const app::Color& color);
|
||||
void onColorButtonChange(const app::Color& color);
|
||||
|
||||
private:
|
||||
class ScrollableView : public ui::View
|
||||
|
@ -45,7 +45,7 @@ static int colorbutton_type()
|
||||
return type;
|
||||
}
|
||||
|
||||
ColorButton::ColorButton(const Color& color, PixelFormat pixelFormat)
|
||||
ColorButton::ColorButton(const app::Color& color, PixelFormat pixelFormat)
|
||||
: ButtonBase("", colorbutton_type(), JI_BUTTON, JI_BUTTON)
|
||||
, m_color(color)
|
||||
, m_pixelFormat(pixelFormat)
|
||||
@ -72,12 +72,12 @@ void ColorButton::setPixelFormat(PixelFormat pixelFormat)
|
||||
invalidate();
|
||||
}
|
||||
|
||||
Color ColorButton::getColor() const
|
||||
app::Color ColorButton::getColor() const
|
||||
{
|
||||
return m_color;
|
||||
}
|
||||
|
||||
void ColorButton::setColor(const Color& color)
|
||||
void ColorButton::setColor(const app::Color& color)
|
||||
{
|
||||
m_color = color;
|
||||
|
||||
@ -111,7 +111,7 @@ bool ColorButton::onProcessMessage(Message* msg)
|
||||
case JM_MOTION:
|
||||
if (hasCapture()) {
|
||||
Widget* picked = getManager()->pick(msg->mouse.x, msg->mouse.y);
|
||||
Color color = m_color;
|
||||
app::Color color = m_color;
|
||||
|
||||
if (picked && picked != this) {
|
||||
// Pick a color from another color-button
|
||||
@ -133,7 +133,7 @@ bool ColorButton::onProcessMessage(Message* msg)
|
||||
y = msg->mouse.y;
|
||||
editor->screenToEditor(x, y, &x, &y);
|
||||
imgcolor = sprite->getPixel(x, y);
|
||||
color = Color::fromImage(sprite->getPixelFormat(), imgcolor);
|
||||
color = app::Color::fromImage(sprite->getPixelFormat(), imgcolor);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -174,21 +174,22 @@ void ColorButton::onPaint(PaintEvent& ev) // TODO use "ev.getGraphics()"
|
||||
struct jrect box, text, icon;
|
||||
jwidget_get_texticon_info(this, &box, &text, &icon, 0, 0, 0);
|
||||
|
||||
int bg = getBgColor();
|
||||
if (bg < 0) bg = ji_color_face();
|
||||
ui::Color bg = getBgColor();
|
||||
if (is_transparent(bg))
|
||||
bg = static_cast<SkinTheme*>(getTheme())->getColor(ThemeColor::Face);
|
||||
jdraw_rectfill(this->rc, bg);
|
||||
|
||||
Color color;
|
||||
app::Color color;
|
||||
|
||||
// When the button is pushed, show the negative
|
||||
if (isSelected()) {
|
||||
color = Color::fromRgb(255-m_color.getRed(),
|
||||
255-m_color.getGreen(),
|
||||
255-m_color.getBlue());
|
||||
color = app::Color::fromRgb(255-m_color.getRed(),
|
||||
255-m_color.getGreen(),
|
||||
255-m_color.getBlue());
|
||||
}
|
||||
// When the button is not pressed, show the real color
|
||||
else
|
||||
color = this->m_color;
|
||||
color = m_color;
|
||||
|
||||
draw_color_button
|
||||
(ji_screen,
|
||||
@ -201,17 +202,17 @@ void ColorButton::onPaint(PaintEvent& ev) // TODO use "ev.getGraphics()"
|
||||
|
||||
// Draw text
|
||||
std::string str = m_color.toHumanReadableString(m_pixelFormat,
|
||||
Color::ShortHumanReadableString);
|
||||
app::Color::ShortHumanReadableString);
|
||||
|
||||
setTextQuiet(str.c_str());
|
||||
jwidget_get_texticon_info(this, &box, &text, &icon, 0, 0, 0);
|
||||
|
||||
int textcolor = makecol(255, 255, 255);
|
||||
ui::Color textcolor = ui::rgba(255, 255, 255);
|
||||
if (color.isValid())
|
||||
textcolor = color_utils::blackandwhite_neg(color.getRed(), color.getGreen(), color.getBlue());
|
||||
textcolor = color_utils::blackandwhite_neg(ui::rgba(color.getRed(), color.getGreen(), color.getBlue()));
|
||||
|
||||
jdraw_text(ji_screen, getFont(), getText(), text.x1, text.y1,
|
||||
textcolor, -1, false, jguiscale());
|
||||
textcolor, ColorNone, false, jguiscale());
|
||||
}
|
||||
|
||||
void ColorButton::onClick(Event& ev)
|
||||
@ -272,7 +273,7 @@ void ColorButton::closeSelectorDialog()
|
||||
m_window->closeWindow(NULL);
|
||||
}
|
||||
|
||||
void ColorButton::onWindowColorChange(const Color& color)
|
||||
void ColorButton::onWindowColorChange(const app::Color& color)
|
||||
{
|
||||
setColor(color);
|
||||
}
|
||||
|
@ -30,17 +30,17 @@ class ColorSelector;
|
||||
class ColorButton : public ui::ButtonBase
|
||||
{
|
||||
public:
|
||||
ColorButton(const Color& color, PixelFormat pixelFormat);
|
||||
ColorButton(const app::Color& color, PixelFormat pixelFormat);
|
||||
~ColorButton();
|
||||
|
||||
PixelFormat getPixelFormat() const;
|
||||
void setPixelFormat(PixelFormat pixelFormat);
|
||||
|
||||
Color getColor() const;
|
||||
void setColor(const Color& color);
|
||||
app::Color getColor() const;
|
||||
void setColor(const app::Color& color);
|
||||
|
||||
// Signals
|
||||
Signal1<void, const Color&> Change;
|
||||
Signal1<void, const app::Color&> Change;
|
||||
|
||||
protected:
|
||||
// Events
|
||||
@ -52,9 +52,9 @@ protected:
|
||||
private:
|
||||
void openSelectorDialog();
|
||||
void closeSelectorDialog();
|
||||
void onWindowColorChange(const Color& color);
|
||||
void onWindowColorChange(const app::Color& color);
|
||||
|
||||
Color m_color;
|
||||
app::Color m_color;
|
||||
PixelFormat m_pixelFormat;
|
||||
ColorSelector* m_window;
|
||||
};
|
||||
|
@ -39,7 +39,7 @@ using namespace ui;
|
||||
|
||||
ColorSelector::ColorSelector()
|
||||
: PopupWindowPin("Color Selector", false)
|
||||
, m_color(Color::fromMask())
|
||||
, m_color(app::Color::fromMask())
|
||||
, m_vbox(JI_VERTICAL)
|
||||
, m_topBox(JI_HORIZONTAL)
|
||||
, m_colorPalette(false)
|
||||
@ -97,7 +97,7 @@ ColorSelector::ColorSelector()
|
||||
m_graySlider.ColorChange.connect(&ColorSelector::onColorSlidersChange, this);
|
||||
m_hexColorEntry.ColorChange.connect(&ColorSelector::onColorHexEntryChange, this);
|
||||
|
||||
selectColorType(Color::RgbType);
|
||||
selectColorType(app::Color::RgbType);
|
||||
setPreferredSize(gfx::Size(300*jguiscale(), getPreferredSize().h));
|
||||
|
||||
m_onPaletteChangeSlot =
|
||||
@ -114,11 +114,11 @@ ColorSelector::~ColorSelector()
|
||||
getPin()->getParent()->removeChild(getPin());
|
||||
}
|
||||
|
||||
void ColorSelector::setColor(const Color& color, SetColorOptions options)
|
||||
void ColorSelector::setColor(const app::Color& color, SetColorOptions options)
|
||||
{
|
||||
m_color = color;
|
||||
|
||||
if (color.getType() == Color::IndexType) {
|
||||
if (color.getType() == app::Color::IndexType) {
|
||||
m_colorPalette.clearSelection();
|
||||
m_colorPalette.selectColor(color.getIndex());
|
||||
}
|
||||
@ -133,14 +133,14 @@ void ColorSelector::setColor(const Color& color, SetColorOptions options)
|
||||
selectColorType(m_color.getType());
|
||||
}
|
||||
|
||||
Color ColorSelector::getColor() const
|
||||
app::Color ColorSelector::getColor() const
|
||||
{
|
||||
return m_color;
|
||||
}
|
||||
|
||||
void ColorSelector::onColorPaletteIndexChange(int index)
|
||||
{
|
||||
setColorWithSignal(Color::fromIndex(index));
|
||||
setColorWithSignal(app::Color::fromIndex(index));
|
||||
}
|
||||
|
||||
void ColorSelector::onColorSlidersChange(ColorSlidersChangeEvent& ev)
|
||||
@ -149,7 +149,7 @@ void ColorSelector::onColorSlidersChange(ColorSlidersChangeEvent& ev)
|
||||
findBestfitIndex(ev.getColor());
|
||||
}
|
||||
|
||||
void ColorSelector::onColorHexEntryChange(const Color& color)
|
||||
void ColorSelector::onColorHexEntryChange(const app::Color& color)
|
||||
{
|
||||
// Disable updating the hex entry so we don't override what the user
|
||||
// is writting in the text field.
|
||||
@ -165,13 +165,13 @@ void ColorSelector::onColorTypeButtonClick(Event& ev)
|
||||
{
|
||||
RadioButton* source = static_cast<RadioButton*>(ev.getSource());
|
||||
|
||||
if (source == &m_indexButton) selectColorType(Color::IndexType);
|
||||
else if (source == &m_rgbButton) selectColorType(Color::RgbType);
|
||||
else if (source == &m_hsvButton) selectColorType(Color::HsvType);
|
||||
else if (source == &m_grayButton) selectColorType(Color::GrayType);
|
||||
if (source == &m_indexButton) selectColorType(app::Color::IndexType);
|
||||
else if (source == &m_rgbButton) selectColorType(app::Color::RgbType);
|
||||
else if (source == &m_hsvButton) selectColorType(app::Color::HsvType);
|
||||
else if (source == &m_grayButton) selectColorType(app::Color::GrayType);
|
||||
else if (source == &m_maskButton) {
|
||||
// Select mask color directly when the radio button is pressed
|
||||
setColorWithSignal(Color::fromMask());
|
||||
setColorWithSignal(app::Color::fromMask());
|
||||
}
|
||||
}
|
||||
|
||||
@ -181,7 +181,7 @@ void ColorSelector::onPaletteChange()
|
||||
invalidate();
|
||||
}
|
||||
|
||||
void ColorSelector::findBestfitIndex(const Color& color)
|
||||
void ColorSelector::findBestfitIndex(const app::Color& color)
|
||||
{
|
||||
// Find bestfit palette entry
|
||||
int r = color.getRed();
|
||||
@ -196,7 +196,7 @@ void ColorSelector::findBestfitIndex(const Color& color)
|
||||
}
|
||||
}
|
||||
|
||||
void ColorSelector::setColorWithSignal(const Color& color)
|
||||
void ColorSelector::setColorWithSignal(const app::Color& color)
|
||||
{
|
||||
setColor(color, ChangeType);
|
||||
|
||||
@ -204,20 +204,20 @@ void ColorSelector::setColorWithSignal(const Color& color)
|
||||
ColorChange(color);
|
||||
}
|
||||
|
||||
void ColorSelector::selectColorType(Color::Type type)
|
||||
void ColorSelector::selectColorType(app::Color::Type type)
|
||||
{
|
||||
m_colorPaletteContainer.setVisible(type == Color::IndexType);
|
||||
m_rgbSliders.setVisible(type == Color::RgbType);
|
||||
m_hsvSliders.setVisible(type == Color::HsvType);
|
||||
m_graySlider.setVisible(type == Color::GrayType);
|
||||
m_maskLabel.setVisible(type == Color::MaskType);
|
||||
m_colorPaletteContainer.setVisible(type == app::Color::IndexType);
|
||||
m_rgbSliders.setVisible(type == app::Color::RgbType);
|
||||
m_hsvSliders.setVisible(type == app::Color::HsvType);
|
||||
m_graySlider.setVisible(type == app::Color::GrayType);
|
||||
m_maskLabel.setVisible(type == app::Color::MaskType);
|
||||
|
||||
switch (type) {
|
||||
case Color::IndexType: m_indexButton.setSelected(true); break;
|
||||
case Color::RgbType: m_rgbButton.setSelected(true); break;
|
||||
case Color::HsvType: m_hsvButton.setSelected(true); break;
|
||||
case Color::GrayType: m_grayButton.setSelected(true); break;
|
||||
case Color::MaskType: m_maskButton.setSelected(true); break;
|
||||
case app::Color::IndexType: m_indexButton.setSelected(true); break;
|
||||
case app::Color::RgbType: m_rgbButton.setSelected(true); break;
|
||||
case app::Color::HsvType: m_hsvButton.setSelected(true); break;
|
||||
case app::Color::GrayType: m_grayButton.setSelected(true); break;
|
||||
case app::Color::MaskType: m_maskButton.setSelected(true); break;
|
||||
}
|
||||
|
||||
m_vbox.layout();
|
||||
|
@ -41,27 +41,27 @@ public:
|
||||
ColorSelector();
|
||||
~ColorSelector();
|
||||
|
||||
void setColor(const Color& color, SetColorOptions options);
|
||||
Color getColor() const;
|
||||
void setColor(const app::Color& color, SetColorOptions options);
|
||||
app::Color getColor() const;
|
||||
|
||||
// Signals
|
||||
Signal1<void, const Color&> ColorChange;
|
||||
Signal1<void, const app::Color&> ColorChange;
|
||||
|
||||
protected:
|
||||
void onColorPaletteIndexChange(int index);
|
||||
void onColorSlidersChange(ColorSlidersChangeEvent& ev);
|
||||
void onColorHexEntryChange(const Color& color);
|
||||
void onColorHexEntryChange(const app::Color& color);
|
||||
void onColorTypeButtonClick(ui::Event& ev);
|
||||
void onPaletteChange();
|
||||
|
||||
private:
|
||||
void selectColorType(Color::Type type);
|
||||
void setColorWithSignal(const Color& color);
|
||||
void findBestfitIndex(const Color& color);
|
||||
void selectColorType(app::Color::Type type);
|
||||
void setColorWithSignal(const app::Color& color);
|
||||
void findBestfitIndex(const app::Color& color);
|
||||
|
||||
ui::Box m_vbox;
|
||||
ui::Box m_topBox;
|
||||
Color m_color;
|
||||
app::Color m_color;
|
||||
ui::View m_colorPaletteContainer;
|
||||
PaletteView m_colorPalette;
|
||||
ui::RadioButton m_indexButton;
|
||||
|
@ -45,35 +45,34 @@ namespace {
|
||||
: m_channel(channel)
|
||||
{ }
|
||||
|
||||
void setColor(const Color& color) {
|
||||
void setColor(const app::Color& color) {
|
||||
m_color = color;
|
||||
}
|
||||
|
||||
void paint(Slider* slider, Graphics* g, const gfx::Rect& rc) {
|
||||
int depth = g->getBitsPerPixel();
|
||||
int color;
|
||||
ui::Color color;
|
||||
for (int x=0; x < rc.w; ++x) {
|
||||
switch (m_channel) {
|
||||
case ColorSliders::Red:
|
||||
color = makecol(255 * x / (rc.w-1), m_color.getGreen(), m_color.getBlue());
|
||||
color = ui::rgba(255 * x / (rc.w-1), m_color.getGreen(), m_color.getBlue());
|
||||
break;
|
||||
case ColorSliders::Green:
|
||||
color = makecol(m_color.getRed(), 255 * x / (rc.w-1), m_color.getBlue());
|
||||
color = ui::rgba(m_color.getRed(), 255 * x / (rc.w-1), m_color.getBlue());
|
||||
break;
|
||||
case ColorSliders::Blue:
|
||||
color = makecol(m_color.getRed(), m_color.getGreen(), 255 * x / (rc.w-1));
|
||||
color = ui::rgba(m_color.getRed(), m_color.getGreen(), 255 * x / (rc.w-1));
|
||||
break;
|
||||
case ColorSliders::Hue:
|
||||
color = color_utils::color_for_allegro(Color::fromHsv(360 * x / (rc.w-1), m_color.getSaturation(), m_color.getValue()), depth);
|
||||
color = color_utils::color_for_ui(app::Color::fromHsv(360 * x / (rc.w-1), m_color.getSaturation(), m_color.getValue()));
|
||||
break;
|
||||
case ColorSliders::Saturation:
|
||||
color = color_utils::color_for_allegro(Color::fromHsv(m_color.getHue(), 100 * x / (rc.w-1), m_color.getValue()), depth);
|
||||
color = color_utils::color_for_ui(app::Color::fromHsv(m_color.getHue(), 100 * x / (rc.w-1), m_color.getValue()));
|
||||
break;
|
||||
case ColorSliders::Value:
|
||||
color = color_utils::color_for_allegro(Color::fromHsv(m_color.getHue(), m_color.getSaturation(), 100 * x / (rc.w-1)), depth);
|
||||
color = color_utils::color_for_ui(app::Color::fromHsv(m_color.getHue(), m_color.getSaturation(), 100 * x / (rc.w-1)));
|
||||
break;
|
||||
case ColorSliders::Gray:
|
||||
color = color_utils::color_for_allegro(Color::fromGray(255 * x / (rc.w-1)), depth);
|
||||
color = color_utils::color_for_ui(app::Color::fromGray(255 * x / (rc.w-1)));
|
||||
break;
|
||||
}
|
||||
g->drawVLine(color, rc.x+x, rc.y, rc.h);
|
||||
@ -83,7 +82,7 @@ namespace {
|
||||
private:
|
||||
ColorSliders::Channel m_channel;
|
||||
BITMAP* m_cachedBg;
|
||||
Color m_color;
|
||||
app::Color m_color;
|
||||
};
|
||||
|
||||
}
|
||||
@ -102,7 +101,7 @@ ColorSliders::~ColorSliders()
|
||||
{
|
||||
}
|
||||
|
||||
void ColorSliders::setColor(const Color& color)
|
||||
void ColorSliders::setColor(const app::Color& color)
|
||||
{
|
||||
onSetColor(color);
|
||||
|
||||
@ -175,7 +174,7 @@ void ColorSliders::onControlChange(int i)
|
||||
{
|
||||
// Call derived class impl of getColorFromSliders() to update the
|
||||
// background color of sliders.
|
||||
Color color = getColorFromSliders();
|
||||
app::Color color = getColorFromSliders();
|
||||
|
||||
updateSlidersBgColor(color);
|
||||
|
||||
@ -190,13 +189,13 @@ void ColorSliders::updateEntryText(int entryIndex)
|
||||
m_entry[entryIndex]->setTextf("%d", m_slider[entryIndex]->getValue());
|
||||
}
|
||||
|
||||
void ColorSliders::updateSlidersBgColor(const Color& color)
|
||||
void ColorSliders::updateSlidersBgColor(const app::Color& color)
|
||||
{
|
||||
for (size_t i = 0; i < m_slider.size(); ++i)
|
||||
updateSliderBgColor(m_slider[i], color);
|
||||
}
|
||||
|
||||
void ColorSliders::updateSliderBgColor(Slider* slider, const Color& color)
|
||||
void ColorSliders::updateSliderBgColor(Slider* slider, const app::Color& color)
|
||||
{
|
||||
SharedPtr<SkinSliderProperty> sliderProperty(slider->getProperty("SkinProperty"));
|
||||
|
||||
@ -216,18 +215,18 @@ RgbSliders::RgbSliders()
|
||||
addSlider(Blue, "B", 0, 255);
|
||||
}
|
||||
|
||||
void RgbSliders::onSetColor(const Color& color)
|
||||
void RgbSliders::onSetColor(const app::Color& color)
|
||||
{
|
||||
setSliderValue(0, color.getRed());
|
||||
setSliderValue(1, color.getGreen());
|
||||
setSliderValue(2, color.getBlue());
|
||||
}
|
||||
|
||||
Color RgbSliders::getColorFromSliders()
|
||||
app::Color RgbSliders::getColorFromSliders()
|
||||
{
|
||||
return Color::fromRgb(getSliderValue(0),
|
||||
getSliderValue(1),
|
||||
getSliderValue(2));
|
||||
return app::Color::fromRgb(getSliderValue(0),
|
||||
getSliderValue(1),
|
||||
getSliderValue(2));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
@ -241,18 +240,18 @@ HsvSliders::HsvSliders()
|
||||
addSlider(Value, "B", 0, 100);
|
||||
}
|
||||
|
||||
void HsvSliders::onSetColor(const Color& color)
|
||||
void HsvSliders::onSetColor(const app::Color& color)
|
||||
{
|
||||
setSliderValue(0, color.getHue());
|
||||
setSliderValue(1, color.getSaturation());
|
||||
setSliderValue(2, color.getValue());
|
||||
}
|
||||
|
||||
Color HsvSliders::getColorFromSliders()
|
||||
app::Color HsvSliders::getColorFromSliders()
|
||||
{
|
||||
return Color::fromHsv(getSliderValue(0),
|
||||
getSliderValue(1),
|
||||
getSliderValue(2));
|
||||
return app::Color::fromHsv(getSliderValue(0),
|
||||
getSliderValue(1),
|
||||
getSliderValue(2));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
@ -264,13 +263,13 @@ GraySlider::GraySlider()
|
||||
addSlider(Gray, "V", 0, 255);
|
||||
}
|
||||
|
||||
void GraySlider::onSetColor(const Color& color)
|
||||
void GraySlider::onSetColor(const app::Color& color)
|
||||
{
|
||||
setSliderValue(0, color.getGray());
|
||||
}
|
||||
|
||||
|
||||
Color GraySlider::getColorFromSliders()
|
||||
app::Color GraySlider::getColorFromSliders()
|
||||
{
|
||||
return Color::fromGray(getSliderValue(0));
|
||||
return app::Color::fromGray(getSliderValue(0));
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public:
|
||||
ColorSliders();
|
||||
~ColorSliders();
|
||||
|
||||
void setColor(const Color& color);
|
||||
void setColor(const app::Color& color);
|
||||
|
||||
// Signals
|
||||
Signal1<void, ColorSlidersChangeEvent&> ColorChange;
|
||||
@ -62,8 +62,8 @@ protected:
|
||||
void setSliderValue(int sliderIndex, int value);
|
||||
int getSliderValue(int sliderIndex) const;
|
||||
|
||||
virtual void onSetColor(const Color& color) = 0;
|
||||
virtual Color getColorFromSliders() = 0;
|
||||
virtual void onSetColor(const app::Color& color) = 0;
|
||||
virtual app::Color getColorFromSliders() = 0;
|
||||
|
||||
private:
|
||||
void onSliderChange(int i);
|
||||
@ -71,8 +71,8 @@ private:
|
||||
void onControlChange(int i);
|
||||
|
||||
void updateEntryText(int entryIndex);
|
||||
void updateSlidersBgColor(const Color& color);
|
||||
void updateSliderBgColor(ui::Slider* slider, const Color& color);
|
||||
void updateSlidersBgColor(const app::Color& color);
|
||||
void updateSliderBgColor(ui::Slider* slider, const app::Color& color);
|
||||
|
||||
std::vector<ui::Label*> m_label;
|
||||
std::vector<ui::Slider*> m_slider;
|
||||
@ -90,8 +90,8 @@ public:
|
||||
RgbSliders();
|
||||
|
||||
private:
|
||||
virtual void onSetColor(const Color& color) OVERRIDE;
|
||||
virtual Color getColorFromSliders() OVERRIDE;
|
||||
virtual void onSetColor(const app::Color& color) OVERRIDE;
|
||||
virtual app::Color getColorFromSliders() OVERRIDE;
|
||||
};
|
||||
|
||||
class HsvSliders : public ColorSliders
|
||||
@ -100,8 +100,8 @@ public:
|
||||
HsvSliders();
|
||||
|
||||
private:
|
||||
virtual void onSetColor(const Color& color) OVERRIDE;
|
||||
virtual Color getColorFromSliders() OVERRIDE;
|
||||
virtual void onSetColor(const app::Color& color) OVERRIDE;
|
||||
virtual app::Color getColorFromSliders() OVERRIDE;
|
||||
};
|
||||
|
||||
class GraySlider : public ColorSliders
|
||||
@ -110,8 +110,8 @@ public:
|
||||
GraySlider();
|
||||
|
||||
private:
|
||||
virtual void onSetColor(const Color& color) OVERRIDE;
|
||||
virtual Color getColorFromSliders() OVERRIDE;
|
||||
virtual void onSetColor(const app::Color& color) OVERRIDE;
|
||||
virtual app::Color getColorFromSliders() OVERRIDE;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
@ -120,17 +120,17 @@ private:
|
||||
class ColorSlidersChangeEvent : public ui::Event
|
||||
{
|
||||
public:
|
||||
ColorSlidersChangeEvent(const Color& color, ColorSliders::Channel channel, ui::Component* source)
|
||||
ColorSlidersChangeEvent(const app::Color& color, ColorSliders::Channel channel, ui::Component* source)
|
||||
: Event(source)
|
||||
, m_color(color)
|
||||
, m_channel(channel) { }
|
||||
|
||||
Color getColor() const { return m_color; }
|
||||
app::Color getColor() const { return m_color; }
|
||||
|
||||
ColorSliders::Channel getModifiedChannel() const { return m_channel; }
|
||||
|
||||
private:
|
||||
Color m_color;
|
||||
app::Color m_color;
|
||||
ColorSliders::Channel m_channel;
|
||||
};
|
||||
|
||||
|
@ -106,7 +106,7 @@ static int get_pen_color(Sprite *sprite);
|
||||
// CURSOR COLOR
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
static Color cursor_color;
|
||||
static app::Color cursor_color;
|
||||
static int _cursor_color;
|
||||
static bool _cursor_mask;
|
||||
|
||||
@ -117,7 +117,7 @@ static void update_cursor_color()
|
||||
else
|
||||
_cursor_color = 0;
|
||||
|
||||
_cursor_mask = (cursor_color.getType() == Color::MaskType);
|
||||
_cursor_mask = (cursor_color.getType() == app::Color::MaskType);
|
||||
}
|
||||
|
||||
int Editor::get_raw_cursor_color()
|
||||
@ -130,12 +130,12 @@ bool Editor::is_cursor_mask()
|
||||
return _cursor_mask;
|
||||
}
|
||||
|
||||
Color Editor::get_cursor_color()
|
||||
app::Color Editor::get_cursor_color()
|
||||
{
|
||||
return cursor_color;
|
||||
}
|
||||
|
||||
void Editor::set_cursor_color(const Color& color)
|
||||
void Editor::set_cursor_color(const app::Color& color)
|
||||
{
|
||||
cursor_color = color;
|
||||
update_cursor_color();
|
||||
@ -205,7 +205,7 @@ static Pen* editor_get_current_pen()
|
||||
void Editor::editor_cursor_init()
|
||||
{
|
||||
/* cursor color */
|
||||
set_cursor_color(get_config_color("Tools", "CursorColor", Color::fromMask()));
|
||||
set_cursor_color(get_config_color("Tools", "CursorColor", app::Color::fromMask()));
|
||||
|
||||
App::instance()->PaletteChange.connect(&on_palette_change_update_cursor_color);
|
||||
App::instance()->PenSizeBeforeChange.connect(&on_pen_size_before_change);
|
||||
@ -266,7 +266,7 @@ void Editor::editor_draw_cursor(int x, int y, bool refresh)
|
||||
else if (// Use cursor bounds for inks that are effects (eraser, blur, etc.)
|
||||
current_tool->getInk(0)->isEffect() ||
|
||||
// or when the FG color is mask and we are not in the background layer
|
||||
(UIContext::instance()->getSettings()->getFgColor().getType() == Color::MaskType &&
|
||||
(UIContext::instance()->getSettings()->getFgColor().getType() == app::Color::MaskType &&
|
||||
(m_sprite->getCurrentLayer() != NULL &&
|
||||
!m_sprite->getCurrentLayer()->is_background()))) {
|
||||
cursor_type = CURSOR_BOUNDS;
|
||||
@ -648,7 +648,7 @@ static void drawpixel(BITMAP *bmp, int x, int y, int color)
|
||||
g = getg(c);
|
||||
b = getb(c);
|
||||
|
||||
putpixel(bmp, x, y, color_utils::blackandwhite_neg(r, g, b));
|
||||
putpixel(bmp, x, y, ui::to_system(color_utils::blackandwhite_neg(ui::rgba(r, g, b))));
|
||||
}
|
||||
else {
|
||||
putpixel(bmp, x, y, color);
|
||||
@ -675,7 +675,7 @@ static int point_inside_region(int x, int y, JRegion region)
|
||||
|
||||
static int get_pen_color(Sprite *sprite)
|
||||
{
|
||||
Color c = UIContext::instance()->getSettings()->getFgColor();
|
||||
app::Color c = UIContext::instance()->getSettings()->getFgColor();
|
||||
ASSERT(sprite != NULL);
|
||||
|
||||
// Avoid using invalid colors
|
||||
|
@ -612,7 +612,7 @@ void Editor::drawMaskSafe()
|
||||
}
|
||||
}
|
||||
|
||||
void Editor::drawGrid(const Rect& gridBounds, const Color& color)
|
||||
void Editor::drawGrid(const Rect& gridBounds, const app::Color& color)
|
||||
{
|
||||
// Copy the grid bounds
|
||||
Rect grid(gridBounds);
|
||||
@ -906,8 +906,8 @@ bool Editor::onProcessMessage(Message* msg)
|
||||
View* view = View::getView(this);
|
||||
Rect vp = view->getViewportBounds();
|
||||
|
||||
jdraw_rectfill(vp, theme->get_editor_face_color());
|
||||
draw_emptyset_symbol(ji_screen, vp, makecol(64, 64, 64));
|
||||
jdraw_rectfill(vp, theme->getColor(ThemeColor::EditorFace));
|
||||
draw_emptyset_symbol(ji_screen, vp, ui::rgba(64, 64, 64));
|
||||
}
|
||||
// Editor with sprite
|
||||
else {
|
||||
@ -925,14 +925,14 @@ bool Editor::onProcessMessage(Message* msg)
|
||||
jrectexclude(ji_screen,
|
||||
this->rc->x1, this->rc->y1,
|
||||
this->rc->x2-1, this->rc->y2-1,
|
||||
x1-1, y1-1, x2+1, y2+2, theme->get_editor_face_color());
|
||||
x1-1, y1-1, x2+1, y2+2, theme->getColor(ThemeColor::EditorFace));
|
||||
|
||||
// Draw the sprite in the editor
|
||||
drawSprite(0, 0, m_sprite->getWidth()-1, m_sprite->getHeight()-1);
|
||||
|
||||
// Draw the sprite boundary
|
||||
rect(ji_screen, x1-1, y1-1, x2+1, y2+1, theme->get_editor_sprite_border());
|
||||
hline(ji_screen, x1-1, y2+2, x2+1, theme->get_editor_sprite_bottom_edge());
|
||||
rect(ji_screen, x1-1, y1-1, x2+1, y2+1, to_system(theme->getColor(ThemeColor::EditorSpriteBorder)));
|
||||
hline(ji_screen, x1-1, y2+2, x2+1, to_system(theme->getColor(ThemeColor::EditorSpriteBottomBorder)));
|
||||
|
||||
// Draw the mask boundaries
|
||||
if (m_document->getBoundariesSegments()) {
|
||||
@ -954,7 +954,7 @@ bool Editor::onProcessMessage(Message* msg)
|
||||
|
||||
View* view = View::getView(this);
|
||||
Rect vp = view->getViewportBounds();
|
||||
jdraw_rectfill(vp, theme->get_editor_face_color());
|
||||
jdraw_rectfill(vp, theme->getColor(ThemeColor::EditorFace));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -146,8 +146,8 @@ public:
|
||||
|
||||
static int get_raw_cursor_color();
|
||||
static bool is_cursor_mask();
|
||||
static Color get_cursor_color();
|
||||
static void set_cursor_color(const Color& color);
|
||||
static app::Color get_cursor_color();
|
||||
static void set_cursor_color(const app::Color& color);
|
||||
|
||||
static void editor_cursor_init();
|
||||
static void editor_cursor_exit();
|
||||
@ -172,7 +172,7 @@ private:
|
||||
void editor_clean_cursor(bool refresh = true);
|
||||
bool editor_cursor_is_subpixel();
|
||||
|
||||
void drawGrid(const gfx::Rect& gridBounds, const Color& color);
|
||||
void drawGrid(const gfx::Rect& gridBounds, const app::Color& color);
|
||||
|
||||
void editor_setcursor();
|
||||
|
||||
@ -219,7 +219,7 @@ private:
|
||||
// signals).
|
||||
Slot0<void>* m_currentToolChangeSlot;
|
||||
|
||||
Slot1<void, const Color&>* m_fgColorChangeSlot;
|
||||
Slot1<void, const app::Color&>* m_fgColorChangeSlot;
|
||||
|
||||
EditorObservers m_observers;
|
||||
|
||||
|
@ -82,7 +82,8 @@ bool EditorView::onProcessMessage(Message* msg)
|
||||
pos->x1, pos->y1,
|
||||
pos->x2-1, pos->y2-1,
|
||||
selected ? PART_EDITOR_SELECTED_NW:
|
||||
PART_EDITOR_NORMAL_NW, false);
|
||||
PART_EDITOR_NORMAL_NW,
|
||||
ColorNone);
|
||||
|
||||
jrect_free(pos);
|
||||
}
|
||||
|
@ -406,12 +406,12 @@ void MovingPixelsState::dispose()
|
||||
// StatusBar's observer.
|
||||
}
|
||||
|
||||
void MovingPixelsState::onChangeTransparentColor(const Color& color)
|
||||
void MovingPixelsState::onChangeTransparentColor(const app::Color& color)
|
||||
{
|
||||
setTransparentColor(color);
|
||||
}
|
||||
|
||||
void MovingPixelsState::setTransparentColor(const Color& color)
|
||||
void MovingPixelsState::setTransparentColor(const app::Color& color)
|
||||
{
|
||||
ASSERT(current_editor != NULL);
|
||||
ASSERT(m_pixelsMovement != NULL);
|
||||
|
@ -55,10 +55,10 @@ public:
|
||||
protected:
|
||||
// StatusBarObserver interface
|
||||
virtual void dispose() OVERRIDE;
|
||||
virtual void onChangeTransparentColor(const Color& color) OVERRIDE;
|
||||
virtual void onChangeTransparentColor(const app::Color& color) OVERRIDE;
|
||||
|
||||
private:
|
||||
void setTransparentColor(const Color& color);
|
||||
void setTransparentColor(const app::Color& color);
|
||||
void dropPixels(Editor* editor);
|
||||
|
||||
// Helper member to move/translate selection and pixels.
|
||||
|
@ -297,11 +297,11 @@ bool StandbyState::onMouseWheel(Editor* editor, Message* msg)
|
||||
// if (m_state == EDITOR_STATE_STANDBY)
|
||||
{
|
||||
int newIndex = 0;
|
||||
if (ColorBar::instance()->getFgColor().getType() == Color::IndexType) {
|
||||
if (ColorBar::instance()->getFgColor().getType() == app::Color::IndexType) {
|
||||
newIndex = ColorBar::instance()->getFgColor().getIndex() + dz;
|
||||
newIndex = MID(0, newIndex, 255);
|
||||
}
|
||||
ColorBar::instance()->setFgColor(Color::fromIndex(newIndex));
|
||||
ColorBar::instance()->setFgColor(app::Color::fromIndex(newIndex));
|
||||
}
|
||||
break;
|
||||
|
||||
@ -309,11 +309,11 @@ bool StandbyState::onMouseWheel(Editor* editor, Message* msg)
|
||||
// if (m_state == EDITOR_STATE_STANDBY)
|
||||
{
|
||||
int newIndex = 0;
|
||||
if (ColorBar::instance()->getBgColor().getType() == Color::IndexType) {
|
||||
if (ColorBar::instance()->getBgColor().getType() == app::Color::IndexType) {
|
||||
newIndex = ColorBar::instance()->getBgColor().getIndex() + dz;
|
||||
newIndex = MID(0, newIndex, 255);
|
||||
}
|
||||
ColorBar::instance()->setBgColor(Color::fromIndex(newIndex));
|
||||
ColorBar::instance()->setBgColor(app::Color::fromIndex(newIndex));
|
||||
}
|
||||
break;
|
||||
|
||||
@ -454,7 +454,7 @@ bool StandbyState::onUpdateStatusBar(Editor* editor)
|
||||
else if (current_tool->getInk(0)->isEyedropper()) {
|
||||
PixelFormat format = sprite->getPixelFormat();
|
||||
uint32_t pixel = sprite->getPixel(x, y);
|
||||
Color color = Color::fromImage(format, pixel);
|
||||
app::Color color = app::Color::fromImage(format, pixel);
|
||||
|
||||
int alpha = 255;
|
||||
switch (format) {
|
||||
|
@ -84,8 +84,8 @@ public:
|
||||
Sprite* sprite,
|
||||
Layer* layer,
|
||||
tools::ToolLoop::Button button,
|
||||
const Color& primary_color,
|
||||
const Color& secondary_color)
|
||||
const app::Color& primary_color,
|
||||
const app::Color& secondary_color)
|
||||
: m_editor(editor)
|
||||
, m_context(context)
|
||||
, m_tool(tool)
|
||||
@ -276,8 +276,8 @@ tools::ToolLoop* create_tool_loop(Editor* editor, Context* context, Message* msg
|
||||
|
||||
// Get fg/bg colors
|
||||
ColorBar* colorbar = ColorBar::instance();
|
||||
Color fg = colorbar->getFgColor();
|
||||
Color bg = colorbar->getBgColor();
|
||||
app::Color fg = colorbar->getFgColor();
|
||||
app::Color bg = colorbar->getBgColor();
|
||||
|
||||
if (!fg.isValid() || !bg.isValid()) {
|
||||
Alert::show(PACKAGE
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "widgets/file_list.h"
|
||||
|
||||
#include "modules/gfx.h"
|
||||
#include "skin/skin_theme.h"
|
||||
#include "thumbnail_generator.h"
|
||||
#include "ui/gui.h"
|
||||
|
||||
@ -110,13 +111,14 @@ bool FileList::onProcessMessage(Message* msg)
|
||||
switch (msg->type) {
|
||||
|
||||
case JM_DRAW: {
|
||||
SkinTheme* theme = static_cast<SkinTheme*>(getTheme());
|
||||
View* view = View::getView(this);
|
||||
gfx::Rect vp = view->getViewportBounds();
|
||||
int th = jwidget_get_text_height(this);
|
||||
int x, y = this->rc->y1;
|
||||
int row = 0;
|
||||
int bgcolor;
|
||||
int fgcolor;
|
||||
int evenRow = 0;
|
||||
ui::Color bgcolor;
|
||||
ui::Color fgcolor;
|
||||
BITMAP *thumbnail = NULL;
|
||||
int thumbnail_y = 0;
|
||||
|
||||
@ -127,17 +129,18 @@ bool FileList::onProcessMessage(Message* msg)
|
||||
gfx::Size itemSize = getFileItemSize(fi);
|
||||
|
||||
if (fi == m_selected) {
|
||||
bgcolor = ji_color_selected();
|
||||
fgcolor = ji_color_background();
|
||||
fgcolor = theme->getColor(ThemeColor::FileListSelectedRowText);
|
||||
bgcolor = theme->getColor(ThemeColor::FileListSelectedRowFace);
|
||||
}
|
||||
else {
|
||||
bgcolor = row ? makecol(240, 240, 240):
|
||||
ji_color_background();
|
||||
bgcolor = evenRow ? theme->getColor(ThemeColor::FileListEvenRowFace):
|
||||
theme->getColor(ThemeColor::FileListOddRowFace);
|
||||
|
||||
fgcolor =
|
||||
fi->isFolder() &&
|
||||
!fi->isBrowsable() ? makecol(255, 200, 200):
|
||||
ji_color_foreground();
|
||||
if (fi->isFolder() && !fi->isBrowsable())
|
||||
fgcolor = theme->getColor(ThemeColor::FileListDisabledRowText);
|
||||
else
|
||||
fgcolor = evenRow ? theme->getColor(ThemeColor::FileListEvenRowText):
|
||||
theme->getColor(ThemeColor::FileListOddRowText);
|
||||
}
|
||||
|
||||
x = this->rc->x1+2;
|
||||
@ -169,7 +172,7 @@ bool FileList::onProcessMessage(Message* msg)
|
||||
rectfill(ji_screen,
|
||||
this->rc->x1, y,
|
||||
x-1, y+2+th+2-1,
|
||||
bgcolor);
|
||||
to_system(bgcolor));
|
||||
}
|
||||
|
||||
// item name
|
||||
@ -209,14 +212,14 @@ bool FileList::onProcessMessage(Message* msg)
|
||||
}
|
||||
|
||||
y += itemSize.h;
|
||||
row ^= 1;
|
||||
evenRow ^= 1;
|
||||
}
|
||||
|
||||
if (y < this->rc->y2-1)
|
||||
rectfill(ji_screen,
|
||||
this->rc->x1, y,
|
||||
this->rc->x2-1, this->rc->y2-1,
|
||||
ji_color_background());
|
||||
to_system(theme->getColor(ThemeColor::Background)));
|
||||
|
||||
// Draw the thumbnail
|
||||
if (thumbnail) {
|
||||
@ -232,7 +235,7 @@ bool FileList::onProcessMessage(Message* msg)
|
||||
|
||||
// is the current folder empty?
|
||||
if (m_list.empty())
|
||||
draw_emptyset_symbol(ji_screen, vp, makecol(194, 194, 194));
|
||||
draw_emptyset_symbol(ji_screen, vp, ui::rgba(194, 194, 194));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ HexColorEntry::HexColorEntry()
|
||||
child_spacing = 0;
|
||||
}
|
||||
|
||||
void HexColorEntry::setColor(const Color& color)
|
||||
void HexColorEntry::setColor(const app::Color& color)
|
||||
{
|
||||
m_entry.setTextf("%02x%02x%02x",
|
||||
color.getRed(),
|
||||
@ -78,5 +78,5 @@ void HexColorEntry::onEntryChange()
|
||||
g = (hex & 0xff00) >> 8;
|
||||
b = (hex & 0xff);
|
||||
|
||||
ColorChange(Color::fromRgb(r, g, b));
|
||||
ColorChange(app::Color::fromRgb(r, g, b));
|
||||
}
|
||||
|
@ -31,10 +31,10 @@ class HexColorEntry : public ui::Box
|
||||
public:
|
||||
HexColorEntry();
|
||||
|
||||
void setColor(const Color& color);
|
||||
void setColor(const app::Color& color);
|
||||
|
||||
// Signals
|
||||
Signal1<void, const Color&> ColorChange;
|
||||
Signal1<void, const app::Color&> ColorChange;
|
||||
|
||||
protected:
|
||||
void onEntryChange();
|
||||
|
@ -160,7 +160,7 @@ void PaletteView::getSelectedEntries(SelectedEntries& entries) const
|
||||
entries = m_selectedEntries;
|
||||
}
|
||||
|
||||
Color PaletteView::getColorByPosition(int target_x, int target_y)
|
||||
app::Color PaletteView::getColorByPosition(int target_x, int target_y)
|
||||
{
|
||||
Palette* palette = get_current_palette();
|
||||
JRect cpos = jwidget_get_child_rect(this);
|
||||
@ -185,7 +185,7 @@ Color PaletteView::getColorByPosition(int target_x, int target_y)
|
||||
|
||||
if ((target_x >= x) && (target_x <= x+m_boxsize) &&
|
||||
(target_y >= y) && (target_y <= y+m_boxsize))
|
||||
return Color::fromIndex(c);
|
||||
return app::Color::fromIndex(c);
|
||||
|
||||
x += m_boxsize+this->child_spacing;
|
||||
c++;
|
||||
@ -195,7 +195,7 @@ Color PaletteView::getColorByPosition(int target_x, int target_y)
|
||||
}
|
||||
|
||||
jrect_free(cpos);
|
||||
return Color::fromMask();
|
||||
return app::Color::fromMask();
|
||||
}
|
||||
|
||||
bool PaletteView::onProcessMessage(Message* msg)
|
||||
@ -291,8 +291,8 @@ bool PaletteView::onProcessMessage(Message* msg)
|
||||
|
||||
jrect_free(cpos);
|
||||
|
||||
Color color = getColorByPosition(mouse_x, mouse_y);
|
||||
if (color.getType() == Color::IndexType) {
|
||||
app::Color color = getColorByPosition(mouse_x, mouse_y);
|
||||
if (color.getType() == app::Color::IndexType) {
|
||||
int idx = color.getIndex();
|
||||
|
||||
StatusBar::instance()->showColor(0, "", color, 255);
|
||||
|
@ -45,7 +45,7 @@ public:
|
||||
bool getSelectedRange(int& index1, int& index2) const;
|
||||
void getSelectedEntries(SelectedEntries& entries) const;
|
||||
|
||||
Color getColorByPosition(int x, int y);
|
||||
app::Color getColorByPosition(int x, int y);
|
||||
|
||||
// Signals
|
||||
Signal1<void, int> IndexChange;
|
||||
|
@ -138,7 +138,7 @@ StatusBar* StatusBar::m_instance = NULL;
|
||||
|
||||
StatusBar::StatusBar()
|
||||
: Widget(statusbar_type())
|
||||
, m_color(Color::fromMask())
|
||||
, m_color(app::Color::fromMask())
|
||||
{
|
||||
m_instance = this;
|
||||
|
||||
@ -237,7 +237,7 @@ StatusBar::StatusBar()
|
||||
|
||||
m_movePixelsBox = new Box(JI_HORIZONTAL);
|
||||
m_transparentLabel = new Label("Transparent Color:");
|
||||
m_transparentColor = new ColorButton(Color::fromMask(), IMAGE_RGB);
|
||||
m_transparentColor = new ColorButton(app::Color::fromMask(), IMAGE_RGB);
|
||||
|
||||
m_movePixelsBox->addChild(filler);
|
||||
m_movePixelsBox->addChild(m_transparentLabel);
|
||||
@ -285,8 +285,8 @@ void StatusBar::onCurrentToolChange()
|
||||
|
||||
void StatusBar::onTransparentColorChange()
|
||||
{
|
||||
m_observers.notifyObservers<const Color&>(&StatusBarObserver::onChangeTransparentColor,
|
||||
getTransparentColor());
|
||||
m_observers.notifyObservers<const app::Color&>(&StatusBarObserver::onChangeTransparentColor,
|
||||
getTransparentColor());
|
||||
}
|
||||
|
||||
void StatusBar::clearText()
|
||||
@ -356,7 +356,7 @@ void StatusBar::showTip(int msecs, const char *format, ...)
|
||||
invalidate();
|
||||
}
|
||||
|
||||
void StatusBar::showColor(int msecs, const char* text, const Color& color, int alpha)
|
||||
void StatusBar::showColor(int msecs, const char* text, const app::Color& color, int alpha)
|
||||
{
|
||||
if (setStatusText(msecs, text)) {
|
||||
m_state = SHOW_COLOR;
|
||||
@ -403,7 +403,7 @@ void StatusBar::hideMovePixelsOptions()
|
||||
}
|
||||
}
|
||||
|
||||
Color StatusBar::getTransparentColor()
|
||||
app::Color StatusBar::getTransparentColor()
|
||||
{
|
||||
return m_transparentColor->getColor();
|
||||
}
|
||||
@ -498,19 +498,16 @@ bool StatusBar::onProcessMessage(Message* msg)
|
||||
|
||||
case JM_DRAW: {
|
||||
SkinTheme* theme = static_cast<SkinTheme*>(this->getTheme());
|
||||
int text_color = ji_color_foreground();
|
||||
int face_color = ji_color_face();
|
||||
ui::Color text_color = theme->getColor(ThemeColor::Text);
|
||||
ui::Color face_color = theme->getColor(ThemeColor::Face);
|
||||
JRect rc = jwidget_get_rect(this);
|
||||
BITMAP *doublebuffer = create_bitmap(jrect_w(&msg->draw.rect),
|
||||
BITMAP* doublebuffer = create_bitmap(jrect_w(&msg->draw.rect),
|
||||
jrect_h(&msg->draw.rect));
|
||||
jrect_displace(rc,
|
||||
-msg->draw.rect.x1,
|
||||
-msg->draw.rect.y1);
|
||||
|
||||
clear_to_color(doublebuffer, face_color);
|
||||
|
||||
putpixel(doublebuffer, rc->x1, rc->y1, theme->get_tab_selected_face_color());
|
||||
putpixel(doublebuffer, rc->x2-1, rc->y1, theme->get_tab_selected_face_color());
|
||||
clear_to_color(doublebuffer, to_system(face_color));
|
||||
|
||||
rc->x1 += 2*jguiscale();
|
||||
rc->y1 += 1*jguiscale();
|
||||
@ -542,7 +539,7 @@ bool StatusBar::onProcessMessage(Message* msg)
|
||||
|
||||
// Draw color description
|
||||
std::string str = m_color.toHumanReadableString(app_get_current_pixel_format(),
|
||||
Color::LongHumanReadableString);
|
||||
app::Color::LongHumanReadableString);
|
||||
if (m_alpha < 255) {
|
||||
char buf[512];
|
||||
usprintf(buf, ", Alpha %d", m_alpha);
|
||||
@ -551,7 +548,7 @@ bool StatusBar::onProcessMessage(Message* msg)
|
||||
|
||||
textout_ex(doublebuffer, this->getFont(), str.c_str(),
|
||||
x, (rc->y1+rc->y2)/2-text_height(this->getFont())/2,
|
||||
text_color, -1);
|
||||
to_system(text_color), -1);
|
||||
|
||||
x += ji_font_text_len(this->getFont(), str.c_str()) + 4*jguiscale();
|
||||
}
|
||||
@ -574,7 +571,7 @@ bool StatusBar::onProcessMessage(Message* msg)
|
||||
textout_ex(doublebuffer, this->getFont(), this->getText(),
|
||||
x,
|
||||
(rc->y1+rc->y2)/2-text_height(this->getFont())/2,
|
||||
text_color, -1);
|
||||
to_system(text_color), -1);
|
||||
|
||||
x += ji_font_text_len(this->getFont(), this->getText()) + 4*jguiscale();
|
||||
}
|
||||
@ -631,8 +628,8 @@ bool StatusBar::onProcessMessage(Message* msg)
|
||||
x1, rc->y1, x2, rc->y2,
|
||||
hot ? PART_TOOLBUTTON_HOT_NW:
|
||||
PART_TOOLBUTTON_NORMAL_NW,
|
||||
hot ? theme->get_button_hot_face_color():
|
||||
theme->get_button_normal_face_color());
|
||||
hot ? theme->getColor(ThemeColor::ButtonHotFace):
|
||||
theme->getColor(ThemeColor::ButtonNormalFace));
|
||||
|
||||
if (count == 1)
|
||||
uszprintf(buf, sizeof(buf), "%s", (*it)->getName().c_str());
|
||||
@ -647,8 +644,9 @@ bool StatusBar::onProcessMessage(Message* msg)
|
||||
textout_centre_ex(doublebuffer, this->getFont(), buf,
|
||||
(x1+x2)/2,
|
||||
(rc->y1+rc->y2)/2-text_height(this->getFont())/2,
|
||||
hot ? theme->get_button_hot_text_color():
|
||||
theme->get_button_normal_text_color(), -1);
|
||||
to_system(hot ? theme->getColor(ThemeColor::ButtonHotText):
|
||||
theme->getColor(ThemeColor::ButtonNormalText)),
|
||||
-1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -66,7 +66,7 @@ class StatusBarObserver
|
||||
public:
|
||||
virtual ~StatusBarObserver() { }
|
||||
virtual void dispose() = 0;
|
||||
virtual void onChangeTransparentColor(const Color& color) = 0;
|
||||
virtual void onChangeTransparentColor(const app::Color& color) = 0;
|
||||
};
|
||||
|
||||
typedef Observers<StatusBarObserver> StatusBarObservers;
|
||||
@ -87,13 +87,13 @@ public:
|
||||
|
||||
bool setStatusText(int msecs, const char *format, ...);
|
||||
void showTip(int msecs, const char *format, ...);
|
||||
void showColor(int msecs, const char* text, const Color& color, int alpha);
|
||||
void showColor(int msecs, const char* text, const app::Color& color, int alpha);
|
||||
void showTool(int msecs, tools::Tool* tool);
|
||||
|
||||
void showMovePixelsOptions();
|
||||
void hideMovePixelsOptions();
|
||||
|
||||
Color getTransparentColor();
|
||||
app::Color getTransparentColor();
|
||||
|
||||
// Methods to add and remove progress bars
|
||||
Progress* addProgress();
|
||||
@ -124,7 +124,7 @@ private:
|
||||
tools::Tool* m_tool;
|
||||
|
||||
// Showing a color
|
||||
Color m_color;
|
||||
app::Color m_color;
|
||||
int m_alpha;
|
||||
|
||||
// Progress bar
|
||||
|
@ -244,8 +244,6 @@ void* Tabs::getSelectedTab()
|
||||
|
||||
bool Tabs::onProcessMessage(Message* msg)
|
||||
{
|
||||
SkinTheme* theme = static_cast<SkinTheme*>(this->getTheme());
|
||||
|
||||
switch (msg->type) {
|
||||
|
||||
case JM_SETPOS:
|
||||
@ -254,6 +252,7 @@ bool Tabs::onProcessMessage(Message* msg)
|
||||
return true;
|
||||
|
||||
case JM_DRAW: {
|
||||
SkinTheme* theme = static_cast<SkinTheme*>(this->getTheme());
|
||||
BITMAP *doublebuffer = create_bitmap(jrect_w(&msg->draw.rect),
|
||||
jrect_h(&msg->draw.rect));
|
||||
JRect rect = jwidget_get_rect(this);
|
||||
@ -264,7 +263,7 @@ bool Tabs::onProcessMessage(Message* msg)
|
||||
rect->x1-m_scrollX+2*jguiscale(),
|
||||
rect->y1+theme->get_part(PART_TAB_FILLER)->h);
|
||||
|
||||
clear_to_color(doublebuffer, theme->get_window_face_color());
|
||||
clear_to_color(doublebuffer, to_system(theme->getColor(ThemeColor::WindowFace)));
|
||||
|
||||
theme->draw_part_as_hline(doublebuffer, box->x1, box->y1, box->x2-1, box->y2-1, PART_TAB_FILLER);
|
||||
theme->draw_part_as_hline(doublebuffer, box->x1, box->y2, box->x2-1, rect->y2-1, PART_TAB_BOTTOM_NORMAL);
|
||||
@ -446,10 +445,10 @@ void Tabs::onInitTheme(InitThemeEvent& ev)
|
||||
{
|
||||
Widget::onInitTheme(ev);
|
||||
|
||||
SkinTheme* skinTheme = static_cast<SkinTheme*>(ev.getTheme());
|
||||
SkinTheme* theme = static_cast<SkinTheme*>(ev.getTheme());
|
||||
|
||||
m_button_left->setBgColor(skinTheme->get_tab_selected_face_color());
|
||||
m_button_right->setBgColor(skinTheme->get_tab_selected_face_color());
|
||||
m_button_left->setBgColor(theme->getColor(ThemeColor::TabSelectedFace));
|
||||
m_button_right->setBgColor(theme->getColor(ThemeColor::TabSelectedFace));
|
||||
}
|
||||
|
||||
void Tabs::onSetText()
|
||||
@ -476,25 +475,27 @@ void Tabs::drawTab(BITMAP* bmp, JRect box, Tab* tab, int y_delta, bool selected)
|
||||
return;
|
||||
|
||||
SkinTheme* theme = static_cast<SkinTheme*>(this->getTheme());
|
||||
int text_color;
|
||||
int face_color;
|
||||
ui::Color text_color;
|
||||
ui::Color face_color;
|
||||
|
||||
// Selected
|
||||
if (selected) {
|
||||
text_color = theme->get_tab_selected_text_color();
|
||||
face_color = theme->get_tab_selected_face_color();
|
||||
text_color = theme->getColor(ThemeColor::TabSelectedText);
|
||||
face_color = theme->getColor(ThemeColor::TabSelectedFace);
|
||||
}
|
||||
// Non-selected
|
||||
else {
|
||||
text_color = theme->get_tab_normal_text_color();
|
||||
face_color = theme->get_tab_normal_face_color();
|
||||
text_color = theme->getColor(ThemeColor::TabNormalText);
|
||||
face_color = theme->getColor(ThemeColor::TabNormalFace);
|
||||
}
|
||||
|
||||
if (jrect_w(box) > 2) {
|
||||
theme->draw_bounds_nw(bmp,
|
||||
box->x1, box->y1+y_delta, box->x2-1, box->y2-1,
|
||||
(selected) ? PART_TAB_SELECTED_NW:
|
||||
PART_TAB_NORMAL_NW, face_color);
|
||||
PART_TAB_NORMAL_NW,
|
||||
face_color);
|
||||
|
||||
jdraw_text(bmp, this->getFont(), tab->text.c_str(),
|
||||
box->x1+4*jguiscale(),
|
||||
(box->y1+box->y2)/2-text_height(this->getFont())/2+1 + y_delta,
|
||||
@ -505,7 +506,7 @@ void Tabs::drawTab(BITMAP* bmp, JRect box, Tab* tab, int y_delta, bool selected)
|
||||
theme->draw_bounds_nw(bmp,
|
||||
box->x1, box->y2, box->x2-1, this->rc->y2-1,
|
||||
PART_TAB_BOTTOM_SELECTED_NW,
|
||||
theme->get_tab_selected_face_color());
|
||||
theme->getColor(ThemeColor::TabSelectedFace));
|
||||
}
|
||||
else {
|
||||
theme->draw_part_as_hline(bmp,
|
||||
|
@ -128,27 +128,30 @@ bool ToolBar::onProcessMessage(Message* msg)
|
||||
BITMAP *doublebuffer = create_bitmap(jrect_w(&msg->draw.rect),
|
||||
jrect_h(&msg->draw.rect));
|
||||
SkinTheme* theme = static_cast<SkinTheme*>(this->getTheme());
|
||||
ui::Color normalFace = theme->getColor(ThemeColor::ButtonNormalFace);
|
||||
ui::Color hotFace = theme->getColor(ThemeColor::ButtonHotFace);
|
||||
ToolBox* toolbox = App::instance()->getToolBox();
|
||||
ToolGroupList::iterator it = toolbox->begin_group();
|
||||
int groups = toolbox->getGroupsCount();
|
||||
Rect toolrc;
|
||||
|
||||
clear_to_color(doublebuffer, theme->get_tab_selected_face_color());
|
||||
clear_to_color(doublebuffer, to_system(theme->getColor(ThemeColor::TabSelectedFace)));
|
||||
|
||||
for (int c=0; c<groups; ++c, ++it) {
|
||||
ToolGroup* tool_group = *it;
|
||||
Tool* tool = m_selected_in_group[tool_group];
|
||||
int face, nw;
|
||||
ui::Color face;
|
||||
int nw;
|
||||
|
||||
if (UIContext::instance()->getSettings()->getCurrentTool() == tool ||
|
||||
m_hot_index == c) {
|
||||
nw = PART_TOOLBUTTON_HOT_NW;
|
||||
face = theme->get_button_hot_face_color();
|
||||
face = hotFace;
|
||||
}
|
||||
else {
|
||||
nw = c >= 0 && c < groups-1 ? PART_TOOLBUTTON_NORMAL_NW:
|
||||
PART_TOOLBUTTON_LAST_NW;
|
||||
face = theme->get_button_normal_face_color();
|
||||
face = normalFace;
|
||||
}
|
||||
|
||||
toolrc = getToolGroupBounds(c);
|
||||
@ -173,8 +176,7 @@ bool ToolBar::onProcessMessage(Message* msg)
|
||||
toolrc,
|
||||
isHot ? PART_TOOLBUTTON_HOT_NW:
|
||||
PART_TOOLBUTTON_LAST_NW,
|
||||
isHot ? theme->get_button_hot_face_color():
|
||||
theme->get_button_normal_face_color());
|
||||
isHot ? hotFace: normalFace);
|
||||
|
||||
BITMAP* icon = theme->get_toolicon("configuration");
|
||||
if (icon) {
|
||||
@ -193,8 +195,7 @@ bool ToolBar::onProcessMessage(Message* msg)
|
||||
toolrc,
|
||||
isHot ? PART_TOOLBUTTON_HOT_NW:
|
||||
PART_TOOLBUTTON_LAST_NW,
|
||||
isHot ? theme->get_button_hot_face_color():
|
||||
theme->get_button_normal_face_color());
|
||||
isHot ? hotFace: normalFace);
|
||||
|
||||
icon = theme->get_toolicon("minieditor");
|
||||
if (icon) {
|
||||
@ -622,16 +623,17 @@ bool ToolStrip::onProcessMessage(Message* msg)
|
||||
for (ToolIterator it = toolbox->begin(); it != toolbox->end(); ++it) {
|
||||
Tool* tool = *it;
|
||||
if (tool->getGroup() == m_group) {
|
||||
int face, nw;
|
||||
ui::Color face;
|
||||
int nw;
|
||||
|
||||
if (UIContext::instance()->getSettings()->getCurrentTool() == tool ||
|
||||
m_hot_tool == tool) {
|
||||
nw = PART_TOOLBUTTON_HOT_NW;
|
||||
face = theme->get_button_hot_face_color();
|
||||
face = theme->getColor(ThemeColor::ButtonHotFace);
|
||||
}
|
||||
else {
|
||||
nw = PART_TOOLBUTTON_LAST_NW;
|
||||
face = theme->get_button_normal_face_color();
|
||||
face = theme->getColor(ThemeColor::ButtonNormalFace);
|
||||
}
|
||||
|
||||
toolrc = getToolBounds(index++);
|
||||
|
Loading…
x
Reference in New Issue
Block a user