mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-13 01:13:22 +00:00
Merge branch 'main' into beta
This commit is contained in:
commit
9e10a1c82c
@ -379,13 +379,13 @@ void AppBrushes::load(const std::string& filename)
|
||||
|
||||
// Pixel-perfect
|
||||
if (TiXmlElement* pixelPerfectElem = brushElem->FirstChildElement("pixelperfect")) {
|
||||
pixelPerfect = bool_attr_is_true(pixelPerfectElem, "value");
|
||||
pixelPerfect = bool_attr(pixelPerfectElem, "value", false);
|
||||
flags |= int(BrushSlot::Flags::PixelPerfect);
|
||||
}
|
||||
|
||||
// Image color (enabled by default for backward compatibility)
|
||||
if (!brushElem->Attribute("imagecolor") ||
|
||||
bool_attr_is_true(brushElem, "imagecolor"))
|
||||
bool_attr(brushElem, "imagecolor", false))
|
||||
flags |= int(BrushSlot::Flags::ImageColor);
|
||||
|
||||
if (flags != 0)
|
||||
|
@ -75,15 +75,20 @@ void ChangeColorCommand::onExecute(Context* context)
|
||||
// do nothing
|
||||
break;
|
||||
case IncrementIndex: {
|
||||
int index = color.getIndex();
|
||||
if (index < get_current_palette()->size()-1)
|
||||
color = app::Color::fromIndex(index+1);
|
||||
const int palSize = get_current_palette()->size();
|
||||
if (palSize >= 1) {
|
||||
// Seems safe to assume getIndex() will return a
|
||||
// positive number, so use truncation modulo.
|
||||
color = app::Color::fromIndex((color.getIndex() + 1) % palSize);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DecrementIndex: {
|
||||
int index = color.getIndex();
|
||||
if (index > 0)
|
||||
color = app::Color::fromIndex(index-1);
|
||||
const int palSize = get_current_palette()->size();
|
||||
if (palSize >= 1) {
|
||||
// Floor modulo.
|
||||
color = app::Color::fromIndex(((color.getIndex() - 1) % palSize + palSize) % palSize);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "app/color_spaces.h"
|
||||
#include "app/color_utils.h"
|
||||
#include "app/console.h"
|
||||
#include "app/modules/editors.h"
|
||||
#include "app/modules/gui.h"
|
||||
#include "app/modules/palettes.h"
|
||||
#include "app/site.h"
|
||||
@ -42,9 +43,21 @@ using namespace gfx;
|
||||
|
||||
namespace {
|
||||
|
||||
// TODO hard-coded values, use pref.xml values
|
||||
gfx::Color gridColor1 = gfx::rgba(128, 128, 128);
|
||||
gfx::Color gridColor2 = gfx::rgba(192, 192, 192);
|
||||
gfx::Color gridColor1()
|
||||
{
|
||||
if (ui::is_ui_thread() && current_editor)
|
||||
return color_utils::color_for_ui(current_editor->docPref().bg.color1());
|
||||
else
|
||||
return gfx::rgba(128, 128, 128);
|
||||
}
|
||||
|
||||
gfx::Color gridColor2()
|
||||
{
|
||||
if (ui::is_ui_thread() && current_editor)
|
||||
return color_utils::color_for_ui(current_editor->docPref().bg.color2());
|
||||
else
|
||||
return gfx::rgba(192, 192, 192);
|
||||
}
|
||||
|
||||
void draw_checked_grid(ui::Graphics* g,
|
||||
const gfx::Rect& rc,
|
||||
@ -84,8 +97,7 @@ void draw_checked_grid(ui::Graphics* g,
|
||||
const gfx::Rect& rc,
|
||||
const gfx::Size& tile)
|
||||
{
|
||||
draw_checked_grid(g, rc, tile,
|
||||
gridColor1, gridColor2);
|
||||
draw_checked_grid(g, rc, tile, gridColor1(), gridColor2());
|
||||
}
|
||||
|
||||
void draw_checked_grid(ui::Graphics* g,
|
||||
@ -93,9 +105,7 @@ void draw_checked_grid(ui::Graphics* g,
|
||||
const gfx::Size& tile,
|
||||
DocumentPreferences& docPref)
|
||||
{
|
||||
draw_checked_grid(g, rc, tile,
|
||||
color_utils::color_for_ui(docPref.bg.color1()),
|
||||
color_utils::color_for_ui(docPref.bg.color2()));
|
||||
draw_checked_grid(g, rc, tile, gridColor1(), gridColor2());
|
||||
}
|
||||
|
||||
void draw_color(ui::Graphics* g,
|
||||
@ -268,8 +278,8 @@ void draw_alpha_slider(ui::Graphics* g,
|
||||
|
||||
for (int x=0; x<rc.w; ++x) {
|
||||
const int a = (255 * x / xmax);
|
||||
const doc::color_t c1 = doc::rgba_blender_normal(gridColor1, c, a);
|
||||
const doc::color_t c2 = doc::rgba_blender_normal(gridColor2, c, a);
|
||||
const doc::color_t c1 = doc::rgba_blender_normal(gridColor1(), c, a);
|
||||
const doc::color_t c2 = doc::rgba_blender_normal(gridColor2(), c, a);
|
||||
const int mid = rc.h/2;
|
||||
const int odd = (x / rc.h) & 1;
|
||||
g->drawVLine(
|
||||
@ -296,8 +306,8 @@ void draw_alpha_slider(os::Surface* s,
|
||||
os::Paint paint;
|
||||
for (int x=0; x<rc.w; ++x) {
|
||||
const int a = (255 * x / xmax);
|
||||
const doc::color_t c1 = doc::rgba_blender_normal(gridColor1, c, a);
|
||||
const doc::color_t c2 = doc::rgba_blender_normal(gridColor2, c, a);
|
||||
const doc::color_t c1 = doc::rgba_blender_normal(gridColor1(), c, a);
|
||||
const doc::color_t c2 = doc::rgba_blender_normal(gridColor2(), c, a);
|
||||
const int mid = rc.h/2;
|
||||
const int odd = (x / rc.h) & 1;
|
||||
|
||||
|
@ -462,7 +462,7 @@ void KeyboardShortcuts::importFile(TiXmlElement* rootElement, KeySource source)
|
||||
while (xmlKey) {
|
||||
const char* command_name = xmlKey->Attribute("command");
|
||||
const char* command_key = get_shortcut(xmlKey);
|
||||
bool removed = bool_attr_is_true(xmlKey, "removed");
|
||||
bool removed = bool_attr(xmlKey, "removed", false);
|
||||
|
||||
if (command_name) {
|
||||
Command* command = Commands::instance()->byId(command_name);
|
||||
@ -521,7 +521,7 @@ void KeyboardShortcuts::importFile(TiXmlElement* rootElement, KeySource source)
|
||||
while (xmlKey) {
|
||||
const char* tool_id = xmlKey->Attribute("tool");
|
||||
const char* tool_key = get_shortcut(xmlKey);
|
||||
bool removed = bool_attr_is_true(xmlKey, "removed");
|
||||
bool removed = bool_attr(xmlKey, "removed", false);
|
||||
|
||||
if (tool_id) {
|
||||
tools::Tool* tool = App::instance()->toolBox()->getToolById(tool_id);
|
||||
@ -549,7 +549,7 @@ void KeyboardShortcuts::importFile(TiXmlElement* rootElement, KeySource source)
|
||||
while (xmlKey) {
|
||||
const char* tool_id = xmlKey->Attribute("tool");
|
||||
const char* tool_key = get_shortcut(xmlKey);
|
||||
bool removed = bool_attr_is_true(xmlKey, "removed");
|
||||
bool removed = bool_attr(xmlKey, "removed", false);
|
||||
|
||||
if (tool_id) {
|
||||
tools::Tool* tool = App::instance()->toolBox()->getToolById(tool_id);
|
||||
@ -577,7 +577,7 @@ void KeyboardShortcuts::importFile(TiXmlElement* rootElement, KeySource source)
|
||||
while (xmlKey) {
|
||||
const char* action_id = xmlKey->Attribute("action");
|
||||
const char* action_key = get_shortcut(xmlKey);
|
||||
bool removed = bool_attr_is_true(xmlKey, "removed");
|
||||
bool removed = bool_attr(xmlKey, "removed", false);
|
||||
|
||||
if (action_id) {
|
||||
KeyAction action = base::convert_to<KeyAction, std::string>(action_id);
|
||||
@ -612,7 +612,7 @@ void KeyboardShortcuts::importFile(TiXmlElement* rootElement, KeySource source)
|
||||
while (xmlKey) {
|
||||
const char* action_id = xmlKey->Attribute("action");
|
||||
const char* action_key = get_shortcut(xmlKey);
|
||||
bool removed = bool_attr_is_true(xmlKey, "removed");
|
||||
bool removed = bool_attr(xmlKey, "removed", false);
|
||||
|
||||
if (action_id) {
|
||||
WheelAction action = base::convert_to<WheelAction, std::string>(action_id);
|
||||
|
@ -168,7 +168,7 @@ static FontData* load_font(std::map<std::string, FontData*>& fonts,
|
||||
const char* fileStr = xmlFont->Attribute("file");
|
||||
bool antialias = true;
|
||||
if (xmlFont->Attribute("antialias"))
|
||||
antialias = bool_attr_is_true(xmlFont, "antialias");
|
||||
antialias = bool_attr(xmlFont, "antialias", false);
|
||||
|
||||
std::string fontFilename;
|
||||
if (platformFileStr)
|
||||
|
@ -135,8 +135,8 @@ Widget* WidgetLoader::convertXmlElementToWidget(const TiXmlElement* elem, Widget
|
||||
widget = new Panel();
|
||||
}
|
||||
else if (elem_name == "box") {
|
||||
bool horizontal = bool_attr_is_true(elem, "horizontal");
|
||||
bool vertical = bool_attr_is_true(elem, "vertical");
|
||||
bool horizontal = bool_attr(elem, "horizontal", false);
|
||||
bool vertical = bool_attr(elem, "vertical", false);
|
||||
int align = (horizontal ? HORIZONTAL: vertical ? VERTICAL: 0);
|
||||
|
||||
if (!widget)
|
||||
@ -173,11 +173,11 @@ Widget* WidgetLoader::convertXmlElementToWidget(const TiXmlElement* elem, Widget
|
||||
}
|
||||
}
|
||||
|
||||
bool left = bool_attr_is_true(elem, "left");
|
||||
bool right = bool_attr_is_true(elem, "right");
|
||||
bool top = bool_attr_is_true(elem, "top");
|
||||
bool bottom = bool_attr_is_true(elem, "bottom");
|
||||
bool closewindow = bool_attr_is_true(elem, "closewindow");
|
||||
bool left = bool_attr(elem, "left", false);
|
||||
bool right = bool_attr(elem, "right", false);
|
||||
bool top = bool_attr(elem, "top", false);
|
||||
bool bottom = bool_attr(elem, "bottom", false);
|
||||
bool closewindow = bool_attr(elem, "closewindow", false);
|
||||
|
||||
widget->setAlign((left ? LEFT: (right ? RIGHT: CENTER)) |
|
||||
(top ? TOP: (bottom ? BOTTOM: MIDDLE)));
|
||||
@ -214,10 +214,10 @@ Widget* WidgetLoader::convertXmlElementToWidget(const TiXmlElement* elem, Widget
|
||||
}
|
||||
}
|
||||
|
||||
bool center = bool_attr_is_true(elem, "center");
|
||||
bool right = bool_attr_is_true(elem, "right");
|
||||
bool top = bool_attr_is_true(elem, "top");
|
||||
bool bottom = bool_attr_is_true(elem, "bottom");
|
||||
bool center = bool_attr(elem, "center", false);
|
||||
bool right = bool_attr(elem, "right", false);
|
||||
bool top = bool_attr(elem, "top", false);
|
||||
bool bottom = bool_attr(elem, "bottom", false);
|
||||
|
||||
widget->setAlign((center ? CENTER:
|
||||
(right ? RIGHT: LEFT)) |
|
||||
@ -228,7 +228,7 @@ Widget* WidgetLoader::convertXmlElementToWidget(const TiXmlElement* elem, Widget
|
||||
if (!widget)
|
||||
widget = new ComboBox();
|
||||
|
||||
bool editable = bool_attr_is_true(elem, "editable");
|
||||
bool editable = bool_attr(elem, "editable", false);
|
||||
if (editable)
|
||||
((ComboBox*)widget)->setEditable(true);
|
||||
}
|
||||
@ -240,7 +240,7 @@ Widget* WidgetLoader::convertXmlElementToWidget(const TiXmlElement* elem, Widget
|
||||
|
||||
const char* suffix = elem->Attribute("suffix");
|
||||
const char* decimals = elem->Attribute("decimals");
|
||||
const bool readonly = bool_attr_is_true(elem, "readonly");
|
||||
const bool readonly = bool_attr(elem, "readonly", false);
|
||||
|
||||
widget = (elem_name == "expr" ?
|
||||
new ExprEntry:
|
||||
@ -257,7 +257,7 @@ Widget* WidgetLoader::convertXmlElementToWidget(const TiXmlElement* elem, Widget
|
||||
}
|
||||
else if (elem_name == "grid") {
|
||||
const char *columns = elem->Attribute("columns");
|
||||
bool same_width_columns = bool_attr_is_true(elem, "same_width_columns");
|
||||
bool same_width_columns = bool_attr(elem, "same_width_columns", false);
|
||||
|
||||
if (columns != NULL) {
|
||||
widget = new ui::Grid(strtol(columns, NULL, 10),
|
||||
@ -268,10 +268,10 @@ Widget* WidgetLoader::convertXmlElementToWidget(const TiXmlElement* elem, Widget
|
||||
if (!widget)
|
||||
widget = new Label("");
|
||||
|
||||
bool center = bool_attr_is_true(elem, "center");
|
||||
bool right = bool_attr_is_true(elem, "right");
|
||||
bool top = bool_attr_is_true(elem, "top");
|
||||
bool bottom = bool_attr_is_true(elem, "bottom");
|
||||
bool center = bool_attr(elem, "center", false);
|
||||
bool right = bool_attr(elem, "right", false);
|
||||
bool top = bool_attr(elem, "top", false);
|
||||
bool bottom = bool_attr(elem, "bottom", false);
|
||||
|
||||
widget->setAlign((center ? CENTER:
|
||||
(right ? RIGHT: LEFT)) |
|
||||
@ -290,10 +290,10 @@ Widget* WidgetLoader::convertXmlElementToWidget(const TiXmlElement* elem, Widget
|
||||
link->setUrl(url);
|
||||
}
|
||||
|
||||
bool center = bool_attr_is_true(elem, "center");
|
||||
bool right = bool_attr_is_true(elem, "right");
|
||||
bool top = bool_attr_is_true(elem, "top");
|
||||
bool bottom = bool_attr_is_true(elem, "bottom");
|
||||
bool center = bool_attr(elem, "center", false);
|
||||
bool right = bool_attr(elem, "right", false);
|
||||
bool top = bool_attr(elem, "top", false);
|
||||
bool bottom = bool_attr(elem, "bottom", false);
|
||||
|
||||
widget->setAlign(
|
||||
(center ? CENTER: (right ? RIGHT: LEFT)) |
|
||||
@ -303,7 +303,7 @@ Widget* WidgetLoader::convertXmlElementToWidget(const TiXmlElement* elem, Widget
|
||||
if (!widget)
|
||||
widget = new ListBox();
|
||||
|
||||
bool multiselect = bool_attr_is_true(elem, "multiselect");
|
||||
bool multiselect = bool_attr(elem, "multiselect", false);
|
||||
if (multiselect)
|
||||
static_cast<ListBox*>(widget)->setMultiselect(multiselect);
|
||||
}
|
||||
@ -323,8 +323,8 @@ Widget* WidgetLoader::convertXmlElementToWidget(const TiXmlElement* elem, Widget
|
||||
listitem->setValue(value);
|
||||
}
|
||||
else if (elem_name == "splitter") {
|
||||
bool horizontal = bool_attr_is_true(elem, "horizontal");
|
||||
bool vertical = bool_attr_is_true(elem, "vertical");
|
||||
bool horizontal = bool_attr(elem, "horizontal", false);
|
||||
bool vertical = bool_attr(elem, "vertical", false);
|
||||
const char* by = elem->Attribute("by");
|
||||
const char* position = elem->Attribute("position");
|
||||
Splitter::Type type = (by && strcmp(by, "pixel") == 0 ?
|
||||
@ -361,10 +361,10 @@ Widget* WidgetLoader::convertXmlElementToWidget(const TiXmlElement* elem, Widget
|
||||
radio->setRadioGroup(radio_group);
|
||||
}
|
||||
|
||||
bool center = bool_attr_is_true(elem, "center");
|
||||
bool right = bool_attr_is_true(elem, "right");
|
||||
bool top = bool_attr_is_true(elem, "top");
|
||||
bool bottom = bool_attr_is_true(elem, "bottom");
|
||||
bool center = bool_attr(elem, "center", false);
|
||||
bool right = bool_attr(elem, "right", false);
|
||||
bool top = bool_attr(elem, "top", false);
|
||||
bool bottom = bool_attr(elem, "bottom", false);
|
||||
|
||||
widget->setAlign(
|
||||
(center ? CENTER:
|
||||
@ -373,12 +373,12 @@ Widget* WidgetLoader::convertXmlElementToWidget(const TiXmlElement* elem, Widget
|
||||
(bottom ? BOTTOM: MIDDLE)));
|
||||
}
|
||||
else if (elem_name == "separator") {
|
||||
bool center = bool_attr_is_true(elem, "center");
|
||||
bool right = bool_attr_is_true(elem, "right");
|
||||
bool middle = bool_attr_is_true(elem, "middle");
|
||||
bool bottom = bool_attr_is_true(elem, "bottom");
|
||||
bool horizontal = bool_attr_is_true(elem, "horizontal");
|
||||
bool vertical = bool_attr_is_true(elem, "vertical");
|
||||
bool center = bool_attr(elem, "center", false);
|
||||
bool right = bool_attr(elem, "right", false);
|
||||
bool middle = bool_attr(elem, "middle", false);
|
||||
bool bottom = bool_attr(elem, "bottom", false);
|
||||
bool horizontal = bool_attr(elem, "horizontal", false);
|
||||
bool vertical = bool_attr(elem, "vertical", false);
|
||||
int align =
|
||||
(horizontal ? HORIZONTAL: 0) |
|
||||
(vertical ? VERTICAL: 0) |
|
||||
@ -400,7 +400,7 @@ Widget* WidgetLoader::convertXmlElementToWidget(const TiXmlElement* elem, Widget
|
||||
widget = new Slider(min_value, max_value, min_value);
|
||||
}
|
||||
else if (elem_name == "textbox") {
|
||||
bool wordwrap = bool_attr_is_true(elem, "wordwrap");
|
||||
bool wordwrap = bool_attr(elem, "wordwrap", false);
|
||||
|
||||
if (!widget)
|
||||
widget = new TextBox(elem->GetText(), 0);
|
||||
@ -416,7 +416,7 @@ Widget* WidgetLoader::convertXmlElementToWidget(const TiXmlElement* elem, Widget
|
||||
}
|
||||
else if (elem_name == "window") {
|
||||
if (!widget) {
|
||||
bool desktop = bool_attr_is_true(elem, "desktop");
|
||||
bool desktop = bool_attr(elem, "desktop", false);
|
||||
|
||||
if (desktop)
|
||||
widget = new Window(Window::DesktopWindow);
|
||||
@ -427,8 +427,8 @@ Widget* WidgetLoader::convertXmlElementToWidget(const TiXmlElement* elem, Widget
|
||||
}
|
||||
}
|
||||
else if (elem_name == "colorpicker") {
|
||||
const bool rgba = bool_attr_is_true(elem, "rgba");
|
||||
const bool simple = bool_attr_is_true(elem, "simple");
|
||||
const bool rgba = bool_attr(elem, "rgba", false);
|
||||
const bool simple = bool_attr(elem, "simple", false);
|
||||
|
||||
if (!widget) {
|
||||
ColorButtonOptions options;
|
||||
@ -453,9 +453,9 @@ Widget* WidgetLoader::convertXmlElementToWidget(const TiXmlElement* elem, Widget
|
||||
widget = new ButtonSet(strtol(columns, NULL, 10));
|
||||
|
||||
if (ButtonSet* buttonset = dynamic_cast<ButtonSet*>(widget)) {
|
||||
if (bool_attr_is_true(elem, "multiple"))
|
||||
if (bool_attr(elem, "multiple", false))
|
||||
buttonset->setMultiMode(ButtonSet::MultiMode::Set);
|
||||
if (bool_attr_is_true(elem, "oneormore"))
|
||||
if (bool_attr(elem, "oneormore", false))
|
||||
buttonset->setMultiMode(ButtonSet::MultiMode::OneOrMore);
|
||||
}
|
||||
}
|
||||
@ -487,21 +487,28 @@ Widget* WidgetLoader::convertXmlElementToWidget(const TiXmlElement* elem, Widget
|
||||
else if (elem_name == "image") {
|
||||
if (!widget) {
|
||||
const char* file = elem->Attribute("file");
|
||||
const char* icon = elem->Attribute("icon");
|
||||
|
||||
// Load image
|
||||
std::string icon(file);
|
||||
if (file) {
|
||||
ResourceFinder rf;
|
||||
rf.includeDataDir(file);
|
||||
if (!rf.findFirst())
|
||||
throw base::Exception("File %s not found", file);
|
||||
|
||||
ResourceFinder rf;
|
||||
rf.includeDataDir(file);
|
||||
if (!rf.findFirst())
|
||||
throw base::Exception("File %s not found", file);
|
||||
|
||||
try {
|
||||
os::SurfaceRef sur = os::instance()->loadRgbaSurface(rf.filename().c_str());
|
||||
widget = new ImageView(sur, 0);
|
||||
try {
|
||||
os::SurfaceRef sur = os::instance()->loadRgbaSurface(rf.filename().c_str());
|
||||
widget = new ImageView(sur, 0);
|
||||
}
|
||||
catch (...) {
|
||||
throw base::Exception("Error loading %s file", file);
|
||||
}
|
||||
}
|
||||
catch (...) {
|
||||
throw base::Exception("Error loading %s file", file);
|
||||
|
||||
if (icon) {
|
||||
SkinPartPtr part = SkinTheme::instance()->getPartById(std::string(icon));
|
||||
if (part) {
|
||||
widget = new ImageView(part->bitmapRef(0), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -522,12 +529,13 @@ void WidgetLoader::fillWidgetWithXmlElementAttributes(const TiXmlElement* elem,
|
||||
{
|
||||
const char* id = elem->Attribute("id");
|
||||
const char* tooltip_dir = elem->Attribute("tooltip_dir");
|
||||
bool selected = bool_attr_is_true(elem, "selected");
|
||||
bool disabled = bool_attr_is_true(elem, "disabled");
|
||||
bool expansive = bool_attr_is_true(elem, "expansive");
|
||||
bool homogeneous = bool_attr_is_true(elem, "homogeneous");
|
||||
bool magnet = bool_attr_is_true(elem, "magnet");
|
||||
bool noborders = bool_attr_is_true(elem, "noborders");
|
||||
bool selected = bool_attr(elem, "selected", false);
|
||||
bool disabled = bool_attr(elem, "disabled", false);
|
||||
bool expansive = bool_attr(elem, "expansive", false);
|
||||
bool homogeneous = bool_attr(elem, "homogeneous", false);
|
||||
bool magnet = bool_attr(elem, "magnet", false);
|
||||
bool noborders = bool_attr(elem, "noborders", false);
|
||||
bool visible = bool_attr(elem, "visible", true);
|
||||
const char* width = elem->Attribute("width");
|
||||
const char* height = elem->Attribute("height");
|
||||
const char* minwidth = elem->Attribute("minwidth");
|
||||
@ -585,6 +593,9 @@ void WidgetLoader::fillWidgetWithXmlElementAttributes(const TiXmlElement* elem,
|
||||
if (expansive)
|
||||
widget->setExpansive(true);
|
||||
|
||||
if (!visible)
|
||||
widget->setVisible(false);
|
||||
|
||||
if (homogeneous)
|
||||
widget->setAlign(widget->align() | HOMOGENEOUS);
|
||||
|
||||
@ -699,7 +710,7 @@ void WidgetLoader::fillWidgetWithXmlElementAttributesWithChildren(const TiXmlEle
|
||||
}
|
||||
|
||||
if (widget->type() == kViewWidget) {
|
||||
bool maxsize = bool_attr_is_true(elem, "maxsize");
|
||||
bool maxsize = bool_attr(elem, "maxsize", false);
|
||||
if (maxsize)
|
||||
static_cast<View*>(widget)->makeVisibleAllScrollableArea();
|
||||
}
|
||||
|
@ -45,11 +45,11 @@ void save_xml(XmlDocumentRef doc, const std::string& filename)
|
||||
throw XmlException(doc.get());
|
||||
}
|
||||
|
||||
bool bool_attr_is_true(const TiXmlElement* elem, const char* attrName)
|
||||
bool bool_attr(const TiXmlElement* elem, const char* attrName, bool defaultVal)
|
||||
{
|
||||
const char* value = elem->Attribute(attrName);
|
||||
|
||||
return (value != NULL) && (strcmp(value, "true") == 0);
|
||||
return value == NULL ? defaultVal : strcmp(value, "true") == 0;
|
||||
}
|
||||
|
||||
} // namespace app
|
||||
|
@ -23,7 +23,7 @@ namespace app {
|
||||
XmlDocumentRef open_xml(const std::string& filename);
|
||||
void save_xml(XmlDocumentRef doc, const std::string& filename);
|
||||
|
||||
bool bool_attr_is_true(const TiXmlElement* elem, const char* attrName);
|
||||
bool bool_attr(const TiXmlElement* elem, const char* attrName, bool defaultVal);
|
||||
|
||||
} // namespace app
|
||||
|
||||
|
@ -116,6 +116,9 @@ static Item convert_to_item(TiXmlElement* elem)
|
||||
if (name == "hbox")
|
||||
return item.typeIncl("ui::HBox",
|
||||
"ui/box.h");
|
||||
if (name == "image")
|
||||
return item.typeIncl("ui::ImageView",
|
||||
"ui/image_view.h");
|
||||
if (name == "item" &&
|
||||
parent == "buttonset")
|
||||
return item.typeIncl("app::ButtonSet::Item",
|
||||
|
@ -115,12 +115,14 @@ public:
|
||||
template<>
|
||||
class BlenderHelper<IndexedTraits, IndexedTraits> {
|
||||
BlendMode m_blendMode;
|
||||
color_t m_mask_color;
|
||||
color_t m_maskColor;
|
||||
int m_paletteSize;
|
||||
public:
|
||||
BlenderHelper(const Image* src, const Palette* pal, BlendMode blendMode, const bool newBlend)
|
||||
{
|
||||
m_blendMode = blendMode;
|
||||
m_mask_color = src->maskColor();
|
||||
m_maskColor = src->maskColor();
|
||||
m_paletteSize = pal->size();
|
||||
}
|
||||
inline IndexedTraits::pixel_t
|
||||
operator()(const IndexedTraits::pixel_t& dst,
|
||||
@ -131,13 +133,13 @@ public:
|
||||
return src;
|
||||
}
|
||||
else if (m_blendMode == BlendMode::DST_OVER) {
|
||||
if (dst != m_mask_color)
|
||||
if (dst != m_maskColor)
|
||||
return dst;
|
||||
else
|
||||
return src;
|
||||
}
|
||||
else {
|
||||
if (src != m_mask_color)
|
||||
if (src != m_maskColor && src < m_paletteSize)
|
||||
return src;
|
||||
else
|
||||
return dst;
|
||||
|
@ -16,7 +16,13 @@ namespace ui {
|
||||
{
|
||||
public:
|
||||
CloseEvent(Component* source)
|
||||
: Event(source) { }
|
||||
: Event(source)
|
||||
, m_canceled(false) { }
|
||||
void cancel() { m_canceled = true; }
|
||||
bool canceled() const { return m_canceled; }
|
||||
|
||||
private:
|
||||
bool m_canceled;
|
||||
};
|
||||
|
||||
} // namespace ui
|
||||
|
@ -404,14 +404,18 @@ void Window::openWindowInForeground()
|
||||
|
||||
void Window::closeWindow(Widget* closer)
|
||||
{
|
||||
// Close event
|
||||
CloseEvent ev(closer);
|
||||
onBeforeClose(ev);
|
||||
if (ev.canceled())
|
||||
return;
|
||||
|
||||
m_closer = closer;
|
||||
if (m_ownDisplay)
|
||||
m_lastFrame = m_display->nativeWindow()->frame();
|
||||
|
||||
manager()->_closeWindow(this, true);
|
||||
|
||||
// Close event
|
||||
CloseEvent ev(closer);
|
||||
onClose(ev);
|
||||
}
|
||||
|
||||
|
@ -87,6 +87,7 @@ namespace ui {
|
||||
|
||||
// New events
|
||||
virtual void onOpen(Event& ev);
|
||||
virtual void onBeforeClose(CloseEvent& ev) {}
|
||||
virtual void onClose(CloseEvent& ev);
|
||||
virtual void onHitTest(HitTestEvent& ev);
|
||||
virtual void onWindowResize();
|
||||
|
Loading…
x
Reference in New Issue
Block a user