Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
2983bea
Added searching for xcb dependency and set up of compiling the approp…
robertosfield Nov 24, 2018
b8ea517
Removed unneccessary setting of cmke module path.
robertosfield Nov 24, 2018
a84b820
Set the USE_GLFW to default to OFF.
robertosfield Nov 24, 2018
b5ff59f
Merge branch 'master' into Xcb_Window
robertosfield Nov 25, 2018
8b75f08
Experiments with Xcb window creation and basic event handling
robertosfield Nov 27, 2018
da89cff
Added an experimental KeyboardMap class for mapping raw keycodes to k…
robertosfield Nov 28, 2018
e4c14b5
Added initial UI Event classes
robertosfield Nov 29, 2018
dc95c5b
Added test for mapping XCB timestamps to a std::chrono clock time.
robertosfield Nov 29, 2018
107c55c
Added setting of the the initial serve xcb_timestamp and start point.
robertosfield Nov 29, 2018
f1fa1a9
Removed the no longer neccessary links to X11
robertosfield Nov 29, 2018
45e7079
Moved the window creation into Xcb_Window constructor
robertosfield Nov 30, 2018
5b34595
Changed the Window::pollEvents() method to Window::pollEvents(Events&…
robertosfield Nov 30, 2018
7c9e82e
Added vsg::ExposeWindowEvent and vsg::DeleteWindowEvent classes
robertosfield Nov 30, 2018
683a5be
Added MoveEvent and XCB mouse event handling.
robertosfield Nov 30, 2018
6b7deed
Moved the PrintEvents visitor into Viewer::pollEvents() to facilitate…
robertosfield Nov 30, 2018
ff83c95
First cut of VCB Vulkan Window+Surface creation
robertosfield Nov 30, 2018
7cba615
Implemented handling of window resizing
robertosfield Nov 30, 2018
fef3aaf
Added XCB_CONFIGURE_NOTIFY case to see how values and frequence compa…
robertosfield Nov 30, 2018
b8671d2
Merge branch 'master' into Xcb_Window
vsg-dev Nov 30, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,23 @@ endif()
set(VSG_WARNING_FLAGS ${VSG_WARNING_FLAGS} CACHE STRING "Compiler flags to use." FORCE)
add_compile_options(${VSG_WARNING_FLAGS})

find_package(glfw3)
find_package(Vulkan)

if (ANDROID)
# TODO
elseif (WIN32)
# just use native windowing
elseif (APPLE)
find_package(glfw3)
else()
find_package(glfw3)

find_package(PkgConfig)
pkg_check_modules(xcb REQUIRED IMPORTED_TARGET xcb)
option(USE_GLFW "Use GLFW for Windowing" OFF)
endif()



# create doxygen build target
find_package(Doxygen QUIET)
Expand Down
8 changes: 8 additions & 0 deletions include/vsg/core/ConstVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,16 @@ namespace vsg

// forward declare ui events classes
class UIEvent;
class WindowEvent;
class ExposeWindowEvent;
class DeleteWindowEvent;
class KeyEvent;
class KeyPressEvent;
class KeyReleaseEvent;
class PointerEvent;
class ButtonPressEvent;
class ButtonReleaseEvent;
class MoveEvent;

class VSG_DECLSPEC ConstVisitor : public Object
{
Expand Down Expand Up @@ -120,12 +124,16 @@ namespace vsg

// ui events
virtual void apply(const UIEvent&);
virtual void apply(const WindowEvent&);
virtual void apply(const ExposeWindowEvent&);
virtual void apply(const DeleteWindowEvent&);
virtual void apply(const KeyEvent&);
virtual void apply(const KeyPressEvent&);
virtual void apply(const KeyReleaseEvent&);
virtual void apply(const PointerEvent&);
virtual void apply(const ButtonPressEvent&);
virtual void apply(const ButtonReleaseEvent&);
virtual void apply(const MoveEvent&);
};

// provide Value<>::accept() implementation
Expand Down
8 changes: 8 additions & 0 deletions include/vsg/core/Visitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,16 @@ namespace vsg

// forward declare ui events classes
class UIEvent;
class WindowEvent;
class ExposeWindowEvent;
class DeleteWindowEvent;
class KeyEvent;
class KeyPressEvent;
class KeyReleaseEvent;
class PointerEvent;
class ButtonPressEvent;
class ButtonReleaseEvent;
class MoveEvent;

class VSG_DECLSPEC Visitor : public Object
{
Expand Down Expand Up @@ -120,12 +124,16 @@ namespace vsg

// ui events
virtual void apply(UIEvent&);
virtual void apply(WindowEvent&);
virtual void apply(ExposeWindowEvent&);
virtual void apply(DeleteWindowEvent&);
virtual void apply(KeyEvent&);
virtual void apply(KeyPressEvent&);
virtual void apply(KeyReleaseEvent&);
virtual void apply(PointerEvent&);
virtual void apply(ButtonPressEvent&);
virtual void apply(ButtonReleaseEvent&);
virtual void apply(MoveEvent&);
};

// provide Value<>::accept() implementation
Expand Down
8 changes: 3 additions & 5 deletions include/vsg/ui/KeyEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
</editor-fold> */

#include <vsg/core/observer_ptr.h>
#include <vsg/ui/UIEvent.h>
#include <vsg/ui/WindowEvent.h>
#include <vsg/viewer/Window.h>

namespace vsg
Expand Down Expand Up @@ -264,18 +264,16 @@ namespace vsg
MODKEY_Meta = 128
};

