final commit for today - still searching to get the mouse_button
This commit is contained in:
parent
f840d51f4f
commit
fdf7714d11
6 changed files with 55 additions and 16 deletions
|
@ -12,6 +12,7 @@ public:
|
|||
static input& get();
|
||||
|
||||
point mouse_position() const { return _mouse_position; }
|
||||
int mouse_button() const { return _mouse_button; }
|
||||
|
||||
~input() = default;
|
||||
|
||||
|
@ -24,6 +25,7 @@ protected:
|
|||
private:
|
||||
|
||||
point _mouse_position;
|
||||
int _mouse_button;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <pw/core/globals.hpp>
|
||||
#include <pw/core/size.hpp>
|
||||
#include <pw/core/point.hpp>
|
||||
|
||||
namespace pw {
|
||||
|
||||
|
@ -19,6 +20,9 @@ public:
|
|||
void set_size(const size& s);
|
||||
size size() const;
|
||||
|
||||
void set_position(const point& p);
|
||||
point position() const;
|
||||
|
||||
typedef void drop_callback;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -6,11 +6,14 @@
|
|||
#include "pw/visual/context.hpp"
|
||||
#include "pw/system/input.hpp"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace pw {
|
||||
|
||||
struct window_context : context {
|
||||
struct window_context : context
|
||||
{
|
||||
virtual bool make_current() override;
|
||||
virtual void resize() override;
|
||||
// virtual context::size size() override;
|
||||
|
@ -36,8 +39,10 @@ struct window::impl {
|
|||
// window_context _context;
|
||||
|
||||
static void drop_callback(GLFWwindow* window, int count, const char** paths)
|
||||
{
|
||||
std::cout << __FUNCTION__ << std::endl;
|
||||
{
|
||||
// std::cout << __FUNCTION__ << std::endl;
|
||||
// for (int i = 0; i < count; i++)
|
||||
// std::cout << "\t" << paths[i] << std::endl;
|
||||
}
|
||||
|
||||
static void scroll_callback(GLFWwindow* window, double xoffset, double yoffset)
|
||||
|
@ -47,7 +52,9 @@ struct window::impl {
|
|||
|
||||
static void mouse_button_callback(GLFWwindow* window, int button, int action, int mods)
|
||||
{
|
||||
std::cout << __FUNCTION__ << std::endl;
|
||||
input::get()._mouse_button = button;
|
||||
|
||||
std::cout << __FUNCTION__ << " " << button << " " << action << " " << mods << std::endl;
|
||||
// input::get()._mouse_position
|
||||
}
|
||||
|
||||
|
@ -147,15 +154,24 @@ struct window::impl {
|
|||
glfwSetWindowSize(_window,w,h);
|
||||
}
|
||||
|
||||
::pw::size size() const {
|
||||
|
||||
::pw::size size() const
|
||||
{
|
||||
int w,h;
|
||||
glfwGetWindowSize(_window,&w,&h);
|
||||
|
||||
return ::pw::size(w,h);
|
||||
}
|
||||
|
||||
::pw::point position() const
|
||||
{
|
||||
int x,y;
|
||||
glfwGetWindowPos(_window,&x,&y);
|
||||
return ::pw::point(x,y);
|
||||
}
|
||||
|
||||
void set_position(int x,int y)
|
||||
{
|
||||
glfwSetWindowPos(_window,x,y);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
@ -180,12 +196,22 @@ void window::set_title(const std::string& title)
|
|||
|
||||
void window::set_size(const ::pw::size& s)
|
||||
{
|
||||
_impl->set_size(s.width,s.height);
|
||||
_impl->set_size(static_cast<int>(std::round(s.width)),static_cast<int>(std::round(s.height)));
|
||||
}
|
||||
|
||||
size window::size() const
|
||||
{
|
||||
return _impl->size();
|
||||
return _impl->size();
|
||||
}
|
||||
|
||||
void window::set_position(const point &p)
|
||||
{
|
||||
_impl->set_position(p.x,p.y);
|
||||
}
|
||||
|
||||
point window::position() const
|
||||
{
|
||||
return _impl->position();
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue