mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-11 18:34:58 +01:00
Minor UI improvement Input Mapping
This commit is contained in:
21
Source.cpp
21
Source.cpp
@@ -690,12 +690,27 @@ void Source::removeInputCallback(SourceCallback *callback)
|
|||||||
{
|
{
|
||||||
if ( k->second.model_ == callback) {
|
if ( k->second.model_ == callback) {
|
||||||
delete callback;
|
delete callback;
|
||||||
|
if (k->second.reverse_)
|
||||||
|
delete k->second.reverse_;
|
||||||
input_callbacks_.erase(k);
|
input_callbacks_.erase(k);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Source::clearInputCallbacks()
|
||||||
|
{
|
||||||
|
for (auto k = input_callbacks_.begin(); k != input_callbacks_.end(); )
|
||||||
|
{
|
||||||
|
if (k->second.model_)
|
||||||
|
delete k->second.model_;
|
||||||
|
if (k->second.reverse_)
|
||||||
|
delete k->second.reverse_;
|
||||||
|
|
||||||
|
k = input_callbacks_.erase(k);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::list<SourceCallback *> Source::inputCallbacks(uint input)
|
std::list<SourceCallback *> Source::inputCallbacks(uint input)
|
||||||
{
|
{
|
||||||
std::list<SourceCallback *> ret;
|
std::list<SourceCallback *> ret;
|
||||||
@@ -741,15 +756,15 @@ void Source::updateCallbacks(float dt)
|
|||||||
|
|
||||||
// ON PRESS
|
// ON PRESS
|
||||||
if (activate) {
|
if (activate) {
|
||||||
// delete the reverse if was not released
|
|
||||||
if (k->second.reverse_ != nullptr)
|
|
||||||
delete k->second.reverse_;
|
|
||||||
// generate a new callback from the model
|
// generate a new callback from the model
|
||||||
SourceCallback *C = k->second.model_->clone();
|
SourceCallback *C = k->second.model_->clone();
|
||||||
// apply value multiplyer from input
|
// apply value multiplyer from input
|
||||||
C->multiply( Control::inputValue(k->first) );
|
C->multiply( Control::inputValue(k->first) );
|
||||||
// add callback to the source (force override)
|
// add callback to the source (force override)
|
||||||
call( C, true );
|
call( C, true );
|
||||||
|
// delete the reverse if was not released
|
||||||
|
if (k->second.reverse_ != nullptr)
|
||||||
|
delete k->second.reverse_;
|
||||||
// get the reverse if the callback, and remember it (can be null)
|
// get the reverse if the callback, and remember it (can be null)
|
||||||
k->second.reverse_ = C->reverse(this);
|
k->second.reverse_ = C->reverse(this);
|
||||||
}
|
}
|
||||||
|
|||||||
1
Source.h
1
Source.h
@@ -153,6 +153,7 @@ public:
|
|||||||
void removeInputCallback(SourceCallback *callback);
|
void removeInputCallback(SourceCallback *callback);
|
||||||
std::list<SourceCallback *> inputCallbacks(uint input);
|
std::list<SourceCallback *> inputCallbacks(uint input);
|
||||||
std::list<uint> callbackInputs();
|
std::list<uint> callbackInputs();
|
||||||
|
void clearInputCallbacks();
|
||||||
|
|
||||||
// update mode
|
// update mode
|
||||||
inline bool active () const { return active_; }
|
inline bool active () const { return active_; }
|
||||||
|
|||||||
@@ -2243,7 +2243,7 @@ void SourceController::Render()
|
|||||||
Mixer::selection().clear();
|
Mixer::selection().clear();
|
||||||
selection_ = playable_only( Mixer::manager().session()->getDepthSortedList() );
|
selection_ = playable_only( Mixer::manager().session()->getDepthSortedList() );
|
||||||
}
|
}
|
||||||
if (ImGui::MenuItem( ICON_FA_WIND " Clear")) {
|
if (ImGui::MenuItem( ICON_FA_ELLIPSIS_H " List none")) {
|
||||||
selection_.clear();
|
selection_.clear();
|
||||||
resetActiveSelection();
|
resetActiveSelection();
|
||||||
Mixer::manager().unsetCurrentSource();
|
Mixer::manager().unsetCurrentSource();
|
||||||
@@ -4288,7 +4288,7 @@ void TimerMetronome::Render()
|
|||||||
|
|
||||||
InputMappingInterface::InputMappingInterface() : WorkspaceWindow("InputMappingInterface")
|
InputMappingInterface::InputMappingInterface() : WorkspaceWindow("InputMappingInterface")
|
||||||
{
|
{
|
||||||
input_mode = { ICON_FA_KEYBOARD " Keyboard", ICON_FA_CALCULATOR " Numpad" , ICON_FA_GAMEPAD " Gamepad" };
|
input_mode = { ICON_FA_KEYBOARD " Keyboard", ICON_FA_CALCULATOR " Numpad" , ICON_FA_GAMEPAD " Gamepad" };
|
||||||
current_input_for_mode = { INPUT_KEYBOARD_FIRST, INPUT_NUMPAD_FIRST, INPUT_JOYSTICK_FIRST };
|
current_input_for_mode = { INPUT_KEYBOARD_FIRST, INPUT_NUMPAD_FIRST, INPUT_JOYSTICK_FIRST };
|
||||||
current_input_ = current_input_for_mode[Settings::application.mapping.mode];
|
current_input_ = current_input_for_mode[Settings::application.mapping.mode];
|
||||||
}
|
}
|
||||||
@@ -4459,6 +4459,8 @@ void InputMappingInterface::SliderParametersCallback(SourceCallback *callback)
|
|||||||
|
|
||||||
void InputMappingInterface::Render()
|
void InputMappingInterface::Render()
|
||||||
{
|
{
|
||||||
|
Session *ses = Mixer::manager().session();
|
||||||
|
|
||||||
const ImGuiContext& g = *GImGui;
|
const ImGuiContext& g = *GImGui;
|
||||||
static ImVec2 keyLetterIconSize = ImVec2(60, 60);
|
static ImVec2 keyLetterIconSize = ImVec2(60, 60);
|
||||||
static ImVec2 keyLetterItemSize = keyLetterIconSize + g.Style.ItemSpacing;
|
static ImVec2 keyLetterItemSize = keyLetterIconSize + g.Style.ItemSpacing;
|
||||||
@@ -4486,9 +4488,15 @@ void InputMappingInterface::Render()
|
|||||||
Settings::application.widget.inputs = false;
|
Settings::application.widget.inputs = false;
|
||||||
if (ImGui::BeginMenu(IMGUI_TITLE_INPUT_MAPPING))
|
if (ImGui::BeginMenu(IMGUI_TITLE_INPUT_MAPPING))
|
||||||
{
|
{
|
||||||
// Enable/Disable
|
// Disable
|
||||||
ImGui::MenuItem( ICON_FA_BAN " Disable", nullptr, &Settings::application.mapping.disabled);
|
ImGui::MenuItem( ICON_FA_BAN " Disable", nullptr, &Settings::application.mapping.disabled);
|
||||||
|
|
||||||
|
// Clear
|
||||||
|
if ( ImGui::MenuItem( ICON_FA_BACKSPACE " Clear" ) ){
|
||||||
|
for (auto sit = ses->begin(); sit != ses->end(); ++sit)
|
||||||
|
(*sit)->clearInputCallbacks();
|
||||||
|
}
|
||||||
|
|
||||||
// output manager menu
|
// output manager menu
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
bool pinned = Settings::application.widget.inputs_view == Settings::application.current_view;
|
bool pinned = Settings::application.widget.inputs_view == Settings::application.current_view;
|
||||||
@@ -4525,8 +4533,6 @@ void InputMappingInterface::Render()
|
|||||||
const ImGuiWindow* window = ImGui::GetCurrentWindow();
|
const ImGuiWindow* window = ImGui::GetCurrentWindow();
|
||||||
ImDrawList* draw_list = window->DrawList;
|
ImDrawList* draw_list = window->DrawList;
|
||||||
ImVec2 frame_top = ImGui::GetCursorScreenPos();
|
ImVec2 frame_top = ImGui::GetCursorScreenPos();
|
||||||
Session *ses = Mixer::manager().session();
|
|
||||||
|
|
||||||
|
|
||||||
// create data structures more adapted for display
|
// create data structures more adapted for display
|
||||||
std::multimap< uint, std::pair<Source *, SourceCallback*> > input_sources_callbacks;
|
std::multimap< uint, std::pair<Source *, SourceCallback*> > input_sources_callbacks;
|
||||||
@@ -4798,7 +4804,7 @@ void InputMappingInterface::Render()
|
|||||||
|
|
||||||
if (input_sources_callbacks.count(current_input_) < 1) {
|
if (input_sources_callbacks.count(current_input_) < 1) {
|
||||||
|
|
||||||
ImGui::Text("No action associated to this input. Create a new one with '+'.");
|
ImGui::Text("No action mapped to this input. Add one with '+'.");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
@@ -4813,7 +4819,7 @@ void InputMappingInterface::Render()
|
|||||||
ImGui::PushID( (void*) callback);
|
ImGui::PushID( (void*) callback);
|
||||||
|
|
||||||
// Delete interface
|
// Delete interface
|
||||||
if (ImGuiToolkit::IconButton(ICON_FA_MINUS, "Delete") ){
|
if (ImGuiToolkit::IconButton(ICON_FA_MINUS, "Remove") ){
|
||||||
source->removeInputCallback(callback);
|
source->removeInputCallback(callback);
|
||||||
// reload
|
// reload
|
||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
@@ -4867,8 +4873,16 @@ void InputMappingInterface::Render()
|
|||||||
|
|
||||||
ImGui::Columns(3, "NewInputMapping", false);
|
ImGui::Columns(3, "NewInputMapping", false);
|
||||||
// step 1 : press '+'
|
// step 1 : press '+'
|
||||||
if (ImGuiToolkit::IconButton(ICON_FA_PLUS, "New") )
|
if (temp_new_input) {
|
||||||
|
if (ImGuiToolkit::IconButton(ICON_FA_TIMES, "Cancel") ){
|
||||||
|
temp_new_source = nullptr;
|
||||||
|
temp_new_callback = 0;
|
||||||
|
temp_new_input = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (ImGuiToolkit::IconButton(ICON_FA_PLUS, "Add mapping") )
|
||||||
temp_new_input = true;
|
temp_new_input = true;
|
||||||
|
|
||||||
if (temp_new_input) {
|
if (temp_new_input) {
|
||||||
// step 2 : Get input for source
|
// step 2 : Get input for source
|
||||||
ImGui::SameLine(0, IMGUI_SAME_LINE);
|
ImGui::SameLine(0, IMGUI_SAME_LINE);
|
||||||
|
|||||||
Reference in New Issue
Block a user