class KeyEvent : public Inherit<UIEvent, KeyEvent>
class KeyEvent : public Inherit<WindowEvent, KeyEvent>
{
public:
KeyEvent(Window* in_window, time_point in_time, KeySymbol in_keyBase, KeySymbol in_keyModified, KeyModifier in_modifier, uint32_t in_repeatCount=0):
Inherit(in_time),
window(in_window),
Inherit(in_window, in_time),
keyBase(in_keyBase),
keyModified(in_keyModified),
keyModifier(in_modifier),
repeatCount(in_repeatCount) {}

observer_ptr<Window> window;
KeySymbol keyBase;
KeySymbol keyModified;
KeyModifier keyModifier;
Expand Down
31 changes: 21 additions & 10 deletions include/vsg/ui/PointerEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
</editor-fold> */

#include <vsg/core/observer_ptr.h>
#include <vsg/ui/UIEvent.h>
#include <vsg/ui/WindowEvent.h>
#include <vsg/viewer/Window.h>

namespace vsg
Expand All @@ -30,33 +30,44 @@ namespace vsg

// VSG_type_name(vsg::PointerEvent);

class PointerEvent : public Inherit<UIEvent, PointerEvent>
class PointerEvent : public Inherit<WindowEvent, PointerEvent>
{
public:
PointerEvent(Window* in_window, time_point in_time, uint32_t in_x, uint32_t in_y, ButtonMask in_buttonMask):
Inherit(in_time),
window(in_window),
Inherit(in_window, in_time),
x(in_x),
y(in_y),
buttonMask(in_buttonMask) {}
mask(in_buttonMask) {}

observer_ptr<Window> window;
uint32_t x;
uint32_t y;
ButtonMask buttonMask;
ButtonMask mask;
};

class ButtonPressEvent : public Inherit<PointerEvent, ButtonPressEvent>
{
public:
ButtonPressEvent(Window* in_window, time_point in_time, uint32_t in_x, uint32_t in_y, ButtonMask in_buttonMask):
Inherit(in_window, in_time, in_x, in_y, in_buttonMask) {}
ButtonPressEvent(Window* in_window, time_point in_time, uint32_t in_x, uint32_t in_y, ButtonMask in_buttonMask, uint32_t in_button):
Inherit(in_window, in_time, in_x, in_y, in_buttonMask),
button(in_button) {}

uint32_t button;
};

class ButtonReleaseEvent : public Inherit<PointerEvent, ButtonReleaseEvent>
{
public:
ButtonReleaseEvent(Window* in_window, time_point in_time, uint32_t in_x, uint32_t in_y, ButtonMask in_buttonMask):
ButtonReleaseEvent(Window* in_window, time_point in_time, uint32_t in_x, uint32_t in_y, ButtonMask in_buttonMask, uint32_t in_button):
Inherit(in_window, in_time, in_x, in_y, in_buttonMask),
button(in_button) {}

uint32_t button;
};

class MoveEvent : public Inherit<PointerEvent, MoveEvent>
{
public:
MoveEvent(Window* in_window, time_point in_time, uint32_t in_x, uint32_t in_y, ButtonMask in_buttonMask):
Inherit(in_window, in_time, in_x, in_y, in_buttonMask) {}
};

Expand Down
3 changes: 2 additions & 1 deletion include/vsg/ui/UIEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#include <vsg/core/Inherit.h>

#include <chrono>
#include <list>

namespace vsg
{
Expand All @@ -31,5 +32,5 @@ namespace vsg
time_point time;
};


using Events = std::list<ref_ptr<UIEvent>>;
}
56 changes: 56 additions & 0 deletions include/vsg/ui/WindowEvent.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#pragma once

/* <editor-fold desc="MIT License">

Copyright(c) 2018 Robert Osfield

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

</editor-fold> */

#include <vsg/core/observer_ptr.h>
#include <vsg/ui/UIEvent.h>
#include <vsg/viewer/Window.h>

