Fixed: #1193 Fixed flickering graphics viewport under windows.

This commit is contained in:
dnk-88 2011-05-09 23:46:14 +03:00
parent 787ebd0f6f
commit 68f5753c67
6 changed files with 26 additions and 45 deletions

View file

@ -77,7 +77,7 @@ const char * const DATA_PATH_SECTION = "DataPath";
const char * const SEARCH_PATHS = "SearchPaths";
const char * const RECURSIVE_SEARCH_PATHS = "RecursiveSearchPathes";
const char * const LEVELDESIGN_PATH = "LevelDesignPath";
const char * const ASSETS_PATH = "LevelDesignPath";
const char * const ASSETS_PATH = "AssetsPath";
//resources
const char * const ICON_NEL = ":/core/images/nel.png";

View file

@ -38,6 +38,9 @@ QNLWidget::QNLWidget(QWidget *parent)
m_initialized(false),
m_interval(25)
{
setAttribute(Qt::WA_OpaquePaintEvent);
setAttribute(Qt::WA_NoSystemBackground);
setAttribute(Qt::WA_PaintOnScreen);
setMouseTracking(true);
setFocusPolicy(Qt::StrongFocus);

View file

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>195</width>
<height>64</height>
<width>192</width>
<height>52</height>
</rect>
</property>
<property name="maximumSize">
@ -21,6 +21,12 @@
</property>
<widget class="QWidget" name="dockWidgetContents">
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<number>3</number>
</property>
<property name="spacing">
<number>3</number>
</property>
<item row="1" column="1" colspan="2">
<widget class="QSlider" name="horizontalSlider">
<property name="maximum">

View file

@ -49,6 +49,9 @@ namespace NLQT
CGraphicsViewport::CGraphicsViewport(QWidget *parent)
: QNLWidget(parent)
{
setAttribute(Qt::WA_OpaquePaintEvent);
setAttribute(Qt::WA_NoSystemBackground);
setAttribute(Qt::WA_PaintOnScreen);
}
CGraphicsViewport::~CGraphicsViewport()
@ -77,7 +80,7 @@ void CGraphicsViewport::release()
{
//H_AUTO2
nldebug("CGraphicsViewport::release");
Modules::veget().release();
Modules::psEdit().release();
Modules::objView().release();
@ -119,39 +122,6 @@ void CGraphicsViewport::resizeEvent(QResizeEvent *resizeEvent)
Modules::objView().setSizeViewport(resizeEvent->size().width(), resizeEvent->size().height());
}
#if defined(NL_OS_MAC)
// Qt does not provide wheel events through winEvent() and macEvent() (but it
// does through x11Event(), which is inconsistent...)
// Workaround is to handle wheel events like implemented below.
//
// TODO: this is not a clean solution, because all but wheel events are
// handled using winEvent(), x11Event(), macEvent(). But this seems to be a
// limitation of current (4.7.1) Qt versions. (see e.g. qapplication_mac.mm)
void CGraphicsViewport::wheelEvent(QWheelEvent *event)
{
// Get relative positions.
float fX = 1.0f - (float)event->pos().x() / this->width();
float fY = 1.0f - (float)event->pos().y() / this->height();
// Get the buttons currently pressed.
uint32 buttons = NLMISC::noButton;
if(event->buttons() & Qt::LeftButton) buttons |= NLMISC::leftButton;
if(event->buttons() & Qt::RightButton) buttons |= NLMISC::rightButton;
if(event->buttons() & Qt::MidButton) buttons |= NLMISC::middleButton;
if(event->modifiers() & Qt::ControlModifier) buttons |= NLMISC::ctrlButton;
if(event->modifiers() & Qt::ShiftModifier) buttons |= NLMISC::shiftButton;
if(event->modifiers() & Qt::AltModifier) buttons |= NLMISC::altButton;
if(event->delta() > 0)
Modules::objView().getDriver()->EventServer.postEvent(
new NLMISC::CEventMouseWheel(-fX, fY, (NLMISC::TMouseButton)buttons, true, NULL));
else
Modules::objView().getDriver()->EventServer.postEvent(
new NLMISC::CEventMouseWheel(-fX, fY, (NLMISC::TMouseButton)buttons, false, NULL));
}
#endif // defined(NL_OS_MAC)
#if defined(NL_OS_WINDOWS)
typedef bool (*winProc)(NL3D::IDriver *driver, HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);

View file

@ -80,10 +80,6 @@ private Q_SLOTS:
protected:
virtual void resizeEvent(QResizeEvent *resizeEvent);
#if defined(NL_OS_MAC)
virtual void wheelEvent(QWheelEvent *event);
#endif
#if defined(NL_OS_WINDOWS)
virtual bool winEvent(MSG *message, long *result);
#elif defined(NL_OS_MAC)

View file

@ -6,14 +6,14 @@
<rect>
<x>0</x>
<y>0</y>
<width>460</width>
<height>64</height>
<width>452</width>
<height>52</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>86</width>
<height>64</height>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="features">
@ -24,6 +24,12 @@
</property>
<widget class="QWidget" name="dockWidgetContents">
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<number>3</number>
</property>
<property name="spacing">
<number>3</number>
</property>
<item row="0" column="0">
<widget class="QSlider" name="horizontalSlider">
<property name="maximum">