Magic_Game/src/kiwano/core/event/WindowEvent.h

118 lines
2.9 KiB
C
Raw Normal View History

2019-12-31 11:22:23 +08:00
// Copyright (c) 2016-2018 Kiwano - Nomango
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#pragma once
#include <kiwano/core/event/Event.h>
namespace kiwano
{
2020-01-16 18:33:42 +08:00
KGE_DECLARE_SMART_PTR(WindowEvent);
KGE_DECLARE_SMART_PTR(WindowMovedEvent);
KGE_DECLARE_SMART_PTR(WindowResizedEvent);
KGE_DECLARE_SMART_PTR(WindowFocusChangedEvent);
KGE_DECLARE_SMART_PTR(WindowTitleChangedEvent);
KGE_DECLARE_SMART_PTR(WindowClosedEvent);
2019-12-31 11:22:23 +08:00
/**
* \addtogroup Events
* @{
*/
/// \~chinese
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
class KGE_API WindowEvent
: public Event
{
2020-01-16 18:33:42 +08:00
public:
WindowEvent(const EventType& type);
2019-12-31 11:22:23 +08:00
};
/// \~chinese
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD><C6B6>¼<EFBFBD>
class KGE_API WindowMovedEvent
2020-01-16 18:33:42 +08:00
: public WindowEvent
2019-12-31 11:22:23 +08:00
{
public:
int x; ///< <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͻ<EFBFBD> x <20><><EFBFBD><EFBFBD>
int y; ///< <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͻ<EFBFBD> y <20><><EFBFBD><EFBFBD>
WindowMovedEvent();
};
/// \~chinese
/// @brief <20><><EFBFBD>ڴ<EFBFBD>С<EFBFBD><EFBFBD>¼<EFBFBD>
class KGE_API WindowResizedEvent
2020-01-16 18:33:42 +08:00
: public WindowEvent
2019-12-31 11:22:23 +08:00
{
public:
2020-01-16 18:33:42 +08:00
uint32_t width; ///< <20><><EFBFBD>ڿ<EFBFBD><DABF><EFBFBD>
uint32_t height; ///< <20><><EFBFBD>ڸ߶<DAB8>
2019-12-31 11:22:23 +08:00
WindowResizedEvent();
};
/// \~chinese
/// @brief <20><><EFBFBD>ڽ<EFBFBD><DABD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
class KGE_API WindowFocusChangedEvent
2020-01-16 18:33:42 +08:00
: public WindowEvent
2019-12-31 11:22:23 +08:00
{
public:
bool focus; ///< <20>Ƿ<EFBFBD><C7B7><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
WindowFocusChangedEvent();
};
/// \~chinese
/// @brief <20><><EFBFBD>ڱ<EFBFBD><DAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
class KGE_API WindowTitleChangedEvent
2020-01-16 18:33:42 +08:00
: public WindowEvent
2019-12-31 11:22:23 +08:00
{
public:
String title; ///< <20><><EFBFBD><EFBFBD>
WindowTitleChangedEvent();
};
/// \~chinese
/// @brief <20><><EFBFBD>ڹر<DAB9><D8B1>¼<EFBFBD>
class KGE_API WindowClosedEvent
2020-01-16 18:33:42 +08:00
: public WindowEvent
2019-12-31 11:22:23 +08:00
{
public:
WindowClosedEvent();
};
/** @} */
template <>
struct IsEventType<WindowEvent>
{
2020-01-16 18:33:42 +08:00
inline bool operator()(const Event* evt) const
2019-12-31 11:22:23 +08:00
{
2020-01-16 18:33:42 +08:00
return evt->GetType() == KGE_EVENT(WindowMovedEvent)
|| evt->GetType() == KGE_EVENT(WindowResizedEvent)
|| evt->GetType() == KGE_EVENT(WindowFocusChangedEvent)
|| evt->GetType() == KGE_EVENT(WindowTitleChangedEvent)
|| evt->GetType() == KGE_EVENT(WindowClosedEvent);
2019-12-31 11:22:23 +08:00
}
};
}