Skip to content

Commit

Permalink
Rename EventType KeyPress etc. to prevent collisions with X11/X.h
Browse files Browse the repository at this point in the history
  • Loading branch information
adamkewley committed Sep 18, 2024
1 parent 349d845 commit c3fb1cf
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 25 deletions.
6 changes: 3 additions & 3 deletions src/OpenSimCreator/UI/FrameDefinition/FrameDefinitionTab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1082,8 +1082,8 @@ class osc::FrameDefinitionTab::Impl final : public IEditorAPI {

bool onEvent(const Event& e)
{
if (e.type() == EventType::KeyPress) {
return onKeyPress(dynamic_cast<const KeyEvent&>(e));
if (e.type() == EventType::KeyDown) {
return onKeyDown(dynamic_cast<const KeyEvent&>(e));
}
else {
return false;
Expand All @@ -1110,7 +1110,7 @@ class osc::FrameDefinitionTab::Impl final : public IEditorAPI {
}

private:
bool onKeyPress(const KeyEvent& e)
bool onKeyDown(const KeyEvent& e)
{
if (e.matches(KeyModifier::CtrlORGui, KeyModifier::Shift, Key::Z)) {
// Ctrl+Shift+Z: redo
Expand Down
12 changes: 6 additions & 6 deletions src/OpenSimCreator/UI/MainUIScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class osc::MainUIScreen::Impl final :
public std::enable_shared_from_this<Impl> {
public:

bool onUnhandledKeyRelease(const KeyEvent& e)
bool onUnhandledKeyUp(const KeyEvent& e)
{
if (e.matches(KeyModifier::CtrlORGui, Key::P)) {
// `Ctrl+P` or `Super+P`: "take a screenshot"
Expand Down Expand Up @@ -115,8 +115,8 @@ class osc::MainUIScreen::Impl final :
// either the global 2D UI context or the active tab
bool onUnhandledEvent(const Event& e)
{
if (e.type() == EventType::KeyRelease) {
return onUnhandledKeyRelease(dynamic_cast<const KeyEvent&>(e));
if (e.type() == EventType::KeyUp) {
return onUnhandledKeyUp(dynamic_cast<const KeyEvent&>(e));
}
return false;
}
Expand Down Expand Up @@ -176,9 +176,9 @@ class osc::MainUIScreen::Impl final :
bool onEvent(const Event& ev)
{
bool handled = false;
if (ev.type() == EventType::KeyPress or
ev.type() == EventType::KeyRelease or
ev.type() == EventType::MouseButtonRelease or
if (ev.type() == EventType::KeyDown or
ev.type() == EventType::KeyUp or
ev.type() == EventType::MouseButtonUp or
ev.type() == EventType::MouseMove or
ev.type() == EventType::MouseWheel) {

Expand Down
2 changes: 1 addition & 1 deletion src/OpenSimCreator/UI/MeshWarper/MeshWarpingTab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class osc::MeshWarpingTab::Impl final {

bool onEvent(const Event& e)
{
if (e.type() == EventType::KeyPress) {
if (e.type() == EventType::KeyDown) {
return onKeydownEvent(dynamic_cast<const KeyEvent&>(e));
}
else {
Expand Down
2 changes: 1 addition & 1 deletion src/OpenSimCreator/UI/ModelEditor/ModelEditorTab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class osc::ModelEditorTab::Impl final : public IEditorAPI {
bool onEvent(const Event& ev)
{
switch (ev.type()) {
case EventType::KeyPress: return onKeydownEvent(dynamic_cast<const KeyEvent&>(ev));
case EventType::KeyDown: return onKeydownEvent(dynamic_cast<const KeyEvent&>(ev));
case EventType::DropFile: return onDropEvent(dynamic_cast<const DropFileEvent&>(ev));
default: return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/OpenSimCreator/UI/Simulation/SimulationTab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ class osc::SimulationTab::Impl final : public ISimulatorUIAPI {

bool onEvent(const Event& e)
{
if (e.type() == EventType::KeyPress) {
if (e.type() == EventType::KeyDown) {
if (dynamic_cast<const KeyEvent&>(e).matches(Key::Space)) {
togglePlaybackMode();
return true;
Expand Down
4 changes: 2 additions & 2 deletions src/oscar/Platform/Event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ osc::DropFileEvent::DropFileEvent(const SDL_Event& e) :
}

osc::KeyEvent::KeyEvent(const SDL_Event& e) :
Event{e, e.type == SDL_KEYUP ? EventType::KeyRelease : EventType::KeyPress},
Event{e, e.type == SDL_KEYUP ? EventType::KeyUp : EventType::KeyDown},
modifier_{to<KeyModifier>(e.key.keysym.mod)},
key_{to<Key>(e.key.keysym.sym)}
{
Expand All @@ -136,7 +136,7 @@ osc::QuitEvent::QuitEvent(const SDL_Event& e) :
}

osc::MouseEvent::MouseEvent(const SDL_Event& e) :
Event{e, e.type == SDL_MOUSEBUTTONDOWN ? EventType::MouseButtonPress : (e.type == SDL_MOUSEBUTTONUP ? EventType::MouseButtonRelease : EventType::MouseMove)},
Event{e, e.type == SDL_MOUSEBUTTONDOWN ? EventType::MouseButtonDown : (e.type == SDL_MOUSEBUTTONUP ? EventType::MouseButtonUp : EventType::MouseMove)},
relative_delta_{static_cast<float>(e.motion.xrel), static_cast<float>(e.motion.yrel)}
{
OSC_ASSERT(e.type == SDL_MOUSEBUTTONDOWN or e.type == SDL_MOUSEBUTTONUP or e.type == SDL_MOUSEMOTION);
Expand Down
8 changes: 4 additions & 4 deletions src/oscar/Platform/Event.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ namespace osc
enum class EventType {
Raw,
DropFile,
KeyPress,
KeyRelease,
MouseButtonPress,
MouseButtonRelease,
KeyDown,
KeyUp,
MouseButtonDown,
MouseButtonUp,
MouseMove,
MouseWheel,
Quit,
Expand Down
4 changes: 2 additions & 2 deletions src/oscar/UI/MouseCapturingCamera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ void osc::MouseCapturingCamera::on_unmount()

bool osc::MouseCapturingCamera::on_event(const Event& e)
{
if (e.type() == EventType::KeyRelease) {
if (e.type() == EventType::KeyUp) {
if (dynamic_cast<const KeyEvent&>(e).matches(Key::Escape)) {
mouse_captured_ = false;
return true;
}
}
else if (e.type() == EventType::MouseButtonPress) {
else if (e.type() == EventType::MouseButtonDown) {
if (ui::is_mouse_in_main_viewport_workspace()) {
mouse_captured_ = true;
return true;
Expand Down
4 changes: 2 additions & 2 deletions src/oscar/UI/ui_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -797,10 +797,10 @@ bool osc::ui::context::on_event(const Event& ev)
{
ImGui_ImplSDL2_ProcessEvent(ev);

if (ImGui::GetIO().WantCaptureKeyboard and (ev.type() == EventType::KeyPress or ev.type() == EventType::KeyRelease)) {
if (ImGui::GetIO().WantCaptureKeyboard and (ev.type() == EventType::KeyDown or ev.type() == EventType::KeyUp)) {
return true;
}
if (ImGui::GetIO().WantCaptureMouse and (ev.type() == EventType::MouseWheel or ev.type() == EventType::MouseMove or ev.type() == EventType::MouseButtonRelease or ev.type() == EventType::MouseButtonPress)) {
if (ImGui::GetIO().WantCaptureMouse and (ev.type() == EventType::MouseWheel or ev.type() == EventType::MouseMove or ev.type() == EventType::MouseButtonUp or ev.type() == EventType::MouseButtonDown)) {
return true;
}
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/oscar_demos/MandelbrotTab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class osc::MandelbrotTab::Impl final : public StandardTabImpl {

bool impl_on_event(const Event& ev) final
{
if (ev.type() == EventType::KeyRelease) {
if (ev.type() == EventType::KeyUp) {
return on_keyup(dynamic_cast<const KeyEvent&>(ev));
}
else if (ev.type() == EventType::MouseWheel) {
Expand Down
4 changes: 2 additions & 2 deletions src/oscar_simbody/UI/RendererGeometryShaderTab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ class osc::RendererGeometryShaderTab::Impl final {

bool onEvent(const Event& e)
{
if (e.type() == EventType::KeyPress) {
if (e.type() == EventType::KeyDown) {
if (dynamic_cast<const KeyEvent&>(e).matches(Key::Escape)) {
m_IsMouseCaptured = false;
return true;
}
}
else if (e.type() == EventType::MouseButtonPress) {
else if (e.type() == EventType::MouseButtonDown) {
if (ui::is_mouse_in_main_viewport_workspace()) {
m_IsMouseCaptured = true;
return true;
Expand Down

0 comments on commit c3fb1cf

Please sign in to comment.