Commit 13846b63 authored by Bryan Gardiner's avatar Bryan Gardiner

Minor touch-ups to graphics scene code.

- SceneEventListener: Define sceneEventFilter, not eventFilter.

- QTimer: remainingTime() is Qt 5+.

- QGraphicsEllipseItem, QGraphicsRectItem: Change ctor names.
parent 97e0c414
...@@ -19,6 +19,11 @@ ...@@ -19,6 +19,11 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QEvent> #include <QEvent>
#include <QGraphicsItem>
#include <QObject>
#include <QPainter>
#include <QStyleOptionGraphicsItem>
#include <QWidget>
#include "b_callback.hpp" #include "b_callback.hpp"
namespace qtah { namespace qtah {
...@@ -81,7 +86,7 @@ public: ...@@ -81,7 +86,7 @@ public:
} }
} }
virtual bool eventFilter(QGraphicsItem* receiver, QEvent* event) { virtual bool sceneEventFilter(QGraphicsItem* receiver, QEvent* event) {
return eventCallback_(receiver, event); return eventCallback_(receiver, event);
} }
...@@ -90,8 +95,7 @@ public: ...@@ -90,8 +95,7 @@ public:
} }
virtual QRectF boundingRect() const { return QRectF(); } virtual QRectF boundingRect() const { return QRectF(); }
virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget* = 0) { return; }
QWidget * widget = 0) { return; }
private: private:
CallbackPtrQGraphicsItemPtrQEventBool eventCallback_; CallbackPtrQGraphicsItemPtrQEventBool eventCallback_;
......
...@@ -32,6 +32,8 @@ import Foreign.Hoppy.Generator.Spec ( ...@@ -32,6 +32,8 @@ import Foreign.Hoppy.Generator.Spec (
mkCtor, mkCtor,
) )
import Foreign.Hoppy.Generator.Types (boolT, intT, voidT) import Foreign.Hoppy.Generator.Types (boolT, intT, voidT)
import Foreign.Hoppy.Generator.Version (collect, just, test)
import Graphics.UI.Qtah.Generator.Flags (qtVersion)
import Graphics.UI.Qtah.Generator.Interface.Internal.Listener (c_Listener) import Graphics.UI.Qtah.Generator.Interface.Internal.Listener (c_Listener)
import Graphics.UI.Qtah.Generator.Interface.Core.QObject (c_QObject) import Graphics.UI.Qtah.Generator.Interface.Core.QObject (c_QObject)
import Graphics.UI.Qtah.Generator.Module (AModule (AQtModule), makeQtModule) import Graphics.UI.Qtah.Generator.Module (AModule (AQtModule), makeQtModule)
...@@ -49,21 +51,22 @@ aModule = ...@@ -49,21 +51,22 @@ aModule =
c_QTimer = c_QTimer =
addReqIncludes [includeStd "QTimer"] $ addReqIncludes [includeStd "QTimer"] $
classSetEntityPrefix "" $ classSetEntityPrefix "" $
makeClass (ident "QTimer") Nothing [c_QObject] makeClass (ident "QTimer") Nothing [c_QObject] $
[ mkCtor "new" [] collect
, mkConstMethod "interval" [] intT [ just $ mkCtor "new" []
-- , mkConstMethod "intervalAsDuration" [] $ objT c_std::chrono::milliseconds , just $ mkConstMethod "interval" [] intT
, mkConstMethod "isActive" [] boolT -- , just $ mkConstMethod "intervalAsDuration" [] $ objT c_std::chrono::milliseconds
, mkConstMethod "isSingleShot" [] boolT , just $ mkConstMethod "isActive" [] boolT
, mkConstMethod "remainingTime" [] intT , just $ mkConstMethod "isSingleShot" [] boolT
-- , mkConstMethod "remainingTimeAsDuration" [] $ objT c_std::chrono::milliseconds , test (qtVersion >= [5, 0]) $ mkConstMethod "remainingTime" [] intT
, mkMethod "setInterval" [intT] voidT -- , just $ mkConstMethod "remainingTimeAsDuration" [] $ objT c_std::chrono::milliseconds
-- , mkMethod' "setInterval" "setInterval" [objT c_std::chrono::milliseconds] voidT , just $ mkMethod "setInterval" [intT] voidT
, mkMethod "setSingleShot" [boolT] voidT -- , just $ mkMethod' "setInterval" "setInterval" [objT c_std::chrono::milliseconds] voidT
-- , mkMethod "setTimerType" [objT c_Qt::TimerType] voidT , just $ mkMethod "setSingleShot" [boolT] voidT
, mkMethod "start" [intT] voidT -- , just $ mkMethod "setTimerType" [objT c_Qt::TimerType] voidT
, mkConstMethod "timerId" [] intT , just $ mkMethod "start" [intT] voidT
-- , mkConstMethod "timerType" [] $ objT c_Qt::TimerType , just $ mkConstMethod "timerId" [] intT
-- , just $ mkConstMethod "timerType" [] $ objT c_Qt::TimerType
] ]
s_timeout = makeSignal c_QTimer "timeout" c_Listener s_timeout = makeSignal c_QTimer "timeout" c_Listener
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
module Graphics.UI.Qtah.Generator.Interface.Widgets (modules) where module Graphics.UI.Qtah.Generator.Interface.Widgets (modules) where
import qualified Graphics.UI.Qtah.Generator.Interface.Widgets.QAbstractButton as QAbstractButton import qualified Graphics.UI.Qtah.Generator.Interface.Widgets.QAbstractButton as QAbstractButton
import qualified Graphics.UI.Qtah.Generator.Interface.Widgets.QAbstractGraphicsShapeItem as QAbstractGraphicsShapeItem
import qualified Graphics.UI.Qtah.Generator.Interface.Widgets.QAbstractScrollArea as QAbstractScrollArea import qualified Graphics.UI.Qtah.Generator.Interface.Widgets.QAbstractScrollArea as QAbstractScrollArea
import qualified Graphics.UI.Qtah.Generator.Interface.Widgets.QAbstractSlider as QAbstractSlider import qualified Graphics.UI.Qtah.Generator.Interface.Widgets.QAbstractSlider as QAbstractSlider
import qualified Graphics.UI.Qtah.Generator.Interface.Widgets.QAbstractSpinBox as QAbstractSpinBox import qualified Graphics.UI.Qtah.Generator.Interface.Widgets.QAbstractSpinBox as QAbstractSpinBox
...@@ -34,7 +35,6 @@ import qualified Graphics.UI.Qtah.Generator.Interface.Widgets.QDoubleSpinBox as ...@@ -34,7 +35,6 @@ import qualified Graphics.UI.Qtah.Generator.Interface.Widgets.QDoubleSpinBox as
import qualified Graphics.UI.Qtah.Generator.Interface.Widgets.QFileDialog as QFileDialog import qualified Graphics.UI.Qtah.Generator.Interface.Widgets.QFileDialog as QFileDialog
import qualified Graphics.UI.Qtah.Generator.Interface.Widgets.QFormLayout as QFormLayout import qualified Graphics.UI.Qtah.Generator.Interface.Widgets.QFormLayout as QFormLayout
import qualified Graphics.UI.Qtah.Generator.Interface.Widgets.QFrame as QFrame import qualified Graphics.UI.Qtah.Generator.Interface.Widgets.QFrame as QFrame
import qualified Graphics.UI.Qtah.Generator.Interface.Widgets.QAbstractGraphicsShapeItem as QAbstractGraphicsShapeItem
import qualified Graphics.UI.Qtah.Generator.Interface.Widgets.QGraphicsEllipseItem as QGraphicsEllipseItem import qualified Graphics.UI.Qtah.Generator.Interface.Widgets.QGraphicsEllipseItem as QGraphicsEllipseItem
import qualified Graphics.UI.Qtah.Generator.Interface.Widgets.QGraphicsItem as QGraphicsItem import qualified Graphics.UI.Qtah.Generator.Interface.Widgets.QGraphicsItem as QGraphicsItem
import qualified Graphics.UI.Qtah.Generator.Interface.Widgets.QGraphicsPolygonItem as QGraphicsPolygonItem import qualified Graphics.UI.Qtah.Generator.Interface.Widgets.QGraphicsPolygonItem as QGraphicsPolygonItem
...@@ -81,6 +81,7 @@ import Graphics.UI.Qtah.Generator.Module (AModule) ...@@ -81,6 +81,7 @@ import Graphics.UI.Qtah.Generator.Module (AModule)
modules :: [AModule] modules :: [AModule]
modules = modules =
[ QAbstractButton.aModule [ QAbstractButton.aModule
, QAbstractGraphicsShapeItem.aModule
, QAbstractScrollArea.aModule , QAbstractScrollArea.aModule
, QAbstractSlider.aModule , QAbstractSlider.aModule
, QAbstractSpinBox.aModule , QAbstractSpinBox.aModule
...@@ -97,7 +98,6 @@ modules = ...@@ -97,7 +98,6 @@ modules =
, QFileDialog.aModule , QFileDialog.aModule
, QFormLayout.aModule , QFormLayout.aModule
, QFrame.aModule , QFrame.aModule
, QAbstractGraphicsShapeItem.aModule
, QGraphicsEllipseItem.aModule , QGraphicsEllipseItem.aModule
, QGraphicsItem.aModule , QGraphicsItem.aModule
, QGraphicsPolygonItem.aModule , QGraphicsPolygonItem.aModule
......
...@@ -48,5 +48,5 @@ c_QGraphicsEllipseItem = ...@@ -48,5 +48,5 @@ c_QGraphicsEllipseItem =
classSetEntityPrefix "" $ classSetEntityPrefix "" $
makeClass (ident "QGraphicsEllipseItem") Nothing [c_QAbstractGraphicsShapeItem] makeClass (ident "QGraphicsEllipseItem") Nothing [c_QAbstractGraphicsShapeItem]
[ mkCtor "new" [] [ mkCtor "new" []
, mkCtor "newRectRaw" [qreal, qreal, qreal, qreal] , mkCtor "newWithRaw" [qreal, qreal, qreal, qreal]
] ]
...@@ -52,7 +52,7 @@ c_QGraphicsRectItem = ...@@ -52,7 +52,7 @@ c_QGraphicsRectItem =
classSetEntityPrefix "" $ classSetEntityPrefix "" $
makeClass (ident "QGraphicsRectItem") Nothing [c_QAbstractGraphicsShapeItem] makeClass (ident "QGraphicsRectItem") Nothing [c_QAbstractGraphicsShapeItem]
[ mkCtor "new" [] [ mkCtor "new" []
, mkCtor "newWithRect" [qreal, qreal, qreal, qreal] , mkCtor "newWithRaw" [qreal, qreal, qreal, qreal]
, mkConstMethod "rect" [] $ objT c_QRectF , mkConstMethod "rect" [] $ objT c_QRectF
, mkMethod' "setRect" "setRectRaw" [qreal, qreal, qreal, qreal] voidT , mkMethod' "setRect" "setRectRaw" [qreal, qreal, qreal, qreal] voidT
] ]
...@@ -17,26 +17,6 @@ ...@@ -17,26 +17,6 @@
{-# LANGUAGE ExistentialQuantification #-} {-# LANGUAGE ExistentialQuantification #-}
-- | General routines for managing 'QEvent's.
-- This file is part of Qtah.
--
-- Copyright 2016-2017 Bryan Gardiner <bog@khumba.net>
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU Lesser General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU Lesser General Public License for more details.
--
-- You should have received a copy of the GNU Lesser General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
{-# LANGUAGE ExistentialQuantification #-}
-- | General routines for managing 'QEvent's. -- | General routines for managing 'QEvent's.
module Graphics.UI.Qtah.Event ( module Graphics.UI.Qtah.Event (
-- * High-level interface. -- * High-level interface.
......
...@@ -17,27 +17,8 @@ ...@@ -17,27 +17,8 @@
{-# LANGUAGE ExistentialQuantification #-} {-# LANGUAGE ExistentialQuantification #-}
-- | General routines for managing 'QEvent's. -- | General routines for managing events for
-- This file is part of Qtah. -- "Graphics.UI.Qtah.Widgets.QGraphicsScene"s.
--
-- Copyright 2016-2017 Bryan Gardiner <bog@khumba.net>
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU Lesser General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU Lesser General Public License for more details.
--
-- You should have received a copy of the GNU Lesser General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
{-# LANGUAGE ExistentialQuantification #-}
-- | General routines for managing 'QEvent's.
module Graphics.UI.Qtah.SceneEvent ( module Graphics.UI.Qtah.SceneEvent (
-- * High-level interface. -- * High-level interface.
SceneEvent (..), SceneEvent (..),
...@@ -53,15 +34,14 @@ module Graphics.UI.Qtah.SceneEvent ( ...@@ -53,15 +34,14 @@ module Graphics.UI.Qtah.SceneEvent (
import Control.Concurrent.MVar (MVar, modifyMVar_, newMVar, readMVar) import Control.Concurrent.MVar (MVar, modifyMVar_, newMVar, readMVar)
import Control.Monad (when) import Control.Monad (when)
import Foreign.Hoppy.Runtime (delete) import Foreign.Hoppy.Runtime (delete)
import Graphics.UI.Qtah.Widgets.QGraphicsScene (addItem) import Graphics.UI.Qtah.Widgets.QGraphicsItem (QGraphicsItem, QGraphicsItemPtr)
import Graphics.UI.Qtah.Widgets.QGraphicsItem
(QGraphicsItem, QGraphicsItemPtr, scene, installSceneEventFilter, removeSceneEventFilter)
-- Note, Generated import, since the non-Generated import imports this module. -- Note, Generated import, since the non-Generated import imports this module.
import Graphics.UI.Qtah.Generated.Core.QEvent (QEvent) import Graphics.UI.Qtah.Generated.Core.QEvent (QEvent)
import Graphics.UI.Qtah.Internal.SceneEventListener (SceneEventListener) import Graphics.UI.Qtah.Internal.SceneEventListener (SceneEventListener)
import qualified Graphics.UI.Qtah.Internal.SceneEventListener as SceneEventListener import qualified Graphics.UI.Qtah.Internal.SceneEventListener as SceneEventListener
-- | A typeclass for Qt event classes (subclasses of @QEvent@). -- | A typeclass for Qt events within a
-- 'Graphics.UI.Qtah.Widgets.QGraphicsScene.QGraphicsScene'.
class SceneEvent e where class SceneEvent e where
-- | Registers a callback function to be invoked when an event of type @e@ is -- | Registers a callback function to be invoked when an event of type @e@ is
-- sent to an object. This is a wrapper around 'onAnySceneEvent', so for details, -- sent to an object. This is a wrapper around 'onAnySceneEvent', so for details,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment