Permalink
Browse files

Merge remote-tracking branch 'upstream/master-dev' into travis_fixes

  • Loading branch information...
gralkapk committed Dec 8, 2018
2 parents 57d560b + 1d6f05f commit 2a61bd9abdbc833c3d7e7a382c7fbcbee56e0ef9
Showing with 26 additions and 4 deletions.
  1. +4 −2 core/include/mmcore/view/RendererModule.h
  2. +22 −2 plugins/gui/src/GUIRenderer.h
@@ -82,14 +82,14 @@ template <class C> class MEGAMOLCORE_API RendererModule : public Module, public
virtual bool OnMouseButton(MouseButton button, MouseButtonAction action, Modifiers mods) {
MouseFlags mouseFlags;
// Ugly mapping to deprecated functions (can be removed some day).
auto down = action == core::view::MouseButtonAction::PRESS;
if (mods.test(core::view::Modifier::SHIFT)) {
view::MouseFlagsSetFlag(mouseFlags, view::MOUSEFLAG_MODKEY_SHIFT_DOWN, true);
} else if (mods.test(core::view::Modifier::CTRL)) {
view::MouseFlagsSetFlag(mouseFlags, view::MOUSEFLAG_MODKEY_CTRL_DOWN, true);
} else if (mods.test(core::view::Modifier::ALT)) {
view::MouseFlagsSetFlag(mouseFlags, view::MOUSEFLAG_MODKEY_ALT_DOWN, true);
}
auto down = action == core::view::MouseButtonAction::PRESS;
if (button == MouseButton::BUTTON_LEFT) {
view::MouseFlagsSetFlag(mouseFlags, view::MOUSEFLAG_BUTTON_LEFT_DOWN, down);
} else if (button == MouseButton::BUTTON_RIGHT) {
@@ -101,14 +101,16 @@ template <class C> class MEGAMOLCORE_API RendererModule : public Module, public
// - Could be "world space" (see View2D/View3D) instead of window space!
// - If so, then provide a freaking method in the Call to the the transformation instead of passing around black magic!
this->MouseEvent(lastX, lastY, mouseFlags);
return down;
// Ignore deprecated "event was processed" flag because too many renderers fail to use it properly
return false;
}

virtual bool OnMouseMove(double x, double y) {
// Ugly mapping to deprecated functions (can be removed some day).
this->lastX = x;
this->lastY = y;
this->MouseEvent(x, y, 0);
// Ignore deprecated "event was processed" flag because too many renderers fail to use it properly
return false;
}

@@ -242,13 +242,33 @@ template <class M, class C> void GUIRenderer<M, C>::drawMainMenu() {
}


template <class M, class C> bool GUIRenderer<M, C>::GetExtents(C& call) {
auto* cr = this->decoratedRendererSlot.template CallAs<C>();
template <>
inline bool GUIRenderer<core::view::Renderer2DModule, core::view::CallRender2D>::GetExtents(
core::view::CallRender2D& call) {
auto* cr = this->decoratedRendererSlot.CallAs<core::view::CallRender2D>();
if (cr != NULL) {
(*cr) = call;
if ((*cr)(core::view::AbstractCallRender::FnGetExtents)) {
call = (*cr);
}
} else {
call.SetBoundingBox(vislib::math::Rectangle<float>(0, 1, 1, 0));
}
return true;
}


template <>
inline bool GUIRenderer<core::view::Renderer3DModule, core::view::CallRender3D>::GetExtents(
core::view::CallRender3D& call) {
auto* cr = this->decoratedRendererSlot.CallAs<core::view::CallRender3D>();
if (cr != NULL) {
(*cr) = call;
if ((*cr)(core::view::AbstractCallRender::FnGetExtents)) {
call = (*cr);
}
} else {
// TODO: set dummy bounding box?
}
return true;
}

0 comments on commit 2a61bd9

Please sign in to comment.