2015-02-12 23:16:25 +08:00
|
|
|
// Aseprite
|
2017-02-07 04:58:55 +08:00
|
|
|
// Copyright (C) 2001-2017 David Capello
|
2015-02-12 23:16:25 +08:00
|
|
|
//
|
2016-08-27 04:02:58 +08:00
|
|
|
// This program is distributed under the terms of
|
|
|
|
// the End-User License Agreement for Aseprite.
|
2009-11-22 04:02:31 +08:00
|
|
|
|
2013-08-06 08:20:19 +08:00
|
|
|
#ifdef HAVE_CONFIG_H
|
2010-03-08 00:21:24 +08:00
|
|
|
#include "config.h"
|
2013-08-06 08:20:19 +08:00
|
|
|
#endif
|
2010-03-08 00:21:24 +08:00
|
|
|
|
2016-10-27 21:44:31 +08:00
|
|
|
#include "app/console.h"
|
2013-08-06 08:20:19 +08:00
|
|
|
#include "app/modules/gui.h"
|
2015-09-18 22:56:45 +08:00
|
|
|
#include "app/pref/preferences.h"
|
2013-08-06 08:20:19 +08:00
|
|
|
#include "app/resource_finder.h"
|
2014-10-29 22:58:03 +08:00
|
|
|
#include "app/ui/app_menuitem.h"
|
|
|
|
#include "app/ui/keyboard_shortcuts.h"
|
2013-08-06 08:20:19 +08:00
|
|
|
#include "app/ui/skin/button_icon_impl.h"
|
|
|
|
#include "app/ui/skin/skin_property.h"
|
|
|
|
#include "app/ui/skin/skin_slider_property.h"
|
2015-02-26 20:53:19 +08:00
|
|
|
#include "app/ui/skin/skin_style_property.h"
|
2013-08-06 08:20:19 +08:00
|
|
|
#include "app/ui/skin/skin_theme.h"
|
2013-12-11 11:34:16 +08:00
|
|
|
#include "app/ui/skin/style.h"
|
|
|
|
#include "app/ui/skin/style_sheet.h"
|
2013-10-15 06:58:11 +08:00
|
|
|
#include "app/xml_document.h"
|
2013-08-06 08:20:19 +08:00
|
|
|
#include "app/xml_exception.h"
|
2010-09-26 04:20:59 +08:00
|
|
|
#include "base/bind.h"
|
2013-10-15 06:58:11 +08:00
|
|
|
#include "base/fs.h"
|
2010-09-30 04:14:11 +08:00
|
|
|
#include "base/shared_ptr.h"
|
2014-09-21 22:59:39 +08:00
|
|
|
#include "base/string.h"
|
2013-12-11 11:34:16 +08:00
|
|
|
#include "css/sheet.h"
|
2011-02-05 23:03:22 +08:00
|
|
|
#include "gfx/border.h"
|
|
|
|
#include "gfx/point.h"
|
2011-01-24 11:03:38 +08:00
|
|
|
#include "gfx/rect.h"
|
2011-02-05 23:03:22 +08:00
|
|
|
#include "gfx/size.h"
|
2017-02-07 04:58:55 +08:00
|
|
|
#include "she/draw_text.h"
|
2014-06-23 05:53:14 +08:00
|
|
|
#include "she/font.h"
|
|
|
|
#include "she/surface.h"
|
2012-08-11 10:14:54 +08:00
|
|
|
#include "she/system.h"
|
2012-06-18 09:49:58 +08:00
|
|
|
#include "ui/intern.h"
|
2013-08-06 08:20:19 +08:00
|
|
|
#include "ui/ui.h"
|
2009-11-22 04:02:31 +08:00
|
|
|
|
- All tools stuff refactored in various files/components.
- Added classes: IToolLoop, Tool, ToolGroup, ToolInk, ToolController, ToolPointShape, ToolIntertwine, ToolBox, etc.
- Added ToolLoopManager.
- Removed old src/modules/tools.cpp.
- Added ISettings and UISettingsImpl, adding the tools settings (onion skinning, grid, tiled mode, etc.).
- Added App::PenSizeBeforeChange, PenSizeAfterChange, CurrentToolChange signals.
- Renamed Context::get_bg/fg_color to getBg/FgColor.
- Refactored Brush class to Pen and added PenType.
- Renamed tiled_t to TiledMode.
- get_config_rect now uses the new Rect class imported from Vaca instead of old jrect.
- Added default_skin.xml to load tool icons.
- Added pen preview in Editor::cursor stuff.
- Added Editor::decorators.
Note: This big patch is from some time ago. I did my best to pre-commit other small changes before this big one.
2010-03-08 03:47:45 +08:00
|
|
|
#include "tinyxml.h"
|
|
|
|
|
2013-01-07 01:45:43 +08:00
|
|
|
#define BGCOLOR (getWidgetBgColor(widget))
|
2009-11-22 04:02:31 +08:00
|
|
|
|
2013-08-06 08:20:19 +08:00
|
|
|
namespace app {
|
|
|
|
namespace skin {
|
|
|
|
|
|
|
|
using namespace gfx;
|
|
|
|
using namespace ui;
|
|
|
|
|
2012-06-16 10:37:59 +08:00
|
|
|
const char* SkinTheme::kThemeCloseButtonId = "theme_close_button";
|
|
|
|
|
|
|
|
// Controls the "X" button in a window to close it.
|
2013-08-06 08:20:19 +08:00
|
|
|
class WindowCloseButton : public Button {
|
2012-06-16 10:37:59 +08:00
|
|
|
public:
|
|
|
|
WindowCloseButton() : Button("") {
|
|
|
|
setup_bevels(this, 0, 0, 0, 0);
|
|
|
|
setDecorative(true);
|
|
|
|
setId(SkinTheme::kThemeCloseButtonId);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2016-12-02 02:15:16 +08:00
|
|
|
|
|
|
|
void onSizeHint(SizeHintEvent& ev) override {
|
|
|
|
ev.setSizeHint(SkinTheme::instance()->parts.windowCloseButtonNormal()->size());
|
|
|
|
}
|
|
|
|
|
2014-08-15 10:07:47 +08:00
|
|
|
void onClick(Event& ev) override {
|
2012-06-16 10:37:59 +08:00
|
|
|
Button::onClick(ev);
|
|
|
|
closeWindow();
|
|
|
|
}
|
|
|
|
|
2014-08-15 10:07:47 +08:00
|
|
|
void onPaint(PaintEvent& ev) override {
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
static_cast<SkinTheme*>(theme())->paintWindowButton(ev);
|
2013-05-21 07:40:18 +08:00
|
|
|
}
|
|
|
|
|
2014-08-15 10:07:47 +08:00
|
|
|
bool onProcessMessage(Message* msg) override {
|
2013-07-29 08:17:07 +08:00
|
|
|
switch (msg->type()) {
|
2012-06-16 10:37:59 +08:00
|
|
|
|
2013-04-05 08:53:29 +08:00
|
|
|
case kSetCursorMessage:
|
2014-11-26 08:30:56 +08:00
|
|
|
ui::set_mouse_cursor(kArrowCursor);
|
2012-06-16 10:37:59 +08:00
|
|
|
return true;
|
|
|
|
|
2013-04-05 08:53:29 +08:00
|
|
|
case kKeyDownMessage:
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
if (window()->isForeground() &&
|
2015-05-11 20:53:45 +08:00
|
|
|
static_cast<KeyMessage*>(msg)->scancode() == kKeyEsc) {
|
2012-06-16 10:37:59 +08:00
|
|
|
setSelected(true);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2013-04-05 08:53:29 +08:00
|
|
|
case kKeyUpMessage:
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
if (window()->isForeground() &&
|
2015-05-11 20:53:45 +08:00
|
|
|
static_cast<KeyMessage*>(msg)->scancode() == kKeyEsc) {
|
2012-06-16 10:37:59 +08:00
|
|
|
if (isSelected()) {
|
|
|
|
setSelected(false);
|
|
|
|
closeWindow();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Button::onProcessMessage(msg);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-08-11 10:14:54 +08:00
|
|
|
static const char* cursor_names[kCursorTypes] = {
|
|
|
|
"null", // kNoCursor
|
|
|
|
"normal", // kArrowCursor
|
|
|
|
"normal_add", // kArrowPlusCursor
|
2016-08-31 22:22:08 +08:00
|
|
|
"crosshair", // kCrosshairCursor
|
2012-08-11 10:14:54 +08:00
|
|
|
"forbidden", // kForbiddenCursor
|
|
|
|
"hand", // kHandCursor
|
|
|
|
"scroll", // kScrollCursor
|
|
|
|
"move", // kMoveCursor
|
2014-08-11 06:51:14 +08:00
|
|
|
|
|
|
|
"size_ns", // kSizeNSCursor
|
|
|
|
"size_we", // kSizeWECursor
|
|
|
|
|
|
|
|
"size_n", // kSizeNCursor
|
|
|
|
"size_ne", // kSizeNECursor
|
|
|
|
"size_e", // kSizeECursor
|
|
|
|
"size_se", // kSizeSECursor
|
|
|
|
"size_s", // kSizeSCursor
|
|
|
|
"size_sw", // kSizeSWCursor
|
|
|
|
"size_w", // kSizeWCursor
|
|
|
|
"size_nw", // kSizeNWCursor
|
|
|
|
|
|
|
|
"rotate_n", // kRotateNCursor
|
|
|
|
"rotate_ne", // kRotateNECursor
|
|
|
|
"rotate_e", // kRotateECursor
|
|
|
|
"rotate_se", // kRotateSECursor
|
|
|
|
"rotate_s", // kRotateSCursor
|
|
|
|
"rotate_sw", // kRotateSWCursor
|
|
|
|
"rotate_w", // kRotateWCursor
|
|
|
|
"rotate_nw", // kRotateNWCursor
|
|
|
|
|
2014-04-20 07:08:21 +08:00
|
|
|
"eyedropper", // kEyedropperCursor
|
|
|
|
"magnifier" // kMagnifierCursor
|
2009-11-22 04:02:31 +08:00
|
|
|
};
|
|
|
|
|
2015-12-24 06:57:31 +08:00
|
|
|
static css::Value value_or_none(const char* valueStr)
|
|
|
|
{
|
|
|
|
if (strcmp(valueStr, "none") == 0)
|
|
|
|
return css::Value();
|
|
|
|
else
|
|
|
|
return css::Value(valueStr);
|
|
|
|
}
|
|
|
|
|
2015-02-17 22:43:25 +08:00
|
|
|
// static
|
|
|
|
SkinTheme* SkinTheme::instance()
|
|
|
|
{
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
return static_cast<SkinTheme*>(ui::Manager::getDefault()->theme());
|
2015-02-17 22:43:25 +08:00
|
|
|
}
|
|
|
|
|
2011-01-22 04:29:45 +08:00
|
|
|
SkinTheme::SkinTheme()
|
2012-08-11 10:14:54 +08:00
|
|
|
: m_cursors(ui::kCursorTypes, NULL)
|
2009-11-22 04:02:31 +08:00
|
|
|
{
|
2015-03-17 02:05:13 +08:00
|
|
|
m_defaultFont = nullptr;
|
|
|
|
m_miniFont = nullptr;
|
2009-11-22 04:02:31 +08:00
|
|
|
|
2010-03-26 19:31:47 +08:00
|
|
|
// Initialize all graphics in NULL (these bitmaps are loaded from the skin)
|
2014-06-23 05:53:14 +08:00
|
|
|
m_sheet = NULL;
|
2010-04-24 06:03:09 +08:00
|
|
|
}
|
|
|
|
|
2011-01-22 04:29:45 +08:00
|
|
|
SkinTheme::~SkinTheme()
|
2010-04-24 06:03:09 +08:00
|
|
|
{
|
2012-08-11 10:14:54 +08:00
|
|
|
// Delete all cursors.
|
|
|
|
for (size_t c=0; c<m_cursors.size(); ++c)
|
|
|
|
delete m_cursors[c];
|
2010-04-24 06:03:09 +08:00
|
|
|
|
2014-06-23 05:53:14 +08:00
|
|
|
for (std::map<std::string, she::Surface*>::iterator
|
2012-01-06 06:45:03 +08:00
|
|
|
it = m_toolicon.begin(); it != m_toolicon.end(); ++it) {
|
2014-06-23 05:53:14 +08:00
|
|
|
it->second->dispose();
|
2010-04-24 06:03:09 +08:00
|
|
|
}
|
|
|
|
|
2014-06-23 05:53:14 +08:00
|
|
|
if (m_sheet)
|
|
|
|
m_sheet->dispose();
|
2014-05-03 10:07:11 +08:00
|
|
|
|
|
|
|
m_parts_by_id.clear();
|
2011-04-02 22:45:43 +08:00
|
|
|
|
2015-05-21 03:58:23 +08:00
|
|
|
// Destroy fonts
|
|
|
|
if (m_defaultFont)
|
|
|
|
m_defaultFont->dispose();
|
|
|
|
|
2015-03-17 02:05:13 +08:00
|
|
|
if (m_miniFont)
|
|
|
|
m_miniFont->dispose();
|
2010-04-24 06:03:09 +08:00
|
|
|
}
|
|
|
|
|
2015-09-19 00:05:52 +08:00
|
|
|
void SkinTheme::onRegenerate()
|
2010-04-24 06:03:09 +08:00
|
|
|
{
|
2015-09-19 00:05:52 +08:00
|
|
|
Preferences& pref = Preferences::instance();
|
|
|
|
|
|
|
|
// First we load the skin from default theme, which is more proper
|
|
|
|
// to have every single needed skin part/color/dimension.
|
|
|
|
loadAll(pref.theme.selected.defaultValue());
|
|
|
|
|
|
|
|
// Then we load the selected theme to redefine default theme parts.
|
2016-10-27 21:44:31 +08:00
|
|
|
if (pref.theme.selected.defaultValue() != pref.theme.selected()) {
|
|
|
|
try {
|
|
|
|
loadAll(pref.theme.selected());
|
|
|
|
}
|
|
|
|
catch (const std::exception& e) {
|
|
|
|
LOG("SKIN: Error loading user-theme: %s\n", e.what());
|
|
|
|
|
2016-12-12 20:48:58 +08:00
|
|
|
if (ui::get_theme())
|
2016-10-27 21:44:31 +08:00
|
|
|
Console::showException(e);
|
|
|
|
|
|
|
|
// We can continue, as we've already loaded the default theme
|
2016-10-28 22:25:46 +08:00
|
|
|
// anyway. Here we restore the setting to its default value.
|
|
|
|
pref.theme.selected(pref.theme.selected.defaultValue());
|
2016-10-27 21:44:31 +08:00
|
|
|
}
|
|
|
|
}
|
2015-09-19 00:05:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void SkinTheme::loadAll(const std::string& skinId)
|
|
|
|
{
|
2016-10-27 21:44:31 +08:00
|
|
|
LOG("SKIN: Loading theme %s\n", skinId.c_str());
|
|
|
|
|
2015-09-19 00:05:52 +08:00
|
|
|
loadSheet(skinId);
|
|
|
|
loadFonts(skinId);
|
|
|
|
loadXml(skinId);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkinTheme::loadSheet(const std::string& skinId)
|
|
|
|
{
|
2010-03-07 22:03:47 +08:00
|
|
|
// Load the skin sheet
|
2015-09-19 00:05:52 +08:00
|
|
|
std::string sheet_filename("skins/" + skinId + "/sheet.png");
|
2010-07-17 03:56:45 +08:00
|
|
|
|
2014-04-13 00:35:55 +08:00
|
|
|
ResourceFinder rf;
|
|
|
|
rf.includeDataDir(sheet_filename.c_str());
|
|
|
|
if (!rf.findFirst())
|
|
|
|
throw base::Exception("File %s not found", sheet_filename.c_str());
|
2009-11-22 04:02:31 +08:00
|
|
|
|
2014-06-23 05:53:14 +08:00
|
|
|
try {
|
2016-10-27 21:44:31 +08:00
|
|
|
if (m_sheet) {
|
|
|
|
m_sheet->dispose();
|
|
|
|
m_sheet = nullptr;
|
|
|
|
}
|
2014-06-23 05:53:14 +08:00
|
|
|
m_sheet = she::instance()->loadRgbaSurface(rf.filename().c_str());
|
|
|
|
}
|
|
|
|
catch (...) {
|
2011-01-21 10:33:57 +08:00
|
|
|
throw base::Exception("Error loading %s file", sheet_filename.c_str());
|
2014-06-23 05:53:14 +08:00
|
|
|
}
|
2009-11-22 04:02:31 +08:00
|
|
|
}
|
|
|
|
|
2015-09-19 00:05:52 +08:00
|
|
|
void SkinTheme::loadFonts(const std::string& skinId)
|
2010-04-07 09:30:18 +08:00
|
|
|
{
|
2015-03-17 02:05:13 +08:00
|
|
|
if (m_defaultFont) m_defaultFont->dispose();
|
|
|
|
if (m_miniFont) m_miniFont->dispose();
|
2011-04-02 22:45:43 +08:00
|
|
|
|
2015-09-18 22:56:45 +08:00
|
|
|
Preferences& pref = Preferences::instance();
|
|
|
|
|
2015-09-19 00:05:52 +08:00
|
|
|
m_defaultFont = loadFont(pref.theme.font(), "skins/" + skinId + "/font.png");
|
|
|
|
m_miniFont = loadFont(pref.theme.miniFont(), "skins/" + skinId + "/minifont.png");
|
2010-04-07 09:30:18 +08:00
|
|
|
}
|
|
|
|
|
2015-09-19 00:05:52 +08:00
|
|
|
void SkinTheme::loadXml(const std::string& skinId)
|
2009-11-22 04:02:31 +08:00
|
|
|
{
|
2010-03-25 08:35:44 +08:00
|
|
|
// Load the skin XML
|
2015-09-19 00:05:52 +08:00
|
|
|
std::string xml_filename = "skins/" + skinId + "/skin.xml";
|
2010-07-17 03:56:45 +08:00
|
|
|
ResourceFinder rf;
|
2014-04-13 00:35:55 +08:00
|
|
|
rf.includeDataDir(xml_filename.c_str());
|
|
|
|
if (!rf.findFirst())
|
2013-12-11 11:34:16 +08:00
|
|
|
return;
|
2013-01-07 01:45:43 +08:00
|
|
|
|
2014-04-13 00:35:55 +08:00
|
|
|
XmlDocumentRef doc = open_xml(rf.filename());
|
2015-04-03 07:42:43 +08:00
|
|
|
TiXmlHandle handle(doc.get());
|
2013-12-11 11:34:16 +08:00
|
|
|
|
2015-02-17 23:22:46 +08:00
|
|
|
// Load dimension
|
|
|
|
{
|
|
|
|
TiXmlElement* xmlDim = handle
|
|
|
|
.FirstChild("skin")
|
|
|
|
.FirstChild("dimensions")
|
|
|
|
.FirstChild("dim").ToElement();
|
|
|
|
while (xmlDim) {
|
|
|
|
std::string id = xmlDim->Attribute("id");
|
|
|
|
uint32_t value = strtol(xmlDim->Attribute("value"), NULL, 10);
|
|
|
|
|
2016-10-27 21:44:31 +08:00
|
|
|
LOG(VERBOSE) << "SKIN: Loading dimension '" << id << "\n";
|
2015-02-17 23:22:46 +08:00
|
|
|
|
|
|
|
m_dimensions_by_id[id] = value;
|
|
|
|
xmlDim = xmlDim->NextSiblingElement();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-11 11:34:16 +08:00
|
|
|
// Load colors
|
|
|
|
{
|
|
|
|
TiXmlElement* xmlColor = handle
|
|
|
|
.FirstChild("skin")
|
|
|
|
.FirstChild("colors")
|
|
|
|
.FirstChild("color").ToElement();
|
|
|
|
while (xmlColor) {
|
|
|
|
std::string id = xmlColor->Attribute("id");
|
|
|
|
uint32_t value = strtol(xmlColor->Attribute("value")+1, NULL, 16);
|
2014-06-29 03:10:39 +08:00
|
|
|
gfx::Color color = gfx::rgba(
|
|
|
|
(value & 0xff0000) >> 16,
|
|
|
|
(value & 0xff00) >> 8,
|
|
|
|
(value & 0xff));
|
2013-12-11 11:34:16 +08:00
|
|
|
|
2016-10-27 21:44:31 +08:00
|
|
|
LOG(VERBOSE) << "SKIN: Loading color " << id << "\n";
|
2013-12-11 11:34:16 +08:00
|
|
|
|
|
|
|
m_colors_by_id[id] = color;
|
|
|
|
xmlColor = xmlColor->NextSiblingElement();
|
|
|
|
}
|
|
|
|
}
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2013-12-11 11:34:16 +08:00
|
|
|
// Load cursors
|
|
|
|
{
|
|
|
|
TiXmlElement* xmlCursor = handle
|
|
|
|
.FirstChild("skin")
|
|
|
|
.FirstChild("cursors")
|
|
|
|
.FirstChild("cursor").ToElement();
|
|
|
|
while (xmlCursor) {
|
|
|
|
std::string id = xmlCursor->Attribute("id");
|
|
|
|
int x = strtol(xmlCursor->Attribute("x"), NULL, 10);
|
|
|
|
int y = strtol(xmlCursor->Attribute("y"), NULL, 10);
|
|
|
|
int w = strtol(xmlCursor->Attribute("w"), NULL, 10);
|
|
|
|
int h = strtol(xmlCursor->Attribute("h"), NULL, 10);
|
|
|
|
int focusx = strtol(xmlCursor->Attribute("focusx"), NULL, 10);
|
|
|
|
int focusy = strtol(xmlCursor->Attribute("focusy"), NULL, 10);
|
|
|
|
int c;
|
|
|
|
|
2016-10-27 21:44:31 +08:00
|
|
|
LOG(VERBOSE) << "SKIN: Loading cursor " << id << "\n";
|
2013-12-11 11:34:16 +08:00
|
|
|
|
|
|
|
for (c=0; c<kCursorTypes; ++c) {
|
|
|
|
if (id != cursor_names[c])
|
|
|
|
continue;
|
|
|
|
|
|
|
|
delete m_cursors[c];
|
|
|
|
m_cursors[c] = NULL;
|
|
|
|
|
2014-06-23 05:53:14 +08:00
|
|
|
she::Surface* slice = sliceSheet(NULL, gfx::Rect(x, y, w, h));
|
2013-12-11 11:34:16 +08:00
|
|
|
|
2014-06-23 05:53:14 +08:00
|
|
|
m_cursors[c] = new Cursor(slice,
|
2014-11-26 09:33:45 +08:00
|
|
|
gfx::Point(focusx*guiscale(), focusy*guiscale()));
|
2013-12-11 11:34:16 +08:00
|
|
|
break;
|
|
|
|
}
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2013-12-11 11:34:16 +08:00
|
|
|
if (c == kCursorTypes) {
|
|
|
|
throw base::Exception("Unknown cursor specified in '%s':\n"
|
|
|
|
"<cursor id='%s' ... />\n", xml_filename.c_str(), id.c_str());
|
2010-03-25 08:35:44 +08:00
|
|
|
}
|
2013-12-11 11:34:16 +08:00
|
|
|
|
|
|
|
xmlCursor = xmlCursor->NextSiblingElement();
|
2010-03-25 08:35:44 +08:00
|
|
|
}
|
2013-12-11 11:34:16 +08:00
|
|
|
}
|
- All tools stuff refactored in various files/components.
- Added classes: IToolLoop, Tool, ToolGroup, ToolInk, ToolController, ToolPointShape, ToolIntertwine, ToolBox, etc.
- Added ToolLoopManager.
- Removed old src/modules/tools.cpp.
- Added ISettings and UISettingsImpl, adding the tools settings (onion skinning, grid, tiled mode, etc.).
- Added App::PenSizeBeforeChange, PenSizeAfterChange, CurrentToolChange signals.
- Renamed Context::get_bg/fg_color to getBg/FgColor.
- Refactored Brush class to Pen and added PenType.
- Renamed tiled_t to TiledMode.
- get_config_rect now uses the new Rect class imported from Vaca instead of old jrect.
- Added default_skin.xml to load tool icons.
- Added pen preview in Editor::cursor stuff.
- Added Editor::decorators.
Note: This big patch is from some time ago. I did my best to pre-commit other small changes before this big one.
2010-03-08 03:47:45 +08:00
|
|
|
|
2013-12-11 11:34:16 +08:00
|
|
|
// Load tool icons
|
|
|
|
{
|
|
|
|
TiXmlElement* xmlIcon = handle
|
|
|
|
.FirstChild("skin")
|
|
|
|
.FirstChild("tools")
|
|
|
|
.FirstChild("tool").ToElement();
|
|
|
|
while (xmlIcon) {
|
|
|
|
// Get the tool-icon rectangle
|
2016-10-27 21:44:31 +08:00
|
|
|
const char* id = xmlIcon->Attribute("id");
|
2013-12-11 11:34:16 +08:00
|
|
|
int x = strtol(xmlIcon->Attribute("x"), NULL, 10);
|
|
|
|
int y = strtol(xmlIcon->Attribute("y"), NULL, 10);
|
|
|
|
int w = strtol(xmlIcon->Attribute("w"), NULL, 10);
|
|
|
|
int h = strtol(xmlIcon->Attribute("h"), NULL, 10);
|
|
|
|
|
2016-10-27 21:44:31 +08:00
|
|
|
LOG(VERBOSE) << "SKIN: Loading tool icon " << id << "\n";
|
2013-12-11 11:34:16 +08:00
|
|
|
|
|
|
|
// Crop the tool-icon from the sheet
|
2016-10-27 21:44:31 +08:00
|
|
|
m_toolicon[id] = sliceSheet(
|
|
|
|
m_toolicon[id], gfx::Rect(x, y, w, h));
|
2013-12-11 11:34:16 +08:00
|
|
|
|
|
|
|
xmlIcon = xmlIcon->NextSiblingElement();
|
- All tools stuff refactored in various files/components.
- Added classes: IToolLoop, Tool, ToolGroup, ToolInk, ToolController, ToolPointShape, ToolIntertwine, ToolBox, etc.
- Added ToolLoopManager.
- Removed old src/modules/tools.cpp.
- Added ISettings and UISettingsImpl, adding the tools settings (onion skinning, grid, tiled mode, etc.).
- Added App::PenSizeBeforeChange, PenSizeAfterChange, CurrentToolChange signals.
- Renamed Context::get_bg/fg_color to getBg/FgColor.
- Refactored Brush class to Pen and added PenType.
- Renamed tiled_t to TiledMode.
- get_config_rect now uses the new Rect class imported from Vaca instead of old jrect.
- Added default_skin.xml to load tool icons.
- Added pen preview in Editor::cursor stuff.
- Added Editor::decorators.
Note: This big patch is from some time ago. I did my best to pre-commit other small changes before this big one.
2010-03-08 03:47:45 +08:00
|
|
|
}
|
2013-12-11 11:34:16 +08:00
|
|
|
}
|
2010-03-25 08:35:44 +08:00
|
|
|
|
2013-12-11 11:34:16 +08:00
|
|
|
// Load parts
|
|
|
|
{
|
|
|
|
TiXmlElement* xmlPart = handle
|
|
|
|
.FirstChild("skin")
|
|
|
|
.FirstChild("parts")
|
|
|
|
.FirstChild("part").ToElement();
|
|
|
|
while (xmlPart) {
|
|
|
|
// Get the tool-icon rectangle
|
|
|
|
const char* part_id = xmlPart->Attribute("id");
|
|
|
|
int x = strtol(xmlPart->Attribute("x"), NULL, 10);
|
|
|
|
int y = strtol(xmlPart->Attribute("y"), NULL, 10);
|
|
|
|
int w = xmlPart->Attribute("w") ? strtol(xmlPart->Attribute("w"), NULL, 10): 0;
|
|
|
|
int h = xmlPart->Attribute("h") ? strtol(xmlPart->Attribute("h"), NULL, 10): 0;
|
|
|
|
|
2016-10-27 21:44:31 +08:00
|
|
|
LOG(VERBOSE) << "SKIN: Loading part " << part_id << "\n";
|
2013-12-11 11:34:16 +08:00
|
|
|
|
|
|
|
SkinPartPtr part = m_parts_by_id[part_id];
|
2015-04-03 07:42:43 +08:00
|
|
|
if (!part)
|
2013-12-11 11:34:16 +08:00
|
|
|
part = m_parts_by_id[part_id] = SkinPartPtr(new SkinPart);
|
|
|
|
|
|
|
|
if (w > 0 && h > 0) {
|
2014-06-23 05:53:14 +08:00
|
|
|
part->setBitmap(0,
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
sliceSheet(part->bitmap(0), gfx::Rect(x, y, w, h)));
|
2013-12-11 11:34:16 +08:00
|
|
|
}
|
|
|
|
else if (xmlPart->Attribute("w1")) { // 3x3-1 part (NW, N, NE, E, SE, S, SW, W)
|
|
|
|
int w1 = strtol(xmlPart->Attribute("w1"), NULL, 10);
|
|
|
|
int w2 = strtol(xmlPart->Attribute("w2"), NULL, 10);
|
|
|
|
int w3 = strtol(xmlPart->Attribute("w3"), NULL, 10);
|
|
|
|
int h1 = strtol(xmlPart->Attribute("h1"), NULL, 10);
|
|
|
|
int h2 = strtol(xmlPart->Attribute("h2"), NULL, 10);
|
|
|
|
int h3 = strtol(xmlPart->Attribute("h3"), NULL, 10);
|
|
|
|
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
part->setBitmap(0, sliceSheet(part->bitmap(0), gfx::Rect(x, y, w1, h1))); // NW
|
|
|
|
part->setBitmap(1, sliceSheet(part->bitmap(1), gfx::Rect(x+w1, y, w2, h1))); // N
|
|
|
|
part->setBitmap(2, sliceSheet(part->bitmap(2), gfx::Rect(x+w1+w2, y, w3, h1))); // NE
|
|
|
|
part->setBitmap(3, sliceSheet(part->bitmap(3), gfx::Rect(x+w1+w2, y+h1, w3, h2))); // E
|
|
|
|
part->setBitmap(4, sliceSheet(part->bitmap(4), gfx::Rect(x+w1+w2, y+h1+h2, w3, h3))); // SE
|
|
|
|
part->setBitmap(5, sliceSheet(part->bitmap(5), gfx::Rect(x+w1, y+h1+h2, w2, h3))); // S
|
|
|
|
part->setBitmap(6, sliceSheet(part->bitmap(6), gfx::Rect(x, y+h1+h2, w1, h3))); // SW
|
|
|
|
part->setBitmap(7, sliceSheet(part->bitmap(7), gfx::Rect(x, y+h1, w1, h2))); // W
|
2013-12-11 11:34:16 +08:00
|
|
|
}
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2013-12-11 11:34:16 +08:00
|
|
|
xmlPart = xmlPart->NextSiblingElement();
|
|
|
|
}
|
|
|
|
}
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2013-12-11 11:34:16 +08:00
|
|
|
// Load styles
|
|
|
|
{
|
|
|
|
TiXmlElement* xmlStyle = handle
|
|
|
|
.FirstChild("skin")
|
|
|
|
.FirstChild("stylesheet")
|
|
|
|
.FirstChild("style").ToElement();
|
|
|
|
while (xmlStyle) {
|
|
|
|
const char* style_id = xmlStyle->Attribute("id");
|
|
|
|
const char* base_id = xmlStyle->Attribute("base");
|
|
|
|
const css::Style* base = NULL;
|
|
|
|
|
|
|
|
if (base_id)
|
2014-05-03 10:30:17 +08:00
|
|
|
base = m_stylesheet.getCssStyle(base_id);
|
2013-12-11 11:34:16 +08:00
|
|
|
|
|
|
|
css::Style* style = new css::Style(style_id, base);
|
2014-05-03 10:30:17 +08:00
|
|
|
m_stylesheet.addCssStyle(style);
|
2013-12-11 11:34:16 +08:00
|
|
|
|
|
|
|
TiXmlElement* xmlRule = xmlStyle->FirstChildElement();
|
|
|
|
while (xmlRule) {
|
|
|
|
const std::string ruleName = xmlRule->Value();
|
|
|
|
|
2016-10-27 21:44:31 +08:00
|
|
|
LOG(VERBOSE) << "SKIN: Rule " << ruleName
|
|
|
|
<< " for " << style_id << "\n";
|
2013-12-11 11:34:16 +08:00
|
|
|
|
2013-12-11 12:35:40 +08:00
|
|
|
// TODO This code design to read styles could be improved.
|
|
|
|
|
2013-12-11 11:34:16 +08:00
|
|
|
const char* part_id = xmlRule->Attribute("part");
|
|
|
|
const char* color_id = xmlRule->Attribute("color");
|
|
|
|
|
|
|
|
// Style align
|
|
|
|
int align = 0;
|
|
|
|
const char* halign = xmlRule->Attribute("align");
|
|
|
|
const char* valign = xmlRule->Attribute("valign");
|
2015-03-03 06:54:24 +08:00
|
|
|
const char* wordwrap = xmlRule->Attribute("wordwrap");
|
2013-12-11 11:34:16 +08:00
|
|
|
if (halign) {
|
2015-06-24 01:00:00 +08:00
|
|
|
if (strcmp(halign, "left") == 0) align |= LEFT;
|
|
|
|
else if (strcmp(halign, "right") == 0) align |= RIGHT;
|
|
|
|
else if (strcmp(halign, "center") == 0) align |= CENTER;
|
2012-01-06 06:45:03 +08:00
|
|
|
}
|
2013-12-11 11:34:16 +08:00
|
|
|
if (valign) {
|
2015-06-24 01:00:00 +08:00
|
|
|
if (strcmp(valign, "top") == 0) align |= TOP;
|
|
|
|
else if (strcmp(valign, "bottom") == 0) align |= BOTTOM;
|
|
|
|
else if (strcmp(valign, "middle") == 0) align |= MIDDLE;
|
2012-01-06 06:45:03 +08:00
|
|
|
}
|
2015-03-03 06:54:24 +08:00
|
|
|
if (wordwrap && strcmp(wordwrap, "true") == 0)
|
2015-06-24 01:00:00 +08:00
|
|
|
align |= WORDWRAP;
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2013-12-11 11:34:16 +08:00
|
|
|
if (ruleName == "background") {
|
2015-02-18 03:03:00 +08:00
|
|
|
const char* repeat_id = xmlRule->Attribute("repeat");
|
|
|
|
|
2015-12-24 06:57:31 +08:00
|
|
|
if (color_id) (*style)[StyleSheet::backgroundColorRule()] = value_or_none(color_id);
|
|
|
|
if (part_id) (*style)[StyleSheet::backgroundPartRule()] = value_or_none(part_id);
|
|
|
|
if (repeat_id) (*style)[StyleSheet::backgroundRepeatRule()] = value_or_none(repeat_id);
|
2013-12-11 11:34:16 +08:00
|
|
|
}
|
|
|
|
else if (ruleName == "icon") {
|
|
|
|
if (align) (*style)[StyleSheet::iconAlignRule()] = css::Value(align);
|
|
|
|
if (part_id) (*style)[StyleSheet::iconPartRule()] = css::Value(part_id);
|
2016-06-15 23:00:31 +08:00
|
|
|
if (color_id) (*style)[StyleSheet::iconColorRule()] = value_or_none(color_id);
|
2015-02-20 00:13:25 +08:00
|
|
|
|
|
|
|
const char* x = xmlRule->Attribute("x");
|
|
|
|
const char* y = xmlRule->Attribute("y");
|
|
|
|
if (x) (*style)[StyleSheet::iconXRule()] = css::Value(strtol(x, NULL, 10));
|
|
|
|
if (y) (*style)[StyleSheet::iconYRule()] = css::Value(strtol(y, NULL, 10));
|
2013-12-11 11:34:16 +08:00
|
|
|
}
|
|
|
|
else if (ruleName == "text") {
|
|
|
|
if (color_id) (*style)[StyleSheet::textColorRule()] = css::Value(color_id);
|
|
|
|
if (align) (*style)[StyleSheet::textAlignRule()] = css::Value(align);
|
2013-12-11 12:35:40 +08:00
|
|
|
|
2015-02-20 00:13:25 +08:00
|
|
|
const char* l = xmlRule->Attribute("padding-left");
|
|
|
|
const char* t = xmlRule->Attribute("padding-top");
|
|
|
|
const char* r = xmlRule->Attribute("padding-right");
|
|
|
|
const char* b = xmlRule->Attribute("padding-bottom");
|
2013-12-11 12:35:40 +08:00
|
|
|
|
2015-02-20 00:13:25 +08:00
|
|
|
if (l) (*style)[StyleSheet::paddingLeftRule()] = css::Value(strtol(l, NULL, 10));
|
|
|
|
if (t) (*style)[StyleSheet::paddingTopRule()] = css::Value(strtol(t, NULL, 10));
|
|
|
|
if (r) (*style)[StyleSheet::paddingRightRule()] = css::Value(strtol(r, NULL, 10));
|
|
|
|
if (b) (*style)[StyleSheet::paddingBottomRule()] = css::Value(strtol(b, NULL, 10));
|
2013-12-11 11:34:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
xmlRule = xmlRule->NextSiblingElement();
|
2010-03-26 19:31:47 +08:00
|
|
|
}
|
|
|
|
|
2013-12-11 11:34:16 +08:00
|
|
|
xmlStyle = xmlStyle->NextSiblingElement();
|
|
|
|
}
|
- All tools stuff refactored in various files/components.
- Added classes: IToolLoop, Tool, ToolGroup, ToolInk, ToolController, ToolPointShape, ToolIntertwine, ToolBox, etc.
- Added ToolLoopManager.
- Removed old src/modules/tools.cpp.
- Added ISettings and UISettingsImpl, adding the tools settings (onion skinning, grid, tiled mode, etc.).
- Added App::PenSizeBeforeChange, PenSizeAfterChange, CurrentToolChange signals.
- Renamed Context::get_bg/fg_color to getBg/FgColor.
- Refactored Brush class to Pen and added PenType.
- Renamed tiled_t to TiledMode.
- get_config_rect now uses the new Rect class imported from Vaca instead of old jrect.
- Added default_skin.xml to load tool icons.
- Added pen preview in Editor::cursor stuff.
- Added Editor::decorators.
Note: This big patch is from some time ago. I did my best to pre-commit other small changes before this big one.
2010-03-08 03:47:45 +08:00
|
|
|
}
|
2015-02-16 02:29:16 +08:00
|
|
|
|
|
|
|
SkinFile<SkinTheme>::updateInternals();
|
2010-03-25 08:35:44 +08:00
|
|
|
}
|
|
|
|
|
2014-06-23 05:53:14 +08:00
|
|
|
she::Surface* SkinTheme::sliceSheet(she::Surface* sur, const gfx::Rect& bounds)
|
2010-03-25 08:35:44 +08:00
|
|
|
{
|
2014-06-23 05:53:14 +08:00
|
|
|
if (sur && (sur->width() != bounds.w ||
|
|
|
|
sur->height() != bounds.h)) {
|
|
|
|
sur->dispose();
|
|
|
|
sur = NULL;
|
2010-03-25 08:35:44 +08:00
|
|
|
}
|
|
|
|
|
2014-06-23 05:53:14 +08:00
|
|
|
if (!sur)
|
2014-06-27 10:53:41 +08:00
|
|
|
sur = she::instance()->createRgbaSurface(bounds.w, bounds.h);
|
2014-06-23 05:53:14 +08:00
|
|
|
|
|
|
|
{
|
2016-03-09 22:00:17 +08:00
|
|
|
she::SurfaceLock lockSrc(m_sheet);
|
|
|
|
she::SurfaceLock lockDst(sur);
|
|
|
|
m_sheet->blitTo(sur, bounds.x, bounds.y, 0, 0, bounds.w, bounds.h);
|
2014-06-23 05:53:14 +08:00
|
|
|
}
|
2010-03-25 08:35:44 +08:00
|
|
|
|
2014-11-26 09:33:45 +08:00
|
|
|
sur->applyScale(guiscale());
|
2014-06-23 05:53:14 +08:00
|
|
|
return sur;
|
2009-11-22 04:02:31 +08:00
|
|
|
}
|
|
|
|
|
2015-05-06 06:14:33 +08:00
|
|
|
she::Font* SkinTheme::getWidgetFont(const Widget* widget) const
|
|
|
|
{
|
|
|
|
SkinPropertyPtr skinPropery = widget->getProperty(SkinProperty::Name);
|
|
|
|
if (skinPropery && skinPropery->hasMiniFont())
|
|
|
|
return getMiniFont();
|
|
|
|
else
|
|
|
|
return getDefaultFont();
|
|
|
|
}
|
|
|
|
|
2012-08-11 10:14:54 +08:00
|
|
|
Cursor* SkinTheme::getCursor(CursorType type)
|
2009-11-22 04:02:31 +08:00
|
|
|
{
|
2012-08-11 10:14:54 +08:00
|
|
|
if (type == kNoCursor) {
|
2009-11-22 04:02:31 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
else {
|
2012-08-11 10:14:54 +08:00
|
|
|
ASSERT(type >= kFirstCursorType && type <= kLastCursorType);
|
2010-03-25 08:35:44 +08:00
|
|
|
return m_cursors[type];
|
2009-11-22 04:02:31 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-14 09:39:44 +08:00
|
|
|
void SkinTheme::initWidget(Widget* widget)
|
2009-11-22 04:02:31 +08:00
|
|
|
{
|
2015-06-24 06:20:49 +08:00
|
|
|
#define BORDER(n) \
|
|
|
|
widget->setBorder(gfx::Border(n))
|
|
|
|
|
|
|
|
#define BORDER4(L,T,R,B) \
|
|
|
|
widget->setBorder(gfx::Border((L), (T), (R), (B)))
|
2010-03-08 00:21:24 +08:00
|
|
|
|
2014-11-26 09:33:45 +08:00
|
|
|
int scale = guiscale();
|
2009-11-22 04:02:31 +08:00
|
|
|
|
2015-06-24 01:37:22 +08:00
|
|
|
switch (widget->type()) {
|
2009-11-22 04:02:31 +08:00
|
|
|
|
2013-04-04 09:07:24 +08:00
|
|
|
case kBoxWidget:
|
2009-11-22 04:02:31 +08:00
|
|
|
BORDER(0);
|
2015-06-24 06:20:49 +08:00
|
|
|
widget->setChildSpacing(4 * scale);
|
2009-11-22 04:02:31 +08:00
|
|
|
break;
|
|
|
|
|
2013-04-04 09:07:24 +08:00
|
|
|
case kButtonWidget:
|
2014-06-23 05:53:14 +08:00
|
|
|
BORDER4(
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
parts.buttonNormal()->bitmapW()->width(),
|
|
|
|
parts.buttonNormal()->bitmapN()->height(),
|
|
|
|
parts.buttonNormal()->bitmapE()->width(),
|
|
|
|
parts.buttonNormal()->bitmapS()->height());
|
2015-06-24 06:20:49 +08:00
|
|
|
widget->setChildSpacing(0);
|
2009-11-22 04:02:31 +08:00
|
|
|
break;
|
|
|
|
|
2013-04-04 09:07:24 +08:00
|
|
|
case kCheckWidget:
|
2010-03-08 00:21:24 +08:00
|
|
|
BORDER(2 * scale);
|
2015-06-24 06:20:49 +08:00
|
|
|
widget->setChildSpacing(4 * scale);
|
2011-03-07 03:15:05 +08:00
|
|
|
|
|
|
|
static_cast<ButtonBase*>(widget)->setIconInterface
|
2015-08-05 06:38:52 +08:00
|
|
|
(new ButtonIconImpl(parts.checkNormal(),
|
|
|
|
parts.checkSelected(),
|
|
|
|
parts.checkDisabled(),
|
2015-06-24 01:00:00 +08:00
|
|
|
LEFT | MIDDLE));
|
2009-11-22 04:02:31 +08:00
|
|
|
break;
|
|
|
|
|
2013-04-04 09:07:24 +08:00
|
|
|
case kEntryWidget:
|
2014-06-23 05:53:14 +08:00
|
|
|
BORDER4(
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
parts.sunkenNormal()->bitmapW()->width(),
|
|
|
|
parts.sunkenNormal()->bitmapN()->height(),
|
|
|
|
parts.sunkenNormal()->bitmapE()->width(),
|
|
|
|
parts.sunkenNormal()->bitmapS()->height());
|
2015-12-01 02:08:18 +08:00
|
|
|
widget->setChildSpacing(3 * scale);
|
2009-11-22 04:02:31 +08:00
|
|
|
break;
|
|
|
|
|
2013-04-04 09:07:24 +08:00
|
|
|
case kGridWidget:
|
2009-11-22 04:02:31 +08:00
|
|
|
BORDER(0);
|
2015-06-24 06:20:49 +08:00
|
|
|
widget->setChildSpacing(4 * scale);
|
2009-11-22 04:02:31 +08:00
|
|
|
break;
|
|
|
|
|
2013-04-04 09:07:24 +08:00
|
|
|
case kLabelWidget:
|
2010-03-08 00:21:24 +08:00
|
|
|
BORDER(1 * scale);
|
2009-11-22 04:02:31 +08:00
|
|
|
break;
|
|
|
|
|
2013-04-04 09:07:24 +08:00
|
|
|
case kListBoxWidget:
|
2009-11-22 04:02:31 +08:00
|
|
|
BORDER(0);
|
2015-06-24 06:20:49 +08:00
|
|
|
widget->setChildSpacing(0);
|
2009-11-22 04:02:31 +08:00
|
|
|
break;
|
|
|
|
|
2013-04-04 09:07:24 +08:00
|
|
|
case kListItemWidget:
|
2010-03-08 00:21:24 +08:00
|
|
|
BORDER(1 * scale);
|
2009-11-22 04:02:31 +08:00
|
|
|
break;
|
|
|
|
|
2013-04-04 09:07:24 +08:00
|
|
|
case kComboBoxWidget:
|
2010-03-09 07:37:53 +08:00
|
|
|
{
|
2012-01-06 06:45:03 +08:00
|
|
|
ComboBox* combobox = dynamic_cast<ComboBox*>(widget);
|
|
|
|
ASSERT(combobox != NULL);
|
|
|
|
|
|
|
|
Button* button = combobox->getButtonWidget();
|
|
|
|
|
2015-06-24 06:20:49 +08:00
|
|
|
button->setBorder(gfx::Border(0));
|
|
|
|
button->setChildSpacing(0);
|
2015-06-24 02:13:42 +08:00
|
|
|
button->setMinSize(gfx::Size(15 * guiscale(),
|
|
|
|
16 * guiscale()));
|
2012-01-06 06:45:03 +08:00
|
|
|
|
|
|
|
static_cast<ButtonBase*>(button)->setIconInterface
|
2015-08-05 06:38:52 +08:00
|
|
|
(new ButtonIconImpl(parts.comboboxArrowDown(),
|
|
|
|
parts.comboboxArrowDownSelected(),
|
|
|
|
parts.comboboxArrowDownDisabled(),
|
2015-06-24 01:00:00 +08:00
|
|
|
CENTER | MIDDLE));
|
2009-11-22 08:26:58 +08:00
|
|
|
}
|
2009-11-22 04:02:31 +08:00
|
|
|
break;
|
|
|
|
|
2013-04-04 09:07:24 +08:00
|
|
|
case kMenuWidget:
|
|
|
|
case kMenuBarWidget:
|
|
|
|
case kMenuBoxWidget:
|
2009-11-22 04:02:31 +08:00
|
|
|
BORDER(0);
|
2015-06-24 06:20:49 +08:00
|
|
|
widget->setChildSpacing(0);
|
2009-11-22 04:02:31 +08:00
|
|
|
break;
|
|
|
|
|
2013-04-04 09:07:24 +08:00
|
|
|
case kMenuItemWidget:
|
2010-03-09 10:42:31 +08:00
|
|
|
BORDER(2 * scale);
|
2015-06-24 06:20:49 +08:00
|
|
|
widget->setChildSpacing(18 * scale);
|
2009-11-22 04:02:31 +08:00
|
|
|
break;
|
|
|
|
|
2013-04-04 09:07:24 +08:00
|
|
|
case kSplitterWidget:
|
2009-11-22 04:02:31 +08:00
|
|
|
BORDER(0);
|
2015-06-24 06:20:49 +08:00
|
|
|
widget->setChildSpacing(3 * scale);
|
2009-11-22 04:02:31 +08:00
|
|
|
break;
|
|
|
|
|
2013-04-04 09:07:24 +08:00
|
|
|
case kRadioWidget:
|
2010-03-08 00:21:24 +08:00
|
|
|
BORDER(2 * scale);
|
2015-06-24 06:20:49 +08:00
|
|
|
widget->setChildSpacing(4 * scale);
|
2011-03-07 03:15:05 +08:00
|
|
|
|
|
|
|
static_cast<ButtonBase*>(widget)->setIconInterface
|
2015-08-05 06:38:52 +08:00
|
|
|
(new ButtonIconImpl(parts.radioNormal(),
|
|
|
|
parts.radioSelected(),
|
|
|
|
parts.radioDisabled(),
|
2015-06-24 01:00:00 +08:00
|
|
|
LEFT | MIDDLE));
|
2009-11-22 04:02:31 +08:00
|
|
|
break;
|
|
|
|
|
2013-04-04 09:07:24 +08:00
|
|
|
case kSeparatorWidget:
|
2015-05-21 23:28:21 +08:00
|
|
|
// Frame
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
if ((widget->align() & HORIZONTAL) &&
|
|
|
|
(widget->align() & VERTICAL)) {
|
2012-01-06 06:45:03 +08:00
|
|
|
BORDER(4 * scale);
|
2009-11-22 04:02:31 +08:00
|
|
|
}
|
2015-05-21 23:28:21 +08:00
|
|
|
// Horizontal bar
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
else if (widget->align() & HORIZONTAL) {
|
2012-01-06 06:45:03 +08:00
|
|
|
BORDER4(2 * scale, 4 * scale, 2 * scale, 0);
|
2009-11-22 04:02:31 +08:00
|
|
|
}
|
2015-05-21 23:28:21 +08:00
|
|
|
// Vertical bar
|
2009-11-22 04:02:31 +08:00
|
|
|
else {
|
2015-05-21 23:28:21 +08:00
|
|
|
BORDER4(4 * scale, 2 * scale, 1 * scale, 2 * scale);
|
2009-11-22 04:02:31 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2013-04-04 09:07:24 +08:00
|
|
|
case kSliderWidget:
|
2014-06-23 05:53:14 +08:00
|
|
|
BORDER4(
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
parts.sliderEmpty()->bitmapW()->width()-1*scale,
|
|
|
|
parts.sliderEmpty()->bitmapN()->height(),
|
|
|
|
parts.sliderEmpty()->bitmapE()->width()-1*scale,
|
|
|
|
parts.sliderEmpty()->bitmapS()->height()-1*scale);
|
|
|
|
widget->setChildSpacing(widget->textHeight());
|
2015-06-24 01:00:00 +08:00
|
|
|
widget->setAlign(CENTER | MIDDLE);
|
2009-11-22 04:02:31 +08:00
|
|
|
break;
|
|
|
|
|
2013-04-04 09:07:24 +08:00
|
|
|
case kTextBoxWidget:
|
2016-12-07 08:30:46 +08:00
|
|
|
BORDER(4*guiscale());
|
2015-06-24 06:20:49 +08:00
|
|
|
widget->setChildSpacing(0);
|
2016-12-07 08:30:46 +08:00
|
|
|
widget->setBgColor(colors.textboxFace());
|
2009-11-22 04:02:31 +08:00
|
|
|
break;
|
|
|
|
|
2013-04-04 09:07:24 +08:00
|
|
|
case kViewWidget:
|
2014-06-23 05:53:14 +08:00
|
|
|
BORDER4(
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
parts.sunkenNormal()->bitmapW()->width()-1*scale,
|
|
|
|
parts.sunkenNormal()->bitmapN()->height(),
|
|
|
|
parts.sunkenNormal()->bitmapE()->width()-1*scale,
|
|
|
|
parts.sunkenNormal()->bitmapS()->height()-1*scale);
|
2015-06-24 06:20:49 +08:00
|
|
|
widget->setChildSpacing(0);
|
2015-02-16 02:29:16 +08:00
|
|
|
widget->setBgColor(colors.windowFace());
|
2009-11-22 04:02:31 +08:00
|
|
|
break;
|
|
|
|
|
2013-04-04 09:07:24 +08:00
|
|
|
case kViewScrollbarWidget:
|
2010-03-08 00:21:24 +08:00
|
|
|
BORDER(1 * scale);
|
2015-06-24 06:20:49 +08:00
|
|
|
widget->setChildSpacing(0);
|
2009-11-22 04:02:31 +08:00
|
|
|
break;
|
|
|
|
|
2013-04-04 09:07:24 +08:00
|
|
|
case kViewViewportWidget:
|
2009-11-22 04:02:31 +08:00
|
|
|
BORDER(0);
|
2015-06-24 06:20:49 +08:00
|
|
|
widget->setChildSpacing(0);
|
2009-11-22 04:02:31 +08:00
|
|
|
break;
|
|
|
|
|
2013-04-04 09:07:24 +08:00
|
|
|
case kWindowWidget:
|
2013-01-11 23:43:25 +08:00
|
|
|
if (!static_cast<Window*>(widget)->isDesktop()) {
|
2012-01-06 06:45:03 +08:00
|
|
|
if (widget->hasText()) {
|
2015-06-24 06:20:49 +08:00
|
|
|
BORDER4(6 * scale,
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
(4+6) * scale + widget->textHeight(),
|
2015-06-24 06:20:49 +08:00
|
|
|
6 * scale,
|
|
|
|
6 * scale);
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2015-06-24 03:07:41 +08:00
|
|
|
if (!widget->hasFlags(INITIALIZED)) {
|
2012-06-16 10:37:59 +08:00
|
|
|
Button* button = new WindowCloseButton();
|
2012-01-06 06:45:03 +08:00
|
|
|
widget->addChild(button);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
BORDER(3 * scale);
|
|
|
|
}
|
2009-11-22 04:02:31 +08:00
|
|
|
}
|
|
|
|
else {
|
2012-01-06 06:45:03 +08:00
|
|
|
BORDER(0);
|
2009-11-22 04:02:31 +08:00
|
|
|
}
|
2015-12-11 03:46:01 +08:00
|
|
|
|
2015-06-24 06:20:49 +08:00
|
|
|
widget->setChildSpacing(4 * scale); // TODO this hard-coded 4 should be configurable in skin.xml
|
2015-12-11 03:46:01 +08:00
|
|
|
|
|
|
|
// Tooltip background color
|
|
|
|
if (dynamic_cast<TipWindow*>(widget))
|
|
|
|
widget->setBgColor(SkinTheme::instance()->colors.tooltipFace());
|
|
|
|
else
|
|
|
|
widget->setBgColor(colors.windowFace());
|
2009-11-22 04:02:31 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-14 09:39:44 +08:00
|
|
|
void SkinTheme::getWindowMask(Widget* widget, Region& region)
|
2009-11-22 04:02:31 +08:00
|
|
|
{
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
region = widget->bounds();
|
2009-11-22 04:02:31 +08:00
|
|
|
}
|
|
|
|
|
2013-01-21 08:58:16 +08:00
|
|
|
void SkinTheme::setDecorativeWidgetBounds(Widget* widget)
|
2009-11-22 04:02:31 +08:00
|
|
|
{
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
if (widget->id() == kThemeCloseButtonId) {
|
|
|
|
Widget* window = widget->parent();
|
|
|
|
gfx::Rect rect(parts.windowCloseButtonNormal()->size());
|
2009-11-22 04:02:31 +08:00
|
|
|
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
rect.offset(window->bounds().x2() - 3*guiscale() - rect.w,
|
|
|
|
window->bounds().y + 3*guiscale());
|
2009-11-22 04:02:31 +08:00
|
|
|
|
2013-05-12 04:56:27 +08:00
|
|
|
widget->setBounds(rect);
|
2009-11-22 04:02:31 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-13 03:48:40 +08:00
|
|
|
int SkinTheme::getScrollbarSize()
|
|
|
|
{
|
2015-08-13 03:56:19 +08:00
|
|
|
return dimensions.scrollbarSize();
|
2015-08-13 03:48:40 +08:00
|
|
|
}
|
|
|
|
|
2017-02-08 06:05:47 +08:00
|
|
|
gfx::Size SkinTheme::getEntryCaretSize(Widget* widget)
|
|
|
|
{
|
|
|
|
if (widget->font()->type() == she::FontType::kTrueType)
|
|
|
|
return gfx::Size(2*guiscale(), widget->textHeight());
|
|
|
|
else
|
|
|
|
return gfx::Size(2*guiscale(), widget->textHeight()+2*guiscale());
|
|
|
|
}
|
|
|
|
|
2013-01-07 01:45:43 +08:00
|
|
|
void SkinTheme::paintDesktop(PaintEvent& ev)
|
2009-11-22 04:02:31 +08:00
|
|
|
{
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
Graphics* g = ev.graphics();
|
2009-11-22 04:02:31 +08:00
|
|
|
|
2015-02-16 02:29:16 +08:00
|
|
|
g->fillRect(colors.disabled(), g->getClipBounds());
|
2009-11-22 04:02:31 +08:00
|
|
|
}
|
|
|
|
|
2011-02-12 20:32:57 +08:00
|
|
|
void SkinTheme::paintBox(PaintEvent& ev)
|
2009-11-22 04:02:31 +08:00
|
|
|
{
|
2011-02-12 20:32:57 +08:00
|
|
|
Widget* widget = static_cast<Widget*>(ev.getSource());
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
Graphics* g = ev.graphics();
|
2013-01-07 01:45:43 +08:00
|
|
|
|
2016-04-08 03:12:03 +08:00
|
|
|
if (!widget->isTransparent() &&
|
|
|
|
!is_transparent(BGCOLOR)) {
|
2014-04-20 05:51:42 +08:00
|
|
|
g->fillRect(BGCOLOR, g->getClipBounds());
|
2016-04-08 03:12:03 +08:00
|
|
|
}
|
2009-11-22 04:02:31 +08:00
|
|
|
}
|
|
|
|
|
2011-02-12 20:32:57 +08:00
|
|
|
void SkinTheme::paintButton(PaintEvent& ev)
|
2009-11-22 04:02:31 +08:00
|
|
|
{
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
Graphics* g = ev.graphics();
|
2011-02-12 20:32:57 +08:00
|
|
|
ButtonBase* widget = static_cast<ButtonBase*>(ev.getSource());
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
IButtonIcon* iconInterface = widget->iconInterface();
|
2013-10-26 23:50:55 +08:00
|
|
|
gfx::Rect box, text, icon;
|
2014-06-29 03:10:39 +08:00
|
|
|
gfx::Color fg, bg;
|
2015-08-05 06:38:52 +08:00
|
|
|
SkinPartPtr part_nw;
|
2009-11-22 04:02:31 +08:00
|
|
|
|
2014-04-20 02:18:16 +08:00
|
|
|
widget->getTextIconInfo(&box, &text, &icon,
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
iconInterface ? iconInterface->iconAlign(): 0,
|
|
|
|
iconInterface ? iconInterface->size().w: 0,
|
|
|
|
iconInterface ? iconInterface->size().h: 0);
|
2009-11-22 04:02:31 +08:00
|
|
|
|
2010-03-22 08:28:32 +08:00
|
|
|
// Tool buttons are smaller
|
2011-03-30 08:07:37 +08:00
|
|
|
LookType look = NormalLook;
|
2013-12-05 12:19:46 +08:00
|
|
|
SkinPropertyPtr skinPropery = widget->getProperty(SkinProperty::Name);
|
2015-04-03 07:42:43 +08:00
|
|
|
if (skinPropery)
|
2011-03-30 08:07:37 +08:00
|
|
|
look = skinPropery->getLook();
|
2010-03-22 08:28:32 +08:00
|
|
|
|
2011-04-22 08:07:11 +08:00
|
|
|
// Selected
|
2010-07-04 02:03:26 +08:00
|
|
|
if (widget->isSelected()) {
|
2015-02-16 02:29:16 +08:00
|
|
|
fg = colors.buttonSelectedText();
|
|
|
|
bg = colors.buttonSelectedFace();
|
2015-08-05 06:38:52 +08:00
|
|
|
part_nw = (look == MiniLook ? parts.toolbuttonNormal():
|
|
|
|
look == LeftButtonLook ? parts.dropDownButtonLeftSelected():
|
|
|
|
look == RightButtonLook ? parts.dropDownButtonRightSelected():
|
|
|
|
parts.buttonSelected());
|
2009-11-22 04:02:31 +08:00
|
|
|
}
|
2011-04-22 08:07:11 +08:00
|
|
|
// With mouse
|
2010-07-04 02:26:27 +08:00
|
|
|
else if (widget->isEnabled() && widget->hasMouseOver()) {
|
2015-02-16 02:29:16 +08:00
|
|
|
fg = colors.buttonHotText();
|
|
|
|
bg = colors.buttonHotFace();
|
2015-08-05 06:38:52 +08:00
|
|
|
part_nw = (look == MiniLook ? parts.toolbuttonHot():
|
|
|
|
look == LeftButtonLook ? parts.dropDownButtonLeftHot():
|
|
|
|
look == RightButtonLook ? parts.dropDownButtonRightHot():
|
|
|
|
parts.buttonHot());
|
2009-11-22 04:02:31 +08:00
|
|
|
}
|
2011-04-22 08:07:11 +08:00
|
|
|
// Without mouse
|
2009-11-22 04:02:31 +08:00
|
|
|
else {
|
2015-02-16 02:29:16 +08:00
|
|
|
fg = colors.buttonNormalText();
|
|
|
|
bg = colors.buttonNormalFace();
|
2009-11-22 04:02:31 +08:00
|
|
|
|
2010-04-25 23:03:25 +08:00
|
|
|
if (widget->hasFocus())
|
2015-08-05 06:38:52 +08:00
|
|
|
part_nw = (look == MiniLook ? parts.toolbuttonHot():
|
|
|
|
look == LeftButtonLook ? parts.dropDownButtonLeftFocused():
|
|
|
|
look == RightButtonLook ? parts.dropDownButtonRightFocused():
|
|
|
|
parts.buttonFocused());
|
2009-11-22 04:02:31 +08:00
|
|
|
else
|
2015-08-05 06:38:52 +08:00
|
|
|
part_nw = (look == MiniLook ? parts.toolbuttonNormal():
|
|
|
|
look == LeftButtonLook ? parts.dropDownButtonLeftNormal():
|
|
|
|
look == RightButtonLook ? parts.dropDownButtonRightNormal():
|
|
|
|
parts.buttonNormal());
|
2009-11-22 04:02:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// external background
|
2013-05-21 07:40:18 +08:00
|
|
|
g->fillRect(BGCOLOR, g->getClipBounds());
|
2009-11-22 04:02:31 +08:00
|
|
|
|
|
|
|
// draw borders
|
2015-08-05 06:38:52 +08:00
|
|
|
if (part_nw)
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
drawRect(g, widget->clientBounds(), part_nw.get(), bg);
|
2009-11-22 04:02:31 +08:00
|
|
|
|
|
|
|
// text
|
2017-02-07 04:58:55 +08:00
|
|
|
drawText(g, NULL, fg, ColorNone, widget,
|
|
|
|
widget->clientChildrenBounds(), get_button_selected_offset());
|
2009-11-22 04:02:31 +08:00
|
|
|
|
2011-03-07 03:15:05 +08:00
|
|
|
// Paint the icon
|
|
|
|
if (iconInterface) {
|
2010-07-04 02:03:26 +08:00
|
|
|
if (widget->isSelected())
|
2013-10-26 23:50:55 +08:00
|
|
|
icon.offset(get_button_selected_offset(),
|
|
|
|
get_button_selected_offset());
|
2009-11-22 04:02:31 +08:00
|
|
|
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
paintIcon(widget, ev.graphics(), iconInterface, icon.x, icon.y);
|
2009-11-22 04:02:31 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-12 20:32:57 +08:00
|
|
|
void SkinTheme::paintCheckBox(PaintEvent& ev)
|
2009-11-22 04:02:31 +08:00
|
|
|
{
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
Graphics* g = ev.graphics();
|
2011-02-12 20:32:57 +08:00
|
|
|
ButtonBase* widget = static_cast<ButtonBase*>(ev.getSource());
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
gfx::Rect bounds = widget->clientBounds();
|
|
|
|
IButtonIcon* iconInterface = widget->iconInterface();
|
2013-10-26 23:50:55 +08:00
|
|
|
gfx::Rect box, text, icon;
|
2014-06-29 03:10:39 +08:00
|
|
|
gfx::Color bg;
|
2009-11-22 04:02:31 +08:00
|
|
|
|
2014-04-20 02:18:16 +08:00
|
|
|
widget->getTextIconInfo(&box, &text, &icon,
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
iconInterface ? iconInterface->iconAlign(): 0,
|
|
|
|
iconInterface ? iconInterface->size().w: 0,
|
|
|
|
iconInterface ? iconInterface->size().h: 0);
|
2009-11-22 04:02:31 +08:00
|
|
|
|
2011-03-30 08:07:37 +08:00
|
|
|
// Check box look
|
|
|
|
LookType look = NormalLook;
|
2013-12-05 12:19:46 +08:00
|
|
|
SkinPropertyPtr skinPropery = widget->getProperty(SkinProperty::Name);
|
2015-04-03 07:42:43 +08:00
|
|
|
if (skinPropery)
|
2011-03-30 08:07:37 +08:00
|
|
|
look = skinPropery->getLook();
|
|
|
|
|
|
|
|
// Background
|
2014-04-20 02:18:16 +08:00
|
|
|
g->fillRect(bg = BGCOLOR, bounds);
|
2009-11-22 04:02:31 +08:00
|
|
|
|
2011-03-30 08:07:37 +08:00
|
|
|
// Mouse
|
2010-07-04 02:26:27 +08:00
|
|
|
if (widget->isEnabled()) {
|
2010-04-25 23:03:25 +08:00
|
|
|
if (widget->hasMouseOver())
|
2015-02-16 02:29:16 +08:00
|
|
|
g->fillRect(bg = colors.checkHotFace(), bounds);
|
2010-04-25 23:03:25 +08:00
|
|
|
else if (widget->hasFocus())
|
2015-02-16 02:29:16 +08:00
|
|
|
g->fillRect(bg = colors.checkFocusFace(), bounds);
|
2009-11-22 04:02:31 +08:00
|
|
|
}
|
|
|
|
|
2011-03-30 08:07:37 +08:00
|
|
|
// Text
|
2017-02-07 04:58:55 +08:00
|
|
|
drawText(g, NULL, ColorNone, ColorNone, widget, text, 0);
|
2009-11-22 04:02:31 +08:00
|
|
|
|
2011-03-07 03:15:05 +08:00
|
|
|
// Paint the icon
|
|
|
|
if (iconInterface)
|
2014-04-20 02:18:16 +08:00
|
|
|
paintIcon(widget, g, iconInterface, icon.x, icon.y);
|
2009-11-22 04:02:31 +08:00
|
|
|
|
2016-11-22 05:03:06 +08:00
|
|
|
// Draw focus
|
|
|
|
if (look != WithoutBordersLook &&
|
|
|
|
(widget->hasFocus() || (iconInterface &&
|
|
|
|
widget->text().empty() &&
|
|
|
|
widget->hasMouseOver()))) {
|
2015-08-05 06:38:52 +08:00
|
|
|
drawRect(g, bounds, parts.checkFocus().get(), gfx::ColorNone);
|
2016-11-22 05:03:06 +08:00
|
|
|
}
|
2009-11-22 04:02:31 +08:00
|
|
|
}
|
|
|
|
|
2011-02-12 20:32:57 +08:00
|
|
|
void SkinTheme::paintGrid(PaintEvent& ev)
|
2009-11-22 04:02:31 +08:00
|
|
|
{
|
2011-02-12 20:32:57 +08:00
|
|
|
Widget* widget = static_cast<Widget*>(ev.getSource());
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
Graphics* g = ev.graphics();
|
2013-05-21 07:40:18 +08:00
|
|
|
|
2014-04-20 05:51:42 +08:00
|
|
|
if (!is_transparent(BGCOLOR))
|
|
|
|
g->fillRect(BGCOLOR, g->getClipBounds());
|
2009-11-22 04:02:31 +08:00
|
|
|
}
|
|
|
|
|
2011-02-12 20:32:57 +08:00
|
|
|
void SkinTheme::paintEntry(PaintEvent& ev)
|
2009-11-22 04:02:31 +08:00
|
|
|
{
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
Graphics* g = ev.graphics();
|
2011-02-12 20:32:57 +08:00
|
|
|
Entry* widget = static_cast<Entry*>(ev.getSource());
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
gfx::Rect bounds = widget->clientBounds();
|
2009-11-22 04:02:31 +08:00
|
|
|
|
2013-03-31 00:27:38 +08:00
|
|
|
// Outside borders
|
2014-04-20 02:18:16 +08:00
|
|
|
g->fillRect(BGCOLOR, bounds);
|
2009-11-22 04:02:31 +08:00
|
|
|
|
2012-01-10 08:18:32 +08:00
|
|
|
bool isMiniLook = false;
|
2013-12-05 12:19:46 +08:00
|
|
|
SkinPropertyPtr skinPropery = widget->getProperty(SkinProperty::Name);
|
2015-04-03 07:42:43 +08:00
|
|
|
if (skinPropery)
|
2012-01-10 08:18:32 +08:00
|
|
|
isMiniLook = (skinPropery->getLook() == MiniLook);
|
|
|
|
|
2015-02-16 02:29:16 +08:00
|
|
|
gfx::Color bg = colors.background();
|
2015-08-05 06:38:52 +08:00
|
|
|
drawRect(g, bounds,
|
2014-04-20 02:18:16 +08:00
|
|
|
(widget->hasFocus() ?
|
2015-08-05 06:38:52 +08:00
|
|
|
(isMiniLook ? parts.sunkenMiniFocused().get(): parts.sunkenFocused().get()):
|
|
|
|
(isMiniLook ? parts.sunkenMiniNormal().get() : parts.sunkenNormal().get())),
|
2014-04-20 02:18:16 +08:00
|
|
|
bg);
|
2009-11-22 04:02:31 +08:00
|
|
|
|
2017-02-07 04:58:55 +08:00
|
|
|
drawEntryText(g, widget);
|
|
|
|
}
|
2009-11-22 04:02:31 +08:00
|
|
|
|
2017-02-07 04:58:55 +08:00
|
|
|
namespace {
|
2015-04-06 22:53:14 +08:00
|
|
|
|
2017-02-07 04:58:55 +08:00
|
|
|
class DrawEntryTextDelegate : public she::DrawTextDelegate {
|
|
|
|
public:
|
|
|
|
DrawEntryTextDelegate(Entry* widget, Graphics* graphics,
|
|
|
|
const gfx::Point& pos, const int h)
|
|
|
|
: m_widget(widget)
|
|
|
|
, m_graphics(graphics)
|
|
|
|
, m_caretDrawn(false)
|
|
|
|
// m_lastX is an absolute position on screen
|
|
|
|
, m_lastX(pos.x+m_widget->bounds().x)
|
|
|
|
, m_y(pos.y)
|
|
|
|
, m_h(h)
|
|
|
|
{
|
|
|
|
m_widget->getEntryThemeInfo(&m_index, &m_caret, &m_state, &m_selbeg, &m_selend);
|
|
|
|
}
|
|
|
|
|
|
|
|
int index() const { return m_index; }
|
|
|
|
bool caretDrawn() const { return m_caretDrawn; }
|
|
|
|
const gfx::Rect& textBounds() const { return m_textBounds; }
|
|
|
|
|
|
|
|
void preProcessChar(const base::utf8_const_iterator& it,
|
|
|
|
const base::utf8_const_iterator& end,
|
|
|
|
int& chr,
|
|
|
|
gfx::Color& fg,
|
|
|
|
gfx::Color& bg,
|
|
|
|
bool& drawChar,
|
|
|
|
bool& moveCaret) override {
|
|
|
|
if (m_widget->isPassword())
|
|
|
|
chr = '*';
|
2009-11-22 04:02:31 +08:00
|
|
|
|
2013-01-07 01:45:43 +08:00
|
|
|
// Normal text
|
2017-02-07 04:58:55 +08:00
|
|
|
auto& colors = SkinTheme::instance()->colors;
|
2013-01-07 01:45:43 +08:00
|
|
|
bg = ColorNone;
|
2017-02-07 04:58:55 +08:00
|
|
|
fg = colors.text();
|
2009-11-22 04:02:31 +08:00
|
|
|
|
2013-01-07 01:45:43 +08:00
|
|
|
// Selected
|
2017-02-07 04:58:55 +08:00
|
|
|
if ((m_index >= m_selbeg) &&
|
|
|
|
(m_index <= m_selend)) {
|
|
|
|
if (m_widget->hasFocus())
|
2015-02-16 02:29:16 +08:00
|
|
|
bg = colors.selected();
|
2009-11-22 04:02:31 +08:00
|
|
|
else
|
2015-02-16 02:29:16 +08:00
|
|
|
bg = colors.disabled();
|
|
|
|
fg = colors.background();
|
2009-11-22 04:02:31 +08:00
|
|
|
}
|
|
|
|
|
2013-01-07 01:45:43 +08:00
|
|
|
// Disabled
|
2017-02-07 04:58:55 +08:00
|
|
|
if (!m_widget->isEnabled()) {
|
2013-03-30 03:27:08 +08:00
|
|
|
bg = ColorNone;
|
2015-02-16 02:29:16 +08:00
|
|
|
fg = colors.disabled();
|
2013-03-30 03:27:08 +08:00
|
|
|
}
|
|
|
|
|
2017-02-07 04:58:55 +08:00
|
|
|
drawChar = true;
|
|
|
|
moveCaret = true;
|
|
|
|
m_bg = bg;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool preDrawChar(const gfx::Rect& charBounds) override {
|
2017-02-08 06:05:47 +08:00
|
|
|
m_textBounds |= charBounds;
|
|
|
|
m_charStartX = charBounds.x;
|
|
|
|
|
2017-02-07 04:58:55 +08:00
|
|
|
if (charBounds.x2()-m_widget->bounds().x < m_widget->clientBounds().x2()) {
|
|
|
|
if (m_bg != ColorNone) {
|
|
|
|
// Fill background e.g. needed for selected/highlighted
|
|
|
|
// regions with TTF fonts where the char is smaller than the
|
|
|
|
// text bounds [m_y,m_y+m_h)
|
|
|
|
gfx::Rect fillThisRect(m_lastX-m_widget->bounds().x,
|
|
|
|
m_y, charBounds.x2()-m_lastX, m_h);
|
|
|
|
if (charBounds != fillThisRect)
|
|
|
|
m_graphics->fillRect(m_bg, fillThisRect);
|
|
|
|
}
|
|
|
|
m_lastX = charBounds.x2();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
2009-11-22 04:02:31 +08:00
|
|
|
|
2017-02-07 04:58:55 +08:00
|
|
|
void postDrawChar(const gfx::Rect& charBounds) override {
|
2013-01-07 01:45:43 +08:00
|
|
|
// Caret
|
2017-02-07 04:58:55 +08:00
|
|
|
if (m_state &&
|
|
|
|
m_index == m_caret &&
|
|
|
|
m_widget->hasFocus() &&
|
|
|
|
m_widget->isEnabled()) {
|
|
|
|
SkinTheme::instance()->drawEntryCaret(
|
|
|
|
m_graphics, m_widget,
|
2017-02-08 06:05:47 +08:00
|
|
|
m_charStartX-m_widget->bounds().x, m_y);
|
2017-02-07 04:58:55 +08:00
|
|
|
m_caretDrawn = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
++m_index;
|
2009-11-22 04:02:31 +08:00
|
|
|
}
|
|
|
|
|
2017-02-07 04:58:55 +08:00
|
|
|
private:
|
|
|
|
Entry* m_widget;
|
|
|
|
Graphics* m_graphics;
|
|
|
|
int m_index;
|
|
|
|
int m_caret;
|
|
|
|
int m_state;
|
|
|
|
int m_selbeg;
|
|
|
|
int m_selend;
|
|
|
|
gfx::Rect m_textBounds;
|
|
|
|
bool m_caretDrawn;
|
|
|
|
gfx::Color m_bg;
|
2017-02-08 06:05:47 +08:00
|
|
|
int m_lastX; // Last position used to fill the background
|
2017-02-07 04:58:55 +08:00
|
|
|
int m_y, m_h;
|
2017-02-08 06:05:47 +08:00
|
|
|
int m_charStartX;
|
2017-02-07 04:58:55 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // anonymous namespace
|
|
|
|
|
|
|
|
void SkinTheme::drawEntryText(ui::Graphics* g, ui::Entry* widget)
|
|
|
|
{
|
|
|
|
// Draw the text
|
|
|
|
gfx::Rect bounds = widget->getEntryTextBounds();
|
|
|
|
|
|
|
|
DrawEntryTextDelegate delegate(widget, g, bounds.origin(), widget->textHeight());
|
|
|
|
int scroll = delegate.index();
|
|
|
|
|
|
|
|
const std::string& textString = widget->text();
|
|
|
|
base::utf8_const_iterator utf8_it((textString.begin()));
|
|
|
|
int textlen = base::utf8_length(textString);
|
2017-02-08 06:05:47 +08:00
|
|
|
scroll = MIN(scroll, textlen);
|
|
|
|
if (scroll)
|
2017-02-07 04:58:55 +08:00
|
|
|
utf8_it += scroll;
|
|
|
|
|
|
|
|
g->drawText(utf8_it,
|
|
|
|
base::utf8_const_iterator(textString.end()),
|
|
|
|
colors.text(), ColorNone,
|
|
|
|
bounds.origin(), &delegate);
|
|
|
|
|
|
|
|
bounds.x += delegate.textBounds().w;
|
|
|
|
|
2015-11-25 06:54:10 +08:00
|
|
|
// Draw suffix if there is enough space
|
|
|
|
if (!widget->getSuffix().empty()) {
|
2017-02-07 04:58:55 +08:00
|
|
|
Rect sufBounds(bounds.x, bounds.y,
|
|
|
|
bounds.x2()-widget->childSpacing()*guiscale()-bounds.x,
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
widget->textHeight());
|
2017-02-08 06:05:47 +08:00
|
|
|
IntersectClip clip(g, sufBounds & widget->clientChildrenBounds());
|
2015-11-25 06:54:10 +08:00
|
|
|
if (clip) {
|
2017-02-07 04:58:55 +08:00
|
|
|
drawText(
|
2015-11-25 06:54:10 +08:00
|
|
|
g, widget->getSuffix().c_str(),
|
|
|
|
colors.entrySuffix(), ColorNone,
|
|
|
|
widget, sufBounds, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-07 04:58:55 +08:00
|
|
|
// Draw caret at the end of the text
|
|
|
|
if (!delegate.caretDrawn()) {
|
2017-02-08 06:05:47 +08:00
|
|
|
gfx::Rect charBounds(bounds.x+widget->bounds().x,
|
|
|
|
bounds.y+widget->bounds().y, 0, widget->textHeight());
|
|
|
|
delegate.preDrawChar(charBounds);
|
|
|
|
delegate.postDrawChar(charBounds);
|
2013-01-07 01:45:43 +08:00
|
|
|
}
|
2009-11-22 04:02:31 +08:00
|
|
|
}
|
|
|
|
|
2011-02-12 20:32:57 +08:00
|
|
|
void SkinTheme::paintLabel(PaintEvent& ev)
|
2009-11-22 04:02:31 +08:00
|
|
|
{
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
Graphics* g = ev.graphics();
|
2011-02-20 10:08:15 +08:00
|
|
|
Label* widget = static_cast<Label*>(ev.getSource());
|
2015-02-26 20:53:19 +08:00
|
|
|
Style* style = styles.label();
|
2014-06-29 03:10:39 +08:00
|
|
|
gfx::Color bg = BGCOLOR;
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
Rect text, rc = widget->clientBounds();
|
2009-11-22 04:02:31 +08:00
|
|
|
|
2015-02-26 20:53:19 +08:00
|
|
|
SkinStylePropertyPtr styleProp = widget->getProperty(SkinStyleProperty::Name);
|
|
|
|
if (styleProp)
|
|
|
|
style = styleProp->getStyle();
|
|
|
|
|
2014-04-20 05:51:42 +08:00
|
|
|
if (!is_transparent(bg))
|
|
|
|
g->fillRect(bg, rc);
|
|
|
|
|
2015-06-24 06:20:49 +08:00
|
|
|
rc.shrink(widget->border());
|
2011-02-20 10:08:15 +08:00
|
|
|
|
2016-08-31 04:27:19 +08:00
|
|
|
Style::State state;
|
|
|
|
if (!widget->isEnabled()) state += Style::disabled();
|
|
|
|
|
2014-04-20 02:18:16 +08:00
|
|
|
widget->getTextIconInfo(NULL, &text);
|
2016-08-31 04:27:19 +08:00
|
|
|
style->paint(g, text, widget->text().c_str(), state);
|
2009-11-22 04:02:31 +08:00
|
|
|
}
|
|
|
|
|
2011-02-12 20:32:57 +08:00
|
|
|
void SkinTheme::paintLinkLabel(PaintEvent& ev)
|
2010-07-04 01:33:31 +08:00
|
|
|
{
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
Graphics* g = ev.graphics();
|
2011-02-12 20:32:57 +08:00
|
|
|
Widget* widget = static_cast<Widget*>(ev.getSource());
|
2015-02-26 20:53:19 +08:00
|
|
|
Style* style = styles.link();
|
2016-12-07 08:30:46 +08:00
|
|
|
Rect text, rc = widget->clientBounds();
|
2014-06-29 03:10:39 +08:00
|
|
|
gfx::Color bg = BGCOLOR;
|
2010-07-04 01:33:31 +08:00
|
|
|
|
2015-02-26 20:53:19 +08:00
|
|
|
SkinStylePropertyPtr styleProp = widget->getProperty(SkinStyleProperty::Name);
|
|
|
|
if (styleProp)
|
|
|
|
style = styleProp->getStyle();
|
2010-07-04 01:33:31 +08:00
|
|
|
|
2015-02-26 20:53:19 +08:00
|
|
|
Style::State state;
|
|
|
|
if (widget->hasMouseOver()) state += Style::hover();
|
|
|
|
if (widget->isSelected()) state += Style::clicked();
|
2016-08-31 04:27:19 +08:00
|
|
|
if (!widget->isEnabled()) state += Style::disabled();
|
2015-02-26 20:53:19 +08:00
|
|
|
|
2016-12-16 22:07:43 +08:00
|
|
|
if (!is_transparent(bg))
|
|
|
|
g->fillRect(bg, rc);
|
|
|
|
|
|
|
|
style->paint(g, rc, widget->text().c_str(), state);
|
2010-07-04 01:33:31 +08:00
|
|
|
}
|
|
|
|
|
2013-05-21 07:40:18 +08:00
|
|
|
void SkinTheme::paintListBox(PaintEvent& ev)
|
2009-11-22 04:02:31 +08:00
|
|
|
{
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
Graphics* g = ev.graphics();
|
2013-05-21 07:40:18 +08:00
|
|
|
|
2015-02-16 02:29:16 +08:00
|
|
|
g->fillRect(colors.background(), g->getClipBounds());
|
2009-11-22 04:02:31 +08:00
|
|
|
}
|
|
|
|
|
2013-05-21 07:40:18 +08:00
|
|
|
void SkinTheme::paintListItem(ui::PaintEvent& ev)
|
2009-11-22 04:02:31 +08:00
|
|
|
{
|
2013-05-21 07:40:18 +08:00
|
|
|
Widget* widget = static_cast<Widget*>(ev.getSource());
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
gfx::Rect bounds = widget->clientBounds();
|
|
|
|
Graphics* g = ev.graphics();
|
2014-06-29 03:10:39 +08:00
|
|
|
gfx::Color fg, bg;
|
2009-11-22 04:02:31 +08:00
|
|
|
|
2010-07-04 02:26:27 +08:00
|
|
|
if (!widget->isEnabled()) {
|
2015-02-16 02:29:16 +08:00
|
|
|
bg = colors.face();
|
|
|
|
fg = colors.disabled();
|
2009-11-22 04:02:31 +08:00
|
|
|
}
|
2010-07-04 02:03:26 +08:00
|
|
|
else if (widget->isSelected()) {
|
2015-02-16 02:29:16 +08:00
|
|
|
fg = colors.listitemSelectedText();
|
|
|
|
bg = colors.listitemSelectedFace();
|
2009-11-22 04:02:31 +08:00
|
|
|
}
|
|
|
|
else {
|
2015-02-16 02:29:16 +08:00
|
|
|
fg = colors.listitemNormalText();
|
|
|
|
bg = colors.listitemNormalFace();
|
2009-11-22 04:02:31 +08:00
|
|
|
}
|
|
|
|
|
2014-04-20 02:18:16 +08:00
|
|
|
g->fillRect(bg, bounds);
|
2009-11-22 04:02:31 +08:00
|
|
|
|
2010-01-26 08:38:05 +08:00
|
|
|
if (widget->hasText()) {
|
2015-06-24 06:20:49 +08:00
|
|
|
bounds.shrink(widget->border());
|
2017-02-07 04:58:55 +08:00
|
|
|
drawText(g, NULL, fg, bg, widget, bounds, 0);
|
2009-11-22 04:02:31 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-21 07:40:18 +08:00
|
|
|
void SkinTheme::paintMenu(PaintEvent& ev)
|
2009-11-22 04:02:31 +08:00
|
|
|
{
|
2013-05-21 07:40:18 +08:00
|
|
|
Widget* widget = static_cast<Widget*>(ev.getSource());
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
Graphics* g = ev.graphics();
|
2013-05-21 07:40:18 +08:00
|
|
|
|
|
|
|
g->fillRect(BGCOLOR, g->getClipBounds());
|
2009-11-22 04:02:31 +08:00
|
|
|
}
|
|
|
|
|
2013-05-21 07:40:18 +08:00
|
|
|
void SkinTheme::paintMenuItem(ui::PaintEvent& ev)
|
2009-11-22 04:02:31 +08:00
|
|
|
{
|
2014-11-26 09:33:45 +08:00
|
|
|
int scale = guiscale();
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
Graphics* g = ev.graphics();
|
2014-11-07 05:41:18 +08:00
|
|
|
MenuItem* widget = static_cast<MenuItem*>(ev.getSource());
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
gfx::Rect bounds = widget->clientBounds();
|
2014-06-29 03:10:39 +08:00
|
|
|
gfx::Color fg, bg;
|
2013-01-07 01:45:43 +08:00
|
|
|
int c, bar;
|
2009-11-22 04:02:31 +08:00
|
|
|
|
2013-01-07 01:45:43 +08:00
|
|
|
// TODO ASSERT?
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
if (!widget->parent()->parent())
|
2009-11-22 04:02:31 +08:00
|
|
|
return;
|
|
|
|
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
bar = (widget->parent()->parent()->type() == kMenuBarWidget);
|
2009-11-22 04:02:31 +08:00
|
|
|
|
2013-01-07 01:45:43 +08:00
|
|
|
// Colors
|
2010-07-04 02:26:27 +08:00
|
|
|
if (!widget->isEnabled()) {
|
2013-01-07 01:45:43 +08:00
|
|
|
fg = ColorNone;
|
2015-02-16 02:29:16 +08:00
|
|
|
bg = colors.menuitemNormalFace();
|
2009-11-22 04:02:31 +08:00
|
|
|
}
|
|
|
|
else {
|
2011-04-23 10:00:35 +08:00
|
|
|
if (widget->isHighlighted()) {
|
2015-02-16 02:29:16 +08:00
|
|
|
fg = colors.menuitemHighlightText();
|
|
|
|
bg = colors.menuitemHighlightFace();
|
2009-11-22 04:02:31 +08:00
|
|
|
}
|
2014-04-25 19:59:00 +08:00
|
|
|
else if (widget->hasMouse()) {
|
2015-02-16 02:29:16 +08:00
|
|
|
fg = colors.menuitemHotText();
|
|
|
|
bg = colors.menuitemHotFace();
|
2009-11-22 04:02:31 +08:00
|
|
|
}
|
|
|
|
else {
|
2015-02-16 02:29:16 +08:00
|
|
|
fg = colors.menuitemNormalText();
|
|
|
|
bg = colors.menuitemNormalFace();
|
2009-11-22 04:02:31 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-20 02:18:16 +08:00
|
|
|
// Background
|
|
|
|
g->fillRect(bg, bounds);
|
2009-11-22 04:02:31 +08:00
|
|
|
|
2014-04-20 02:18:16 +08:00
|
|
|
// Draw an indicator for selected items
|
2010-07-04 02:03:26 +08:00
|
|
|
if (widget->isSelected()) {
|
2014-06-23 05:53:14 +08:00
|
|
|
she::Surface* icon =
|
2015-08-05 06:38:52 +08:00
|
|
|
(widget->isEnabled() ?
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
parts.checkSelected()->bitmap(0):
|
|
|
|
parts.checkDisabled()->bitmap(0));
|
2014-06-23 05:53:14 +08:00
|
|
|
|
|
|
|
int x = bounds.x+4*scale-icon->width()/2;
|
|
|
|
int y = bounds.y+bounds.h/2-icon->height()/2;
|
|
|
|
g->drawRgbaSurface(icon, x, y);
|
2009-11-22 04:02:31 +08:00
|
|
|
}
|
|
|
|
|
2014-04-20 02:18:16 +08:00
|
|
|
// Text
|
2009-11-22 04:02:31 +08:00
|
|
|
if (bar)
|
2015-06-24 01:00:00 +08:00
|
|
|
widget->setAlign(CENTER | MIDDLE);
|
2009-11-22 04:02:31 +08:00
|
|
|
else
|
2015-06-24 01:00:00 +08:00
|
|
|
widget->setAlign(LEFT | MIDDLE);
|
2009-11-22 04:02:31 +08:00
|
|
|
|
2014-04-20 02:18:16 +08:00
|
|
|
Rect pos = bounds;
|
2009-11-22 04:02:31 +08:00
|
|
|
if (!bar)
|
2015-06-24 06:20:49 +08:00
|
|
|
pos.offset(widget->childSpacing()/2, 0);
|
2017-02-07 04:58:55 +08:00
|
|
|
drawText(g, NULL, fg, ColorNone, widget, pos, 0);
|
2009-11-22 04:02:31 +08:00
|
|
|
|
2013-05-21 07:40:18 +08:00
|
|
|
// For menu-box
|
2009-11-22 04:02:31 +08:00
|
|
|
if (!bar) {
|
2013-05-21 07:40:18 +08:00
|
|
|
// Draw the arrown (to indicate which this menu has a sub-menu)
|
2011-04-23 10:00:35 +08:00
|
|
|
if (widget->getSubmenu()) {
|
2013-05-21 07:40:18 +08:00
|
|
|
// Enabled
|
2010-07-04 02:26:27 +08:00
|
|
|
if (widget->isEnabled()) {
|
2012-01-06 06:45:03 +08:00
|
|
|
for (c=0; c<3*scale; c++)
|
2014-04-20 02:18:16 +08:00
|
|
|
g->drawVLine(fg,
|
|
|
|
bounds.x2()-3*scale-c,
|
|
|
|
bounds.y+bounds.h/2-c, 2*c+1);
|
2009-11-22 04:02:31 +08:00
|
|
|
}
|
2013-05-21 07:40:18 +08:00
|
|
|
// Disabled
|
2009-11-22 04:02:31 +08:00
|
|
|
else {
|
2012-01-06 06:45:03 +08:00
|
|
|
for (c=0; c<3*scale; c++)
|
2015-02-16 02:29:16 +08:00
|
|
|
g->drawVLine(colors.background(),
|
2014-04-20 02:18:16 +08:00
|
|
|
bounds.x2()-3*scale-c+1,
|
|
|
|
bounds.y+bounds.h/2-c+1, 2*c+1);
|
|
|
|
|
2012-01-06 06:45:03 +08:00
|
|
|
for (c=0; c<3*scale; c++)
|
2015-02-16 02:29:16 +08:00
|
|
|
g->drawVLine(colors.disabled(),
|
2014-04-20 02:18:16 +08:00
|
|
|
bounds.x2()-3*scale-c,
|
|
|
|
bounds.y+bounds.h/2-c, 2*c+1);
|
2009-11-22 04:02:31 +08:00
|
|
|
}
|
|
|
|
}
|
2012-07-18 08:42:02 +08:00
|
|
|
// Draw the keyboard shortcut
|
2014-11-07 05:41:18 +08:00
|
|
|
else if (AppMenuItem* appMenuItem = dynamic_cast<AppMenuItem*>(widget)) {
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
if (appMenuItem->key() && !appMenuItem->key()->accels().empty()) {
|
|
|
|
int old_align = appMenuItem->align();
|
2009-11-22 04:02:31 +08:00
|
|
|
|
2014-11-07 05:41:18 +08:00
|
|
|
pos = bounds;
|
2015-06-24 06:20:49 +08:00
|
|
|
pos.w -= widget->childSpacing()/4;
|
2009-11-22 04:02:31 +08:00
|
|
|
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
std::string buf = appMenuItem->key()->accels().front().toString();
|
2009-11-22 04:02:31 +08:00
|
|
|
|
2015-06-24 01:00:00 +08:00
|
|
|
widget->setAlign(RIGHT | MIDDLE);
|
2017-02-07 04:58:55 +08:00
|
|
|
drawText(g, buf.c_str(), fg, ColorNone, widget, pos, 0);
|
2014-11-07 05:41:18 +08:00
|
|
|
widget->setAlign(old_align);
|
|
|
|
}
|
2009-11-22 04:02:31 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-21 07:40:18 +08:00
|
|
|
void SkinTheme::paintSplitter(PaintEvent& ev)
|
2009-11-22 04:02:31 +08:00
|
|
|
{
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
Graphics* g = ev.graphics();
|
2013-05-21 07:40:18 +08:00
|
|
|
|
2015-02-16 02:29:16 +08:00
|
|
|
g->fillRect(colors.splitterNormalFace(), g->getClipBounds());
|
2009-11-22 04:02:31 +08:00
|
|
|
}
|
|
|
|
|
2011-02-12 20:32:57 +08:00
|
|
|
void SkinTheme::paintRadioButton(PaintEvent& ev)
|
2009-11-22 04:02:31 +08:00
|
|
|
{
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
Graphics* g = ev.graphics();
|
2014-04-20 02:18:16 +08:00
|
|
|
ButtonBase* widget = static_cast<ButtonBase*>(ev.getSource());
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
gfx::Rect bounds = widget->clientBounds();
|
|
|
|
IButtonIcon* iconInterface = widget->iconInterface();
|
2014-06-29 03:10:39 +08:00
|
|
|
gfx::Color bg = BGCOLOR;
|
2009-11-22 04:02:31 +08:00
|
|
|
|
2013-10-26 23:50:55 +08:00
|
|
|
gfx::Rect box, text, icon;
|
2014-04-20 02:18:16 +08:00
|
|
|
widget->getTextIconInfo(&box, &text, &icon,
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
iconInterface ? iconInterface->iconAlign(): 0,
|
|
|
|
iconInterface ? iconInterface->size().w: 0,
|
|
|
|
iconInterface ? iconInterface->size().h: 0);
|
2009-11-22 04:02:31 +08:00
|
|
|
|
2013-05-21 07:40:18 +08:00
|
|
|
// Background
|
|
|
|
g->fillRect(bg, g->getClipBounds());
|
2009-11-22 04:02:31 +08:00
|
|
|
|
2013-05-21 07:40:18 +08:00
|
|
|
// Mouse
|
2010-07-04 02:26:27 +08:00
|
|
|
if (widget->isEnabled()) {
|
2010-04-25 23:03:25 +08:00
|
|
|
if (widget->hasMouseOver())
|
2015-02-16 02:29:16 +08:00
|
|
|
g->fillRect(bg = colors.radioHotFace(), bounds);
|
2010-04-25 23:03:25 +08:00
|
|
|
else if (widget->hasFocus())
|
2015-02-16 02:29:16 +08:00
|
|
|
g->fillRect(bg = colors.radioFocusFace(), bounds);
|
2009-11-22 04:02:31 +08:00
|
|
|
}
|
|
|
|
|
2013-05-21 07:40:18 +08:00
|
|
|
// Text
|
2017-02-07 04:58:55 +08:00
|
|
|
drawText(g, NULL, ColorNone, ColorNone, widget, text, 0);
|
2009-11-22 04:02:31 +08:00
|
|
|
|
2014-04-20 02:18:16 +08:00
|
|
|
// Icon
|
2011-03-07 03:15:05 +08:00
|
|
|
if (iconInterface)
|
2014-04-20 02:18:16 +08:00
|
|
|
paintIcon(widget, g, iconInterface, icon.x, icon.y);
|
2009-11-22 04:02:31 +08:00
|
|
|
|
2014-04-20 02:18:16 +08:00
|
|
|
// Focus
|
|
|
|
if (widget->hasFocus())
|
2015-08-05 06:38:52 +08:00
|
|
|
drawRect(g, bounds, parts.radioFocus().get(), gfx::ColorNone);
|
2009-11-22 04:02:31 +08:00
|
|
|
}
|
|
|
|
|
2013-05-21 07:40:18 +08:00
|
|
|
void SkinTheme::paintSeparator(ui::PaintEvent& ev)
|
2009-11-22 04:02:31 +08:00
|
|
|
{
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
Graphics* g = ev.graphics();
|
2014-04-20 02:18:16 +08:00
|
|
|
Widget* widget = static_cast<Widget*>(ev.getSource());
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
gfx::Rect bounds = widget->clientBounds();
|
2009-11-22 04:02:31 +08:00
|
|
|
|
|
|
|
// background
|
2014-04-20 02:18:16 +08:00
|
|
|
g->fillRect(BGCOLOR, bounds);
|
2009-11-22 04:02:31 +08:00
|
|
|
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
if (widget->align() & HORIZONTAL) {
|
|
|
|
int h = parts.separatorHorz()->bitmap(0)->height();
|
2015-12-01 02:08:18 +08:00
|
|
|
drawHline(g, gfx::Rect(bounds.x, bounds.y+bounds.h/2-h/2,
|
|
|
|
bounds.w, h),
|
|
|
|
parts.separatorHorz().get());
|
|
|
|
}
|
2010-04-26 02:02:28 +08:00
|
|
|
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
if (widget->align() & VERTICAL) {
|
|
|
|
int w = parts.separatorVert()->bitmap(0)->width();
|
2015-12-01 02:08:18 +08:00
|
|
|
drawVline(g, gfx::Rect(bounds.x+bounds.w/2-w/2, bounds.y,
|
|
|
|
w, bounds.h),
|
|
|
|
parts.separatorVert().get());
|
|
|
|
}
|
2009-11-22 04:02:31 +08:00
|
|
|
|
|
|
|
// text
|
2010-01-26 08:38:05 +08:00
|
|
|
if (widget->hasText()) {
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
int h = widget->textHeight();
|
2014-04-20 02:18:16 +08:00
|
|
|
Rect r(
|
2015-12-01 02:08:18 +08:00
|
|
|
bounds.x + widget->border().left()/2 + h/2,
|
|
|
|
bounds.y + bounds.h/2 - h/2,
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
widget->textWidth(), h);
|
2014-04-20 02:18:16 +08:00
|
|
|
|
2017-02-07 04:58:55 +08:00
|
|
|
drawText(g, NULL,
|
2015-02-16 02:29:16 +08:00
|
|
|
colors.separatorLabel(), BGCOLOR,
|
2014-04-20 02:18:16 +08:00
|
|
|
widget, r, 0);
|
2009-11-22 04:02:31 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-05 23:03:22 +08:00
|
|
|
void SkinTheme::paintSlider(PaintEvent& ev)
|
2009-11-22 04:02:31 +08:00
|
|
|
{
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
Graphics* g = ev.graphics();
|
2014-04-20 02:18:16 +08:00
|
|
|
Slider* widget = static_cast<Slider*>(ev.getSource());
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
Rect bounds = widget->clientBounds();
|
2009-11-22 04:02:31 +08:00
|
|
|
int min, max, value;
|
|
|
|
|
2013-04-04 08:17:12 +08:00
|
|
|
// Outside borders
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
gfx::Color bgcolor = widget->bgColor();
|
2013-04-04 08:17:12 +08:00
|
|
|
if (!is_transparent(bgcolor))
|
2014-04-20 02:18:16 +08:00
|
|
|
g->fillRect(bgcolor, bounds);
|
2013-04-04 08:17:12 +08:00
|
|
|
|
2010-12-05 03:13:21 +08:00
|
|
|
widget->getSliderThemeInfo(&min, &max, &value);
|
2009-11-22 04:02:31 +08:00
|
|
|
|
2015-06-24 06:20:49 +08:00
|
|
|
Rect rc(Rect(bounds).shrink(widget->border()));
|
2011-02-05 23:03:22 +08:00
|
|
|
int x;
|
2009-11-22 04:02:31 +08:00
|
|
|
if (min != max)
|
2011-02-05 23:03:22 +08:00
|
|
|
x = rc.x + rc.w * (value-min) / (max-min);
|
2009-11-22 04:02:31 +08:00
|
|
|
else
|
2011-02-05 23:03:22 +08:00
|
|
|
x = rc.x;
|
2009-11-22 04:02:31 +08:00
|
|
|
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
rc = widget->clientBounds();
|
2009-11-22 04:02:31 +08:00
|
|
|
|
2011-01-24 11:03:38 +08:00
|
|
|
// The mini-look is used for sliders with tiny borders.
|
|
|
|
bool isMiniLook = false;
|
|
|
|
|
|
|
|
// The BG painter is used for sliders without a number-indicator and
|
|
|
|
// customized background (e.g. RGB sliders)
|
|
|
|
ISliderBgPainter* bgPainter = NULL;
|
|
|
|
|
2013-12-05 12:19:46 +08:00
|
|
|
SkinPropertyPtr skinPropery = widget->getProperty(SkinProperty::Name);
|
2015-04-03 07:42:43 +08:00
|
|
|
if (skinPropery)
|
2011-03-30 08:07:37 +08:00
|
|
|
isMiniLook = (skinPropery->getLook() == MiniLook);
|
2011-01-24 11:03:38 +08:00
|
|
|
|
2013-12-05 12:19:46 +08:00
|
|
|
SkinSliderPropertyPtr skinSliderPropery = widget->getProperty(SkinSliderProperty::Name);
|
2015-04-03 07:42:43 +08:00
|
|
|
if (skinSliderPropery)
|
2013-12-05 12:19:46 +08:00
|
|
|
bgPainter = skinSliderPropery->getBgPainter();
|
2011-01-24 11:03:38 +08:00
|
|
|
|
|
|
|
// Draw customized background
|
|
|
|
if (bgPainter) {
|
2015-08-05 06:38:52 +08:00
|
|
|
SkinPartPtr nw = parts.miniSliderEmpty();
|
2014-06-23 05:53:14 +08:00
|
|
|
she::Surface* thumb =
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
(widget->hasFocus() ? parts.miniSliderThumbFocused()->bitmap(0):
|
|
|
|
parts.miniSliderThumb()->bitmap(0));
|
2011-01-24 11:03:38 +08:00
|
|
|
|
|
|
|
// Draw background
|
2011-02-05 23:03:22 +08:00
|
|
|
g->fillRect(BGCOLOR, rc);
|
2011-01-24 11:03:38 +08:00
|
|
|
|
|
|
|
// Draw thumb
|
2016-09-13 04:53:01 +08:00
|
|
|
int thumb_y = rc.y;
|
|
|
|
if (rc.h > thumb->height()*3)
|
|
|
|
rc.shrink(Border(0, thumb->height(), 0, 0));
|
2011-01-24 11:03:38 +08:00
|
|
|
|
|
|
|
// Draw borders
|
2016-09-13 04:53:01 +08:00
|
|
|
if (rc.h > 4*guiscale()) {
|
|
|
|
rc.shrink(Border(3, 0, 3, 1) * guiscale());
|
|
|
|
drawRect(g, rc, nw.get(), gfx::ColorNone);
|
|
|
|
}
|
2010-03-22 08:28:32 +08:00
|
|
|
|
2011-02-05 23:03:22 +08:00
|
|
|
// Draw background (using the customized ISliderBgPainter implementation)
|
2014-11-26 09:33:45 +08:00
|
|
|
rc.shrink(Border(1, 1, 1, 2) * guiscale());
|
2011-02-05 23:03:22 +08:00
|
|
|
if (!rc.isEmpty())
|
|
|
|
bgPainter->paint(widget, g, rc);
|
2016-09-13 04:53:01 +08:00
|
|
|
|
|
|
|
g->drawRgbaSurface(thumb, x-thumb->width()/2, thumb_y);
|
2010-03-22 08:28:32 +08:00
|
|
|
}
|
|
|
|
else {
|
2011-01-24 11:03:38 +08:00
|
|
|
// Draw borders
|
2015-08-05 06:38:52 +08:00
|
|
|
SkinPartPtr full_part;
|
|
|
|
SkinPartPtr empty_part;
|
2011-01-24 11:03:38 +08:00
|
|
|
|
|
|
|
if (isMiniLook) {
|
2015-08-05 06:38:52 +08:00
|
|
|
full_part = widget->hasMouseOver() ? parts.miniSliderFullFocused():
|
|
|
|
parts.miniSliderFull();
|
|
|
|
empty_part = widget->hasMouseOver() ? parts.miniSliderEmptyFocused():
|
|
|
|
parts.miniSliderEmpty();
|
2011-01-24 11:03:38 +08:00
|
|
|
}
|
|
|
|
else {
|
2015-08-05 06:38:52 +08:00
|
|
|
full_part = widget->hasFocus() ? parts.sliderFullFocused():
|
|
|
|
parts.sliderFull();
|
|
|
|
empty_part = widget->hasFocus() ? parts.sliderEmptyFocused():
|
|
|
|
parts.sliderEmpty();
|
2011-01-24 11:03:38 +08:00
|
|
|
}
|
2009-11-22 04:02:31 +08:00
|
|
|
|
2011-01-24 11:03:38 +08:00
|
|
|
if (value == min)
|
2015-08-05 06:38:52 +08:00
|
|
|
drawRect(g, rc, empty_part.get(), colors.sliderEmptyFace());
|
2011-01-24 11:03:38 +08:00
|
|
|
else if (value == max)
|
2015-08-05 06:38:52 +08:00
|
|
|
drawRect(g, rc, full_part.get(), colors.sliderFullFace());
|
2011-01-24 11:03:38 +08:00
|
|
|
else
|
2015-08-05 06:38:52 +08:00
|
|
|
drawRect2(g, rc, x,
|
|
|
|
full_part.get(), empty_part.get(),
|
|
|
|
colors.sliderFullFace(),
|
|
|
|
colors.sliderEmptyFace());
|
2009-11-22 04:02:31 +08:00
|
|
|
|
2011-01-24 11:03:38 +08:00
|
|
|
// Draw text
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
std::string old_text = widget->text();
|
2015-08-15 06:46:48 +08:00
|
|
|
widget->setTextQuiet(widget->convertValueToText(value));
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2014-05-05 08:51:52 +08:00
|
|
|
{
|
|
|
|
IntersectClip clip(g, Rect(rc.x, rc.y, x-rc.x, rc.h));
|
|
|
|
if (clip) {
|
2017-02-07 04:58:55 +08:00
|
|
|
drawText(g, NULL,
|
2015-02-16 02:29:16 +08:00
|
|
|
colors.sliderFullText(), ColorNone,
|
2014-06-27 09:14:39 +08:00
|
|
|
widget, rc, 0);
|
2014-05-05 08:51:52 +08:00
|
|
|
}
|
2011-02-05 23:03:22 +08:00
|
|
|
}
|
2009-11-22 04:02:31 +08:00
|
|
|
|
2014-05-05 08:51:52 +08:00
|
|
|
{
|
|
|
|
IntersectClip clip(g, Rect(x+1, rc.y, rc.w-(x-rc.x+1), rc.h));
|
|
|
|
if (clip) {
|
2017-02-07 04:58:55 +08:00
|
|
|
drawText(g, NULL,
|
2015-02-16 02:29:16 +08:00
|
|
|
colors.sliderEmptyText(),
|
2014-06-27 09:14:39 +08:00
|
|
|
ColorNone, widget, rc, 0);
|
2014-05-05 08:51:52 +08:00
|
|
|
}
|
2011-02-05 23:03:22 +08:00
|
|
|
}
|
2009-11-22 04:02:31 +08:00
|
|
|
|
2010-01-26 08:38:05 +08:00
|
|
|
widget->setTextQuiet(old_text.c_str());
|
2009-11-22 04:02:31 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-21 07:40:18 +08:00
|
|
|
void SkinTheme::paintComboBoxEntry(ui::PaintEvent& ev)
|
2009-11-22 08:26:58 +08:00
|
|
|
{
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
Graphics* g = ev.graphics();
|
2013-05-21 07:40:18 +08:00
|
|
|
Entry* widget = static_cast<Entry*>(ev.getSource());
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
gfx::Rect bounds = widget->clientBounds();
|
2009-11-22 08:26:58 +08:00
|
|
|
|
2013-03-31 00:27:38 +08:00
|
|
|
// Outside borders
|
2014-04-20 02:18:16 +08:00
|
|
|
g->fillRect(BGCOLOR, bounds);
|
2009-11-22 08:26:58 +08:00
|
|
|
|
2017-02-07 04:58:55 +08:00
|
|
|
gfx::Color bg = colors.background();
|
2009-11-22 08:26:58 +08:00
|
|
|
|
2015-08-05 06:38:52 +08:00
|
|
|
drawRect(g, bounds,
|
|
|
|
(widget->hasFocus() ?
|
|
|
|
parts.sunken2Focused().get():
|
|
|
|
parts.sunken2Normal().get()), bg);
|
2009-11-22 08:26:58 +08:00
|
|
|
|
2017-02-07 04:58:55 +08:00
|
|
|
drawEntryText(g, widget);
|
2009-11-22 08:26:58 +08:00
|
|
|
}
|
|
|
|
|
2011-03-07 03:15:05 +08:00
|
|
|
void SkinTheme::paintComboBoxButton(PaintEvent& ev)
|
2009-11-22 08:26:58 +08:00
|
|
|
{
|
2011-03-07 03:15:05 +08:00
|
|
|
Button* widget = static_cast<Button*>(ev.getSource());
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
Graphics* g = ev.graphics();
|
|
|
|
IButtonIcon* iconInterface = widget->iconInterface();
|
2015-08-05 06:38:52 +08:00
|
|
|
SkinPartPtr part_nw;
|
2014-06-29 03:10:39 +08:00
|
|
|
gfx::Color bg;
|
2009-11-22 08:26:58 +08:00
|
|
|
|
2011-03-07 03:15:05 +08:00
|
|
|
if (widget->isSelected()) {
|
2015-02-16 02:29:16 +08:00
|
|
|
bg = colors.buttonSelectedFace();
|
2015-08-05 06:38:52 +08:00
|
|
|
part_nw = parts.toolbuttonPushed();
|
2011-03-07 03:15:05 +08:00
|
|
|
}
|
|
|
|
// With mouse
|
|
|
|
else if (widget->isEnabled() && widget->hasMouseOver()) {
|
2015-02-16 02:29:16 +08:00
|
|
|
bg = colors.buttonHotFace();
|
2015-08-05 06:38:52 +08:00
|
|
|
part_nw = parts.toolbuttonHot();
|
2009-11-22 08:26:58 +08:00
|
|
|
}
|
2011-03-07 03:15:05 +08:00
|
|
|
// Without mouse
|
2009-11-22 08:26:58 +08:00
|
|
|
else {
|
2015-02-16 02:29:16 +08:00
|
|
|
bg = colors.buttonNormalFace();
|
2015-08-05 06:38:52 +08:00
|
|
|
part_nw = parts.toolbuttonLast();
|
2009-11-22 08:26:58 +08:00
|
|
|
}
|
|
|
|
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
Rect rc = widget->clientBounds();
|
2009-11-22 08:26:58 +08:00
|
|
|
|
|
|
|
// external background
|
2011-03-07 03:15:05 +08:00
|
|
|
g->fillRect(BGCOLOR, rc);
|
2009-11-22 08:26:58 +08:00
|
|
|
|
|
|
|
// draw borders
|
2015-08-05 06:38:52 +08:00
|
|
|
drawRect(g, rc, part_nw.get(), bg);
|
2009-11-22 08:26:58 +08:00
|
|
|
|
2011-03-07 03:15:05 +08:00
|
|
|
// Paint the icon
|
|
|
|
if (iconInterface) {
|
|
|
|
// Icon
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
int x = rc.x + rc.w/2 - iconInterface->size().w/2;
|
|
|
|
int y = rc.y + rc.h/2 - iconInterface->size().h/2;
|
2009-11-22 08:26:58 +08:00
|
|
|
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
paintIcon(widget, ev.graphics(), iconInterface, x, y);
|
2011-03-07 03:15:05 +08:00
|
|
|
}
|
2009-11-22 08:26:58 +08:00
|
|
|
}
|
|
|
|
|
2013-05-21 07:40:18 +08:00
|
|
|
void SkinTheme::paintTextBox(ui::PaintEvent& ev)
|
2009-11-22 04:02:31 +08:00
|
|
|
{
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
Graphics* g = ev.graphics();
|
2013-05-21 07:40:18 +08:00
|
|
|
Widget* widget = static_cast<Widget*>(ev.getSource());
|
2014-04-20 02:18:16 +08:00
|
|
|
|
2016-12-15 21:50:47 +08:00
|
|
|
Theme::drawTextBox(g, widget, nullptr, nullptr,
|
|
|
|
BGCOLOR, colors.textboxText());
|
2009-11-22 04:02:31 +08:00
|
|
|
}
|
|
|
|
|
2013-01-07 01:45:43 +08:00
|
|
|
void SkinTheme::paintView(PaintEvent& ev)
|
2009-11-22 04:02:31 +08:00
|
|
|
{
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
Graphics* g = ev.graphics();
|
2013-01-07 01:45:43 +08:00
|
|
|
View* widget = static_cast<View*>(ev.getSource());
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
gfx::Rect bounds = widget->clientBounds();
|
2014-06-29 03:10:39 +08:00
|
|
|
gfx::Color bg = BGCOLOR;
|
2015-02-26 20:53:19 +08:00
|
|
|
Style* style = styles.view();
|
|
|
|
|
|
|
|
SkinStylePropertyPtr styleProp = widget->getProperty(SkinStyleProperty::Name);
|
|
|
|
if (styleProp)
|
|
|
|
style = styleProp->getStyle();
|
|
|
|
|
|
|
|
Style::State state;
|
|
|
|
if (widget->hasMouseOver()) state += Style::hover();
|
2013-01-07 01:45:43 +08:00
|
|
|
|
2014-04-20 05:51:42 +08:00
|
|
|
if (!is_transparent(bg))
|
|
|
|
g->fillRect(bg, bounds);
|
2013-03-31 00:27:38 +08:00
|
|
|
|
2015-02-26 20:53:19 +08:00
|
|
|
style->paint(g, bounds, nullptr, state);
|
2009-11-22 04:02:31 +08:00
|
|
|
}
|
|
|
|
|
2013-01-07 01:45:43 +08:00
|
|
|
void SkinTheme::paintViewScrollbar(PaintEvent& ev)
|
2009-11-22 04:02:31 +08:00
|
|
|
{
|
2013-01-07 01:45:43 +08:00
|
|
|
ScrollBar* widget = static_cast<ScrollBar*>(ev.getSource());
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
Graphics* g = ev.graphics();
|
2009-11-22 04:02:31 +08:00
|
|
|
int pos, len;
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2014-01-27 00:28:11 +08:00
|
|
|
bool isMiniLook = false;
|
|
|
|
SkinPropertyPtr skinPropery = widget->getProperty(SkinProperty::Name);
|
2015-04-03 07:42:43 +08:00
|
|
|
if (skinPropery)
|
2014-01-27 00:28:11 +08:00
|
|
|
isMiniLook = (skinPropery->getLook() == MiniLook);
|
|
|
|
|
2015-09-18 02:19:47 +08:00
|
|
|
skin::Style* bgStyle;
|
|
|
|
skin::Style* thumbStyle;
|
2015-02-17 22:43:25 +08:00
|
|
|
|
2015-09-18 02:19:47 +08:00
|
|
|
if (widget->isTransparent()) {
|
|
|
|
bgStyle = styles.transparentScrollbar();
|
|
|
|
thumbStyle = styles.transparentScrollbarThumb();
|
|
|
|
}
|
|
|
|
else if (isMiniLook) {
|
|
|
|
bgStyle = styles.miniScrollbar();
|
|
|
|
thumbStyle = styles.miniScrollbarThumb();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
bgStyle = styles.scrollbar();
|
|
|
|
thumbStyle = styles.scrollbarThumb();
|
|
|
|
}
|
2014-01-27 00:28:11 +08:00
|
|
|
|
2011-02-21 05:35:21 +08:00
|
|
|
widget->getScrollBarThemeInfo(&pos, &len);
|
2009-11-22 04:02:31 +08:00
|
|
|
|
2015-09-18 02:19:47 +08:00
|
|
|
Style::State state;
|
|
|
|
if (widget->hasMouse()) state += Style::hover();
|
2009-11-22 04:02:31 +08:00
|
|
|
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
gfx::Rect rc = widget->clientBounds();
|
2015-09-18 02:19:47 +08:00
|
|
|
bgStyle->paint(g, rc, NULL, state);
|
2009-11-22 04:02:31 +08:00
|
|
|
|
2010-06-24 11:09:46 +08:00
|
|
|
// Horizontal bar
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
if (widget->align() & HORIZONTAL) {
|
2013-01-07 01:45:43 +08:00
|
|
|
rc.x += pos;
|
|
|
|
rc.w = len;
|
2009-11-22 04:02:31 +08:00
|
|
|
}
|
2010-06-24 11:09:46 +08:00
|
|
|
// Vertical bar
|
2009-11-22 04:02:31 +08:00
|
|
|
else {
|
2013-01-07 01:45:43 +08:00
|
|
|
rc.y += pos;
|
|
|
|
rc.h = len;
|
2009-11-22 04:02:31 +08:00
|
|
|
}
|
|
|
|
|
2015-09-18 02:19:47 +08:00
|
|
|
thumbStyle->paint(g, rc, NULL, state);
|
2009-11-22 04:02:31 +08:00
|
|
|
}
|
|
|
|
|
2013-01-07 01:45:43 +08:00
|
|
|
void SkinTheme::paintViewViewport(PaintEvent& ev)
|
2009-11-22 04:02:31 +08:00
|
|
|
{
|
2013-01-07 01:45:43 +08:00
|
|
|
Viewport* widget = static_cast<Viewport*>(ev.getSource());
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
Graphics* g = ev.graphics();
|
2014-06-29 03:10:39 +08:00
|
|
|
gfx::Color bg = BGCOLOR;
|
2013-01-07 01:45:43 +08:00
|
|
|
|
2014-04-20 05:51:42 +08:00
|
|
|
if (!is_transparent(bg))
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
g->fillRect(bg, widget->clientBounds());
|
2009-11-22 04:02:31 +08:00
|
|
|
}
|
|
|
|
|
2012-07-09 10:24:42 +08:00
|
|
|
void SkinTheme::paintWindow(PaintEvent& ev)
|
2009-11-22 04:02:31 +08:00
|
|
|
{
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
Graphics* g = ev.graphics();
|
2012-07-09 10:24:42 +08:00
|
|
|
Window* window = static_cast<Window*>(ev.getSource());
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
Rect pos = window->clientBounds();
|
|
|
|
Rect cpos = window->clientChildrenBounds();
|
2009-11-22 04:02:31 +08:00
|
|
|
|
2013-01-11 23:43:25 +08:00
|
|
|
if (!window->isDesktop()) {
|
2009-11-22 04:02:31 +08:00
|
|
|
// window frame
|
2010-01-26 08:38:05 +08:00
|
|
|
if (window->hasText()) {
|
2015-02-17 22:43:25 +08:00
|
|
|
styles.window()->paint(g, pos, NULL, Style::State());
|
|
|
|
styles.windowTitle()->paint(g,
|
2014-11-26 09:33:45 +08:00
|
|
|
gfx::Rect(cpos.x, pos.y+5*guiscale(), cpos.w, // TODO this hard-coded 5 should be configurable in skin.xml
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
window->textHeight()),
|
|
|
|
window->text().c_str(), Style::State());
|
2009-11-22 04:02:31 +08:00
|
|
|
}
|
|
|
|
// menubox
|
|
|
|
else {
|
2015-02-17 22:43:25 +08:00
|
|
|
styles.menubox()->paint(g, pos, NULL, Style::State());
|
2009-11-22 04:02:31 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// desktop
|
|
|
|
else {
|
2015-02-17 22:43:25 +08:00
|
|
|
styles.desktop()->paint(g, pos, NULL, Style::State());
|
2009-11-22 04:02:31 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-07 01:45:43 +08:00
|
|
|
void SkinTheme::paintPopupWindow(PaintEvent& ev)
|
|
|
|
{
|
2014-04-20 05:51:42 +08:00
|
|
|
Widget* widget = static_cast<Widget*>(ev.getSource());
|
2013-01-07 01:45:43 +08:00
|
|
|
Window* window = static_cast<Window*>(ev.getSource());
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
Graphics* g = ev.graphics();
|
|
|
|
gfx::Rect pos = window->clientBounds();
|
2013-01-07 01:45:43 +08:00
|
|
|
|
2014-04-20 05:51:42 +08:00
|
|
|
if (!is_transparent(BGCOLOR))
|
2015-02-17 22:43:25 +08:00
|
|
|
styles.menubox()->paint(g, pos, NULL, Style::State());
|
2014-04-20 05:51:42 +08:00
|
|
|
|
2015-06-24 06:20:49 +08:00
|
|
|
pos.shrink(window->border());
|
2013-01-07 01:45:43 +08:00
|
|
|
|
2017-02-07 04:58:55 +08:00
|
|
|
g->drawAlignedUIText(window->text(),
|
2015-02-16 02:29:16 +08:00
|
|
|
colors.text(),
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
window->bgColor(), pos,
|
|
|
|
window->align());
|
2013-01-07 01:45:43 +08:00
|
|
|
}
|
|
|
|
|
2013-05-21 07:40:18 +08:00
|
|
|
void SkinTheme::paintWindowButton(ui::PaintEvent& ev)
|
2009-11-22 04:02:31 +08:00
|
|
|
{
|
2013-05-21 07:40:18 +08:00
|
|
|
ButtonBase* widget = static_cast<ButtonBase*>(ev.getSource());
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
Graphics* g = ev.graphics();
|
|
|
|
Rect rc = widget->clientBounds();
|
2015-08-05 06:38:52 +08:00
|
|
|
SkinPartPtr part;
|
2009-11-22 04:02:31 +08:00
|
|
|
|
2010-01-26 08:38:05 +08:00
|
|
|
if (widget->isSelected())
|
2015-08-05 06:38:52 +08:00
|
|
|
part = parts.windowCloseButtonSelected();
|
2010-04-25 23:03:25 +08:00
|
|
|
else if (widget->hasMouseOver())
|
2015-08-05 06:38:52 +08:00
|
|
|
part = parts.windowCloseButtonHot();
|
2009-11-22 04:02:31 +08:00
|
|
|
else
|
2015-08-05 06:38:52 +08:00
|
|
|
part = parts.windowCloseButtonNormal();
|
2009-11-22 04:02:31 +08:00
|
|
|
|
2016-12-02 02:15:16 +08:00
|
|
|
g->fillRect(BGCOLOR, rc);
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
g->drawRgbaSurface(part->bitmap(0), rc.x, rc.y);
|
2009-11-22 04:02:31 +08:00
|
|
|
}
|
|
|
|
|
2011-02-15 09:50:39 +08:00
|
|
|
void SkinTheme::paintTooltip(PaintEvent& ev)
|
|
|
|
{
|
2012-06-18 09:02:54 +08:00
|
|
|
ui::TipWindow* widget = static_cast<ui::TipWindow*>(ev.getSource());
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
Graphics* g = ev.graphics();
|
|
|
|
Rect absRc = widget->bounds();
|
|
|
|
Rect rc = widget->clientBounds();
|
2015-02-16 02:29:16 +08:00
|
|
|
gfx::Color fg = colors.tooltipText();
|
|
|
|
gfx::Color bg = colors.tooltipFace();
|
2015-08-05 06:38:52 +08:00
|
|
|
SkinPartPtr tooltipPart = parts.tooltip();
|
2011-02-15 09:50:39 +08:00
|
|
|
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
she::Surface* nw = tooltipPart->bitmapNW();
|
|
|
|
she::Surface* n = tooltipPart->bitmapN();
|
|
|
|
she::Surface* ne = tooltipPart->bitmapNE();
|
|
|
|
she::Surface* e = tooltipPart->bitmapE();
|
|
|
|
she::Surface* se = tooltipPart->bitmapSE();
|
|
|
|
she::Surface* s = tooltipPart->bitmapS();
|
|
|
|
she::Surface* sw = tooltipPart->bitmapSW();
|
|
|
|
she::Surface* w = tooltipPart->bitmapW();
|
2011-02-15 20:02:51 +08:00
|
|
|
|
2015-12-11 03:50:16 +08:00
|
|
|
switch (widget->arrowAlign()) {
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
case TOP | LEFT: nw = parts.tooltipArrow()->bitmapNW(); break;
|
|
|
|
case TOP | RIGHT: ne = parts.tooltipArrow()->bitmapNE(); break;
|
|
|
|
case BOTTOM | LEFT: sw = parts.tooltipArrow()->bitmapSW(); break;
|
|
|
|
case BOTTOM | RIGHT: se = parts.tooltipArrow()->bitmapSE(); break;
|
2011-02-15 20:02:51 +08:00
|
|
|
}
|
|
|
|
|
2015-08-05 06:38:52 +08:00
|
|
|
drawRect(g, rc, nw, n, ne, e, se, s, sw, w);
|
2011-02-15 20:02:51 +08:00
|
|
|
|
|
|
|
// Draw arrow in sides
|
2014-06-23 05:53:14 +08:00
|
|
|
she::Surface* arrow = NULL;
|
2015-05-10 00:20:57 +08:00
|
|
|
gfx::Rect target(widget->target());
|
2015-06-10 03:22:47 +08:00
|
|
|
target = target.createIntersection(gfx::Rect(0, 0, ui::display_w(), ui::display_h()));
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
target.offset(-absRc.origin());
|
2015-05-10 00:20:57 +08:00
|
|
|
|
2015-12-11 03:50:16 +08:00
|
|
|
switch (widget->arrowAlign()) {
|
2015-06-24 01:00:00 +08:00
|
|
|
case TOP:
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
arrow = parts.tooltipArrow()->bitmapN();
|
2015-05-10 00:20:57 +08:00
|
|
|
g->drawRgbaSurface(arrow,
|
|
|
|
target.x+target.w/2-arrow->width()/2,
|
|
|
|
rc.y);
|
2011-02-15 20:02:51 +08:00
|
|
|
break;
|
2015-06-24 01:00:00 +08:00
|
|
|
case BOTTOM:
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
arrow = parts.tooltipArrow()->bitmapS();
|
2014-06-23 05:53:14 +08:00
|
|
|
g->drawRgbaSurface(arrow,
|
2015-05-10 00:20:57 +08:00
|
|
|
target.x+target.w/2-arrow->width()/2,
|
|
|
|
rc.y+rc.h-arrow->height());
|
2011-02-15 20:02:51 +08:00
|
|
|
break;
|
2015-06-24 01:00:00 +08:00
|
|
|
case LEFT:
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
arrow = parts.tooltipArrow()->bitmapW();
|
2015-05-10 00:20:57 +08:00
|
|
|
g->drawRgbaSurface(arrow,
|
|
|
|
rc.x,
|
|
|
|
target.y+target.h/2-arrow->height()/2);
|
2011-02-15 20:02:51 +08:00
|
|
|
break;
|
2015-06-24 01:00:00 +08:00
|
|
|
case RIGHT:
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
arrow = parts.tooltipArrow()->bitmapE();
|
2014-06-23 05:53:14 +08:00
|
|
|
g->drawRgbaSurface(arrow,
|
2015-05-10 00:20:57 +08:00
|
|
|
rc.x+rc.w-arrow->width(),
|
|
|
|
target.y+target.h/2-arrow->height()/2);
|
2011-02-15 20:02:51 +08:00
|
|
|
break;
|
|
|
|
}
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2011-02-15 20:02:51 +08:00
|
|
|
// Fill background
|
2015-08-05 06:38:52 +08:00
|
|
|
g->fillRect(
|
|
|
|
bg, Rect(rc).shrink(
|
2014-06-23 05:53:14 +08:00
|
|
|
Border(
|
2015-08-05 06:38:52 +08:00
|
|
|
w->width(),
|
|
|
|
n->height(),
|
|
|
|
e->width(),
|
|
|
|
s->height())));
|
2011-02-15 20:02:51 +08:00
|
|
|
|
2015-06-24 06:20:49 +08:00
|
|
|
rc.shrink(widget->border());
|
2011-02-15 09:50:39 +08:00
|
|
|
|
2017-02-07 04:58:55 +08:00
|
|
|
g->drawAlignedUIText(widget->text(), fg, bg, rc, widget->align());
|
2011-02-15 09:50:39 +08:00
|
|
|
}
|
|
|
|
|
2014-06-29 03:10:39 +08:00
|
|
|
gfx::Color SkinTheme::getWidgetBgColor(Widget* widget)
|
2009-11-22 04:02:31 +08:00
|
|
|
{
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
gfx::Color c = widget->bgColor();
|
2012-04-06 06:00:19 +08:00
|
|
|
bool decorative = widget->isDecorative();
|
2009-11-22 04:02:31 +08:00
|
|
|
|
2015-06-24 01:37:22 +08:00
|
|
|
if (!is_transparent(c) || widget->type() == kWindowWidget)
|
2014-04-20 05:51:42 +08:00
|
|
|
return c;
|
|
|
|
else if (decorative)
|
2015-02-16 02:29:16 +08:00
|
|
|
return colors.selected();
|
2014-04-20 05:51:42 +08:00
|
|
|
else
|
2015-02-16 02:29:16 +08:00
|
|
|
return colors.face();
|
2009-11-22 04:02:31 +08:00
|
|
|
}
|
|
|
|
|
2017-02-07 04:58:55 +08:00
|
|
|
void SkinTheme::drawText(Graphics* g, const char *t, gfx::Color fg_color, gfx::Color bg_color,
|
|
|
|
Widget* widget, const Rect& rc,
|
|
|
|
int selected_offset)
|
2011-02-05 23:03:22 +08:00
|
|
|
{
|
|
|
|
if (t || widget->hasText()) {
|
2012-06-18 09:02:54 +08:00
|
|
|
Rect textrc;
|
2011-02-05 23:03:22 +08:00
|
|
|
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
g->setFont(widget->font());
|
2011-02-05 23:03:22 +08:00
|
|
|
|
|
|
|
if (!t)
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
t = widget->text().c_str();
|
2011-02-05 23:03:22 +08:00
|
|
|
|
2017-02-07 04:58:55 +08:00
|
|
|
textrc.setSize(g->measureUIText(t));
|
2011-02-05 23:03:22 +08:00
|
|
|
|
|
|
|
// Horizontally text alignment
|
|
|
|
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
if (widget->align() & RIGHT)
|
2011-02-05 23:03:22 +08:00
|
|
|
textrc.x = rc.x + rc.w - textrc.w - 1;
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
else if (widget->align() & CENTER)
|
|
|
|
textrc.x = rc.center().x - textrc.w/2;
|
2011-02-05 23:03:22 +08:00
|
|
|
else
|
|
|
|
textrc.x = rc.x;
|
|
|
|
|
|
|
|
// Vertically text alignment
|
|
|
|
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
if (widget->align() & BOTTOM)
|
2011-02-05 23:03:22 +08:00
|
|
|
textrc.y = rc.y + rc.h - textrc.h - 1;
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
else if (widget->align() & MIDDLE)
|
|
|
|
textrc.y = rc.center().y - textrc.h/2;
|
2011-02-05 23:03:22 +08:00
|
|
|
else
|
|
|
|
textrc.y = rc.y;
|
|
|
|
|
|
|
|
if (widget->isSelected()) {
|
|
|
|
textrc.x += selected_offset;
|
|
|
|
textrc.y += selected_offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Background
|
2013-01-07 01:45:43 +08:00
|
|
|
if (!is_transparent(bg_color)) {
|
2011-02-05 23:03:22 +08:00
|
|
|
if (!widget->isEnabled())
|
2014-11-26 09:33:45 +08:00
|
|
|
g->fillRect(bg_color, Rect(textrc).inflate(guiscale(), guiscale()));
|
2011-02-05 23:03:22 +08:00
|
|
|
else
|
2012-01-06 06:45:03 +08:00
|
|
|
g->fillRect(bg_color, textrc);
|
2011-02-05 23:03:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Text
|
2015-06-10 03:22:47 +08:00
|
|
|
Rect textWrap = textrc.createIntersection(
|
2014-04-20 02:18:16 +08:00
|
|
|
// TODO add ui::Widget::getPadding() property
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
// Rect(widget->clientBounds()).shrink(widget->border()));
|
|
|
|
widget->clientBounds()).inflate(0, 1*guiscale());
|
2011-02-05 23:03:22 +08:00
|
|
|
|
2014-05-05 08:51:52 +08:00
|
|
|
IntersectClip clip(g, textWrap);
|
|
|
|
if (clip) {
|
2014-04-18 03:24:04 +08:00
|
|
|
if (!widget->isEnabled()) {
|
|
|
|
// Draw white part
|
2017-02-07 04:58:55 +08:00
|
|
|
g->drawUIText(t,
|
2015-02-16 02:29:16 +08:00
|
|
|
colors.background(),
|
2014-06-29 03:10:39 +08:00
|
|
|
gfx::ColorNone,
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
textrc.origin() + Point(guiscale(), guiscale()));
|
2014-04-18 03:24:04 +08:00
|
|
|
}
|
|
|
|
|
2017-02-07 04:58:55 +08:00
|
|
|
g->drawUIText(t,
|
2014-04-18 03:24:04 +08:00
|
|
|
(!widget->isEnabled() ?
|
2015-02-16 02:29:16 +08:00
|
|
|
colors.disabled():
|
2014-06-29 03:10:39 +08:00
|
|
|
(gfx::geta(fg_color) > 0 ? fg_color :
|
2015-02-16 02:29:16 +08:00
|
|
|
colors.text())),
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
bg_color, textrc.origin());
|
2014-04-18 03:24:04 +08:00
|
|
|
}
|
2011-02-05 23:03:22 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-20 02:18:16 +08:00
|
|
|
void SkinTheme::drawEntryCaret(ui::Graphics* g, Entry* widget, int x, int y)
|
2009-11-22 04:02:31 +08:00
|
|
|
{
|
2015-02-16 02:29:16 +08:00
|
|
|
gfx::Color color = colors.text();
|
2017-02-08 06:05:47 +08:00
|
|
|
int textHeight = widget->textHeight();
|
|
|
|
gfx::Size caretSize = getEntryCaretSize(widget);
|
2009-11-22 04:02:31 +08:00
|
|
|
|
2017-02-08 06:05:47 +08:00
|
|
|
for (int u=x; u<x+caretSize.w; ++u)
|
|
|
|
g->drawVLine(color, u, y+textHeight/2-caretSize.h/2, caretSize.h);
|
2009-11-22 04:02:31 +08:00
|
|
|
}
|
|
|
|
|
2015-08-05 06:38:52 +08:00
|
|
|
she::Surface* SkinTheme::getToolIcon(const char* toolId) const
|
- All tools stuff refactored in various files/components.
- Added classes: IToolLoop, Tool, ToolGroup, ToolInk, ToolController, ToolPointShape, ToolIntertwine, ToolBox, etc.
- Added ToolLoopManager.
- Removed old src/modules/tools.cpp.
- Added ISettings and UISettingsImpl, adding the tools settings (onion skinning, grid, tiled mode, etc.).
- Added App::PenSizeBeforeChange, PenSizeAfterChange, CurrentToolChange signals.
- Renamed Context::get_bg/fg_color to getBg/FgColor.
- Refactored Brush class to Pen and added PenType.
- Renamed tiled_t to TiledMode.
- get_config_rect now uses the new Rect class imported from Vaca instead of old jrect.
- Added default_skin.xml to load tool icons.
- Added pen preview in Editor::cursor stuff.
- Added Editor::decorators.
Note: This big patch is from some time ago. I did my best to pre-commit other small changes before this big one.
2010-03-08 03:47:45 +08:00
|
|
|
{
|
2015-08-05 06:38:52 +08:00
|
|
|
std::map<std::string, she::Surface*>::const_iterator it = m_toolicon.find(toolId);
|
- All tools stuff refactored in various files/components.
- Added classes: IToolLoop, Tool, ToolGroup, ToolInk, ToolController, ToolPointShape, ToolIntertwine, ToolBox, etc.
- Added ToolLoopManager.
- Removed old src/modules/tools.cpp.
- Added ISettings and UISettingsImpl, adding the tools settings (onion skinning, grid, tiled mode, etc.).
- Added App::PenSizeBeforeChange, PenSizeAfterChange, CurrentToolChange signals.
- Renamed Context::get_bg/fg_color to getBg/FgColor.
- Refactored Brush class to Pen and added PenType.
- Renamed tiled_t to TiledMode.
- get_config_rect now uses the new Rect class imported from Vaca instead of old jrect.
- Added default_skin.xml to load tool icons.
- Added pen preview in Editor::cursor stuff.
- Added Editor::decorators.
Note: This big patch is from some time ago. I did my best to pre-commit other small changes before this big one.
2010-03-08 03:47:45 +08:00
|
|
|
if (it != m_toolicon.end())
|
|
|
|
return it->second;
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2015-08-05 06:38:52 +08:00
|
|
|
void SkinTheme::drawRect(Graphics* g, const Rect& rc,
|
|
|
|
she::Surface* nw, she::Surface* n, she::Surface* ne,
|
|
|
|
she::Surface* e, she::Surface* se, she::Surface* s,
|
|
|
|
she::Surface* sw, she::Surface* w)
|
2011-02-05 23:03:22 +08:00
|
|
|
{
|
|
|
|
int x, y;
|
|
|
|
|
|
|
|
// Top
|
|
|
|
|
2014-06-23 05:53:14 +08:00
|
|
|
g->drawRgbaSurface(nw, rc.x, rc.y);
|
2014-05-05 08:51:52 +08:00
|
|
|
{
|
2014-06-23 05:53:14 +08:00
|
|
|
IntersectClip clip(g, Rect(rc.x+nw->width(), rc.y,
|
|
|
|
rc.w-nw->width()-ne->width(), rc.h));
|
2014-05-05 08:51:52 +08:00
|
|
|
if (clip) {
|
2014-06-23 05:53:14 +08:00
|
|
|
for (x = rc.x+nw->width();
|
|
|
|
x < rc.x+rc.w-ne->width();
|
|
|
|
x += n->width()) {
|
|
|
|
g->drawRgbaSurface(n, x, rc.y);
|
2014-05-05 08:51:52 +08:00
|
|
|
}
|
2011-02-05 23:03:22 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-23 05:53:14 +08:00
|
|
|
g->drawRgbaSurface(ne, rc.x+rc.w-ne->width(), rc.y);
|
2011-02-05 23:03:22 +08:00
|
|
|
|
|
|
|
// Bottom
|
|
|
|
|
2014-06-23 05:53:14 +08:00
|
|
|
g->drawRgbaSurface(sw, rc.x, rc.y+rc.h-sw->height());
|
2014-05-05 08:51:52 +08:00
|
|
|
{
|
2014-06-23 05:53:14 +08:00
|
|
|
IntersectClip clip(g, Rect(rc.x+sw->width(), rc.y,
|
|
|
|
rc.w-sw->width()-se->width(), rc.h));
|
2014-05-05 08:51:52 +08:00
|
|
|
if (clip) {
|
2014-06-23 05:53:14 +08:00
|
|
|
for (x = rc.x+sw->width();
|
|
|
|
x < rc.x+rc.w-se->width();
|
|
|
|
x += s->width()) {
|
|
|
|
g->drawRgbaSurface(s, x, rc.y+rc.h-s->height());
|
2014-05-05 08:51:52 +08:00
|
|
|
}
|
2011-02-05 23:03:22 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-23 05:53:14 +08:00
|
|
|
g->drawRgbaSurface(se, rc.x+rc.w-se->width(), rc.y+rc.h-se->height());
|
2014-05-05 08:51:52 +08:00
|
|
|
{
|
2014-06-23 05:53:14 +08:00
|
|
|
IntersectClip clip(g, Rect(rc.x, rc.y+nw->height(),
|
|
|
|
rc.w, rc.h-nw->height()-sw->height()));
|
2014-05-05 08:51:52 +08:00
|
|
|
if (clip) {
|
|
|
|
// Left
|
2014-06-23 05:53:14 +08:00
|
|
|
for (y = rc.y+nw->height();
|
|
|
|
y < rc.y+rc.h-sw->height();
|
|
|
|
y += w->height()) {
|
|
|
|
g->drawRgbaSurface(w, rc.x, y);
|
2014-05-05 08:51:52 +08:00
|
|
|
}
|
2011-02-05 23:03:22 +08:00
|
|
|
|
2014-05-05 08:51:52 +08:00
|
|
|
// Right
|
2014-06-23 05:53:14 +08:00
|
|
|
for (y = rc.y+ne->height();
|
|
|
|
y < rc.y+rc.h-se->height();
|
|
|
|
y += e->height()) {
|
|
|
|
g->drawRgbaSurface(e, rc.x+rc.w-e->width(), y);
|
2014-05-05 08:51:52 +08:00
|
|
|
}
|
2011-02-05 23:03:22 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-05 06:38:52 +08:00
|
|
|
void SkinTheme::drawRect(ui::Graphics* g, const gfx::Rect& rc, SkinPart* skinPart, gfx::Color bg)
|
2009-11-22 04:02:31 +08:00
|
|
|
{
|
2015-08-05 06:38:52 +08:00
|
|
|
drawRect(g, rc,
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
skinPart->bitmap(0),
|
|
|
|
skinPart->bitmap(1),
|
|
|
|
skinPart->bitmap(2),
|
|
|
|
skinPart->bitmap(3),
|
|
|
|
skinPart->bitmap(4),
|
|
|
|
skinPart->bitmap(5),
|
|
|
|
skinPart->bitmap(6),
|
|
|
|
skinPart->bitmap(7));
|
2013-12-11 11:34:16 +08:00
|
|
|
|
|
|
|
// Center
|
|
|
|
if (!is_transparent(bg)) {
|
2013-12-16 04:49:46 +08:00
|
|
|
gfx::Rect inside = rc;
|
|
|
|
inside.shrink(Border(
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
skinPart->bitmap(7)->width(),
|
|
|
|
skinPart->bitmap(1)->height(),
|
|
|
|
skinPart->bitmap(3)->width(),
|
|
|
|
skinPart->bitmap(5)->height()));
|
2013-12-16 04:49:46 +08:00
|
|
|
|
2014-05-05 08:51:52 +08:00
|
|
|
IntersectClip clip(g, inside);
|
|
|
|
if (clip)
|
2013-12-16 04:49:46 +08:00
|
|
|
g->fillRect(bg, inside);
|
2013-12-11 11:34:16 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-05 06:38:52 +08:00
|
|
|
void SkinTheme::drawRect2(Graphics* g, const Rect& rc, int x_mid,
|
|
|
|
SkinPart* nw1, SkinPart* nw2,
|
|
|
|
gfx::Color bg1, gfx::Color bg2)
|
2011-02-05 23:03:22 +08:00
|
|
|
{
|
2012-06-18 09:02:54 +08:00
|
|
|
Rect rc2(rc.x, rc.y, x_mid-rc.x+1, rc.h);
|
2014-05-05 08:51:52 +08:00
|
|
|
{
|
|
|
|
IntersectClip clip(g, rc2);
|
|
|
|
if (clip)
|
2015-08-05 06:38:52 +08:00
|
|
|
drawRect(g, rc, nw1, bg1);
|
2014-05-05 08:51:52 +08:00
|
|
|
}
|
2009-11-22 04:02:31 +08:00
|
|
|
|
2011-02-05 23:03:22 +08:00
|
|
|
rc2.x += rc2.w;
|
|
|
|
rc2.w = rc.w - rc2.w;
|
2009-11-22 04:02:31 +08:00
|
|
|
|
2014-05-05 08:51:52 +08:00
|
|
|
IntersectClip clip(g, rc2);
|
|
|
|
if (clip)
|
2015-08-05 06:38:52 +08:00
|
|
|
drawRect(g, rc, nw2, bg2);
|
2009-11-22 04:02:31 +08:00
|
|
|
}
|
|
|
|
|
2015-08-05 06:38:52 +08:00
|
|
|
void SkinTheme::drawHline(ui::Graphics* g, const gfx::Rect& rc, SkinPart* part)
|
2013-05-21 07:40:18 +08:00
|
|
|
{
|
|
|
|
int x;
|
|
|
|
|
|
|
|
for (x = rc.x;
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
x < rc.x2()-part->size().w;
|
|
|
|
x += part->size().w) {
|
|
|
|
g->drawRgbaSurface(part->bitmap(0), x, rc.y);
|
2013-05-21 07:40:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (x < rc.x2()) {
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
Rect rc2(x, rc.y, rc.w-(x-rc.x), part->size().h);
|
2014-05-05 08:51:52 +08:00
|
|
|
IntersectClip clip(g, rc2);
|
|
|
|
if (clip)
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
g->drawRgbaSurface(part->bitmap(0), x, rc.y);
|
2013-05-21 07:40:18 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-05 06:38:52 +08:00
|
|
|
void SkinTheme::drawVline(ui::Graphics* g, const gfx::Rect& rc, SkinPart* part)
|
2013-05-21 07:40:18 +08:00
|
|
|
{
|
|
|
|
int y;
|
|
|
|
|
|
|
|
for (y = rc.y;
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
y < rc.y2()-part->size().h;
|
|
|
|
y += part->size().h) {
|
|
|
|
g->drawRgbaSurface(part->bitmap(0), rc.x, y);
|
2013-05-21 07:40:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (y < rc.y2()) {
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
Rect rc2(rc.x, y, part->size().w, rc.h-(y-rc.y));
|
2014-05-05 08:51:52 +08:00
|
|
|
IntersectClip clip(g, rc2);
|
|
|
|
if (clip)
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
g->drawRgbaSurface(part->bitmap(0), rc.x, y);
|
2013-05-21 07:40:18 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-15 09:37:56 +08:00
|
|
|
void SkinTheme::paintProgressBar(ui::Graphics* g, const gfx::Rect& rc0, double progress)
|
2013-12-30 08:12:23 +08:00
|
|
|
{
|
2015-02-16 02:29:16 +08:00
|
|
|
g->drawRect(colors.text(), rc0);
|
2013-12-30 08:12:23 +08:00
|
|
|
|
|
|
|
gfx::Rect rc = rc0;
|
|
|
|
rc.shrink(1);
|
|
|
|
|
2015-02-15 09:37:56 +08:00
|
|
|
int u = (int)((double)rc.w*progress);
|
2013-12-30 08:12:23 +08:00
|
|
|
u = MID(0, u, rc.w);
|
|
|
|
|
|
|
|
if (u > 0)
|
2015-02-16 02:29:16 +08:00
|
|
|
g->fillRect(colors.selected(), gfx::Rect(rc.x, rc.y, u, rc.h));
|
2013-12-30 08:12:23 +08:00
|
|
|
|
|
|
|
if (1+u < rc.w)
|
2015-02-16 02:29:16 +08:00
|
|
|
g->fillRect(colors.background(), gfx::Rect(rc.x+u, rc.y, rc.w-u, rc.h));
|
2013-12-30 08:12:23 +08:00
|
|
|
}
|
|
|
|
|
2011-03-07 03:15:05 +08:00
|
|
|
void SkinTheme::paintIcon(Widget* widget, Graphics* g, IButtonIcon* iconInterface, int x, int y)
|
|
|
|
{
|
2014-06-23 05:53:14 +08:00
|
|
|
she::Surface* icon_bmp = NULL;
|
2011-03-07 03:15:05 +08:00
|
|
|
|
|
|
|
// enabled
|
|
|
|
if (widget->isEnabled()) {
|
2012-01-06 06:45:03 +08:00
|
|
|
if (widget->isSelected()) // selected
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
icon_bmp = iconInterface->selectedIcon();
|
2011-03-07 03:15:05 +08:00
|
|
|
else
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
icon_bmp = iconInterface->normalIcon();
|
2011-03-07 03:15:05 +08:00
|
|
|
}
|
|
|
|
// disabled
|
|
|
|
else {
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
icon_bmp = iconInterface->disabledIcon();
|
2011-03-07 03:15:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (icon_bmp)
|
2014-06-23 05:53:14 +08:00
|
|
|
g->drawRgbaSurface(icon_bmp, x, y);
|
2011-03-07 03:15:05 +08:00
|
|
|
}
|
|
|
|
|
2015-09-18 22:56:45 +08:00
|
|
|
she::Font* SkinTheme::loadFont(const std::string& userFont, const std::string& themeFont)
|
2011-04-02 22:45:43 +08:00
|
|
|
{
|
2014-04-13 00:35:55 +08:00
|
|
|
// Directories to find the font
|
2015-09-18 22:56:45 +08:00
|
|
|
ResourceFinder rf;
|
|
|
|
if (!userFont.empty())
|
|
|
|
rf.addPath(userFont.c_str());
|
|
|
|
rf.includeDataDir(themeFont.c_str());
|
2011-04-02 22:45:43 +08:00
|
|
|
|
|
|
|
// Try to load the font
|
2014-04-13 00:35:55 +08:00
|
|
|
while (rf.next()) {
|
2015-03-26 20:31:32 +08:00
|
|
|
try {
|
2016-03-08 04:48:35 +08:00
|
|
|
she::Font* f = she::instance()->loadSpriteSheetFont(rf.filename().c_str(), guiscale());
|
2014-06-23 05:53:14 +08:00
|
|
|
if (f->isScalable())
|
|
|
|
f->setSize(8);
|
2014-04-13 00:35:55 +08:00
|
|
|
return f;
|
2011-04-02 22:45:43 +08:00
|
|
|
}
|
2015-03-26 21:43:39 +08:00
|
|
|
catch (const std::exception&) {
|
2015-03-26 20:31:32 +08:00
|
|
|
// Do nothing
|
|
|
|
}
|
2011-04-02 22:45:43 +08:00
|
|
|
}
|
|
|
|
|
2015-03-24 20:18:23 +08:00
|
|
|
return nullptr;
|
2011-04-02 22:45:43 +08:00
|
|
|
}
|
2013-08-06 08:20:19 +08:00
|
|
|
|
|
|
|
} // namespace skin
|
|
|
|
} // namespace app
|