Skip to content

Commit

Permalink
Tilem: Move to namespace tilem
Browse files Browse the repository at this point in the history
  • Loading branch information
timower committed Oct 18, 2023
1 parent 739345e commit 73437f4
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 4 deletions.
3 changes: 3 additions & 0 deletions apps/tilem/Calculator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

using namespace rmlib;

namespace tilem {

namespace {

constexpr auto calc_save_extension = ".sav";
Expand Down Expand Up @@ -123,3 +125,4 @@ CalcState::updateCalcState() {

lastUpdateTime = time;
}
} // namespace tilem
2 changes: 2 additions & 0 deletions apps/tilem/Calculator.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <tilem.h>

namespace tilem {
class CalcState;

class Calculator : public rmlib::StatefulWidget<Calculator> {
Expand Down Expand Up @@ -76,3 +77,4 @@ class CalcState : public rmlib::StateBase<Calculator> {

std::chrono::steady_clock::time_point lastUpdateTime;
};
} // namespace tilem
10 changes: 8 additions & 2 deletions apps/tilem/KeyPad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using namespace rmlib;
using namespace rmlib::input;

namespace tilem {
struct Key {
int scancode;
std::string_view front;
Expand Down Expand Up @@ -138,8 +139,12 @@ KeypadRenderObject::drawKey(rmlib::Canvas& canvas,
}

// Draw alpha and 2nd label.
{
[&] {
const auto upperLength = key.alpha.size() + key.shift.size();
if (upperLength == 0) {
return;
}

const auto fontSize =
std::min(upperLabelHeight, int(1.6 * keyWidth / upperLength));

Expand All @@ -163,7 +168,7 @@ KeypadRenderObject::drawKey(rmlib::Canvas& canvas,
const auto positonA = pos + Point{ xOffset + spacing.x, yOffset };
canvas.drawText(key.alpha, positonA, fontSize, 0xaa);
}
}
}();

canvas.drawRectangle(pos, pos + Point{ keyWidth - 1, keyHeight - 1 }, black);
}
Expand Down Expand Up @@ -239,3 +244,4 @@ KeypadRenderObject::handleInput(const Event& ev) {
},
ev);
}
} // namespace tilem
3 changes: 3 additions & 0 deletions apps/tilem/KeyPad.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

#include "tilem.h"

namespace tilem {

struct Key;
class KeypadRenderObject;

Expand Down Expand Up @@ -49,3 +51,4 @@ class KeypadRenderObject : public rmlib::LeafRenderObject<Keypad> {
int keyHeight;
int padding;
};
} // namespace tilem
2 changes: 2 additions & 0 deletions apps/tilem/Screen.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "Screen.h"

using namespace rmlib;
namespace tilem {

namespace {
constexpr auto frame_time = std::chrono::milliseconds(50); // 50 ms -> 20 fps
Expand Down Expand Up @@ -112,3 +113,4 @@ std::unique_ptr<RenderObject>
Screen::createRenderObject() const {
return std::make_unique<ScreenRenderObject>(*this);
}
} // namespace tilem
4 changes: 4 additions & 0 deletions apps/tilem/Screen.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include <tilem.h>

namespace tilem {

class ScreenRenderObject;

class Screen : public rmlib::Widget<ScreenRenderObject> {
Expand Down Expand Up @@ -38,3 +40,5 @@ class ScreenRenderObject : public rmlib::LeafRenderObject<Screen> {
TilemLCDBuffer* oldLcd = nullptr;
int timerID = -1;
};

} // namespace tilem
2 changes: 1 addition & 1 deletion apps/tilem/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ int
main(int argc, char* argv[]) {
const auto* calc_name = argc > 1 ? argv[1] : calc_default_rom;

const auto err = runApp(Navigator(Calculator(calc_name)));
const auto err = runApp(Navigator(tilem::Calculator(calc_name)));

if (!err.has_value()) {
std::cerr << err.error().msg << std::endl;
Expand Down
3 changes: 2 additions & 1 deletion test/unit/TestTilem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <cstdlib>

using namespace rmlib;
using namespace tilem;

class TemporaryDirectory {
public:
Expand Down Expand Up @@ -47,7 +48,7 @@ TEST_CASE("Tilem", "[tilem][ui]") {
REQUIRE(ctx.shouldStop());
}

SECTION("Download & Run") {
SECTION("Download") {

ctx.tap(ctx.findByText("Download"));

Expand Down

0 comments on commit 73437f4

Please sign in to comment.