Skip to content

Commit

Permalink
better text
Browse files Browse the repository at this point in the history
  • Loading branch information
C4Phone committed Dec 10, 2015
1 parent bed4f3f commit e8b18a1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
9 changes: 2 additions & 7 deletions mp3/student-distrib/inc/ui/compositor.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,20 +96,15 @@ class Compositor : public KeyB::IEvent {
void drawSingle(const Container *d, const Rectangle &rect);
void drawSingle(const Container *d, const Rectangle &rect, const Rectangle &difference);

void addText(int txtX, int txtY, char c);
Drawable* addText(int txtX, int txtY, char c);

Container *getElementAtPosition(int absX, int absY);

// Unit: text font width
int32_t txtX = 0;

public:
virtual void key(uint32_t kkc, bool capslock)
{
if(kkc &(~KKC_ASCII_MASK))
return;
addText(txtX++, 0, (char)kkc);
}
virtual void key(uint32_t kkc, bool capslock);

// Down and Up cuts changes to ONE single key at a time.
virtual void keyDown(uint32_t kkc, bool capslock)
Expand Down
19 changes: 18 additions & 1 deletion mp3/student-distrib/ui/compositor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ static uint8_t *renderRGBAFont(ArrFile &parser, int width, int height, char c)
}


void Compositor::addText(int txtX, int txtY, char c)
Drawable* Compositor::addText(int txtX, int txtY, char c)
{
constexpr int NumFont = 94;
constexpr int FontWidth = 20;
Expand All @@ -246,6 +246,8 @@ void Compositor::addText(int txtX, int txtY, char c)
theDispatcher->close(fontFile);
rootContainer->addChild(draw);
draw->show();

return draw;
}

void Compositor::drawNikita()
Expand Down Expand Up @@ -288,6 +290,21 @@ void Compositor::enterTextMode()
});
}

void Compositor::key(uint32_t kkc, bool capslock)
{
if(kkc &(~KKC_ASCII_MASK))
return;
static Drawable* all[10] = {0};
all[txtX] = addText(txtX++, 0, (char)kkc);
if(txtX >= 10)
{
txtX = 0;
for(int i=0; i<10; i++)
(all[i])->hide();
}

}


// SYSCALLS

Expand Down

0 comments on commit e8b18a1

Please sign in to comment.