Welcome to mirror list, hosted at ThFree Co, Russian Federation.

generator.hpp « skin_generator - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 399c1619f4d6d57669ca932257804da9bdcc2dfa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#pragma once

#include "geometry/rect2d.hpp"
#include "geometry/packer.hpp"

#include "coding/writer.hpp"

#include "base/base.hpp"

#include <QtGui/QPainter>
#include <QtGui/QImage>
#include <QtCore/QFileInfo>
#include <QtCore/QSize>
#include <QtSvg/QSvgRenderer>
#include <QtXml/QXmlContentHandler>
#include <QtXml/QXmlDefaultHandler>

#include <cstdint>
#include <map>
#include <string>
#include <vector>

class QImage;

namespace tools
{
class SkinGenerator
{
public:
  struct SymbolInfo
  {
    QSize m_size;
    QString m_fullFileName;
    QString m_symbolID;

    m2::Packer::handle_t m_handle;

    SymbolInfo() {}
    SymbolInfo(QSize size, QString const & fullFileName, QString const & symbolID)
      : m_size(size), m_fullFileName(fullFileName), m_symbolID(symbolID)
    {}
  };

  using TSymbols = std::vector<SymbolInfo>;

  struct SkinPageInfo
  {
    TSymbols m_symbols;
    uint32_t m_width = 0;
    uint32_t m_height = 0;
    std::string m_fileName;
    std::string m_dir;
    std::string m_suffix;
    m2::Packer m_packer;
  };

  explicit SkinGenerator(bool needColorCorrection);

  void ProcessSymbols(std::string const & symbolsDir, std::string const & skinName,
                      std::vector<QSize> const & symbolSizes,
                      std::vector<std::string> const & suffix);
  bool RenderPages(uint32_t maxSize);
  bool WriteToFileNewStyle(std::string const & skinName);

private:
  bool m_needColorCorrection;
  QSvgRenderer m_svgRenderer;
  using TSkinPages = std::vector<SkinPageInfo>;
  TSkinPages m_pages;
  bool m_overflowDetected;

  void MarkOverflow();
};
}  // namespace tools