Skip to content

Commit

Permalink
rename namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
igagis committed Jan 21, 2024
1 parent 9e6f94b commit 2aeb413
Show file tree
Hide file tree
Showing 13 changed files with 1,464 additions and 1,464 deletions.
18 changes: 9 additions & 9 deletions examples/basic/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,32 @@
#include <ruis/widgets/button/Button.hpp>


class Application : public mordavokne::application{
class Application : public ruisapp::application{
public:
Application() :
mordavokne::App(mordavokne::window_params(r4::vector2<unsigned>(800, 600)))
ruisapp::App(ruisapp::window_params(r4::vector2<unsigned>(800, 600)))
{
morda::Morda::inst().init_standard_widgets(*this->get_res_file());
ruis::Morda::inst().init_standard_widgets(*this->get_res_file());

//Inflate widgets hierarchy from GUI description script
auto c = morda::Morda::inst().inflater.inflate(
auto c = ruis::Morda::inst().inflater.inflate(
*this->get_res_file("res/main.gui")
);

//set the widgets hierarchy to the application
morda::Morda::inst().setRootWidget(c);
ruis::Morda::inst().setRootWidget(c);

auto textLabel = c->findChildByNameAs<morda::TextLabel>("info_text");
auto textLabel = c->findChildByNameAs<ruis::TextLabel>("info_text");
ASSERT(textLabel)

auto button = c->findChildByNameAs<morda::PushButton>("hw_button");
auto button = c->findChildByNameAs<ruis::PushButton>("hw_button");

auto textLabelWeak = utki::make_weak(textLabel);//make a weak pointer to the TextLabel widget.

bool even = true;

//connect some action on button click
button->clicked = [textLabelWeak, even](morda::PushButton&) mutable {
button->clicked = [textLabelWeak, even](ruis::PushButton&) mutable {
if(auto tl = textLabelWeak.lock()){
even = !even;
if(even){
Expand All @@ -44,7 +44,7 @@ class Application : public mordavokne::application{



std::unique_ptr<mordavokne::application> mordavokne::create_application(int argc, const char** argv, const utki::Buf<uint8_t> savedState){
std::unique_ptr<ruisapp::application> ruisapp::create_application(int argc, const char** argv, const utki::Buf<uint8_t> savedState){
return utki::makeUnique<Application>();
}

18 changes: 9 additions & 9 deletions src/ruisapp/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <utki/config.hpp>
#include <utki/debug.hpp>

using namespace mordavokne;
using namespace ruisapp;

// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
application::instance_type application::instance;
Expand All @@ -41,7 +41,7 @@ void application::render()
this->swap_frame_buffers();
}

void application::update_window_rect(const morda::rectangle& rect)
void application::update_window_rect(const ruis::rectangle& rect)
{
if (this->curWinRect == rect) {
return;
Expand Down Expand Up @@ -84,7 +84,7 @@ void application::hide_virtual_keyboard() noexcept {
}
#endif

morda::real application::get_pixels_per_pp(r4::vector2<unsigned> resolution, r4::vector2<unsigned> screen_size_mm)
ruis::real application::get_pixels_per_pp(r4::vector2<unsigned> resolution, r4::vector2<unsigned> screen_size_mm)
{
utki::log([&](auto& o) {
o << "screen resolution = " << resolution << std::endl;
Expand All @@ -99,7 +99,7 @@ morda::real application::get_pixels_per_pp(r4::vector2<unsigned> resolution, r4:
// physical screen size and pixel resolution.

#if M_OS_NAME == M_OS_NAME_IOS
return morda::real(1); // TODO:
return ruis::real(1); // TODO:
#else
unsigned x_index = [&resolution]() {
if (resolution.x() > resolution.y()) {
Expand All @@ -113,19 +113,19 @@ morda::real application::get_pixels_per_pp(r4::vector2<unsigned> resolution, r4:
// unsigned max_dim_px = max(resolution.x(), resolution.y());
// unsigned max_dim_mm = max(screen_size_mm.x(), screen_size_mm.y());

// morda::real dpmm = morda::real(max_dim_px) / morda::real(max_dim_mm);
// ruis::real dpmm = ruis::real(max_dim_px) / ruis::real(max_dim_mm);

if (screen_size_mm[x_index] < 300) { // NOLINT(cppcoreguidelines-avoid-magic-numbers)
return morda::real(resolution[x_index]) / morda::real(700); // NOLINT(cppcoreguidelines-avoid-magic-numbers)
return ruis::real(resolution[x_index]) / ruis::real(700); // NOLINT(cppcoreguidelines-avoid-magic-numbers)
} else if (screen_size_mm[x_index] < 150) { // NOLINT(cppcoreguidelines-avoid-magic-numbers)
return morda::real(resolution[x_index]) / morda::real(200); // NOLINT(cppcoreguidelines-avoid-magic-numbers)
return ruis::real(resolution[x_index]) / ruis::real(200); // NOLINT(cppcoreguidelines-avoid-magic-numbers)
}

return morda::real(1);
return ruis::real(1);
#endif
}

void application::handle_key_event(bool is_down, morda::key key_code)
void application::handle_key_event(bool is_down, ruis::key key_code)
{
this->gui.send_key(is_down, key_code);
}
Expand Down
30 changes: 15 additions & 15 deletions src/ruisapp/application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.

#include "config.hpp"

namespace mordavokne {
namespace ruisapp {

/**
* @brief Desired window parameters.
Expand Down Expand Up @@ -119,7 +119,7 @@ class application : public utki::intrusive_singleton<application>
void swap_frame_buffers();

public:
morda::gui gui;
ruis::gui gui;

public:
/**
Expand All @@ -144,10 +144,10 @@ class application : public utki::intrusive_singleton<application>
private:
// this is a viewport rectangle in coordinates that are as follows: x grows
// right, y grows up.
morda::rectangle curWinRect = morda::rectangle(0, 0, 0, 0);
ruis::rectangle curWinRect = ruis::rectangle(0, 0, 0, 0);

public:
const morda::vector2& window_dims() const noexcept
const ruis::vector2& window_dims() const noexcept
{
return this->curWinRect.d;
}
Expand All @@ -157,9 +157,9 @@ class application : public utki::intrusive_singleton<application>

friend void render(application& app);

void update_window_rect(const morda::rectangle& rect);
void update_window_rect(const ruis::rectangle& rect);

friend void update_window_rect(application& app, const morda::rectangle& rect);
friend void update_window_rect(application& app, const ruis::rectangle& rect);

// pos is in usual window coordinates, y goes down.
void handle_mouse_move(const r4::vector2<float>& pos, unsigned id)
Expand All @@ -170,7 +170,7 @@ class application : public utki::intrusive_singleton<application>
friend void handle_mouse_move(application& app, const r4::vector2<float>& pos, unsigned id);

// pos is in usual window coordinates, y goes down.
void handle_mouse_button(bool is_down, const r4::vector2<float>& pos, morda::mouse_button button, unsigned id)
void handle_mouse_button(bool is_down, const r4::vector2<float>& pos, ruis::mouse_button button, unsigned id)
{
this->gui.send_mouse_button(is_down, pos, button, id);
}
Expand All @@ -179,7 +179,7 @@ class application : public utki::intrusive_singleton<application>
application& app,
bool is_down,
const r4::vector2<float>& pos,
morda::mouse_button button,
ruis::mouse_button button,
unsigned id
);

Expand Down Expand Up @@ -225,20 +225,20 @@ class application : public utki::intrusive_singleton<application>
// The idea with unicode_resolver parameter is that we don't want to calculate
// the unicode unless it is really needed, thus postpone it as much as
// possible.
void handle_character_input(const morda::gui::input_string_provider& string_provider, morda::key key_code)
void handle_character_input(const ruis::gui::input_string_provider& string_provider, ruis::key key_code)
{
this->gui.send_character_input(string_provider, key_code);
}

friend void handle_character_input(
application& app,
const morda::gui::input_string_provider& string_provider,
morda::key key_code
const ruis::gui::input_string_provider& string_provider,
ruis::key key_code
);

void handle_key_event(bool is_down, morda::key key_code);
void handle_key_event(bool is_down, ruis::key key_code);

friend void handle_key_event(application& app, bool is_down, morda::key key_code);
friend void handle_key_event(application& app, bool is_down, ruis::key key_code);

public:
/**
Expand Down Expand Up @@ -287,7 +287,7 @@ class application : public utki::intrusive_singleton<application>
* @param screen_size_mm - size of the display in millimeters.
* @return Size of one display density pixel in pixels.
*/
static morda::real get_pixels_per_pp(
static ruis::real get_pixels_per_pp(
r4::vector2<unsigned> screen_size_pixels,
r4::vector2<unsigned> screen_size_mm
);
Expand Down Expand Up @@ -324,4 +324,4 @@ class application_factory
static factory_type& get_factory_internal();
};

} // namespace mordavokne
} // namespace ruisapp
Loading

0 comments on commit 2aeb413

Please sign in to comment.