diff --git a/src/doc/CMakeLists.txt b/src/doc/CMakeLists.txt index fb831e96f..847e4170f 100644 --- a/src/doc/CMakeLists.txt +++ b/src/doc/CMakeLists.txt @@ -44,6 +44,7 @@ add_library(doc-lib layer.cpp layer_index.cpp layer_io.cpp + layer_list.cpp mask.cpp mask_boundaries.cpp mask_io.cpp diff --git a/src/doc/layer_list.cpp b/src/doc/layer_list.cpp new file mode 100644 index 000000000..9a1b199dd --- /dev/null +++ b/src/doc/layer_list.cpp @@ -0,0 +1,27 @@ +// Aseprite Document Library +// Copyright (c) 2016 David Capello +// +// This file is released under the terms of the MIT license. +// Read LICENSE.txt for more information. + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "doc/layer.h" +#include "doc/layer_list.h" + +#include + +namespace doc { + +layer_t find_layer_index(const LayerList& layers, const Layer* layer) +{ + auto it = std::find(layers.begin(), layers.end(), layer); + if (it != layers.end()) + return it - layers.begin(); + else + return 0; +} + +} // namespace doc diff --git a/src/doc/layer_list.h b/src/doc/layer_list.h index 0c9248fb5..4e3da2a6f 100644 --- a/src/doc/layer_list.h +++ b/src/doc/layer_list.h @@ -17,6 +17,8 @@ namespace doc { typedef std::vector LayerList; typedef int layer_t; + layer_t find_layer_index(const LayerList& layers, const Layer* layer); + } // namespace doc #endif // DOC_LAYER_LIST_H_INCLUDED