mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
3DFileViewer: Allow zooming via mouse wheel
This commit is contained in:
parent
3c509cf2f7
commit
e405f436b6
Notes:
sideshowbarker
2024-07-18 07:04:39 +09:00
Author: https://github.com/sunverwerth Commit: https://github.com/SerenityOS/serenity/commit/e405f436b69 Pull-request: https://github.com/SerenityOS/serenity/pull/9363
1 changed files with 11 additions and 0 deletions
|
@ -82,6 +82,7 @@ private:
|
|||
virtual void paint_event(GUI::PaintEvent&) override;
|
||||
virtual void timer_event(Core::TimerEvent&) override;
|
||||
virtual void mousemove_event(GUI::MouseEvent&) override;
|
||||
virtual void mousewheel_event(GUI::MouseEvent&) override;
|
||||
|
||||
private:
|
||||
RefPtr<Mesh> m_mesh;
|
||||
|
@ -105,6 +106,7 @@ private:
|
|||
GLint m_wrap_t_mode = GL_REPEAT;
|
||||
float m_texture_scale = 1.0f;
|
||||
GLint m_mag_filter = GL_NEAREST;
|
||||
float m_zoom = 1;
|
||||
};
|
||||
|
||||
void GLContextWidget::paint_event(GUI::PaintEvent& event)
|
||||
|
@ -129,6 +131,14 @@ void GLContextWidget::mousemove_event(GUI::MouseEvent& event)
|
|||
m_last_mouse = event.position();
|
||||
}
|
||||
|
||||
void GLContextWidget::mousewheel_event(GUI::MouseEvent& event)
|
||||
{
|
||||
if (event.wheel_delta() > 0)
|
||||
m_zoom /= 1.1f;
|
||||
else
|
||||
m_zoom *= 1.1f;
|
||||
}
|
||||
|
||||
void GLContextWidget::timer_event(Core::TimerEvent&)
|
||||
{
|
||||
Core::ElapsedTimer timer;
|
||||
|
@ -152,6 +162,7 @@ void GLContextWidget::timer_event(Core::TimerEvent&)
|
|||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, m_wrap_s_mode);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, m_wrap_t_mode);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, m_mag_filter);
|
||||
glScalef(m_zoom, m_zoom, m_zoom);
|
||||
|
||||
if (!m_mesh.is_null())
|
||||
m_mesh->draw(m_texture_scale);
|
||||
|
|
Loading…
Reference in a new issue