mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-06-20 16:55:40 -04:00
UI: Massive revamp, new features and improvements
This commit is contained in:
@ -1,36 +1,35 @@
|
||||
#pragma once
|
||||
#include "core/controller.h"
|
||||
#include "core/types.h"
|
||||
#include "common/types.h"
|
||||
#include "frontend-common/input_manager.h"
|
||||
#include <QtWidgets/QPushButton>
|
||||
#include <optional>
|
||||
|
||||
class QTimer;
|
||||
|
||||
class QtHostInterface;
|
||||
class ControllerSettingsDialog;
|
||||
class SettingsInterface;
|
||||
|
||||
class InputBindingWidget : public QPushButton
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
InputBindingWidget(QtHostInterface* host_interface, std::string section_name, std::string key_name, QWidget* parent);
|
||||
InputBindingWidget(QWidget* parent);
|
||||
InputBindingWidget(QWidget* parent, SettingsInterface* sif, std::string section_name, std::string key_name);
|
||||
~InputBindingWidget();
|
||||
|
||||
ALWAYS_INLINE InputBindingWidget* getNextWidget() const { return m_next_widget; }
|
||||
ALWAYS_INLINE void setNextWidget(InputBindingWidget* widget) { m_next_widget = widget; }
|
||||
static bool isMouseMappingEnabled();
|
||||
|
||||
void initialize(SettingsInterface* sif, std::string section_name, std::string key_name);
|
||||
|
||||
public Q_SLOTS:
|
||||
void bindToControllerAxis(int controller_index, int axis_index, bool inverted,
|
||||
std::optional<bool> half_axis_positive);
|
||||
void bindToControllerButton(int controller_index, int button_index);
|
||||
void bindToControllerHat(int controller_index, int hat_index, const QString& hat_direction);
|
||||
void beginRebindAll();
|
||||
void clearBinding();
|
||||
void reloadBinding();
|
||||
|
||||
protected Q_SLOTS:
|
||||
void onClicked();
|
||||
void onInputListenTimerTimeout();
|
||||
void inputManagerHookCallback(InputBindingKey key, float value);
|
||||
|
||||
protected:
|
||||
enum : u32
|
||||
@ -51,71 +50,45 @@ protected:
|
||||
void setNewBinding();
|
||||
void updateText();
|
||||
|
||||
QtHostInterface* m_host_interface;
|
||||
void hookInputManager();
|
||||
void unhookInputManager();
|
||||
|
||||
SettingsInterface* m_sif = nullptr;
|
||||
std::string m_section_name;
|
||||
std::string m_key_name;
|
||||
std::vector<std::string> m_bindings;
|
||||
std::string m_new_binding_value;
|
||||
std::vector<InputBindingKey> m_new_bindings;
|
||||
QTimer* m_input_listen_timer = nullptr;
|
||||
u32 m_input_listen_remaining_seconds = 0;
|
||||
|
||||
InputBindingWidget* m_next_widget = nullptr;
|
||||
bool m_is_binding_all = false;
|
||||
QPointF m_input_listen_start_position{};
|
||||
bool m_mouse_mapping_enabled = false;
|
||||
};
|
||||
|
||||
class InputButtonBindingWidget : public InputBindingWidget
|
||||
class InputVibrationBindingWidget : public QPushButton
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
InputButtonBindingWidget(QtHostInterface* host_interface, std::string section_name, std::string key_name,
|
||||
QWidget* parent);
|
||||
~InputButtonBindingWidget();
|
||||
InputVibrationBindingWidget(QWidget* parent);
|
||||
InputVibrationBindingWidget(QWidget* parent, ControllerSettingsDialog* dialog, std::string section_name,
|
||||
std::string key_name);
|
||||
~InputVibrationBindingWidget();
|
||||
|
||||
void setKey(ControllerSettingsDialog* dialog, std::string section_name, std::string key_name);
|
||||
|
||||
public Q_SLOTS:
|
||||
void clearBinding();
|
||||
|
||||
protected Q_SLOTS:
|
||||
void onClicked();
|
||||
|
||||
protected:
|
||||
void startListeningForInput(u32 timeout_in_seconds) override;
|
||||
void stopListeningForInput() override;
|
||||
void openDialog() override;
|
||||
void hookControllerInput();
|
||||
void unhookControllerInput();
|
||||
};
|
||||
|
||||
class InputAxisBindingWidget : public InputBindingWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
InputAxisBindingWidget(QtHostInterface* host_interface, std::string section_name, std::string key_name,
|
||||
Controller::AxisType axis_type, QWidget* parent);
|
||||
~InputAxisBindingWidget();
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject* watched, QEvent* event) override;
|
||||
void startListeningForInput(u32 timeout_in_seconds) override;
|
||||
void stopListeningForInput() override;
|
||||
void openDialog() override;
|
||||
void hookControllerInput();
|
||||
void unhookControllerInput();
|
||||
virtual void mouseReleaseEvent(QMouseEvent* e) override;
|
||||
|
||||
private:
|
||||
Controller::AxisType m_axis_type;
|
||||
std::string m_section_name;
|
||||
std::string m_key_name;
|
||||
std::string m_binding;
|
||||
|
||||
ControllerSettingsDialog* m_dialog;
|
||||
};
|
||||
|
||||
class InputRumbleBindingWidget : public InputBindingWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
InputRumbleBindingWidget(QtHostInterface* host_interface, std::string section_name, std::string key_name,
|
||||
QWidget* parent);
|
||||
~InputRumbleBindingWidget();
|
||||
|
||||
private Q_SLOTS:
|
||||
void bindToControllerRumble(int controller_index);
|
||||
|
||||
protected:
|
||||
void startListeningForInput(u32 timeout_in_seconds) override;
|
||||
void stopListeningForInput() override;
|
||||
void hookControllerInput();
|
||||
void unhookControllerInput();
|
||||
};
|
Reference in New Issue
Block a user