Use std:: when necessary, and std::numeric_limits instead of INT_MAX

This commit is contained in:
David Capello 2015-03-04 21:35:11 -03:00
parent e822ddba4c
commit ad856b2a55
50 changed files with 179 additions and 163 deletions

View File

@ -63,7 +63,7 @@ namespace {
int nframes = sprite->totalFrames(); int nframes = sprite->totalFrames();
int framew = sprite->width(); int framew = sprite->width();
int frameh = sprite->height(); int frameh = sprite->height();
Fit result(framew*nframes, frameh, nframes, INT_MAX); Fit result(framew*nframes, frameh, nframes, std::numeric_limits<int>::max());
int w, h; int w, h;
for (w=2; w < framew; w*=2) for (w=2; w < framew; w*=2)

View File

@ -31,6 +31,8 @@
#include "she/surface.h" #include "she/surface.h"
#include "she/system.h" #include "she/system.h"
#include <cstring>
#define PREVIEW_TILED 1 #define PREVIEW_TILED 1
#define PREVIEW_FIT_ON_SCREEN 2 #define PREVIEW_FIT_ON_SCREEN 2
@ -120,10 +122,10 @@ protected:
// Change frame // Change frame
if (command != NULL && if (command != NULL &&
(strcmp(command->short_name(), CommandId::GotoFirstFrame) == 0 || (std::strcmp(command->short_name(), CommandId::GotoFirstFrame) == 0 ||
strcmp(command->short_name(), CommandId::GotoPreviousFrame) == 0 || std::strcmp(command->short_name(), CommandId::GotoPreviousFrame) == 0 ||
strcmp(command->short_name(), CommandId::GotoNextFrame) == 0 || std::strcmp(command->short_name(), CommandId::GotoNextFrame) == 0 ||
strcmp(command->short_name(), CommandId::GotoLastFrame) == 0)) { std::strcmp(command->short_name(), CommandId::GotoLastFrame) == 0)) {
m_context->executeCommand(command); m_context->executeCommand(command);
invalidate(); invalidate();
m_render.reset(NULL); // Re-render m_render.reset(NULL); // Re-render
@ -131,7 +133,7 @@ protected:
#if 0 #if 0
// Play the animation // Play the animation
else if (command != NULL && else if (command != NULL &&
strcmp(command->short_name(), CommandId::PlayAnimation) == 0) { std::strcmp(command->short_name(), CommandId::PlayAnimation) == 0) {
// TODO // TODO
} }
#endif #endif

View File

@ -17,14 +17,15 @@
#include "app/find_widget.h" #include "app/find_widget.h"
#include "app/load_widget.h" #include "app/load_widget.h"
#include "app/modules/gui.h" #include "app/modules/gui.h"
#include "app/transaction.h"
#include "app/ui/main_window.h" #include "app/ui/main_window.h"
#include "app/ui/status_bar.h" #include "app/ui/status_bar.h"
#include "app/transaction.h"
#include "doc/layer.h" #include "doc/layer.h"
#include "doc/sprite.h" #include "doc/sprite.h"
#include "ui/ui.h" #include "ui/ui.h"
#include <cstdio> #include <cstdio>
#include <cstring>
namespace app { namespace app {
@ -126,8 +127,8 @@ static int get_max_layer_num(Layer* layer)
{ {
int max = 0; int max = 0;
if (strncmp(layer->name().c_str(), "Layer ", 6) == 0) if (std::strncmp(layer->name().c_str(), "Layer ", 6) == 0)
max = strtol(layer->name().c_str()+6, NULL, 10); max = std::strtol(layer->name().c_str()+6, NULL, 10);
if (layer->isFolder()) { if (layer->isFolder()) {
LayerIterator it = static_cast<LayerFolder*>(layer)->getLayerBegin(); LayerIterator it = static_cast<LayerFolder*>(layer)->getLayerBegin();

View File

@ -41,6 +41,8 @@
#include "ui/system.h" #include "ui/system.h"
#include "ui/view.h" #include "ui/view.h"
#include <cstring>
namespace app { namespace app {
using namespace ui; using namespace ui;
@ -334,14 +336,14 @@ bool MovingPixelsState::onKeyDown(Editor* editor, KeyMessage* msg)
if (KeyboardShortcuts::instance() if (KeyboardShortcuts::instance()
->getCommandFromKeyMessage(msg, &command, &params)) { ->getCommandFromKeyMessage(msg, &command, &params)) {
// We accept zoom commands. // We accept zoom commands.
if (strcmp(command->short_name(), CommandId::Zoom) == 0) { if (std::strcmp(command->short_name(), CommandId::Zoom) == 0) {
UIContext::instance()->executeCommand(command, params); UIContext::instance()->executeCommand(command, params);
return true; return true;
} }
// Intercept the "Cut" or "Copy" command to handle them locally // Intercept the "Cut" or "Copy" command to handle them locally
// with the current m_pixelsMovement data. // with the current m_pixelsMovement data.
else if (strcmp(command->short_name(), CommandId::Cut) == 0 || else if (std::strcmp(command->short_name(), CommandId::Cut) == 0 ||
strcmp(command->short_name(), CommandId::Copy) == 0) { std::strcmp(command->short_name(), CommandId::Copy) == 0) {
// Copy the floating image to the clipboard. // Copy the floating image to the clipboard.
{ {
Document* document = editor->document(); Document* document = editor->document();
@ -353,7 +355,7 @@ bool MovingPixelsState::onKeyDown(Editor* editor, KeyMessage* msg)
} }
// In case of "Cut" command. // In case of "Cut" command.
if (strcmp(command->short_name(), CommandId::Cut) == 0) { if (std::strcmp(command->short_name(), CommandId::Cut) == 0) {
// Discard the dragged image. // Discard the dragged image.
m_pixelsMovement->discardImage(); m_pixelsMovement->discardImage();
m_discarded = true; m_discarded = true;
@ -367,7 +369,7 @@ bool MovingPixelsState::onKeyDown(Editor* editor, KeyMessage* msg)
} }
// Flip Horizontally/Vertically commands are handled manually to // Flip Horizontally/Vertically commands are handled manually to
// avoid dropping the floating region of pixels. // avoid dropping the floating region of pixels.
else if (strcmp(command->short_name(), CommandId::Flip) == 0) { else if (std::strcmp(command->short_name(), CommandId::Flip) == 0) {
if (FlipCommand* flipCommand = dynamic_cast<FlipCommand*>(command)) { if (FlipCommand* flipCommand = dynamic_cast<FlipCommand*>(command)) {
flipCommand->loadParams(params); flipCommand->loadParams(params);
m_pixelsMovement->flipImage(flipCommand->getFlipType()); m_pixelsMovement->flipImage(flipCommand->getFlipType());
@ -430,8 +432,8 @@ void MovingPixelsState::onBeforeCommandExecution(Command* command)
if (moveMaskCmd->getTarget() == MoveMaskCommand::Content) if (moveMaskCmd->getTarget() == MoveMaskCommand::Content)
return; return;
} }
else if ((strcmp(command->short_name(), CommandId::Zoom) == 0) || else if ((std::strcmp(command->short_name(), CommandId::Zoom) == 0) ||
(strcmp(command->short_name(), CommandId::Scroll) == 0)) { (std::strcmp(command->short_name(), CommandId::Scroll) == 0)) {
return; return;
} }

View File

@ -9,9 +9,10 @@
#define APP_UI_SKIN_SKIN_PART_H_INCLUDED #define APP_UI_SKIN_SKIN_PART_H_INCLUDED
#pragma once #pragma once
#include <vector>
#include "base/shared_ptr.h" #include "base/shared_ptr.h"
#include <vector>
namespace she { namespace she {
class Surface; class Surface;
} }
@ -26,14 +27,14 @@ namespace app {
SkinPart(); SkinPart();
~SkinPart(); ~SkinPart();
size_t size() const { return m_bitmaps.size(); } std::size_t size() const { return m_bitmaps.size(); }
void clear(); void clear();
// It doesn't destroy the previous bitmap in the given "index". // It doesn't destroy the previous bitmap in the given "index".
void setBitmap(size_t index, she::Surface* bitmap); void setBitmap(std::size_t index, she::Surface* bitmap);
she::Surface* getBitmap(size_t index) const { she::Surface* getBitmap(std::size_t index) const {
return (index < m_bitmaps.size() ? m_bitmaps[index]: NULL); return (index < m_bitmaps.size() ? m_bitmaps[index]: NULL);
} }

View File

@ -1,5 +1,5 @@
// Aseprite Base Library // Aseprite Base Library
// Copyright (c) 2001-2013 David Capello // Copyright (c) 2001-2013, 2015 David Capello
// //
// This file is released under the terms of the MIT license. // This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information. // Read LICENSE.txt for more information.
@ -12,7 +12,7 @@
namespace base { namespace base {
std::string get_pretty_memory_size(size_t memsize); std::string get_pretty_memory_size(std::size_t memsize);
} // namespace base } // namespace base

View File

@ -1,5 +1,5 @@
// Aseprite Base Library // Aseprite Base Library
// Copyright (c) 2001-2013 David Capello // Copyright (c) 2001-2013, 2015 David Capello
// //
// This file is released under the terms of the MIT license. // This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information. // Read LICENSE.txt for more information.
@ -8,9 +8,11 @@
#define BASE_MEMORY_H_INCLUDED #define BASE_MEMORY_H_INCLUDED
#pragma once #pragma once
void* base_malloc (size_t bytes); #include <cstddef>
void* base_malloc0(size_t bytes);
void* base_realloc(void* mem, size_t bytes); void* base_malloc (std::size_t bytes);
void* base_malloc0(std::size_t bytes);
void* base_realloc(void* mem, std::size_t bytes);
void base_free (void* mem); void base_free (void* mem);
char* base_strdup (const char* string); char* base_strdup (const char* string);

View File

@ -1,5 +1,5 @@
// Aseprite Base Library // Aseprite Base Library
// Copyright (c) 2001-2014 David Capello // Copyright (c) 2001-2015 David Capello
// //
// This file is released under the terms of the MIT license. // This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information. // Read LICENSE.txt for more information.
@ -22,7 +22,7 @@ public:
typedef typename list_type::const_iterator const_iterator; typedef typename list_type::const_iterator const_iterator;
bool empty() const { return m_observers.empty(); } bool empty() const { return m_observers.empty(); }
size_t size() const { return m_observers.size(); } std::size_t size() const { return m_observers.size(); }
// Adds the observer in the collection. The observer is owned by the // Adds the observer in the collection. The observer is owned by the
// collection and will be destroyed calling the T::dispose() member // collection and will be destroyed calling the T::dispose() member

View File

@ -187,11 +187,11 @@ std::string ProgramOptions::value_of(const Option& option) const
std::ostream& operator<<(std::ostream& os, const base::ProgramOptions& po) std::ostream& operator<<(std::ostream& os, const base::ProgramOptions& po)
{ {
size_t maxOptionWidth = 0; std::size_t maxOptionWidth = 0;
for (base::ProgramOptions::OptionList::const_iterator for (base::ProgramOptions::OptionList::const_iterator
it=po.options().begin(), end=po.options().end(); it != end; ++it) { it=po.options().begin(), end=po.options().end(); it != end; ++it) {
const base::ProgramOptions::Option* option = *it; const base::ProgramOptions::Option* option = *it;
size_t optionWidth = std::size_t optionWidth =
6+option->name().size()+1+ 6+option->name().size()+1+
(option->doesRequireValue() ? option->getValueName().size()+1: 0); (option->doesRequireValue() ? option->getValueName().size()+1: 0);
@ -202,7 +202,7 @@ std::ostream& operator<<(std::ostream& os, const base::ProgramOptions& po)
for (base::ProgramOptions::OptionList::const_iterator for (base::ProgramOptions::OptionList::const_iterator
it=po.options().begin(), end=po.options().end(); it != end; ++it) { it=po.options().begin(), end=po.options().end(); it != end; ++it) {
const base::ProgramOptions::Option* option = *it; const base::ProgramOptions::Option* option = *it;
size_t optionWidth = 6+option->name().size()+1+ std::size_t optionWidth = 6+option->name().size()+1+
(option->doesRequireValue() ? option->getValueName().size()+1: 0); (option->doesRequireValue() ? option->getValueName().size()+1: 0);
if (option->mnemonic() != 0) if (option->mnemonic() != 0)

View File

@ -1,5 +1,5 @@
// Aseprite Base Library // Aseprite Base Library
// Copyright (c) 2001-2013 David Capello // Copyright (c) 2001-2013, 2015 David Capello
// //
// This file is released under the terms of the MIT license. // This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information. // Read LICENSE.txt for more information.
@ -20,14 +20,14 @@ public:
typedef typename Items::iterator iterator; typedef typename Items::iterator iterator;
typedef typename Items::const_iterator const_iterator; typedef typename Items::const_iterator const_iterator;
RecentItems(size_t limit) : m_limit(limit) { } RecentItems(std::size_t limit) : m_limit(limit) { }
const_iterator begin() { return m_items.begin(); } const_iterator begin() { return m_items.begin(); }
const_iterator end() { return m_items.end(); } const_iterator end() { return m_items.end(); }
bool empty() const { return m_items.empty(); } bool empty() const { return m_items.empty(); }
size_t size() const { return m_items.size(); } std::size_t size() const { return m_items.size(); }
size_t limit() const { return m_limit; } std::size_t limit() const { return m_limit; }
void addItem(const T& item) { void addItem(const T& item) {
iterator it = std::find(m_items.begin(), m_items.end(), item); iterator it = std::find(m_items.begin(), m_items.end(), item);
@ -57,7 +57,7 @@ public:
private: private:
Items m_items; Items m_items;
size_t m_limit; std::size_t m_limit;
}; };
} // namespace base } // namespace base

View File

@ -20,7 +20,7 @@ void replace_string(
if (replace_this.empty()) // Do nothing case if (replace_this.empty()) // Do nothing case
return; return;
size_t i = 0; std::size_t i = 0;
while (true) { while (true) {
i = subject.find(replace_this, i); i = subject.find(replace_this, i);
if (i == std::string::npos) if (i == std::string::npos)
@ -29,5 +29,5 @@ void replace_string(
i += with_that.size(); i += with_that.size();
} }
} }
} // namespace base } // namespace base

View File

@ -42,7 +42,7 @@ Sha1 Sha1::calculateFromFile(const std::string& fileName)
unsigned char buf[1024]; unsigned char buf[1024];
while (file.good()) { while (file.good()) {
file.read((char*)buf, 1024); file.read((char*)buf, 1024);
size_t len = (size_t)file.gcount(); std::size_t len = (std::size_t)file.gcount();
if (len > 0) if (len > 0)
SHA1Input(&sha, buf, len); SHA1Input(&sha, buf, len);
} }

View File

@ -1,5 +1,5 @@
// Aseprite Base Library // Aseprite Base Library
// Copyright (c) 2001-2013 David Capello // Copyright (c) 2001-2013, 2015 David Capello
// //
// This file is released under the terms of the MIT license. // This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information. // Read LICENSE.txt for more information.
@ -38,10 +38,10 @@ void base::split_string(const std::string& string,
std::vector<std::string>& parts, std::vector<std::string>& parts,
const std::string& separators) const std::string& separators)
{ {
size_t elements = 1 + std::count_if(string.begin(), string.end(), is_separator(&separators)); std::size_t elements = 1 + std::count_if(string.begin(), string.end(), is_separator(&separators));
parts.reserve(elements); parts.reserve(elements);
size_t beg = 0, end; std::size_t beg = 0, end;
while (true) { while (true) {
end = string.find_first_of(separators, beg); end = string.find_first_of(separators, beg);
if (end != std::string::npos) { if (end != std::string::npos) {

View File

@ -83,7 +83,7 @@ std::wstring from_utf8(const std::string& src)
#else #else
// Based on Allegro Unicode code (allegro/src/unicode.c) // Based on Allegro Unicode code (allegro/src/unicode.c)
static size_t insert_utf8_char(std::string* result, wchar_t chr) static std::size_t insert_utf8_char(std::string* result, wchar_t chr)
{ {
int size, bits, b, i; int size, bits, b, i;
@ -129,7 +129,7 @@ std::string to_utf8(const std::wstring& src)
// Get required size to reserve a string so string::push_back() // Get required size to reserve a string so string::push_back()
// doesn't need to reallocate its data. // doesn't need to reallocate its data.
size_t required_size = 0; std::size_t required_size = 0;
for (it = begin; it != end; ++it) for (it = begin; it != end; ++it)
required_size += insert_utf8_char(NULL, *it); required_size += insert_utf8_char(NULL, *it);
if (!required_size) if (!required_size)

View File

@ -1,5 +1,5 @@
// Aseprite Base Library // Aseprite Base Library
// Copyright (c) 2001-2013 David Capello // Copyright (c) 2001-2013, 2015 David Capello
// //
// This file is released under the terms of the MIT license. // This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information. // Read LICENSE.txt for more information.
@ -36,19 +36,19 @@ namespace base {
Version& revision(int digit) { (*this)[2] = digit; return *this; } Version& revision(int digit) { (*this)[2] = digit; return *this; }
Version& build(int digit) { (*this)[3] = digit; return *this; } Version& build(int digit) { (*this)[3] = digit; return *this; }
size_t size() const { std::size_t size() const {
return m_digits.size(); return m_digits.size();
} }
// operator[] that can be used to set version digits. // operator[] that can be used to set version digits.
int& operator[](size_t index) { int& operator[](std::size_t index) {
if (index >= m_digits.size()) if (index >= m_digits.size())
m_digits.resize(index+1); m_digits.resize(index+1);
return m_digits[index]; return m_digits[index];
} }
// operator[] that can be used to get version digits. // operator[] that can be used to get version digits.
int operator[](size_t index) const { int operator[](std::size_t index) const {
if (index < m_digits.size()) if (index < m_digits.size())
return m_digits[index]; return m_digits[index];
else else

View File

@ -112,9 +112,9 @@ Cel* Cel::link() const
return NULL; return NULL;
} }
size_t Cel::links() const std::size_t Cel::links() const
{ {
size_t links = 0; std::size_t links = 0;
Sprite* sprite = this->sprite(); Sprite* sprite = this->sprite();
for (frame_t fr=0; fr<sprite->totalFrames(); ++fr) { for (frame_t fr=0; fr<sprite->totalFrames(); ++fr) {

View File

@ -44,7 +44,7 @@ namespace doc {
Document* document() const; Document* document() const;
Sprite* sprite() const; Sprite* sprite() const;
Cel* link() const; Cel* link() const;
size_t links() const; std::size_t links() const;
gfx::Rect bounds() const; gfx::Rect bounds() const;
// You should change the frame only if the cel isn't member of a // You should change the frame only if the cel isn't member of a

View File

@ -1,5 +1,5 @@
// Aseprite Document Library // Aseprite Document Library
// Copyright (c) 2001-2014 David Capello // Copyright (c) 2001-2015 David Capello
// //
// This file is released under the terms of the MIT license. // This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information. // Read LICENSE.txt for more information.
@ -28,24 +28,24 @@ Palette* load_col_file(const char* filename)
{ {
Palette *pal = NULL; Palette *pal = NULL;
int c, r, g, b; int c, r, g, b;
FILE *f; FILE* f;
f = fopen(filename, "rb"); f = std::fopen(filename, "rb");
if (!f) if (!f)
return NULL; return NULL;
// Get file size. // Get file size.
fseek(f, 0, SEEK_END); std::fseek(f, 0, SEEK_END);
size_t size = ftell(f); std::size_t size = std::ftell(f);
div_t d = div(size-8, 3); std::div_t d = std::div(size-8, 3);
fseek(f, 0, SEEK_SET); std::fseek(f, 0, SEEK_SET);
bool pro = (size == 768)? false: true; // is Animator Pro format? bool pro = (size == 768)? false: true; // is Animator Pro format?
if (!(size) || (pro && d.rem)) { // Invalid format if (!(size) || (pro && d.rem)) { // Invalid format
fclose(f); fclose(f);
return NULL; return NULL;
} }
// Animator format // Animator format
if (!pro) { if (!pro) {
pal = new Palette(frame_t(0), 256); pal = new Palette(frame_t(0), 256);

View File

@ -1,5 +1,5 @@
// Aseprite Document Library // Aseprite Document Library
// Copyright (c) 2001-2014 David Capello // Copyright (c) 2001-2015 David Capello
// //
// This file is released under the terms of the MIT license. // This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information. // Read LICENSE.txt for more information.
@ -11,18 +11,19 @@
#include "base/shared_ptr.h" #include "base/shared_ptr.h"
#include <vector> #include <vector>
#include <cstddef>
namespace doc { namespace doc {
class ImageBuffer { class ImageBuffer {
public: public:
ImageBuffer(size_t size = 1) : m_buffer(size) { ImageBuffer(std::size_t size = 1) : m_buffer(size) {
} }
size_t size() const { return m_buffer.size(); } std::size_t size() const { return m_buffer.size(); }
uint8_t* buffer() { return &m_buffer[0]; } uint8_t* buffer() { return &m_buffer[0]; }
void resizeIfNecessary(size_t size) { void resizeIfNecessary(std::size_t size) {
if (size > m_buffer.size()) if (size > m_buffer.size())
m_buffer.resize(size); m_buffer.resize(size);
} }

View File

@ -1,5 +1,5 @@
// Aseprite Document Library // Aseprite Document Library
// Copyright (c) 2001-2014 David Capello // Copyright (c) 2001-2015 David Capello
// //
// This file is released under the terms of the MIT license. // This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information. // Read LICENSE.txt for more information.
@ -8,6 +8,9 @@
#define DOC_IMAGE_IMPL_H_INCLUDED #define DOC_IMAGE_IMPL_H_INCLUDED
#pragma once #pragma once
#include <cstdlib>
#include <cstring>
#include "doc/blend.h" #include "doc/blend.h"
#include "doc/image.h" #include "doc/image.h"
#include "doc/image_bits.h" #include "doc/image_bits.h"
@ -54,9 +57,9 @@ namespace doc {
: Image(static_cast<PixelFormat>(Traits::pixel_format), width, height) : Image(static_cast<PixelFormat>(Traits::pixel_format), width, height)
, m_buffer(buffer) , m_buffer(buffer)
{ {
size_t for_rows = sizeof(address_t) * height; std::size_t for_rows = sizeof(address_t) * height;
size_t rowstride_bytes = Traits::getRowStrideBytes(width); std::size_t rowstride_bytes = Traits::getRowStrideBytes(width);
size_t required_size = for_rows + rowstride_bytes*height; std::size_t required_size = for_rows + rowstride_bytes*height;
if (!m_buffer) if (!m_buffer)
m_buffer.reset(new ImageBuffer(required_size)); m_buffer.reset(new ImageBuffer(required_size));
@ -121,7 +124,7 @@ namespace doc {
src_address = src->address(area.src.x, area.src.y); src_address = src->address(area.src.x, area.src.y);
dst_address = address(area.dst.x, area.dst.y); dst_address = address(area.dst.x, area.dst.y);
memcpy(dst_address, src_address, bytes); std::memcpy(dst_address, src_address, bytes);
} }
} }
@ -205,13 +208,13 @@ namespace doc {
template<> template<>
inline void ImageImpl<IndexedTraits>::clear(color_t color) { inline void ImageImpl<IndexedTraits>::clear(color_t color) {
memset(m_bits, color, width()*height()); std::memset(m_bits, color, width()*height());
} }
template<> template<>
inline void ImageImpl<BitmapTraits>::clear(color_t color) { inline void ImageImpl<BitmapTraits>::clear(color_t color) {
memset(m_bits, (color ? 0xff: 0x00), std::memset(m_bits, (color ? 0xff: 0x00),
BitmapTraits::getRowStrideBytes(width()) * height()); BitmapTraits::getRowStrideBytes(width()) * height());
} }
template<> template<>
@ -219,7 +222,7 @@ namespace doc {
ASSERT(x >= 0 && x < width()); ASSERT(x >= 0 && x < width());
ASSERT(y >= 0 && y < height()); ASSERT(y >= 0 && y < height());
div_t d = div(x, 8); std::div_t d = std::div(x, 8);
return ((*(m_rows[y] + d.quot)) & (1<<d.rem)) ? 1: 0; return ((*(m_rows[y] + d.quot)) & (1<<d.rem)) ? 1: 0;
} }
@ -228,7 +231,7 @@ namespace doc {
ASSERT(x >= 0 && x < width()); ASSERT(x >= 0 && x < width());
ASSERT(y >= 0 && y < height()); ASSERT(y >= 0 && y < height());
div_t d = div(x, 8); std::div_t d = std::div(x, 8);
if (color) if (color)
(*(m_rows[y] + d.quot)) |= (1 << d.rem); (*(m_rows[y] + d.quot)) |= (1 << d.rem);
else else

View File

@ -1,5 +1,5 @@
// Aseprite Document Library // Aseprite Document Library
// Copyright (c) 2001-2014 David Capello // Copyright (c) 2001-2015 David Capello
// //
// This file is released under the terms of the MIT license. // This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information. // Read LICENSE.txt for more information.
@ -45,8 +45,8 @@ TYPED_TEST(ImageAllTypes, PutGetAndIterators)
lengths.push_back(33); lengths.push_back(33);
std::vector<gfx::Size> sizes; std::vector<gfx::Size> sizes;
for (size_t i=0; i<lengths.size(); ++i) for (std::size_t i=0; i<lengths.size(); ++i)
for (size_t j=0; j<lengths.size(); ++j) for (std::size_t j=0; j<lengths.size(); ++j)
sizes.push_back(gfx::Size(lengths[j], lengths[i])); sizes.push_back(gfx::Size(lengths[j], lengths[i]));
for (std::vector<gfx::Size>::iterator sizes_it=sizes.begin(); sizes_it!=sizes.end(); ++sizes_it) { for (std::vector<gfx::Size>::iterator sizes_it=sizes.begin(); sizes_it!=sizes.end(); ++sizes_it) {
@ -160,8 +160,8 @@ TYPED_TEST(ImageAllTypes, DrawHLine)
lengths.push_back(33); lengths.push_back(33);
std::vector<gfx::Size> sizes; std::vector<gfx::Size> sizes;
for (size_t i=0; i<lengths.size(); ++i) for (std::size_t i=0; i<lengths.size(); ++i)
for (size_t j=0; j<lengths.size(); ++j) for (std::size_t j=0; j<lengths.size(); ++j)
sizes.push_back(gfx::Size(lengths[j], lengths[i])); sizes.push_back(gfx::Size(lengths[j], lengths[i]));
for (std::vector<gfx::Size>::iterator sizes_it=sizes.begin(); sizes_it!=sizes.end(); ++sizes_it) { for (std::vector<gfx::Size>::iterator sizes_it=sizes.begin(); sizes_it!=sizes.end(); ++sizes_it) {
@ -169,7 +169,7 @@ TYPED_TEST(ImageAllTypes, DrawHLine)
int h = sizes_it->h; int h = sizes_it->h;
UniquePtr<Image> image(Image::create(ImageTraits::pixel_format, w, h)); UniquePtr<Image> image(Image::create(ImageTraits::pixel_format, w, h));
image->clear(0); image->clear(0);
for (int c=0; c<100; ++c) { for (int c=0; c<100; ++c) {
int x = rand() % w; int x = rand() % w;
int y = rand() % h; int y = rand() % h;

View File

@ -1,5 +1,5 @@
// Aseprite Document Library // Aseprite Document Library
// Copyright (c) 2001-2014 David Capello // Copyright (c) 2001-2015 David Capello
// //
// This file is released under the terms of the MIT license. // This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information. // Read LICENSE.txt for more information.
@ -57,7 +57,7 @@ namespace doc {
ItemsIterator begin() { return m_items.begin(); } ItemsIterator begin() { return m_items.begin(); }
ItemsIterator end() { return m_items.end(); } ItemsIterator end() { return m_items.end(); }
size_t size() const { return m_items.size(); } std::size_t size() const { return m_items.size(); }
bool empty() const { return m_items.empty(); } bool empty() const { return m_items.empty(); }
private: private:

View File

@ -1,5 +1,5 @@
// Aseprite Document Library // Aseprite Document Library
// Copyright (c) 2001-2014 David Capello // Copyright (c) 2001-2015 David Capello
// //
// This file is released under the terms of the MIT license. // This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information. // Read LICENSE.txt for more information.
@ -15,6 +15,7 @@
#include "doc/image.h" #include "doc/image.h"
#include <algorithm> #include <algorithm>
#include <limits>
namespace doc { namespace doc {
@ -124,7 +125,7 @@ int Palette::countDiff(const Palette* other, int* from, int* to) const
bool Palette::isBlack() const bool Palette::isBlack() const
{ {
for (size_t c=0; c<m_colors.size(); ++c) for (std::size_t c=0; c<m_colors.size(); ++c)
if (getEntry(c) != rgba(0, 0, 0, 255)) if (getEntry(c) != rgba(0, 0, 0, 255))
return false; return false;
@ -429,7 +430,7 @@ int Palette::findBestfit(int r, int g, int b, int mask_index) const
bestfit_init(); bestfit_init();
bestfit = 0; bestfit = 0;
lowest = INT_MAX; lowest = std::numeric_limits<int>::max();
r >>= 3; r >>= 3;
g >>= 3; g >>= 3;

View File

@ -398,8 +398,8 @@ void Sprite::setFrameDuration(frame_t frame, int msecs)
void Sprite::setFrameRangeDuration(frame_t from, frame_t to, int msecs) void Sprite::setFrameRangeDuration(frame_t from, frame_t to, int msecs)
{ {
std::fill( std::fill(
m_frlens.begin()+(size_t)from, m_frlens.begin()+(std::size_t)from,
m_frlens.begin()+(size_t)to+1, MID(1, msecs, 65535)); m_frlens.begin()+(std::size_t)to+1, MID(1, msecs, 65535));
} }
void Sprite::setDurationForAllFrames(int msecs) void Sprite::setDurationForAllFrames(int msecs)

View File

@ -9,11 +9,11 @@
#define FILTERS_MEDIAN_FILTER_PROCESS_H_INCLUDED #define FILTERS_MEDIAN_FILTER_PROCESS_H_INCLUDED
#pragma once #pragma once
#include <vector>
#include "filters/filter.h" #include "filters/filter.h"
#include "filters/tiled_mode.h" #include "filters/tiled_mode.h"
#include <vector>
namespace filters { namespace filters {
class MedianFilter : public Filter { class MedianFilter : public Filter {

View File

@ -1,5 +1,5 @@
// Aseprite Code Generator // Aseprite Code Generator
// Copyright (c) 2014 David Capello // Copyright (c) 2014, 2015 David Capello
// //
// This file is released under the terms of the MIT license. // This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information. // Read LICENSE.txt for more information.
@ -15,7 +15,7 @@ inline std::string convert_xmlid_to_cppid(const std::string& xmlid, bool firstLe
{ {
bool firstLetter = firstLetterUpperCase; bool firstLetter = firstLetterUpperCase;
std::string cppid; std::string cppid;
for (size_t i=0; i<xmlid.size(); ++i) { for (std::size_t i=0; i<xmlid.size(); ++i) {
if (xmlid[i] == '_') { if (xmlid[i] == '_') {
firstLetter = true; firstLetter = true;
} }

View File

@ -1,5 +1,5 @@
// Aseprite Gfx Library // Aseprite Gfx Library
// Copyright (C) 2001-2014 David Capello // Copyright (C) 2001-2015 David Capello
// //
// This file is released under the terms of the MIT license. // This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information. // Read LICENSE.txt for more information.
@ -25,7 +25,7 @@ namespace gfx {
const_iterator begin() const { return m_rects.begin(); } const_iterator begin() const { return m_rects.begin(); }
const_iterator end() const { return m_rects.end(); } const_iterator end() const { return m_rects.end(); }
size_t size() const { return m_rects.size(); } std::size_t size() const { return m_rects.size(); }
const Rect& operator[](int i) const { return m_rects[i]; } const Rect& operator[](int i) const { return m_rects[i]; }
// Adds a new rectangle. // Adds a new rectangle.

View File

@ -1,5 +1,5 @@
// Aseprite Gfx Library // Aseprite Gfx Library
// Copyright (C) 2001-2013 David Capello // Copyright (C) 2001-2013, 2015 David Capello
// //
// This file is released under the terms of the MIT license. // This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information. // Read LICENSE.txt for more information.
@ -19,7 +19,7 @@
#include <limits.h> #include <limits.h>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
namespace gfx { namespace gfx {
inline Rect to_rect(const pixman_box32& extends) inline Rect to_rect(const pixman_box32& extends)
@ -109,7 +109,7 @@ Rect Region::bounds() const
return to_rect(*pixman_region32_extents(&m_region)); return to_rect(*pixman_region32_extents(&m_region));
} }
size_t Region::size() const std::size_t Region::size() const
{ {
return pixman_region32_n_rects(&m_region); return pixman_region32_n_rects(&m_region);
} }

View File

@ -1,5 +1,5 @@
// Aseprite Gfx Library // Aseprite Gfx Library
// Copyright (C) 2001-2013 David Capello // Copyright (C) 2001-2013, 2015 David Capello
// //
// This file is released under the terms of the MIT license. // This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information. // Read LICENSE.txt for more information.
@ -82,7 +82,7 @@ namespace gfx {
bool isEmpty() const; bool isEmpty() const;
Rect bounds() const; Rect bounds() const;
size_t size() const; std::size_t size() const;
void clear(); void clear();

View File

@ -1,5 +1,5 @@
// Aseprite Gfx Library // Aseprite Gfx Library
// Copyright (C) 2001-2013 David Capello // Copyright (C) 2001-2013, 2015 David Capello
// //
// This file is released under the terms of the MIT license. // This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information. // Read LICENSE.txt for more information.
@ -45,7 +45,7 @@ void Transformation::transformBox(Corners& corners) const
// critical at this point. // critical at this point.
corners = m_bounds; corners = m_bounds;
for (size_t c=0; c<corners.size(); ++c) for (std::size_t c=0; c<corners.size(); ++c)
corners[c] = Transformation::rotatePoint(corners[c], pivot_f, m_angle); corners[c] = Transformation::rotatePoint(corners[c], pivot_f, m_angle);
} }

View File

@ -1,5 +1,5 @@
// Aseprite Gfx Library // Aseprite Gfx Library
// Copyright (C) 2001-2013 David Capello // Copyright (C) 2001-2013, 2015 David Capello
// //
// This file is released under the terms of the MIT license. // This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information. // Read LICENSE.txt for more information.
@ -31,7 +31,7 @@ public:
Corners() : m_corners(NUM_OF_CORNERS) { } Corners() : m_corners(NUM_OF_CORNERS) { }
size_t size() const { return m_corners.size(); } std::size_t size() const { return m_corners.size(); }
PointT<double>& operator[](int index) { return m_corners[index]; } PointT<double>& operator[](int index) { return m_corners[index]; }
const PointT<double>& operator[](int index) const { return m_corners[index]; } const PointT<double>& operator[](int index) const { return m_corners[index]; }

View File

@ -74,14 +74,14 @@ public:
} }
private: private:
size_t writeBody(char* ptr, size_t bytes) std::size_t writeBody(char* ptr, std::size_t bytes)
{ {
ASSERT(m_response != NULL); ASSERT(m_response != NULL);
m_response->write(ptr, bytes); m_response->write(ptr, bytes);
return bytes; return bytes;
} }
static size_t writeBodyCallback(char* ptr, size_t size, size_t nmemb, void* userdata) static std::size_t writeBodyCallback(char* ptr, std::size_t size, std::size_t nmemb, void* userdata)
{ {
HttpRequestImpl* req = reinterpret_cast<HttpRequestImpl*>(userdata); HttpRequestImpl* req = reinterpret_cast<HttpRequestImpl*>(userdata);
return req->writeBody(ptr, size*nmemb); return req->writeBody(ptr, size*nmemb);

View File

@ -15,7 +15,7 @@
namespace net { namespace net {
void HttpResponse::write(const char* data, size_t length) void HttpResponse::write(const char* data, std::size_t length)
{ {
m_stream->write(data, length); m_stream->write(data, length);
} }

View File

@ -30,7 +30,7 @@ public:
void setStatus(int status) { m_status = status; } void setStatus(int status) { m_status = status; }
// Writes data in the stream. // Writes data in the stream.
void write(const char* data, size_t length); void write(const char* data, std::size_t length);
private: private:
int m_status; int m_status;

View File

@ -1,5 +1,5 @@
// Aseprite Render Library // Aseprite Render Library
// Copyright (c) 2001-2014 David Capello // Copyright (c) 2001-2015 David Capello
// //
// This file is released under the terms of the MIT license. // This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information. // Read LICENSE.txt for more information.
@ -39,21 +39,21 @@ namespace render {
// Returns the number of points in the specified histogram // Returns the number of points in the specified histogram
// entry. Each index (i, j, k) is in the range of the // entry. Each index (i, j, k) is in the range of the
// histogram i=[0,RElements), etc. // histogram i=[0,RElements), etc.
size_t at(int i, int j, int k) const std::size_t at(int i, int j, int k) const
{ {
return m_histogram[histogramIndex(i, j, k)]; return m_histogram[histogramIndex(i, j, k)];
} }
// Add the specified "color" in the histogram as many times as the // Add the specified "color" in the histogram as many times as the
// specified value in "count". // specified value in "count".
void addSamples(uint32_t color, size_t count = 1) void addSamples(uint32_t color, std::size_t count = 1)
{ {
int i = histogramIndex(color); int i = histogramIndex(color);
if (m_histogram[i] < std::numeric_limits<size_t>::max()-count) // Avoid overflow if (m_histogram[i] < std::numeric_limits<std::size_t>::max()-count) // Avoid overflow
m_histogram[i] += count; m_histogram[i] += count;
else else
m_histogram[i] = std::numeric_limits<size_t>::max(); m_histogram[i] = std::numeric_limits<std::size_t>::max();
// Accurate colors are used only for less than 256 colors. If the // Accurate colors are used only for less than 256 colors. If the
// image has more than 256 colors the m_histogram is used // image has more than 256 colors the m_histogram is used
@ -105,20 +105,20 @@ namespace render {
// Converts input color in a index for the histogram. It reduces // Converts input color in a index for the histogram. It reduces
// each 8-bit component to the resolution given in the template // each 8-bit component to the resolution given in the template
// parameters. // parameters.
size_t histogramIndex(uint32_t color) const std::size_t histogramIndex(uint32_t color) const
{ {
return histogramIndex((rgba_getr(color) >> (8 - RBits)), return histogramIndex((rgba_getr(color) >> (8 - RBits)),
(rgba_getg(color) >> (8 - GBits)), (rgba_getg(color) >> (8 - GBits)),
(rgba_getb(color) >> (8 - BBits))); (rgba_getb(color) >> (8 - BBits)));
} }
size_t histogramIndex(int i, int j, int k) const std::size_t histogramIndex(int i, int j, int k) const
{ {
return i | (j << RBits) | (k << (RBits+GBits)); return i | (j << RBits) | (k << (RBits+GBits));
} }
// 3D histogram (the index in the histogram is calculated through histogramIndex() function). // 3D histogram (the index in the histogram is calculated through histogramIndex() function).
std::vector<size_t> m_histogram; std::vector<std::size_t> m_histogram;
// High precision histogram to create an accurate palette if RGB // High precision histogram to create an accurate palette if RGB
// source images contains less than 256 colors. // source images contains less than 256 colors.

View File

@ -1,5 +1,5 @@
// Aseprite Render Library // Aseprite Render Library
// Copyright (c) 2001-2014 David Capello // Copyright (c) 2001-2015 David Capello
// //
// This file is released under the terms of the MIT license. // This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information. // Read LICENSE.txt for more information.
@ -21,9 +21,9 @@ namespace render {
// These classes are used as parameters for some Box's generic // These classes are used as parameters for some Box's generic
// member functions, so we can access to a different axis using // member functions, so we can access to a different axis using
// the same generic function (i=Red channel in RAxisGetter, etc.). // the same generic function (i=Red channel in RAxisGetter, etc.).
struct RAxisGetter { static size_t at(const Histogram& h, int i, int j, int k) { return h.at(i, j, k); } }; struct RAxisGetter { static std::size_t at(const Histogram& h, int i, int j, int k) { return h.at(i, j, k); } };
struct GAxisGetter { static size_t at(const Histogram& h, int i, int j, int k) { return h.at(j, i, k); } }; struct GAxisGetter { static std::size_t at(const Histogram& h, int i, int j, int k) { return h.at(j, i, k); } };
struct BAxisGetter { static size_t at(const Histogram& h, int i, int j, int k) { return h.at(j, k, i); } }; struct BAxisGetter { static std::size_t at(const Histogram& h, int i, int j, int k) { return h.at(j, k, i); } };
// These classes are used as template parameter to split a Box // These classes are used as template parameter to split a Box
// along an axis (see splitAlongAxis) // along an axis (see splitAlongAxis)
@ -82,8 +82,8 @@ namespace render {
// all histogram's points inside the box. // all histogram's points inside the box.
uint32_t meanColor(const Histogram& histogram) const uint32_t meanColor(const Histogram& histogram) const
{ {
size_t r = 0, g = 0, b = 0; std::size_t r = 0, g = 0, b = 0;
size_t count = 0; std::size_t count = 0;
int i, j, k; int i, j, k;
for (i=r1; i<=r2; ++i) for (i=r1; i<=r2; ++i)
@ -125,9 +125,9 @@ namespace render {
} }
// Returns the number of histogram's points inside the box bounds. // Returns the number of histogram's points inside the box bounds.
size_t countPoints(const Histogram& histogram) const std::size_t countPoints(const Histogram& histogram) const
{ {
size_t count = 0; std::size_t count = 0;
int i, j, k; int i, j, k;
for (i=r1; i<=r2; ++i) for (i=r1; i<=r2; ++i)
@ -187,8 +187,8 @@ namespace render {
{ {
// These two variables will be used to count how many points are // These two variables will be used to count how many points are
// in each side of the box if we split it in "i" position. // in each side of the box if we split it in "i" position.
size_t totalPoints1 = 0; std::size_t totalPoints1 = 0;
size_t totalPoints2 = this->points; std::size_t totalPoints2 = this->points;
int i, j, k; int i, j, k;
// We will try to split the box along the "i" axis. Imagine a // We will try to split the box along the "i" axis. Imagine a
@ -197,7 +197,7 @@ namespace render {
// the number of points in both sides of the plane are // the number of points in both sides of the plane are
// approximated the same. // approximated the same.
for (i=i1; i<=i2; ++i) { for (i=i1; i<=i2; ++i) {
size_t planePoints = 0; std::size_t planePoints = 0;
// We count all points in "i" plane. // We count all points in "i" plane.
for (j=j1; j<=j2; ++j) for (j=j1; j<=j2; ++j)
@ -236,7 +236,7 @@ namespace render {
int r1, g1, b1; // Min point (closest to origin) int r1, g1, b1; // Min point (closest to origin)
int r2, g2, b2; // Max point int r2, g2, b2; // Max point
size_t points; // Number of points in the space which enclose this box std::size_t points; // Number of points in the space which enclose this box
int volume; int volume;
}; // end of class Box }; // end of class Box
@ -244,7 +244,7 @@ namespace render {
// quantization for frame buffer display,", Computer Graphics, // quantization for frame buffer display,", Computer Graphics,
// 16(3), pp. 297-307 (1982) // 16(3), pp. 297-307 (1982)
template<class Histogram> template<class Histogram>
void median_cut(const Histogram& histogram, size_t maxBoxes, std::vector<uint32_t>& result) void median_cut(const Histogram& histogram, std::size_t maxBoxes, std::vector<uint32_t>& result)
{ {
// We need a priority queue to split bigger boxes first (see Box::operator<). // We need a priority queue to split bigger boxes first (see Box::operator<).
std::priority_queue<Box<Histogram> > boxes; std::priority_queue<Box<Histogram> > boxes;

View File

@ -1,5 +1,5 @@
// Aseprite UI Library // Aseprite UI Library
// Copyright (C) 2001-2013 David Capello // Copyright (C) 2001-2013, 2015 David Capello
// //
// This file is released under the terms of the MIT license. // This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information. // Read LICENSE.txt for more information.
@ -324,7 +324,7 @@ std::string Accelerator::toString() const
"KEY_COLON2", "KEY_COLON2",
"Kanji", "Kanji",
}; };
static size_t table_size = sizeof(table) / sizeof(table[0]); static std::size_t table_size = sizeof(table) / sizeof(table[0]);
std::string buf; std::string buf;

View File

@ -1,5 +1,5 @@
// Aseprite UI Library // Aseprite UI Library
// Copyright (C) 2001-2013 David Capello // Copyright (C) 2001-2013, 2015 David Capello
// //
// This file is released under the terms of the MIT license. // This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information. // Read LICENSE.txt for more information.
@ -55,7 +55,7 @@ namespace ui {
const_iterator end() const { return m_list.end(); } const_iterator end() const { return m_list.end(); }
bool empty() const { return m_list.empty(); } bool empty() const { return m_list.empty(); }
size_t size() const { return m_list.size(); } std::size_t size() const { return m_list.size(); }
const ui::Accelerator& front() const { return m_list.front(); } const ui::Accelerator& front() const { return m_list.front(); }

View File

@ -191,7 +191,7 @@ void ComboBox::removeItem(ListItem* item)
void ComboBox::removeItem(int itemIndex) void ComboBox::removeItem(int itemIndex)
{ {
ASSERT(itemIndex >= 0 && (size_t)itemIndex < m_items.size()); ASSERT(itemIndex >= 0 && (std::size_t)itemIndex < m_items.size());
ListItem* item = m_items[itemIndex]; ListItem* item = m_items[itemIndex];
@ -215,7 +215,7 @@ int ComboBox::getItemCount() const
ListItem* ComboBox::getItem(int itemIndex) ListItem* ComboBox::getItem(int itemIndex)
{ {
if (itemIndex >= 0 && (size_t)itemIndex < m_items.size()) { if (itemIndex >= 0 && (std::size_t)itemIndex < m_items.size()) {
return m_items[itemIndex]; return m_items[itemIndex];
} }
else else
@ -224,7 +224,7 @@ ListItem* ComboBox::getItem(int itemIndex)
const std::string& ComboBox::getItemText(int itemIndex) const const std::string& ComboBox::getItemText(int itemIndex) const
{ {
if (itemIndex >= 0 && (size_t)itemIndex < m_items.size()) { if (itemIndex >= 0 && (std::size_t)itemIndex < m_items.size()) {
ListItem* item = m_items[itemIndex]; ListItem* item = m_items[itemIndex];
return item->getText(); return item->getText();
} }
@ -237,7 +237,7 @@ const std::string& ComboBox::getItemText(int itemIndex) const
void ComboBox::setItemText(int itemIndex, const std::string& text) void ComboBox::setItemText(int itemIndex, const std::string& text)
{ {
ASSERT(itemIndex >= 0 && (size_t)itemIndex < m_items.size()); ASSERT(itemIndex >= 0 && (std::size_t)itemIndex < m_items.size());
ListItem* item = m_items[itemIndex]; ListItem* item = m_items[itemIndex];
item->setText(text); item->setText(text);
@ -285,7 +285,7 @@ int ComboBox::getSelectedItemIndex() const
void ComboBox::setSelectedItemIndex(int itemIndex) void ComboBox::setSelectedItemIndex(int itemIndex)
{ {
if (itemIndex >= 0 && if (itemIndex >= 0 &&
(size_t)itemIndex < m_items.size() && (std::size_t)itemIndex < m_items.size() &&
m_selected != itemIndex) { m_selected != itemIndex) {
m_selected = itemIndex; m_selected = itemIndex;

View File

@ -1,5 +1,5 @@
// Aseprite UI Library // Aseprite UI Library
// Copyright (C) 2001-2014 David Capello // Copyright (C) 2001-2015 David Capello
// //
// This file is released under the terms of the MIT license. // This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information. // Read LICENSE.txt for more information.
@ -28,7 +28,7 @@
namespace ui { namespace ui {
Entry::Entry(size_t maxsize, const char *format, ...) Entry::Entry(std::size_t maxsize, const char *format, ...)
: Widget(kEntryWidget) : Widget(kEntryWidget)
, m_timer(500, this) , m_timer(500, this)
, m_maxsize(maxsize) , m_maxsize(maxsize)
@ -437,7 +437,7 @@ void Entry::onSetText()
{ {
Widget::onSetText(); Widget::onSetText();
if (m_caret >= 0 && (size_t)m_caret > getTextLength()) if (m_caret >= 0 && (std::size_t)m_caret > getTextLength())
m_caret = (int)getTextLength(); m_caret = (int)getTextLength();
} }
@ -508,7 +508,7 @@ void Entry::executeCmd(EntryCmd cmd, int unicodeChar, bool shift_pressed)
// put the character // put the character
if (text.size() < m_maxsize) { if (text.size() < m_maxsize) {
ASSERT((size_t)m_caret <= text.size()); ASSERT((std::size_t)m_caret <= text.size());
text.insert(m_caret++, 1, unicodeChar); text.insert(m_caret++, 1, unicodeChar);
} }

View File

@ -1,5 +1,5 @@
// Aseprite UI Library // Aseprite UI Library
// Copyright (C) 2001-2013 David Capello // Copyright (C) 2001-2013, 2015 David Capello
// //
// This file is released under the terms of the MIT license. // This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information. // Read LICENSE.txt for more information.
@ -19,7 +19,7 @@ namespace ui {
class Entry : public Widget class Entry : public Widget
{ {
public: public:
Entry(size_t maxsize, const char *format, ...); Entry(std::size_t maxsize, const char *format, ...);
~Entry(); ~Entry();
bool isPassword() const; bool isPassword() const;
@ -81,7 +81,7 @@ namespace ui {
void showEditPopupMenu(const gfx::Point& pt); void showEditPopupMenu(const gfx::Point& pt);
Timer m_timer; Timer m_timer;
size_t m_maxsize; std::size_t m_maxsize;
int m_caret; int m_caret;
int m_scroll; int m_scroll;
int m_select; int m_select;

View File

@ -255,7 +255,7 @@ gfx::Size Graphics::doUIStringAlgorithm(const std::string& str, gfx::Color fg, g
} }
gfx::Size calculatedSize(0, 0); gfx::Size calculatedSize(0, 0);
size_t beg, end, new_word_beg, old_end; std::size_t beg, end, new_word_beg, old_end;
std::string line; std::string line;
int lineSeparation = 2*guiscale(); int lineSeparation = 2*guiscale();

View File

@ -1,5 +1,5 @@
// Aseprite UI Library // Aseprite UI Library
// Copyright (C) 2001-2013 David Capello // Copyright (C) 2001-2013, 2015 David Capello
// //
// This file is released under the terms of the MIT license. // This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information. // Read LICENSE.txt for more information.
@ -44,7 +44,7 @@ Grid::Grid(int columns, bool same_width_columns)
m_same_width_columns = same_width_columns; m_same_width_columns = same_width_columns;
for (size_t col=0; col<m_colstrip.size(); ++col) { for (std::size_t col=0; col<m_colstrip.size(); ++col) {
m_colstrip[col].size = 0; m_colstrip[col].size = 0;
m_colstrip[col].expand_count = 0; m_colstrip[col].expand_count = 0;
} }
@ -55,8 +55,8 @@ Grid::Grid(int columns, bool same_width_columns)
Grid::~Grid() Grid::~Grid()
{ {
// Delete all cells. // Delete all cells.
for (size_t row=0; row<m_cells.size(); ++row) for (std::size_t row=0; row<m_cells.size(); ++row)
for (size_t col=0; col<m_cells[row].size(); ++col) for (std::size_t col=0; col<m_cells[row].size(); ++col)
delete m_cells[row][col]; delete m_cells[row][col];
} }

View File

@ -96,7 +96,7 @@ void ListBox::selectIndex(int index)
selectChild(child); selectChild(child);
} }
size_t ListBox::getItemsCount() const std::size_t ListBox::getItemsCount() const
{ {
return getChildren().size(); return getChildren().size();
} }

View File

@ -25,7 +25,7 @@ namespace ui {
void selectChild(Widget* item); void selectChild(Widget* item);
void selectIndex(int index); void selectIndex(int index);
size_t getItemsCount() const; std::size_t getItemsCount() const;
void centerScroll(); void centerScroll();
void sortItems(); void sortItems();

View File

@ -1,5 +1,5 @@
// Aseprite UI Library // Aseprite UI Library
// Copyright (C) 2001-2013 David Capello // Copyright (C) 2001-2013, 2015 David Capello
// //
// This file is released under the terms of the MIT license. // This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information. // Read LICENSE.txt for more information.
@ -32,6 +32,7 @@
#include <iostream> #include <iostream>
#endif #endif
#include <limits>
#include <list> #include <list>
#include <vector> #include <vector>
@ -1372,7 +1373,7 @@ static bool move_focus(Manager* manager, Message* msg)
} }
// Check if the new widget to put the focus is not in the wrong way. // Check if the new widget to put the focus is not in the wrong way.
if ((*cmp) (list[c], x, y) < INT_MAX) if ((*cmp) (list[c], x, y) < std::numeric_limits<int>::max())
focus = list[c]; focus = list[c];
} }
// If only there are one widget, put the focus in this // If only there are one widget, put the focus in this
@ -1439,7 +1440,7 @@ static int cmp_left(Widget* widget, int x, int y)
{ {
int z = x - (widget->getBounds().x+widget->getBounds().w/2); int z = x - (widget->getBounds().x+widget->getBounds().w/2);
if (z <= 0) if (z <= 0)
return INT_MAX; return std::numeric_limits<int>::max();
return z + ABS((widget->getBounds().y+widget->getBounds().h/2) - y) * 8; return z + ABS((widget->getBounds().y+widget->getBounds().h/2) - y) * 8;
} }
@ -1447,7 +1448,7 @@ static int cmp_right(Widget* widget, int x, int y)
{ {
int z = (widget->getBounds().x+widget->getBounds().w/2) - x; int z = (widget->getBounds().x+widget->getBounds().w/2) - x;
if (z <= 0) if (z <= 0)
return INT_MAX; return std::numeric_limits<int>::max();
return z + ABS((widget->getBounds().y+widget->getBounds().h/2) - y) * 8; return z + ABS((widget->getBounds().y+widget->getBounds().h/2) - y) * 8;
} }
@ -1455,7 +1456,7 @@ static int cmp_up(Widget* widget, int x, int y)
{ {
int z = y - (widget->getBounds().y+widget->getBounds().h/2); int z = y - (widget->getBounds().y+widget->getBounds().h/2);
if (z <= 0) if (z <= 0)
return INT_MAX; return std::numeric_limits<int>::max();
return z + ABS((widget->getBounds().x+widget->getBounds().w/2) - x) * 8; return z + ABS((widget->getBounds().x+widget->getBounds().w/2) - x) * 8;
} }
@ -1463,7 +1464,7 @@ static int cmp_down(Widget* widget, int x, int y)
{ {
int z = (widget->getBounds().y+widget->getBounds().h/2) - y; int z = (widget->getBounds().y+widget->getBounds().h/2) - y;
if (z <= 0) if (z <= 0)
return INT_MAX; return std::numeric_limits<int>::max();
return z + ABS((widget->getBounds().x+widget->getBounds().w/2) - x) * 8; return z + ABS((widget->getBounds().x+widget->getBounds().w/2) - x) * 8;
} }

View File

@ -1,5 +1,5 @@
// Aseprite UI Library // Aseprite UI Library
// Copyright (C) 2001-2014 David Capello // Copyright (C) 2001-2015 David Capello
// //
// This file is released under the terms of the MIT license. // This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information. // Read LICENSE.txt for more information.
@ -35,7 +35,7 @@ void move_region(const Region& region, int dx, int dy)
return; return;
she::ScopedSurfaceLock lock(display->getSurface()); she::ScopedSurfaceLock lock(display->getSurface());
size_t nrects = region.size(); std::size_t nrects = region.size();
// Blit directly screen to screen. // Blit directly screen to screen.
if (nrects == 1) { if (nrects == 1) {

View File

@ -1,5 +1,5 @@
// Aseprite UI Library // Aseprite UI Library
// Copyright (C) 2001-2013 David Capello // Copyright (C) 2001-2013, 2015 David Capello
// //
// This file is released under the terms of the MIT license. // This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information. // Read LICENSE.txt for more information.
@ -19,6 +19,8 @@
#include "ui/view.h" #include "ui/view.h"
#include "ui/widget.h" #include "ui/widget.h"
#include <cstring>
namespace ui { namespace ui {
static Theme* current_theme = NULL; static Theme* current_theme = NULL;
@ -142,7 +144,7 @@ void drawTextBox(Graphics* g, Widget* widget,
// Without word-wrap // Without word-wrap
if (!(widget->getAlign() & JI_WORDWRAP)) { if (!(widget->getAlign() & JI_WORDWRAP)) {
end = strchr(beg, '\n'); end = std::strchr(beg, '\n');
if (end) { if (end) {
chr = *end; chr = *end;
*end = 0; *end = 0;
@ -152,7 +154,7 @@ void drawTextBox(Graphics* g, Widget* widget,
else { else {
old_end = NULL; old_end = NULL;
for (beg_end=beg;;) { for (beg_end=beg;;) {
end = strpbrk(beg_end, " \n"); end = std::strpbrk(beg_end, " \n");
if (end) { if (end) {
chr = *end; chr = *end;
*end = 0; *end = 0;

View File

@ -917,7 +917,7 @@ void Widget::flushRedraw()
widget->m_updateRegion.createIntersection(widget->m_updateRegion, region); widget->m_updateRegion.createIntersection(widget->m_updateRegion, region);
} }
size_t c, nrects = widget->m_updateRegion.size(); std::size_t c, nrects = widget->m_updateRegion.size();
Region::const_iterator it = widget->m_updateRegion.begin(); Region::const_iterator it = widget->m_updateRegion.begin();
// Draw the widget // Draw the widget

View File

@ -88,7 +88,7 @@ namespace ui {
const std::string& getText() const { return m_text; } const std::string& getText() const { return m_text; }
int getTextInt() const; int getTextInt() const;
double getTextDouble() const; double getTextDouble() const;
size_t getTextLength() const { return m_text.size(); } std::size_t getTextLength() const { return m_text.size(); }
void setText(const std::string& text); void setText(const std::string& text);
void setTextf(const char* text, ...); void setTextf(const char* text, ...);
void setTextQuiet(const std::string& text); void setTextQuiet(const std::string& text);