namespace vsg
{

class WindowEvent : public Inherit<UIEvent, WindowEvent>
{
public:
WindowEvent(Window* in_window, time_point in_time):
Inherit(in_time),
window(in_window) {}

observer_ptr<Window> window;
};

class ExposeWindowEvent : public Inherit<WindowEvent, ExposeWindowEvent>
{
public:
ExposeWindowEvent(Window* in_window, time_point in_time, int32_t in_x, int32_t in_y, uint32_t in_width, uint32_t in_height):
Inherit(in_window, in_time),
x(in_x),
y(in_y),
width(in_width),
height(in_height) {}

int x = 0;
int y = 0;
int width = 0;
int height = 0;
};

class DeleteWindowEvent : public Inherit<WindowEvent, DeleteWindowEvent>
{
public:
DeleteWindowEvent(Window* in_window, time_point in_time):
Inherit(in_window, in_time) {}
};


}
13 changes: 9 additions & 4 deletions include/vsg/viewer/Window.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI

#include <any>

#include <vsg/ui/UIEvent.h>

#include <vsg/vk/CommandBuffer.h>
#include <vsg/vk/CommandPool.h>
#include <vsg/vk/DeviceMemory.h>
#include <vsg/vk/Framebuffer.h>
#include <vsg/vk/Semaphore.h>
#include <vsg/vk/State.h>


namespace vsg
{

Expand All @@ -32,13 +35,15 @@ namespace vsg

struct Traits
{
uint32_t x = 0;
uint32_t y = 0;
uint32_t x = 100;
uint32_t y = 100;
uint32_t width = 800;
uint32_t height = 600;
uint32_t screenNum = 0;

std::string title = "vsg window";
std::string windowClass = "vsg::Window";
std::string windowTitle = "vsg window";

bool decoration = true;

Window* shareWindow = nullptr;
Expand All @@ -51,7 +56,7 @@ namespace vsg

virtual bool valid() const { return false; }

virtual bool pollEvents() { return false; }
virtual bool pollEvents(Events& /*events*/) { return false; }

virtual bool resized() const { return false; }
virtual void resize() {}
Expand Down
26 changes: 16 additions & 10 deletions src/vsg/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,24 @@ set(SOURCES
)

# add platform specific Window implementation
if(WIN32)
# set up library dependancies
set(LIBRARIES PUBLIC Vulkan::Vulkan)

if (ANDROID)
# TODO
elseif (WIN32)
set(SOURCES ${SOURCES} viewer/Win32_Window.cpp)
else()
elseif (APPLE)
set(SOURCES ${SOURCES} viewer/GLFW_Window.cpp)
set(LIBRARIES ${LIBRARIES} PRIVATE glfw)
else()
if (USE_GLFW)
set(SOURCES ${SOURCES} viewer/GLFW_Window.cpp)
set(LIBRARIES ${LIBRARIES} PRIVATE glfw)
else()
set(SOURCES ${SOURCES} viewer/Xcb_Window.cpp)
set(LIBRARIES ${LIBRARIES} PRIVATE PkgConfig::xcb)
endif()
endif()


Expand Down Expand Up @@ -142,14 +156,6 @@ set_property(TARGET vsg PROPERTY CXX_STANDARD 17)

target_include_directories(vsg PUBLIC $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include> $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>)

# set up library dependancies
set(LIBRARIES PUBLIC Vulkan::Vulkan)

if(WIN32)
set(LIBRARIES ${LIBRARIES})
else()
set(LIBRARIES ${LIBRARIES} PRIVATE glfw)
endif()

target_link_libraries(vsg ${LIBRARIES})

Expand Down
20 changes: 18 additions & 2 deletions src/vsg/core/ConstVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,22 @@ void ConstVisitor::apply(const UIEvent& event)
{
apply(static_cast<const Object&>(event));
}
void ConstVisitor::apply(const KeyEvent& event)
void ConstVisitor::apply(const WindowEvent& event)
{
apply(static_cast<const UIEvent&>(event));
}
void ConstVisitor::apply(const ExposeWindowEvent& event)
{
apply(static_cast<const WindowEvent&>(event));
}
void ConstVisitor::apply(const DeleteWindowEvent& event)
{
apply(static_cast<const WindowEvent&>(event));
}
void ConstVisitor::apply(const KeyEvent& event)
{
apply(static_cast<const WindowEvent&>(event));
}
void ConstVisitor::apply(const KeyPressEvent& event)
{
apply(static_cast<const KeyEvent&>(event));
Expand All @@ -319,7 +331,7 @@ void ConstVisitor::apply(const KeyReleaseEvent& event)
}
void ConstVisitor::apply(const PointerEvent& event)
{
apply(static_cast<const UIEvent&>(event));
apply(static_cast<const WindowEvent&>(event));
}
void ConstVisitor::apply(const ButtonPressEvent& event)
{
Expand All @@ -329,3 +341,7 @@ void ConstVisitor::apply(const ButtonReleaseEvent& event)
{
apply(static_cast<const PointerEvent&>(event));
}
void ConstVisitor::apply(const MoveEvent& event)
{
apply(static_cast<const PointerEvent&>(event));
}
Loading