Skip to content

Commit

Permalink
exit by esc key
Browse files Browse the repository at this point in the history
  • Loading branch information
igagis committed Apr 17, 2024
1 parent 61c9c73 commit 99658f6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/gauge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ void gauge::render(const matrix4& matrix) const
matrix4 mmm;
mmm.set_identity();
mmm.rotate(
-(this->params.start_angle_rad + (this->params.end_angle_rad - this->params.start_angle_rad) * this->get_fraction())
-(this->params.start_angle_rad +
(this->params.end_angle_rad - this->params.start_angle_rad) * this->get_fraction())
);
{
auto div = this->arrow_tex->dims.x() * this->params.arm_fraction;
Expand Down
6 changes: 2 additions & 4 deletions src/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,12 @@ using namespace ruis::make;
using namespace carcockpit::make;
} // namespace m

utki::shared_ref<ruis::widget> carcockpit::make_root_widgets(utki::shared_ref<ruis::context> c)
utki::shared_ref<ruis::key_proxy> carcockpit::make_root_widgets(utki::shared_ref<ruis::context> c)
{
using ruis::lp;

// clang-format off
auto w = m::container(
c,
auto w = m::key_proxy(c,
{
.container_params = {
.layout = ruis::layout::column
Expand Down Expand Up @@ -139,7 +138,6 @@ utki::shared_ref<ruis::widget> carcockpit::make_root_widgets(utki::shared_ref<ru
)
}
)

}
);
// clang-format on
Expand Down
4 changes: 2 additions & 2 deletions src/gui.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.

#pragma once

#include <ruis/widgets/widget.hpp>
#include <ruis/widgets/proxy/key_proxy.hpp>

namespace carcockpit {

utki::shared_ref<ruis::widget> make_root_widgets(utki::shared_ref<ruis::context> c);
utki::shared_ref<ruis::key_proxy> make_root_widgets(utki::shared_ref<ruis::context> c);

} // namespace carcockpit
12 changes: 11 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,17 @@ class application : public ruisapp::application

this->gui.context.get().loader.mount_res_pack(*this->get_res_file(papki::as_dir(res_path)));

this->gui.set_root(make_root_widgets(this->gui.context));
auto kp = make_root_widgets(this->gui.context);
kp.get().key_handler = [this](ruis::key_proxy&, const ruis::key_event& e) {
if (e.is_down) {
if (e.combo.key == ruis::key::escape) {
this->quit();
}
}
return false;
};

this->gui.set_root(std::move(kp));
}
};

Expand Down

0 comments on commit 99658f6

Please sign in to comment.