From 57d33d79ea570773d84ad81d4a61f50e079979ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Konopacki?= Date: Wed, 19 Sep 2012 22:17:28 +0200 Subject: Changes in Ui, solves part of #47 --- src/ui/button.cpp | 4 +-- src/ui/check.cpp | 2 +- src/ui/color.cpp | 2 +- src/ui/compass.cpp | 2 +- src/ui/control.cpp | 4 +-- src/ui/displayinfo.cpp | 2 +- src/ui/edit.cpp | 78 +++++++++++++++++++++++++------------------------- src/ui/editvalue.cpp | 2 +- src/ui/gauge.cpp | 2 +- src/ui/interface.cpp | 2 +- src/ui/key.cpp | 14 ++++----- src/ui/list.cpp | 2 +- src/ui/map.cpp | 6 ++-- src/ui/scroll.cpp | 12 ++++---- src/ui/shortcut.cpp | 2 +- src/ui/slider.cpp | 12 ++++---- src/ui/target.cpp | 6 ++-- 17 files changed, 77 insertions(+), 77 deletions(-) (limited to 'src/ui') diff --git a/src/ui/button.cpp b/src/ui/button.cpp index 7473409..d98e676 100644 --- a/src/ui/button.cpp +++ b/src/ui/button.cpp @@ -105,7 +105,7 @@ bool CButton::EventProcess(const Event &event) (m_state & STATE_VISIBLE) && (m_state & STATE_ENABLE) ) { - if ( CControl::Detect(event.pos) ) + if ( CControl::Detect(event.mouseButton.pos) ) { m_bCapture = true; m_repeat = DELAY1; @@ -128,7 +128,7 @@ bool CButton::EventProcess(const Event &event) event.mouseButton.button == 1 && m_bCapture ) { - if ( CControl::Detect(event.pos) ) + if ( CControl::Detect(event.mouseButton.pos) ) { if ( !m_bImmediat && !m_bRepeat ) { diff --git a/src/ui/check.cpp b/src/ui/check.cpp index e9732a4..a64fb5f 100644 --- a/src/ui/check.cpp +++ b/src/ui/check.cpp @@ -77,7 +77,7 @@ bool CCheck::EventProcess(const Event &event) (m_state & STATE_VISIBLE) && (m_state & STATE_ENABLE) ) { - if ( CControl::Detect(event.pos) ) + if ( CControl::Detect(event.mouseButton.pos) ) { Event newEvent = event; newEvent.type = m_eventType; diff --git a/src/ui/color.cpp b/src/ui/color.cpp index 4d071c6..200ed0c 100644 --- a/src/ui/color.cpp +++ b/src/ui/color.cpp @@ -109,7 +109,7 @@ bool CColor::EventProcess(const Event &event) (m_state & STATE_VISIBLE) && (m_state & STATE_ENABLE) ) { - if ( CControl::Detect(event.pos) ) + if ( CControl::Detect(event.mouseButton.pos) ) { m_repeat = DELAY1; diff --git a/src/ui/compass.cpp b/src/ui/compass.cpp index f7be764..c7d0068 100644 --- a/src/ui/compass.cpp +++ b/src/ui/compass.cpp @@ -62,7 +62,7 @@ bool CCompass::EventProcess(const Event &event) if ( event.type == EVENT_MOUSE_BUTTON_DOWN && event.mouseButton.button == 1) { - if ( CControl::Detect(event.pos) ) + if ( CControl::Detect(event.mouseButton.pos) ) { Event newEvent = event; newEvent.type = m_eventType; diff --git a/src/ui/control.cpp b/src/ui/control.cpp index 81893d5..6ac82bc 100644 --- a/src/ui/control.cpp +++ b/src/ui/control.cpp @@ -323,7 +323,7 @@ bool CControl::EventProcess(const Event &event) if ( event.type == EVENT_MOUSE_BUTTON_DOWN && event.mouseButton.button == 1) { - if ( Detect(event.pos) ) + if ( Detect(event.mouseButton.pos) ) { m_bCapture = true; SetState(STATE_PRESS); @@ -332,7 +332,7 @@ bool CControl::EventProcess(const Event &event) if ( event.type == EVENT_MOUSE_MOVE && m_bCapture ) { - if ( Detect(event.pos) ) + if ( Detect(event.mouseMove.pos) ) { SetState(STATE_PRESS); } diff --git a/src/ui/displayinfo.cpp b/src/ui/displayinfo.cpp index c58f2f8..173c100 100644 --- a/src/ui/displayinfo.cpp +++ b/src/ui/displayinfo.cpp @@ -103,7 +103,7 @@ bool CDisplayInfo::EventProcess(const Event &event) toto = static_cast(m_toto->GetMotion()); if ( toto != 0 ) { - toto->SetMousePos(event.pos); + toto->SetMousePos(event.mouseMove.pos); } } } diff --git a/src/ui/edit.cpp b/src/ui/edit.cpp index 6323885..e2baae9 100644 --- a/src/ui/edit.cpp +++ b/src/ui/edit.cpp @@ -17,7 +17,7 @@ // edit.cpp - +#include "app/app.h" #include "ui/edit.h" #include @@ -263,8 +263,8 @@ bool CEdit::EventProcess(const Event &event) if ( event.type == EVENT_MOUSE_MOVE ) { - if ( Detect(event.pos) && - event.pos.x < m_pos.x+m_dim.x-(m_bMulti?MARGX+SCROLL_WIDTH:0.0f) ) + if ( Detect(event.mouseMove.pos) && + event.mouseMove.pos.x < m_pos.x+m_dim.x-(m_bMulti?MARGX+SCROLL_WIDTH:0.0f) ) { if ( m_bEdit ) { @@ -272,7 +272,7 @@ bool CEdit::EventProcess(const Event &event) } else { - if ( IsLinkPos(event.pos) ) + if ( IsLinkPos(event.mouseMove.pos) ) { m_engine->SetMouseType(Gfx::ENG_MOUSE_HAND); } @@ -297,100 +297,100 @@ bool CEdit::EventProcess(const Event &event) if ( event.type == EVENT_KEY_DOWN && m_bFocus ) { - bShift = (event.keyState&KS_SHIFT); - bControl = (event.keyState&KS_CONTROL); + bShift = ( (event.trackedKeys & TRKEY_SHIFT) != 0 ); + bControl = ( (event.trackedKeys & TRKEY_CONTROL) != 0); - if ( (event.param == 'X' && !bShift && bControl) || - (event.param == KEY(DELETE) && bShift && !bControl) ) + if ( (event.key.unicode == 'X' && !bShift && bControl) || + (event.key.key == KEY(DELETE) && bShift && !bControl) ) { Cut(); return true; } - if ( (event.param == 'C' && !bShift && bControl) || - (event.param == KEY(INSERT) && !bShift && bControl) ) + if ( (event.key.unicode == 'C' && !bShift && bControl) || + (event.key.key == KEY(INSERT) && !bShift && bControl) ) { Copy(); return true; } - if ( (event.param == 'V' && !bShift && bControl) || + if ( (event.key.unicode == 'V' && !bShift && bControl) || (event.param == KEY(INSERT) && bShift && !bControl) ) { Paste(); return true; } - if ( event.param == 'A' && !bShift && bControl ) + if ( event.key.unicode == 'A' && !bShift && bControl ) { SetCursor(999999, 0); return true; } - if ( event.param == 'O' && !bShift && bControl ) + if ( event.key.unicode == 'O' && !bShift && bControl ) { Event newEvent(EVENT_STUDIO_OPEN); // m_event->NewEvent(newEvent, EVENT_STUDIO_OPEN); m_event->AddEvent(newEvent); } - if ( event.param == 'S' && !bShift && bControl ) + if ( event.key.unicode == 'S' && !bShift && bControl ) { Event newEvent( EVENT_STUDIO_SAVE ); // m_event->MakeEvent(newEvent, EVENT_STUDIO_SAVE); m_event->AddEvent(newEvent); } - if ( event.param == 'Z' && !bShift && bControl ) + if ( event.key.unicode == 'Z' && !bShift && bControl ) { Undo(); return true; } - if ( event.param == 'U' && !bShift && bControl ) + if ( event.key.unicode == 'U' && !bShift && bControl ) { if ( MinMaj(false) ) return true; } - if ( event.param == 'U' && bShift && bControl ) + if ( event.key.unicode == 'U' && bShift && bControl ) { if ( MinMaj(true) ) return true; } - if ( event.param == KEY(TAB) && !bShift && !bControl && !m_bAutoIndent ) + if ( event.key.key == KEY(TAB) && !bShift && !bControl && !m_bAutoIndent ) { if ( Shift(false) ) return true; } - if ( event.param == KEY(TAB) && bShift && !bControl && !m_bAutoIndent ) + if ( event.key.key == KEY(TAB) && bShift && !bControl && !m_bAutoIndent ) { if ( Shift(true) ) return true; } if ( m_bEdit ) { - if ( event.param == KEY(LEFT) ) + if ( event.key.key == KEY(LEFT) ) { MoveChar(-1, bControl, bShift); return true; } - if ( event.param == KEY(RIGHT) ) + if ( event.key.key == KEY(RIGHT) ) { MoveChar(1, bControl, bShift); return true; } - if ( event.param == KEY(UP) ) + if ( event.key.key == KEY(UP) ) { MoveLine(-1, bControl, bShift); return true; } - if ( event.param == KEY(DOWN) ) + if ( event.key.key == KEY(DOWN) ) { MoveLine(1, bControl, bShift); return true; } - if ( event.param == KEY(PAGEUP) ) // PageUp ? + if ( event.key.key == KEY(PAGEUP) ) // PageUp ? { MoveLine(-(m_lineVisible-1), bControl, bShift); return true; } - if ( event.param == KEY(PAGEDOWN) ) // PageDown ? + if ( event.key.key == KEY(PAGEDOWN) ) // PageDown ? { MoveLine(m_lineVisible-1, bControl, bShift); return true; @@ -398,62 +398,62 @@ bool CEdit::EventProcess(const Event &event) } else { - if ( event.param == KEY(LEFT) || - event.param == KEY(UP) ) + if ( event.key.key == KEY(LEFT) || + event.key.key == KEY(UP) ) { Scroll(m_lineFirst-1, true); return true; } - if ( event.param == KEY(RIGHT) || - event.param == KEY(DOWN) ) + if ( event.key.key == KEY(RIGHT) || + event.key.key == KEY(DOWN) ) { Scroll(m_lineFirst+1, true); return true; } - if ( event.param == KEY(PAGEUP) ) // PageUp ? + if ( event.key.key == KEY(PAGEUP) ) // PageUp ? { Scroll(m_lineFirst-(m_lineVisible-1), true); return true; } - if ( event.param == KEY(PAGEDOWN) ) // PageDown ? + if ( event.key.key == KEY(PAGEDOWN) ) // PageDown ? { Scroll(m_lineFirst+(m_lineVisible-1), true); return true; } } - if ( event.param == KEY(HOME) ) + if ( event.key.key == KEY(HOME) ) { MoveHome(bControl, bShift); return true; } - if ( event.param == KEY(END) ) + if ( event.key.key == KEY(END) ) { MoveEnd(bControl, bShift); return true; } - if ( event.param == KEY(BACKSPACE) ) // backspace ( <- ) ? + if ( event.key.key == KEY(BACKSPACE) ) // backspace ( <- ) ? { Delete(-1); SendModifEvent(); return true; } - if ( event.param == KEY(DELETE) ) + if ( event.key.key == KEY(DELETE) ) { Delete(1); SendModifEvent(); return true; } - if ( event.param == KEY(RETURN) ) + if ( event.key.key == KEY(RETURN) ) { Insert('\n'); SendModifEvent(); return true; } - if ( event.param == KEY(TAB) ) + if ( event.key.key == KEY(TAB) ) { Insert('\t'); SendModifEvent(); @@ -463,9 +463,9 @@ bool CEdit::EventProcess(const Event &event) if ( event.type == EVENT_ACTIVE && m_bFocus ) { - if ( event.param >= ' ' && event.param <= 255 ) + if ( event.key.key >= ' ' && event.key.key <= 255 ) { - Insert(static_cast(event.param)); + Insert(static_cast(event.key.key)); SendModifEvent(); return true; } diff --git a/src/ui/editvalue.cpp b/src/ui/editvalue.cpp index 0ee41b3..3b819b3 100644 --- a/src/ui/editvalue.cpp +++ b/src/ui/editvalue.cpp @@ -148,7 +148,7 @@ bool CEditValue::EventProcess(const Event &event) { if ( m_edit->GetFocus() && event.type == EVENT_KEY_DOWN && - event.param == KEY(RETURN) ) + event.key.key == KEY(RETURN) ) { value = GetValue(); if ( value > m_maxValue ) value = m_maxValue; diff --git a/src/ui/gauge.cpp b/src/ui/gauge.cpp index 1cbe84b..b1ce31d 100644 --- a/src/ui/gauge.cpp +++ b/src/ui/gauge.cpp @@ -56,7 +56,7 @@ bool CGauge::EventProcess(const Event &event) if ( event.type == EVENT_MOUSE_BUTTON_DOWN ) { - if ( CControl::Detect(event.pos) ) + if ( CControl::Detect(event.mouseButton.pos) ) { Event newEvent = event; newEvent.type = m_eventType; diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp index 465f142..0745c9b 100644 --- a/src/ui/interface.cpp +++ b/src/ui/interface.cpp @@ -282,7 +282,7 @@ bool CInterface::EventProcess(const Event &event) if (m_camera == nullptr) { m_camera = static_cast(m_iMan->SearchInstance(CLASS_CAMERA)); } - m_engine->SetMouseType(m_camera->GetMouseDef(event.pos)); + m_engine->SetMouseType(m_camera->GetMouseDef(event.mouseMove.pos)); } for (int i = MAXCONTROL-1; i >= 0; i--) { diff --git a/src/ui/key.cpp b/src/ui/key.cpp index 0ba3a6f..2e627bd 100644 --- a/src/ui/key.cpp +++ b/src/ui/key.cpp @@ -83,17 +83,17 @@ bool CKey::EventProcess(const Event &event) if (event.type == EVENT_MOUSE_BUTTON_DOWN) { if (event.mouseButton.button == 1) // left - m_bCatch = Detect(event.pos); + m_bCatch = Detect(event.mouseButton.pos); } - if (event.type == EVENT_MOUSE_BUTTON_DOWN && m_bCatch) { + if (event.type == EVENT_KEY_DOWN && m_bCatch) { m_bCatch = false; - if ( TestKey(event.param) ) { // impossible ? + if ( TestKey(event.key.key) ) { // impossible ? m_sound->Play(SOUND_TZOING); } else { - if ( event.param == m_key[0] || event.param == m_key[1] ) { - m_key[0] = event.param; + if ( event.key.key == m_key[0] || event.key.key == m_key[1] ) { + m_key[0] = event.key.key; m_key[1] = 0; } else { m_key[1] = m_key[0]; @@ -118,7 +118,7 @@ bool CKey::TestKey(int key) { if ( key == KEY(PAUSE) || key == KEY(PRINT) ) return true; // blocked key - /* TODO: input bindings + /* TODO: input bindings for (int i = 0; i < 20; i++) { for (int j = 0; j < 2; j++) { if (key == m_app->GetKey(i, j) ) // key used? @@ -129,7 +129,7 @@ bool CKey::TestKey(int key) m_app->SetKey(i, 0, m_app->GetKey(i, 1)); // shift m_app->SetKey(i, 1, 0); } - }*/ + } */ return false; // not used } diff --git a/src/ui/list.cpp b/src/ui/list.cpp index 06eaf37..f62d0ea 100644 --- a/src/ui/list.cpp +++ b/src/ui/list.cpp @@ -275,7 +275,7 @@ bool CList::EventProcess(const Event &event) CControl::EventProcess(event); - if (event.type == EVENT_MOUSE_MOVE && Detect(event.pos)) { + if (event.type == EVENT_MOUSE_MOVE && Detect(event.mouseMove.pos)) { m_engine->SetMouseType(Gfx::ENG_MOUSE_NORM); for (i = 0; i < m_displayLine; i++) { if (i + m_firstLine >= m_totalLine) diff --git a/src/ui/map.cpp b/src/ui/map.cpp index 23ec9fb..3a3d30f 100644 --- a/src/ui/map.cpp +++ b/src/ui/map.cpp @@ -189,13 +189,13 @@ bool CMap::EventProcess(const Event &event) if ( event.type == EVENT_MOUSE_MOVE && Detect(event.pos) ) { m_engine->SetMouseType(Gfx::ENG_MOUSE_NORM); - if ( DetectObject(event.pos, bInMap) != 0 ) + if ( DetectObject(event.mouseMove.pos, bInMap) != 0 ) m_engine->SetMouseType(Gfx::ENG_MOUSE_HAND); } if ( event.type == EVENT_MOUSE_BUTTON_DOWN && event.mouseButton.button == 1 ) { - if ( CControl::Detect(event.pos) ) { - SelectObject(event.pos); + if ( CControl::Detect(event.mouseButton.pos) ) { + SelectObject(event.mouseButton.pos); return false; } } diff --git a/src/ui/scroll.cpp b/src/ui/scroll.cpp index 38379a5..d3d0ed2 100644 --- a/src/ui/scroll.cpp +++ b/src/ui/scroll.cpp @@ -238,17 +238,17 @@ bool CScroll::EventProcess(const Event &event) (m_state & STATE_VISIBLE) && (m_state & STATE_ENABLE) ) { - if ( CControl::Detect(event.pos) ) + if ( CControl::Detect(event.mouseButton.pos) ) { pos.y = m_pos.y+hButton; dim.y = m_dim.y-hButton*2.0f; pos.y += dim.y*(1.0f-m_visibleRatio)*(1.0f-m_visibleValue); dim.y *= m_visibleRatio; - if ( event.pos.y < pos.y || - event.pos.y > pos.y+dim.y ) // click outside cabin? + if ( event.mouseButton.pos.y < pos.y || + event.mouseButton.pos.y > pos.y+dim.y ) // click outside cabin? { h = (m_dim.y-hButton*2.0f)*(1.0f-m_visibleRatio); - value = 1.0f-(event.pos.y-(m_pos.y+hButton+dim.y*0.5f))/h; + value = 1.0f-(event.mouseButton.pos.y-(m_pos.y+hButton+dim.y*0.5f))/h; if ( value < 0.0f ) value = 0.0f; if ( value > 1.0f ) value = 1.0f; m_visibleValue = value; @@ -259,7 +259,7 @@ bool CScroll::EventProcess(const Event &event) m_event->AddEvent(newEvent); } m_bCapture = true; - m_pressPos = event.pos; + m_pressPos = event.mouseButton.pos; m_pressValue = m_visibleValue; } } @@ -269,7 +269,7 @@ bool CScroll::EventProcess(const Event &event) h = (m_dim.y-hButton*2.0f)*(1.0f-m_visibleRatio); if ( h != 0 ) { - value = m_pressValue - (event.pos.y-m_pressPos.y)/h; + value = m_pressValue - (event.mouseMove.pos.y-m_pressPos.y)/h; if ( value < 0.0f ) value = 0.0f; if ( value > 1.0f ) value = 1.0f; diff --git a/src/ui/shortcut.cpp b/src/ui/shortcut.cpp index 8fe62ba..c8d3890 100644 --- a/src/ui/shortcut.cpp +++ b/src/ui/shortcut.cpp @@ -69,7 +69,7 @@ bool CShortcut::EventProcess(const Event &event) if ( event.type == EVENT_MOUSE_BUTTON_DOWN && event.mouseButton.button == 1) { - if ( CControl::Detect(event.pos) ) + if ( CControl::Detect(event.mouseButton.pos) ) { Event newEvent = event; newEvent.type = m_eventType; diff --git a/src/ui/slider.cpp b/src/ui/slider.cpp index 175a6fe..70dd2cc 100644 --- a/src/ui/slider.cpp +++ b/src/ui/slider.cpp @@ -288,20 +288,20 @@ bool CSlider::EventProcess(const Event &event) (m_state & STATE_VISIBLE) && (m_state & STATE_ENABLE) ) { - if ( CControl::Detect(event.pos) ) + if ( CControl::Detect(event.mouseButton.pos) ) { if ( m_bHoriz ) { pos.x = m_pos.x+m_marginButton; dim.x = m_dim.x-m_marginButton*2.0f; - value = (event.pos.x-pos.x-CURSOR_WIDTH/2.0f); + value = (event.mouseButton.pos.x-pos.x-CURSOR_WIDTH/2.0f); value /= (dim.x-CURSOR_WIDTH); } else { pos.y = m_pos.y+m_marginButton; dim.y = m_dim.y-m_marginButton*2.0f; - value = (event.pos.y-pos.y-CURSOR_WIDTH/2.0f); + value = (event.mouseButton.pos.y-pos.y-CURSOR_WIDTH/2.0f); value /= (dim.y-CURSOR_WIDTH); } if ( value < 0.0f ) value = 0.0f; @@ -314,7 +314,7 @@ bool CSlider::EventProcess(const Event &event) m_event->AddEvent(newEvent); m_bCapture = true; - m_pressPos = event.pos; + m_pressPos = event.mouseButton.pos; m_pressValue = m_visibleValue; } } @@ -325,14 +325,14 @@ bool CSlider::EventProcess(const Event &event) { pos.x = m_pos.x+m_marginButton; dim.x = m_dim.x-m_marginButton*2.0f; - value = (event.pos.x-pos.x-CURSOR_WIDTH/2.0f); + value = (event.mouseMove.pos.x-pos.x-CURSOR_WIDTH/2.0f); value /= (dim.x-CURSOR_WIDTH); } else { pos.y = m_pos.y+m_marginButton; dim.y = m_dim.y-m_marginButton*2.0f; - value = (event.pos.y-pos.y-CURSOR_WIDTH/2.0f); + value = (event.mouseMove.pos.y-pos.y-CURSOR_WIDTH/2.0f); value /= (dim.y-CURSOR_WIDTH); } if ( value < 0.0f ) value = 0.0f; diff --git a/src/ui/target.cpp b/src/ui/target.cpp index a2166e4..f398e58 100644 --- a/src/ui/target.cpp +++ b/src/ui/target.cpp @@ -96,9 +96,9 @@ bool CTarget::EventProcess(const Event &event) { m_main->SetFriendAim(false); - if ( CControl::Detect(event.pos) ) + if ( CControl::Detect(event.mouseMove.pos) ) { - pObj = DetectFriendObject(event.pos); + pObj = DetectFriendObject(event.mouseMove.pos); if ( pObj == 0 ) { m_engine->SetMouseType(Gfx::ENG_MOUSE_TARGET); @@ -121,7 +121,7 @@ bool CTarget::EventProcess(const Event &event) (m_state & STATE_VISIBLE) && (m_state & STATE_ENABLE) ) { - if ( CControl::Detect(event.pos) ) + if ( CControl::Detect(event.mouseButton.pos) ) { if ( !m_main->GetFriendAim() ) { -- cgit v1.2.3-1-g7c22