mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-01 01:13:40 +00:00
Improve palette editor's RGB/HSV sliders.
+ Added SkinSliderProperty and ISliderBgPainter to draw a customized background in sliders. + Moved SkinTheme to src/skin/ directory.
This commit is contained in:
parent
18db7513a8
commit
58b2c1bcd0
5
TODO.txt
5
TODO.txt
@ -1,8 +1,9 @@
|
||||
For next release
|
||||
----------------
|
||||
|
||||
+ Mini-look for sliders in palette editor (add ISliderBackground to draw RGB/HSV sliders
|
||||
with a customized background).
|
||||
+ Add Widget::setDoubleBuffered(bool) to double-buffer some widgets
|
||||
when ji_screen==real screen (palette editor sliders must contain
|
||||
this attribute on).
|
||||
+ Fix palette editor to avoid generating a lot of consecutive Undo actions.
|
||||
+ Move "effect/images_ref" to "raster" and refactor it to a class.
|
||||
+ Convert jaccel::key_list to std::vector<>
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.7 KiB |
@ -87,6 +87,8 @@
|
||||
<part id="mini_slider_empty" x="48" y="144" w1="5" w2="6" w3="5" h1="5" h2="5" h3="6" />
|
||||
<part id="mini_slider_full_focused" x="32" y="160" w1="5" w2="6" w3="5" h1="5" h2="5" h3="6" />
|
||||
<part id="mini_slider_empty_focused" x="48" y="160" w1="5" w2="6" w3="5" h1="5" h2="5" h3="6" />
|
||||
<part id="mini_slider_thumb" x="32" y="176" w="5" h="6" />
|
||||
<part id="mini_slider_thumb_focused" x="48" y="176" w="5" h="6" />
|
||||
<part id="separator_horz" x="32" y="80" w="9" h="5" />
|
||||
<part id="separator_vert" x="32" y="96" w="5" h="9" />
|
||||
<part id="combobox_arrow" x="96" y="32" w="16" h="16" />
|
||||
|
@ -79,7 +79,6 @@ add_library(aseprite-library
|
||||
log.cpp
|
||||
recent_files.cpp
|
||||
resource_finder.cpp
|
||||
skin_theme.cpp
|
||||
ui_context.cpp
|
||||
undoable.cpp
|
||||
xml_exception.cpp
|
||||
@ -214,6 +213,9 @@ add_library(aseprite-library
|
||||
raster/stock.cpp
|
||||
raster/undo.cpp
|
||||
settings/ui_settings_impl.cpp
|
||||
skin/skin_theme.cpp
|
||||
skin/skin_property.cpp
|
||||
skin/skin_slider_property.cpp
|
||||
tools/tool.cpp
|
||||
tools/toolbox.cpp
|
||||
util/autocrop.cpp
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
#include "app.h"
|
||||
#include "app/color.h"
|
||||
#include "app/color_utils.h"
|
||||
#include "base/bind.h"
|
||||
#include "commands/command.h"
|
||||
#include "commands/params.h"
|
||||
@ -44,6 +45,7 @@
|
||||
#include "raster/sprite.h"
|
||||
#include "raster/stock.h"
|
||||
#include "raster/undo.h"
|
||||
#include "skin/skin_slider_property.h"
|
||||
#include "sprite_wrappers.h"
|
||||
#include "ui_context.h"
|
||||
#include "widgets/color_bar.h"
|
||||
@ -69,6 +71,68 @@ static void on_exit_delete_this_widget()
|
||||
jwidget_free(window);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
// This class is used as property for RGB/HSV sliders to draw the
|
||||
// background of them.
|
||||
class ColorSliderBgPainter : public ISliderBgPainter
|
||||
{
|
||||
public:
|
||||
enum Channel {
|
||||
Red, Green, Blue,
|
||||
Hue, Saturation, Value
|
||||
};
|
||||
|
||||
ColorSliderBgPainter(Channel channel)
|
||||
: m_channel(channel)
|
||||
{ }
|
||||
|
||||
void setColor(const Color& color) {
|
||||
m_color = color;
|
||||
}
|
||||
|
||||
void paint(Slider* slider, BITMAP* bmp, const gfx::Rect& rc) {
|
||||
int depth = bitmap_color_depth(bmp);
|
||||
BITMAP* bg = create_bitmap_ex(depth, rc.w, rc.h);
|
||||
|
||||
int color;
|
||||
for (int x=0; x < rc.w; ++x) {
|
||||
switch (m_channel) {
|
||||
case Red:
|
||||
color = makecol(255 * x / (rc.w-1), m_color.getGreen(), m_color.getBlue());
|
||||
break;
|
||||
case Green:
|
||||
color = makecol(m_color.getRed(), 255 * x / (rc.w-1), m_color.getBlue());
|
||||
break;
|
||||
case Blue:
|
||||
color = makecol(m_color.getRed(), m_color.getGreen(), 255 * x / (rc.w-1));
|
||||
break;
|
||||
case Hue:
|
||||
color = color_utils::color_for_allegro(Color::fromHsv(360 * x / (rc.w-1), m_color.getSaturation(), m_color.getValue()), depth);
|
||||
break;
|
||||
case Saturation:
|
||||
color = color_utils::color_for_allegro(Color::fromHsv(m_color.getHue(), 100 * x / (rc.w-1), m_color.getValue()), depth);
|
||||
break;
|
||||
case Value:
|
||||
color = color_utils::color_for_allegro(Color::fromHsv(m_color.getHue(), m_color.getSaturation(), 100 * x / (rc.w-1)), depth);
|
||||
break;
|
||||
}
|
||||
|
||||
vline(bg, x, 0, rc.h-1, color);
|
||||
}
|
||||
|
||||
blit(bg, bmp, 0, 0, rc.x, rc.y, rc.w, rc.h);
|
||||
destroy_bitmap(bg);
|
||||
}
|
||||
|
||||
private:
|
||||
Channel m_channel;
|
||||
BITMAP* m_cachedBg;
|
||||
Color m_color;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// palette_editor
|
||||
|
||||
@ -118,6 +182,8 @@ static bool hex_entry_change_hook(JWidget widget, void *data);
|
||||
static void update_entries_from_sliders();
|
||||
static void update_sliders_from_entries();
|
||||
static void update_hex_entry();
|
||||
static void update_slider_bgcolor(Slider* slider, const Color& color);
|
||||
static void update_slider_bgcolors();
|
||||
static void update_current_sprite_palette(const char* operationName);
|
||||
static void update_colorbar();
|
||||
static bool palette_editor_change_hook(JWidget widget, void *data);
|
||||
@ -241,6 +307,14 @@ void PaletteEditorCommand::onExecute(Context* context)
|
||||
|
||||
// Set palette editor columns
|
||||
palette_editor->setColumns(16);
|
||||
|
||||
// Setup slider bg painters
|
||||
R_slider->setProperty(PropertyPtr(new SkinSliderProperty(new ColorSliderBgPainter(ColorSliderBgPainter::Red))));
|
||||
G_slider->setProperty(PropertyPtr(new SkinSliderProperty(new ColorSliderBgPainter(ColorSliderBgPainter::Green))));
|
||||
B_slider->setProperty(PropertyPtr(new SkinSliderProperty(new ColorSliderBgPainter(ColorSliderBgPainter::Blue))));
|
||||
H_slider->setProperty(PropertyPtr(new SkinSliderProperty(new ColorSliderBgPainter(ColorSliderBgPainter::Hue))));
|
||||
S_slider->setProperty(PropertyPtr(new SkinSliderProperty(new ColorSliderBgPainter(ColorSliderBgPainter::Saturation))));
|
||||
V_slider->setProperty(PropertyPtr(new SkinSliderProperty(new ColorSliderBgPainter(ColorSliderBgPainter::Value))));
|
||||
|
||||
// Hook signals
|
||||
jwidget_add_hook(window, -1, window_msg_proc, NULL);
|
||||
@ -747,6 +821,7 @@ static void sliderRGB_change_hook(Slider* widget)
|
||||
|
||||
update_entries_from_sliders();
|
||||
update_hex_entry();
|
||||
update_slider_bgcolors();
|
||||
update_current_sprite_palette("Color Change");
|
||||
update_colorbar();
|
||||
}
|
||||
@ -771,6 +846,7 @@ static void sliderHSV_change_hook(Slider* widget)
|
||||
|
||||
update_entries_from_sliders();
|
||||
update_hex_entry();
|
||||
update_slider_bgcolors();
|
||||
update_current_sprite_palette("Color Change");
|
||||
update_colorbar();
|
||||
}
|
||||
@ -798,6 +874,7 @@ static bool entryRGB_change_hook(JWidget widget, void *data)
|
||||
|
||||
update_sliders_from_entries();
|
||||
update_hex_entry();
|
||||
update_slider_bgcolors();
|
||||
update_current_sprite_palette("Color Change");
|
||||
update_colorbar();
|
||||
return false;
|
||||
@ -826,6 +903,7 @@ static bool entryHSV_change_hook(JWidget widget, void *data)
|
||||
|
||||
update_sliders_from_entries();
|
||||
update_hex_entry();
|
||||
update_slider_bgcolors();
|
||||
update_current_sprite_palette("Color Change");
|
||||
update_colorbar();
|
||||
return false;
|
||||
@ -864,6 +942,7 @@ static bool hex_entry_change_hook(JWidget widget, void *data)
|
||||
S_slider->setValue(hsv.valueInt());
|
||||
|
||||
update_entries_from_sliders();
|
||||
update_slider_bgcolors();
|
||||
update_current_sprite_palette("Color Change");
|
||||
update_colorbar();
|
||||
return false;
|
||||
@ -899,6 +978,29 @@ static void update_hex_entry()
|
||||
B_slider->getValue());
|
||||
}
|
||||
|
||||
static void update_slider_bgcolor(Slider* slider, const Color& color)
|
||||
{
|
||||
SharedPtr<SkinSliderProperty> sliderProperty(slider->getProperty("SkinProperty"));
|
||||
|
||||
static_cast<ColorSliderBgPainter*>(sliderProperty->getBgPainter())->setColor(color);
|
||||
|
||||
slider->invalidate();
|
||||
}
|
||||
|
||||
static void update_slider_bgcolors()
|
||||
{
|
||||
Color color(Color::fromRgb(R_slider->getValue(),
|
||||
G_slider->getValue(),
|
||||
B_slider->getValue()));
|
||||
|
||||
update_slider_bgcolor(R_slider, color);
|
||||
update_slider_bgcolor(G_slider, color);
|
||||
update_slider_bgcolor(B_slider, color);
|
||||
update_slider_bgcolor(H_slider, color);
|
||||
update_slider_bgcolor(S_slider, color);
|
||||
update_slider_bgcolor(V_slider, color);
|
||||
}
|
||||
|
||||
static void update_current_sprite_palette(const char* operationName)
|
||||
{
|
||||
if (UIContext::instance()->getCurrentSprite()) {
|
||||
@ -970,6 +1072,7 @@ static bool palette_editor_change_hook(JWidget widget, void *data)
|
||||
update_sliders_from_color(color); // Update sliders
|
||||
update_entries_from_sliders(); // Update entries
|
||||
update_hex_entry(); // Update hex field
|
||||
update_slider_bgcolors();
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1145,6 +1248,7 @@ static void on_color_changed(const Color& color)
|
||||
update_sliders_from_color(color); // Update sliders
|
||||
update_entries_from_sliders(); // Update entries
|
||||
update_hex_entry(); // Update hex field
|
||||
update_slider_bgcolors();
|
||||
|
||||
jwidget_flush_redraw(window);
|
||||
}
|
||||
|
@ -30,7 +30,7 @@
|
||||
|
||||
#include "app.h"
|
||||
#include "commands/command.h"
|
||||
#include "skin_theme.h"
|
||||
#include "skin/skin_theme.h"
|
||||
#include "sprite_wrappers.h"
|
||||
#include "widgets/statebar.h"
|
||||
|
||||
|
@ -32,7 +32,7 @@
|
||||
#include "modules/gui.h"
|
||||
#include "modules/rootmenu.h"
|
||||
#include "raster/raster.h"
|
||||
#include "skin_theme.h"
|
||||
#include "skin/skin_theme.h"
|
||||
#include "sprite_wrappers.h"
|
||||
#include "ui_context.h"
|
||||
#include "undoable.h"
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include "gui/jview.h"
|
||||
#include "gui/label.h"
|
||||
#include "gui/popup_frame.h"
|
||||
#include "gui/property.h"
|
||||
#include "gui/slider.h"
|
||||
#include "gui/theme.h"
|
||||
#include "gui/widget.h"
|
||||
|
@ -38,7 +38,7 @@
|
||||
#include "raster/blend.h"
|
||||
#include "raster/image.h"
|
||||
#include "raster/palette.h"
|
||||
#include "skin_theme.h"
|
||||
#include "skin/skin_theme.h"
|
||||
#include "widgets/editor.h"
|
||||
|
||||
static BITMAP* gfx_bmps[GFX_BITMAP_COUNT];
|
||||
|
@ -46,7 +46,8 @@
|
||||
#include "modules/rootmenu.h"
|
||||
#include "raster/sprite.h"
|
||||
#include "resource_finder.h"
|
||||
#include "skin_theme.h"
|
||||
#include "skin/skin_property.h"
|
||||
#include "skin/skin_theme.h"
|
||||
#include "sprite_wrappers.h"
|
||||
#include "tools/toolbox.h"
|
||||
#include "ui_context.h"
|
||||
|
87
src/skin/skin_property.cpp
Normal file
87
src/skin/skin_property.cpp
Normal file
@ -0,0 +1,87 @@
|
||||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2011 David Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "skin/skin_property.h"
|
||||
|
||||
const char* SkinProperty::SkinPropertyName = "SkinProperty";
|
||||
|
||||
SkinProperty::SkinProperty()
|
||||
: Property(SkinPropertyName)
|
||||
{
|
||||
m_isMiniLook = false;
|
||||
m_upperLeft = 0;
|
||||
m_upperRight = 0;
|
||||
m_lowerLeft = 0;
|
||||
m_lowerRight = 0;
|
||||
}
|
||||
|
||||
SkinProperty::~SkinProperty()
|
||||
{
|
||||
}
|
||||
|
||||
bool SkinProperty::isMiniLook() const
|
||||
{
|
||||
return m_isMiniLook;
|
||||
}
|
||||
|
||||
void SkinProperty::setMiniLook(bool state)
|
||||
{
|
||||
m_isMiniLook = state;
|
||||
}
|
||||
|
||||
int SkinProperty::getUpperLeft() const
|
||||
{
|
||||
return m_upperLeft;
|
||||
}
|
||||
|
||||
int SkinProperty::getUpperRight() const
|
||||
{
|
||||
return m_upperRight;
|
||||
}
|
||||
|
||||
int SkinProperty::getLowerLeft() const
|
||||
{
|
||||
return m_lowerLeft;
|
||||
}
|
||||
|
||||
int SkinProperty::getLowerRight() const
|
||||
{
|
||||
return m_lowerRight;
|
||||
}
|
||||
|
||||
void SkinProperty::setUpperLeft(int value)
|
||||
{
|
||||
m_upperLeft = value;
|
||||
}
|
||||
|
||||
void SkinProperty::setUpperRight(int value)
|
||||
{
|
||||
m_upperRight = value;
|
||||
}
|
||||
|
||||
void SkinProperty::setLowerLeft(int value)
|
||||
{
|
||||
m_lowerLeft = value;
|
||||
}
|
||||
|
||||
void SkinProperty::setLowerRight(int value)
|
||||
{
|
||||
m_lowerRight = value;
|
||||
}
|
54
src/skin/skin_property.h
Normal file
54
src/skin/skin_property.h
Normal file
@ -0,0 +1,54 @@
|
||||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2011 David Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef SKIN_PROPERTY_H_INCLUDED
|
||||
#define SKIN_PROPERTY_H_INCLUDED
|
||||
|
||||
#include "gui/property.h"
|
||||
|
||||
// Property to show widgets with a special look (e.g.: buttons or sliders with mini-borders)
|
||||
class SkinProperty : public Property
|
||||
{
|
||||
public:
|
||||
static const char* SkinPropertyName;
|
||||
|
||||
SkinProperty();
|
||||
~SkinProperty();
|
||||
|
||||
bool isMiniLook() const;
|
||||
void setMiniLook(bool state);
|
||||
|
||||
int getUpperLeft() const;
|
||||
int getUpperRight() const;
|
||||
int getLowerLeft() const;
|
||||
int getLowerRight() const;
|
||||
|
||||
void setUpperLeft(int value);
|
||||
void setUpperRight(int value);
|
||||
void setLowerLeft(int value);
|
||||
void setLowerRight(int value);
|
||||
|
||||
private:
|
||||
bool m_isMiniLook;
|
||||
int m_upperLeft;
|
||||
int m_upperRight;
|
||||
int m_lowerLeft;
|
||||
int m_lowerRight;
|
||||
};
|
||||
|
||||
#endif
|
37
src/skin/skin_slider_property.cpp
Normal file
37
src/skin/skin_slider_property.cpp
Normal file
@ -0,0 +1,37 @@
|
||||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2011 David Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "skin/skin_slider_property.h"
|
||||
|
||||
SkinSliderProperty::SkinSliderProperty(ISliderBgPainter* painter)
|
||||
: m_painter(painter)
|
||||
{
|
||||
}
|
||||
|
||||
SkinSliderProperty::~SkinSliderProperty()
|
||||
{
|
||||
delete m_painter;
|
||||
}
|
||||
|
||||
ISliderBgPainter* SkinSliderProperty::getBgPainter() const
|
||||
{
|
||||
return m_painter;
|
||||
}
|
||||
|
50
src/skin/skin_slider_property.h
Normal file
50
src/skin/skin_slider_property.h
Normal file
@ -0,0 +1,50 @@
|
||||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2011 David Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef SKIN_SLIDER_PROPERTY_H_INCLUDED
|
||||
#define SKIN_SLIDER_PROPERTY_H_INCLUDED
|
||||
|
||||
#include "skin/skin_property.h"
|
||||
|
||||
// Forward declaration for gfx::Rect
|
||||
namespace gfx { class Rect; }
|
||||
|
||||
class Slider;
|
||||
struct BITMAP;
|
||||
|
||||
class ISliderBgPainter
|
||||
{
|
||||
public:
|
||||
virtual void paint(Slider* slider, BITMAP* bmp, const gfx::Rect& rc) = 0;
|
||||
};
|
||||
|
||||
class SkinSliderProperty : public SkinProperty
|
||||
{
|
||||
public:
|
||||
// The given painter is deleted automatically when this
|
||||
// property the destroyed.
|
||||
SkinSliderProperty(ISliderBgPainter* painter);
|
||||
~SkinSliderProperty();
|
||||
|
||||
ISliderBgPainter* getBgPainter() const;
|
||||
|
||||
private:
|
||||
ISliderBgPainter* m_painter;
|
||||
};
|
||||
|
||||
#endif
|
@ -23,12 +23,15 @@
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "base/shared_ptr.h"
|
||||
#include "gfx/rect.h"
|
||||
#include "gui/jinete.h"
|
||||
#include "gui/jintern.h"
|
||||
#include "loadpng.h"
|
||||
#include "modules/gui.h"
|
||||
#include "resource_finder.h"
|
||||
#include "skin_theme.h"
|
||||
#include "skin/skin_property.h"
|
||||
#include "skin/skin_slider_property.h"
|
||||
#include "skin/skin_theme.h"
|
||||
#include "xml_exception.h"
|
||||
|
||||
#include "tinyxml.h"
|
||||
@ -110,6 +113,8 @@ SkinTheme::SkinTheme()
|
||||
sheet_mapping["mini_slider_empty"] = PART_MINI_SLIDER_EMPTY_NW;
|
||||
sheet_mapping["mini_slider_full_focused"] = PART_MINI_SLIDER_FULL_FOCUSED_NW;
|
||||
sheet_mapping["mini_slider_empty_focused"] = PART_MINI_SLIDER_EMPTY_FOCUSED_NW;
|
||||
sheet_mapping["mini_slider_thumb"] = PART_MINI_SLIDER_THUMB;
|
||||
sheet_mapping["mini_slider_thumb_focused"] = PART_MINI_SLIDER_THUMB_FOCUSED;
|
||||
sheet_mapping["separator_horz"] = PART_SEPARATOR_HORZ;
|
||||
sheet_mapping["separator_vert"] = PART_SEPARATOR_VERT;
|
||||
sheet_mapping["combobox_arrow"] = PART_COMBOBOX_ARROW;
|
||||
@ -1115,17 +1120,11 @@ void SkinTheme::draw_slider(Slider* widget, JRect clip)
|
||||
|
||||
widget->getSliderThemeInfo(&min, &max, &value);
|
||||
|
||||
// Tool buttons are smaller
|
||||
bool isMiniLook = false;
|
||||
SharedPtr<SkinProperty> skinPropery = widget->getProperty(SkinProperty::SkinPropertyName);
|
||||
if (skinPropery != NULL)
|
||||
isMiniLook = skinPropery->isMiniLook();
|
||||
|
||||
x1 = widget->rc->x1 + widget->border_width.l;
|
||||
y1 = widget->rc->y1 + widget->border_width.t;
|
||||
x2 = widget->rc->x2 - widget->border_width.r - 1;
|
||||
y2 = widget->rc->y2 - widget->border_width.b - 1;
|
||||
|
||||
|
||||
if (min != max)
|
||||
x = x1 + (x2-x1) * (value-min) / (max-min);
|
||||
else
|
||||
@ -1136,35 +1135,81 @@ void SkinTheme::draw_slider(Slider* widget, JRect clip)
|
||||
x2 = widget->rc->x2 - 1;
|
||||
y2 = widget->rc->y2 - 1;
|
||||
|
||||
int full_part_nw;
|
||||
int empty_part_nw;
|
||||
// The mini-look is used for sliders with tiny borders.
|
||||
bool isMiniLook = false;
|
||||
|
||||
if (isMiniLook) {
|
||||
full_part_nw = widget->hasMouseOver() ? PART_MINI_SLIDER_FULL_FOCUSED_NW:
|
||||
PART_MINI_SLIDER_FULL_NW;
|
||||
empty_part_nw = widget->hasMouseOver() ? PART_MINI_SLIDER_EMPTY_FOCUSED_NW:
|
||||
PART_MINI_SLIDER_EMPTY_NW;
|
||||
// The BG painter is used for sliders without a number-indicator and
|
||||
// customized background (e.g. RGB sliders)
|
||||
ISliderBgPainter* bgPainter = NULL;
|
||||
|
||||
SharedPtr<SkinProperty> skinPropery = widget->getProperty(SkinProperty::SkinPropertyName);
|
||||
if (skinPropery != NULL)
|
||||
isMiniLook = skinPropery->isMiniLook();
|
||||
|
||||
if (SkinSliderProperty* sliderProperty = dynamic_cast<SkinSliderProperty*>(skinPropery.get()))
|
||||
bgPainter = sliderProperty->getBgPainter();
|
||||
|
||||
// Draw customized background
|
||||
if (bgPainter) {
|
||||
int nw = PART_MINI_SLIDER_EMPTY_NW;
|
||||
BITMAP* thumb = widget->hasFocus() ? m_part[PART_MINI_SLIDER_THUMB_FOCUSED]:
|
||||
m_part[PART_MINI_SLIDER_THUMB];
|
||||
|
||||
// Draw background
|
||||
rectfill(ji_screen, x1, y1, x2, y2, BGCOLOR);
|
||||
|
||||
// Draw thumb
|
||||
set_alpha_blender();
|
||||
draw_trans_sprite(ji_screen, thumb, x-thumb->w/2, y1+1);
|
||||
|
||||
// Draw borders
|
||||
x1 += 3 * jguiscale();
|
||||
y1 += thumb->h + jguiscale();
|
||||
x2 -= 3 * jguiscale();
|
||||
y2 -= 1 * jguiscale();
|
||||
|
||||
draw_bounds_nw(ji_screen, x1, y1, x2, y2, nw, -1);
|
||||
|
||||
// Draw background
|
||||
x1 += 1 * jguiscale();
|
||||
y1 += 1 * jguiscale();
|
||||
x2 -= 1 * jguiscale();
|
||||
y2 -= 2 * jguiscale();
|
||||
|
||||
gfx::Rect rc(x1, y1, x2-x1+1, y2-y1+1);
|
||||
if (rc.w > 0 && rc.h > 0)
|
||||
bgPainter->paint(widget, ji_screen, rc);
|
||||
}
|
||||
else {
|
||||
full_part_nw = widget->hasFocus() ? PART_SLIDER_FULL_FOCUSED_NW:
|
||||
PART_SLIDER_FULL_NW;
|
||||
empty_part_nw = widget->hasFocus() ? PART_SLIDER_EMPTY_FOCUSED_NW:
|
||||
PART_SLIDER_EMPTY_NW;
|
||||
}
|
||||
// Draw borders
|
||||
int full_part_nw;
|
||||
int empty_part_nw;
|
||||
|
||||
if (value == min)
|
||||
draw_bounds_nw(ji_screen, x1, y1, x2, y2, empty_part_nw, get_slider_empty_face_color());
|
||||
else if (value == max)
|
||||
draw_bounds_nw(ji_screen, x1, y1, x2, y2, full_part_nw, get_slider_full_face_color());
|
||||
else
|
||||
draw_bounds_nw2(ji_screen,
|
||||
x1, y1, x2, y2, x,
|
||||
full_part_nw, empty_part_nw,
|
||||
get_slider_full_face_color(),
|
||||
get_slider_empty_face_color());
|
||||
if (isMiniLook) {
|
||||
full_part_nw = widget->hasMouseOver() ? PART_MINI_SLIDER_FULL_FOCUSED_NW:
|
||||
PART_MINI_SLIDER_FULL_NW;
|
||||
empty_part_nw = widget->hasMouseOver() ? PART_MINI_SLIDER_EMPTY_FOCUSED_NW:
|
||||
PART_MINI_SLIDER_EMPTY_NW;
|
||||
}
|
||||
else {
|
||||
full_part_nw = widget->hasFocus() ? PART_SLIDER_FULL_FOCUSED_NW:
|
||||
PART_SLIDER_FULL_NW;
|
||||
empty_part_nw = widget->hasFocus() ? PART_SLIDER_EMPTY_FOCUSED_NW:
|
||||
PART_SLIDER_EMPTY_NW;
|
||||
}
|
||||
|
||||
/* text */
|
||||
{
|
||||
if (value == min)
|
||||
draw_bounds_nw(ji_screen, x1, y1, x2, y2, empty_part_nw, get_slider_empty_face_color());
|
||||
else if (value == max)
|
||||
draw_bounds_nw(ji_screen, x1, y1, x2, y2, full_part_nw, get_slider_full_face_color());
|
||||
else
|
||||
draw_bounds_nw2(ji_screen,
|
||||
x1, y1, x2, y2, x,
|
||||
full_part_nw, empty_part_nw,
|
||||
get_slider_full_face_color(),
|
||||
get_slider_empty_face_color());
|
||||
|
||||
// Draw text
|
||||
std::string old_text = widget->getText();
|
||||
JRect r;
|
||||
int cx1, cy1, cx2, cy2;
|
||||
@ -1750,71 +1795,3 @@ bool SkinTheme::theme_frame_button_msg_proc(JWidget widget, JMessage msg)
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
const char* SkinProperty::SkinPropertyName = "SkinProperty";
|
||||
|
||||
SkinProperty::SkinProperty()
|
||||
: Property(SkinPropertyName)
|
||||
{
|
||||
m_isMiniLook = false;
|
||||
m_upperLeft = 0;
|
||||
m_upperRight = 0;
|
||||
m_lowerLeft = 0;
|
||||
m_lowerRight = 0;
|
||||
}
|
||||
|
||||
SkinProperty::~SkinProperty()
|
||||
{
|
||||
}
|
||||
|
||||
bool SkinProperty::isMiniLook() const
|
||||
{
|
||||
return m_isMiniLook;
|
||||
}
|
||||
|
||||
void SkinProperty::setMiniLook(bool state)
|
||||
{
|
||||
m_isMiniLook = state;
|
||||
}
|
||||
|
||||
int SkinProperty::getUpperLeft() const
|
||||
{
|
||||
return m_upperLeft;
|
||||
}
|
||||
|
||||
int SkinProperty::getUpperRight() const
|
||||
{
|
||||
return m_upperRight;
|
||||
}
|
||||
|
||||
int SkinProperty::getLowerLeft() const
|
||||
{
|
||||
return m_lowerLeft;
|
||||
}
|
||||
|
||||
int SkinProperty::getLowerRight() const
|
||||
{
|
||||
return m_lowerRight;
|
||||
}
|
||||
|
||||
void SkinProperty::setUpperLeft(int value)
|
||||
{
|
||||
m_upperLeft = value;
|
||||
}
|
||||
|
||||
void SkinProperty::setUpperRight(int value)
|
||||
{
|
||||
m_upperRight = value;
|
||||
}
|
||||
|
||||
void SkinProperty::setLowerLeft(int value)
|
||||
{
|
||||
m_lowerLeft = value;
|
||||
}
|
||||
|
||||
void SkinProperty::setLowerRight(int value)
|
||||
{
|
||||
m_lowerRight = value;
|
||||
}
|
@ -25,39 +25,8 @@
|
||||
|
||||
#include "gfx/rect.h"
|
||||
#include "gui/jrect.h"
|
||||
#include "gui/property.h"
|
||||
#include "gui/theme.h"
|
||||
|
||||
// Property to show widgets with a special look (e.g.: buttons or sliders with mini-borders)
|
||||
class SkinProperty : public Property
|
||||
{
|
||||
public:
|
||||
static const char* SkinPropertyName;
|
||||
|
||||
SkinProperty();
|
||||
~SkinProperty();
|
||||
|
||||
bool isMiniLook() const;
|
||||
void setMiniLook(bool state);
|
||||
|
||||
int getUpperLeft() const;
|
||||
int getUpperRight() const;
|
||||
int getLowerLeft() const;
|
||||
int getLowerRight() const;
|
||||
|
||||
void setUpperLeft(int value);
|
||||
void setUpperRight(int value);
|
||||
void setLowerLeft(int value);
|
||||
void setLowerRight(int value);
|
||||
|
||||
private:
|
||||
bool m_isMiniLook;
|
||||
int m_upperLeft;
|
||||
int m_upperRight;
|
||||
int m_lowerLeft;
|
||||
int m_lowerRight;
|
||||
};
|
||||
|
||||
// Available parts in the skin sheet
|
||||
enum {
|
||||
|
||||
@ -253,6 +222,9 @@ enum {
|
||||
PART_MINI_SLIDER_EMPTY_FOCUSED_SW,
|
||||
PART_MINI_SLIDER_EMPTY_FOCUSED_W,
|
||||
|
||||
PART_MINI_SLIDER_THUMB,
|
||||
PART_MINI_SLIDER_THUMB_FOCUSED,
|
||||
|
||||
PART_SEPARATOR_HORZ,
|
||||
PART_SEPARATOR_VERT,
|
||||
|
@ -38,7 +38,7 @@
|
||||
#include "raster/palette.h"
|
||||
#include "raster/sprite.h"
|
||||
#include "raster/undo.h"
|
||||
#include "skin_theme.h"
|
||||
#include "skin/skin_theme.h"
|
||||
#include "sprite_wrappers.h"
|
||||
#include "ui_context.h"
|
||||
#include "widgets/color_bar.h"
|
||||
|
@ -36,7 +36,7 @@
|
||||
#include "modules/palettes.h"
|
||||
#include "raster/raster.h"
|
||||
#include "settings/settings.h"
|
||||
#include "skin_theme.h"
|
||||
#include "skin/skin_theme.h"
|
||||
#include "sprite_wrappers.h"
|
||||
#include "tools/tool.h"
|
||||
#include "ui_context.h"
|
||||
|
@ -38,7 +38,7 @@
|
||||
#include "raster/layer.h"
|
||||
#include "raster/sprite.h"
|
||||
#include "raster/undo.h"
|
||||
#include "skin_theme.h"
|
||||
#include "skin/skin_theme.h"
|
||||
#include "sprite_wrappers.h"
|
||||
#include "tools/tool.h"
|
||||
#include "ui_context.h"
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include "gui/jintern.h"
|
||||
#include "modules/gfx.h"
|
||||
#include "modules/gui.h"
|
||||
#include "skin_theme.h"
|
||||
#include "skin/skin_theme.h"
|
||||
#include "widgets/tabs.h"
|
||||
|
||||
#define ARROW_W (12*jguiscale())
|
||||
|
@ -31,7 +31,7 @@
|
||||
#include "gui/jinete.h"
|
||||
#include "modules/gfx.h"
|
||||
#include "modules/gui.h"
|
||||
#include "skin_theme.h"
|
||||
#include "skin/skin_theme.h"
|
||||
#include "tools/toolbox.h"
|
||||
#include "ui_context.h"
|
||||
#include "widgets/groupbut.h"
|
||||
|
Loading…
x
Reference in New Issue
Block a user