[kandinsky] Get rid of KDText

This commit is contained in:
Romain Goyet
2018-10-09 16:57:24 +02:00
committed by LeaNumworks
parent f8beae3b86
commit c183f0147e
6 changed files with 3 additions and 49 deletions

View File

@@ -4,7 +4,7 @@
#include <apps/i18n.h>
#include <escher.h>
#include <ion/events.h>
#include <kandinsky/text.h>
#include <kandinsky/font.h>
namespace Code {

View File

@@ -1,7 +1,7 @@
#include "graph_controller.h"
#include "../shared/poincare_helpers.h"
#include "../apps_container.h"
#include <kandinsky/text.h>
#include <kandinsky/font.h>
#include <cmath>
using namespace Poincare;

View File

@@ -14,7 +14,6 @@ objs += $(addprefix kandinsky/src/,\
ion_context.o\
point.o\
rect.o\
text.o\
)
objs += kandinsky/src/external/lz4/lz4.o

View File

@@ -1,21 +0,0 @@
#ifndef KANDINSKY_TEXT_H
#define KANDINSKY_TEXT_H
#include <kandinsky/size.h>
#include "../src/large_font.h"
#include "../src/small_font.h"
class KDText {
public:
enum class FontSize {
Small,
Large
};
constexpr static int k_tabCharacterWidth = 4;
static KDSize stringSize(const char * text, FontSize size = FontSize::Large);
constexpr static KDSize charSize(FontSize size = FontSize::Large) {
return size == FontSize::Large ? KDSize(BITMAP_LargeFont_CHARACTER_WIDTH, BITMAP_LargeFont_CHARACTER_HEIGHT) : KDSize(BITMAP_SmallFont_CHARACTER_WIDTH, BITMAP_SmallFont_CHARACTER_HEIGHT);
}
};
#endif

View File

@@ -1,24 +0,0 @@
#include <kandinsky/text.h>
#include <string.h>
#include "small_font.h"
#include "large_font.h"
KDSize KDText::stringSize(const char * text, FontSize size) {
if (text == nullptr) {
return KDSizeZero;
}
KDSize commonCharSize = charSize(size);
KDSize stringSize = KDSize(0, commonCharSize.height());
while (*text != 0) {
KDSize cSize = KDSize(commonCharSize.width(), 0);
if (*text == '\t') {
cSize = KDSize(k_tabCharacterWidth*commonCharSize.width(), 0);
}
if (*text == '\n') {
cSize = KDSize(0, commonCharSize.height());
}
stringSize = KDSize(stringSize.width()+cSize.width(), stringSize.height()+cSize.height());
text++;
}
return stringSize;
}

View File

@@ -3,7 +3,7 @@
#include <poincare/layout_cursor.h>
#include <poincare/layout.h>
#include <kandinsky/text.h>
#include <kandinsky/font.h>
namespace Poincare {