diff --git a/ImGuiToolkit.cpp b/ImGuiToolkit.cpp index b45c01d..cdbe53d 100644 --- a/ImGuiToolkit.cpp +++ b/ImGuiToolkit.cpp @@ -321,6 +321,30 @@ struct Sum int sum{0}; }; + +bool ImGuiToolkit::IconMultistate (std::vector > icons, int* state, std::vector tooltips) +{ + bool ret = false; + Sum id = std::for_each(icons.begin(), icons.end(), Sum()); + ImGui::PushID( id.sum ); + + int num_button = static_cast(icons.size()) -1; + int s = CLAMP(*state, 0, num_button); + int num_tooltips = static_cast(tooltips.size()) -1; + int t = CLAMP(*state, 0, num_tooltips); + if ( IconButton( icons[s].first, icons[s].second, tooltips[t].c_str() ) ){ + ++s; + if (s > num_button) + *state = 0; + else + *state = s; + ret = true; + } + + ImGui::PopID(); + return ret; +} + bool ImGuiToolkit::ButtonIconMultistate(std::vector > icons, int* state, const char* tooltip) { bool ret = false; diff --git a/ImGuiToolkit.h b/ImGuiToolkit.h index 4bc9907..aa35387 100644 --- a/ImGuiToolkit.h +++ b/ImGuiToolkit.h @@ -18,6 +18,7 @@ namespace ImGuiToolkit void Icon (int i, int j, bool enabled = true); bool IconButton (int i, int j, const char *tooltips = nullptr); bool IconButton (const char* icon, const char *tooltips = nullptr); + bool IconMultistate (std::vector > icons, int* state, std::vector tooltips); bool IconToggle (int i, int j, int i_toggle, int j_toggle, bool* toggle, const char *tooltips[] = nullptr); void ShowIconsWindow(bool* p_open); diff --git a/SessionCreator.cpp b/SessionCreator.cpp index 44f32b0..a4b8d29 100644 --- a/SessionCreator.cpp +++ b/SessionCreator.cpp @@ -1156,6 +1156,10 @@ void SessionLoader::visit (Play &c) bool p = true; xmlCurrent_->QueryBoolAttribute("play", &p); c.setValue(p); + + bool b = false; + xmlCurrent_->QueryBoolAttribute("bidirectional", &b); + c.setBidirectional(b); } void SessionLoader::visit (SetAlpha &c) @@ -1167,6 +1171,10 @@ void SessionLoader::visit (SetAlpha &c) float d = 0.f; xmlCurrent_->QueryFloatAttribute("duration", &d); c.setDuration(d); + + bool b = false; + xmlCurrent_->QueryBoolAttribute("bidirectional", &b); + c.setBidirectional(b); } void SessionLoader::visit (SetDepth &c) @@ -1178,6 +1186,10 @@ void SessionLoader::visit (SetDepth &c) d = 0.f; xmlCurrent_->QueryFloatAttribute("duration", &d); c.setDuration(d); + + bool b = false; + xmlCurrent_->QueryBoolAttribute("bidirectional", &b); + c.setBidirectional(b); } void SessionLoader::visit (Loom &c) diff --git a/SessionVisitor.cpp b/SessionVisitor.cpp index 479a741..d05396c 100644 --- a/SessionVisitor.cpp +++ b/SessionVisitor.cpp @@ -767,18 +767,21 @@ void SessionVisitor::visit (SourceCallback &c) void SessionVisitor::visit (Play &c) { xmlCurrent_->SetAttribute("play", c.value()); + xmlCurrent_->SetAttribute("bidirectional", c.bidirectional()); } void SessionVisitor::visit (SetAlpha &c) { xmlCurrent_->SetAttribute("alpha", c.value()); xmlCurrent_->SetAttribute("duration", c.duration()); + xmlCurrent_->SetAttribute("bidirectional", c.bidirectional()); } void SessionVisitor::visit (SetDepth &c) { xmlCurrent_->SetAttribute("depth", c.value()); xmlCurrent_->SetAttribute("duration", c.duration()); + xmlCurrent_->SetAttribute("bidirectional", c.bidirectional()); } void SessionVisitor::visit (Loom &c) diff --git a/SourceCallback.cpp b/SourceCallback.cpp index e0f0e42..9073da7 100644 --- a/SourceCallback.cpp +++ b/SourceCallback.cpp @@ -133,16 +133,12 @@ SourceCallback *ResetGeometry::clone() const return new ResetGeometry; } -SetAlpha::SetAlpha() : SourceCallback(), duration_(0.f), progress_(0.f), alpha_(0.f) +SetAlpha::SetAlpha(float alpha, float ms, bool revert) : SourceCallback(), + duration_(ms), progress_(0.f), alpha_(alpha), bidirectional_(revert) { + alpha_ = CLAMP(alpha_, 0.f, 1.f); start_ = glm::vec2(); - target_ = glm::vec2(); -} - -SetAlpha::SetAlpha(float alpha, float duration) : SetAlpha() -{ - alpha_ = CLAMP(alpha, 0.f, 1.f); - duration_ = duration; + target_ = glm::vec2(); } void SetAlpha::update(Source *s, float dt) @@ -188,7 +184,7 @@ void SetAlpha::update(Source *s, float dt) // perform movement if ( ABS(duration_) > 0.f) - s->group(View::MIXING)->translation_ = glm::vec3(start_ + (progress_/duration_) * target_, s->group(View::MIXING)->translation_.z); + s->group(View::MIXING)->translation_ = glm::vec3(start_ + (progress_/duration_)*(target_ - start_), s->group(View::MIXING)->translation_.z); // time-out if ( progress_ > duration_ ) { @@ -210,12 +206,12 @@ void SetAlpha::multiply (float factor) SourceCallback *SetAlpha::clone() const { - return new SetAlpha(alpha_); + return new SetAlpha(alpha_, duration_, bidirectional_); } SourceCallback *SetAlpha::reverse(Source *s) const { - return new SetAlpha(s->alpha()); + return bidirectional_ ? new SetAlpha(s->alpha(), duration_) : nullptr; } void SetAlpha::accept(Visitor& v) @@ -224,15 +220,10 @@ void SetAlpha::accept(Visitor& v) v.visit(*this); } -Lock::Lock() : SourceCallback(), lock_(true) +Lock::Lock(bool on) : lock_(on) { } -Lock::Lock(bool on) : Lock() -{ - lock_ = on; -} - void Lock::update(Source *s, float) { if (s) @@ -246,16 +237,10 @@ SourceCallback *Lock::clone() const return new Lock(lock_); } -Loom::Loom() : SourceCallback(), speed_(0), duration_(0), progress_(0.f) -{ - pos_ = glm::vec2(); - step_ = glm::normalize(glm::vec2(1.f, 1.f)); // step in diagonal by default -} -Loom::Loom(float d, float duration) : Loom() +Loom::Loom(float speed, float ms) : SourceCallback(), + speed_(speed), duration_(ms), progress_(0.f) { - speed_ = d; - duration_ = duration; pos_ = glm::vec2(); step_ = glm::normalize(glm::vec2(1.f, 1.f)); // step in diagonal by default } @@ -282,9 +267,9 @@ void Loom::update(Source *s, float dt) // move target by speed vector (in the direction of step_, amplitude of speed * time (in second)) pos_ -= step_ * ( speed_ * dt * 0.001f ); - // apply alpha if valid in range [0 1] - float alpha = SourceCore::alphaFromCordinates(pos_.x, pos_.y); - if ( alpha > DELTA_ALPHA && alpha < 1.0 - DELTA_ALPHA ) + // apply alpha if pos in range [0 MIXING_MIN_THRESHOLD] + float l = glm::length( pos_ ); + if ( (l > 0.01f && speed_ > 0.f ) || (l < MIXING_MIN_THRESHOLD && speed_ < 0.f ) ) s->group(View::MIXING)->translation_ = glm::vec3(pos_, s->group(View::MIXING)->translation_.z); // time-out @@ -314,15 +299,11 @@ void Loom::accept(Visitor& v) } -SetDepth::SetDepth() : SourceCallback(), - duration_(0), progress_(0.f), start_(0.f), target_(MIN_DEPTH) -{ -} -SetDepth::SetDepth(float target, float duration) : SetDepth() +SetDepth::SetDepth(float target, float ms, bool revert) : SourceCallback(), + duration_(ms), progress_(0.f), start_(0.f), target_(target), bidirectional_(revert) { - target_ = CLAMP(target, MIN_DEPTH, MAX_DEPTH); - duration_ = duration; + target_ = CLAMP(target_, MIN_DEPTH, MAX_DEPTH); } void SetDepth::update(Source *s, float dt) @@ -363,12 +344,12 @@ void SetDepth::multiply (float factor) SourceCallback *SetDepth::clone() const { - return new SetDepth(target_, duration_); + return new SetDepth(target_, duration_, bidirectional_); } SourceCallback *SetDepth::reverse(Source *s) const { - return new SetDepth(s->depth(), duration_); + return bidirectional_ ? new SetDepth(s->depth(), duration_) : nullptr; } void SetDepth::accept(Visitor& v) @@ -377,15 +358,10 @@ void SetDepth::accept(Visitor& v) v.visit(*this); } -Play::Play() : SourceCallback(), play_(true) +Play::Play(bool on, bool revert) : SourceCallback(), play_(on), bidirectional_(revert) { } -Play::Play(bool on) : Play() -{ - play_ = on; -} - void Play::update(Source *s, float) { if (s && s->playing() != play_) { @@ -398,12 +374,12 @@ void Play::update(Source *s, float) SourceCallback *Play::clone() const { - return new Play(play_); + return new Play(play_, bidirectional_); } SourceCallback *Play::reverse(Source *s) const { - return new Play(s->playing()); + return bidirectional_ ? new Play(s->playing()) : nullptr; } void Play::accept(Visitor& v) @@ -431,16 +407,11 @@ SourceCallback *RePlay::clone() const return new RePlay; } -Grab::Grab() : SourceCallback(), speed_(glm::vec2(0.f)), duration_(0.f), progress_(0.f) +Grab::Grab(float dx, float dy, float ms) : SourceCallback(), + speed_(glm::vec2(dx, dy)), duration_(ms), progress_(0.f) { } -Grab::Grab(float dx, float dy, float duration) : Grab() -{ - speed_ = glm::vec2(dx,dy); - duration_ = duration; -} - void Grab::update(Source *s, float dt) { if (s && !s->locked()) { @@ -486,16 +457,11 @@ void Grab::accept(Visitor& v) v.visit(*this); } -Resize::Resize() : SourceCallback(), speed_(glm::vec2(0.f)), duration_(0.f), progress_(0.f) +Resize::Resize(float dx, float dy, float ms) : SourceCallback(), + speed_(glm::vec2(dx, dy)), duration_(ms), progress_(0.f) { } -Resize::Resize(float dx, float dy, float duration) : Resize() -{ - speed_ = glm::vec2(dx,dy); - duration_ = duration; -} - void Resize::update(Source *s, float dt) { if (s && !s->locked()) { @@ -541,16 +507,11 @@ void Resize::accept(Visitor& v) v.visit(*this); } -Turn::Turn() : SourceCallback(), speed_(0.f), duration_(0.f), progress_(0.f) +Turn::Turn(float speed, float ms) : SourceCallback(), + speed_(speed), duration_(ms), progress_(0.f) { } -Turn::Turn(float da, float duration) : Turn() -{ - speed_ = da; - duration_ = duration; -} - void Turn::update(Source *s, float dt) { if (s && !s->locked()) { diff --git a/SourceCallback.h b/SourceCallback.h index 7650397..371034a 100644 --- a/SourceCallback.h +++ b/SourceCallback.h @@ -61,15 +61,17 @@ class SetAlpha : public SourceCallback float alpha_; glm::vec2 start_; glm::vec2 target_; + bool bidirectional_; public: - SetAlpha (); - SetAlpha (float alpha, float duration = 0.f); + SetAlpha (float alpha = 0.f, float ms = 0.f, bool revert = false); - float value () const { return alpha_;} + float value () const { return alpha_; } void setValue (float a) { alpha_ = a; } - float duration () const { return duration_;} - void setDuration (float d) { duration_ = d; } + float duration () const { return duration_; } + void setDuration (float ms) { duration_ = ms; } + bool bidirectional () const { return bidirectional_; } + void setBidirectional (bool on) { bidirectional_ = on; } void update (Source *s, float) override; void multiply (float factor) override; @@ -88,13 +90,12 @@ class Loom : public SourceCallback float progress_; public: - Loom (); - Loom (float d, float duration = 0.f); + Loom (float speed = 0.f, float ms = 0.f); - float value () const { return speed_;} + float value () const { return speed_; } void setValue (float d) { speed_ = d; } - float duration () const { return duration_;} - void setDuration (float d) { duration_ = d; } + float duration () const { return duration_; } + void setDuration (float ms) { duration_ = ms; } void update (Source *s, float) override; void multiply (float factor) override; @@ -108,11 +109,10 @@ class Lock : public SourceCallback bool lock_; public: - Lock (); - Lock (bool on); + Lock (bool on = true); bool value () const { return lock_;} - void setValue (bool l) { lock_ = l;} + void setValue (bool on) { lock_ = on;} void update (Source *s, float) override; SourceCallback *clone() const override; @@ -125,15 +125,17 @@ class SetDepth : public SourceCallback float progress_; float start_; float target_; + bool bidirectional_; public: - SetDepth (); - SetDepth (float depth, float duration = 0.f); + SetDepth (float depth = 0.f, float ms = 0.f, bool revert = false); float value () const { return target_;} void setValue (float d) { target_ = d; } float duration () const { return duration_;} - void setDuration (float d) { duration_ = d; } + void setDuration (float ms) { duration_ = ms; } + bool bidirectional () const { return bidirectional_;} + void setBidirectional (bool on) { bidirectional_ = on; } void update (Source *s, float dt) override; void multiply (float factor) override; @@ -146,13 +148,15 @@ public: class Play : public SourceCallback { bool play_; + bool bidirectional_; public: - Play (); - Play (bool on); + Play (bool on = true, bool revert = false); bool value () const { return play_;} void setValue (bool on) { play_ = on; } + bool bidirectional () const { return bidirectional_;} + void setBidirectional (bool on) { bidirectional_ = on; } void update (Source *s, float) override; SourceCallback *clone() const override; @@ -179,13 +183,12 @@ class Grab : public SourceCallback float progress_; public: - Grab(); - Grab(float dx, float dy, float duration = 0.f); + Grab(float dx = 0.f, float dy = 0.f, float ms = 0.f); - glm::vec2 value () const { return speed_;} + glm::vec2 value () const { return speed_; } void setValue (glm::vec2 d) { speed_ = d; } - float duration () const { return duration_;} - void setDuration (float d) { duration_ = d; } + float duration () const { return duration_; } + void setDuration (float ns) { duration_ = ns; } void update (Source *s, float) override; void multiply (float factor) override; @@ -202,13 +205,12 @@ class Resize : public SourceCallback float progress_; public: - Resize(); - Resize(float dx, float dy, float duration = 0.f); + Resize(float dx = 0.f, float dy = 0.f, float ms = 0.f); - glm::vec2 value () const { return speed_;} + glm::vec2 value () const { return speed_; } void setValue (glm::vec2 d) { speed_ = d; } - float duration () const { return duration_;} - void setDuration (float d) { duration_ = d; } + float duration () const { return duration_; } + void setDuration (float ms) { duration_ = ms; } void update (Source *s, float) override; void multiply (float factor) override; @@ -225,13 +227,12 @@ class Turn : public SourceCallback float progress_; public: - Turn(); - Turn(float da, float duration = 0.f); + Turn(float speed = 0.f, float ms = 0.f); - float value () const { return speed_;} + float value () const { return speed_; } void setValue (float d) { speed_ = d; } - float duration () const { return duration_;} - void setDuration (float d) { duration_ = d; } + float duration () const { return duration_; } + void setDuration (float ms) { duration_ = ms; } void update (Source *s, float) override; void multiply (float factor) override; diff --git a/UserInterfaceManager.cpp b/UserInterfaceManager.cpp index e33b053..a146de8 100644 --- a/UserInterfaceManager.cpp +++ b/UserInterfaceManager.cpp @@ -4349,8 +4349,6 @@ Source *InputMappingInterface::ComboSelectSource(Source *current) uint InputMappingInterface::ComboSelectCallback(uint current) { - uint selected = SourceCallback::CALLBACK_GENERIC; - const char* callback_names[9] = { "Select", ICON_FA_BULLSEYE " Alpha", ICON_FA_BULLSEYE " Loom", @@ -4362,7 +4360,7 @@ uint InputMappingInterface::ComboSelectCallback(uint current) ICON_FA_PLAY_CIRCLE " Replay" }; - ImGui::SetNextItemWidth(-1.1f * ImGui::GetTextLineHeightWithSpacing()); + int selected = 0; if (ImGui::BeginCombo("##ComboSelectCallback", callback_names[current]) ) { for (uint i = SourceCallback::CALLBACK_ALPHA; i < SourceCallback::CALLBACK_REPLAY; ++i){ if ( ImGui::Selectable( callback_names[i]) ) { @@ -4371,94 +4369,145 @@ uint InputMappingInterface::ComboSelectCallback(uint current) } ImGui::EndCombo(); } - ImGui::SameLine(); - if (current == 1 || current == 6 || current == 7) - ImGuiToolkit::Indication("* On Press *\nApply target value on key press,\nrevert on key up.", 2, 13); - else - ImGuiToolkit::Indication("* Repeat *\nMaintain key down to loop action and animate.", 18, 5); return selected; } +struct ClosestIndex +{ + int index; + float val; + ClosestIndex (float v) { val = v; index = 0; } + void operator()(float v) { if (v < val) ++index; } +}; + void InputMappingInterface::SliderParametersCallback(SourceCallback *callback) { - const float right_align = -1.1f * ImGui::GetTextLineHeightWithSpacing(); + const float right_align = -1.05f * ImGui::GetTextLineHeightWithSpacing(); + static const char *press_tooltip[3] = {"Key Press\nApply value on key press", + "Key Down\nApply value on key down,\nrevert on key up", + "Repeat\nMaintain key down to repeat and iterate" }; + static std::vector< std::pair > speed_icon = { {18,15}, {17,15}, {16,15}, {15,15}, {14,15} }; + static std::vector< std::string > speed_tooltip = { "Fastest\n0 ms", "Fast\n60 ms", "Smooth\n120 ms", "Slow\n240 ms", "Slowest\n500 ms" }; + static std::vector< float > speed_values = { 0.f, 60.f, 120.f, 240.f, 500.f }; switch ( callback->type() ) { case SourceCallback::CALLBACK_ALPHA: { SetAlpha *edited = static_cast(callback); + + bool bd = edited->bidirectional(); + if ( ImGuiToolkit::IconToggle(2, 13, 3, 13, &bd, press_tooltip ) ) + edited->setBidirectional(bd); + + ClosestIndex d = std::for_each(speed_values.begin(), speed_values.end(), ClosestIndex(edited->duration())); + int speed_index = d.index; + ImGui::SameLine(0, IMGUI_SAME_LINE / 2); + if (ImGuiToolkit::IconMultistate(speed_icon, &speed_index, speed_tooltip )) + edited->setDuration(speed_values[speed_index]); + float val = edited->value(); + ImGui::SameLine(0, IMGUI_SAME_LINE / 2); ImGui::SetNextItemWidth(right_align); if (ImGui::SliderFloat("##CALLBACK_ALPHA", &val, 0.f, 1.f, "%.2f")) edited->setValue(val); - ImGui::SameLine(0, 6); - ImGuiToolkit::Indication("Target alpha to make the source\nvisible (1.0) or transparent (0.0)", 18, 12); + + ImGui::SameLine(0, IMGUI_SAME_LINE / 2); + ImGuiToolkit::Indication("Target alpha makes the source\nvisible (1.0) or transparent (0.0)", 18, 12); + } break; case SourceCallback::CALLBACK_LOOM: { + ImGuiToolkit::Indication(press_tooltip[2], 18, 5); + ImGui::SameLine(0, IMGUI_SAME_LINE / 2); Loom *edited = static_cast(callback); float val = edited->value(); ImGui::SetNextItemWidth(right_align); if (ImGui::SliderFloat("##CALLBACK_LOOM", &val, -1.f, 1.f, "%.2f", 2.f)) edited->setValue(val); - ImGui::SameLine(0, 6); - ImGuiToolkit::Indication("Change alpha to make source more visible (>0) or more transparent (<0)", 19, 12); + ImGui::SameLine(0, IMGUI_SAME_LINE / 2); + ImGuiToolkit::Indication("Increment making the source more visible (>0) or more transparent (<0)", 19, 12); } break; case SourceCallback::CALLBACK_GRAB: { + ImGuiToolkit::Indication(press_tooltip[2], 18, 5); + ImGui::SameLine(0, IMGUI_SAME_LINE / 2); Grab *edited = static_cast(callback); float val[2] = {edited->value().x, edited->value().y}; ImGui::SetNextItemWidth(right_align); if (ImGui::SliderFloat2("##CALLBACK_GRAB", val, -2.f, 2.f, "%.2f")) edited->setValue( glm::vec2(val[0], val[1])); - ImGui::SameLine(0, 6); - ImGuiToolkit::Indication("Vector (x,y) to move the source horizontally and vertically.", 6, 15); + ImGui::SameLine(0, IMGUI_SAME_LINE / 2); + ImGuiToolkit::Indication("Vector (x,y) moving the source horizontally and vertically.", 6, 15); } break; case SourceCallback::CALLBACK_RESIZE: { + ImGuiToolkit::Indication(press_tooltip[2], 18, 5); + ImGui::SameLine(0, IMGUI_SAME_LINE / 2); Resize *edited = static_cast(callback); float val[2] = {edited->value().x, edited->value().y}; ImGui::SetNextItemWidth(right_align); if (ImGui::SliderFloat2("##CALLBACK_RESIZE", val, -2.f, 2.f, "%.2f")) edited->setValue( glm::vec2(val[0], val[1])); - ImGui::SameLine(0, 6); - ImGuiToolkit::Indication("Vector (x,y) to scale the source horizontally and vertically.", 2, 15); + ImGui::SameLine(0, IMGUI_SAME_LINE / 2); + ImGuiToolkit::Indication("Vector (x,y) scaling the source horizontally and vertically.", 2, 15); } break; case SourceCallback::CALLBACK_TURN: { + ImGuiToolkit::Indication(press_tooltip[2], 18, 5); + ImGui::SameLine(0, IMGUI_SAME_LINE / 2); Turn *edited = static_cast(callback); float val = edited->value(); ImGui::SetNextItemWidth(right_align); if (ImGui::SliderFloat("##CALLBACK_TURN", &val, -2.f, 2.f, "%.2f")) // 18.9 edited->setValue(val); - ImGui::SameLine(0, 6); + ImGui::SameLine(0, IMGUI_SAME_LINE / 2); ImGuiToolkit::Indication("Angle of rotation of the source, clockwise (>0) or counter-clockwise (<0).", 18, 9); } break; case SourceCallback::CALLBACK_DEPTH: { SetDepth *edited = static_cast(callback); + + bool bd = edited->bidirectional(); + if ( ImGuiToolkit::IconToggle(2, 13, 3, 13, &bd, press_tooltip ) ) + edited->setBidirectional(bd); + + ClosestIndex d = std::for_each(speed_values.begin(), speed_values.end(), ClosestIndex(edited->duration())); + int speed_index = d.index; + ImGui::SameLine(0, IMGUI_SAME_LINE / 2); + if (ImGuiToolkit::IconMultistate(speed_icon, &speed_index, speed_tooltip )) + edited->setDuration(speed_values[speed_index]); + float val = edited->value(); ImGui::SetNextItemWidth(right_align); + ImGui::SameLine(0, IMGUI_SAME_LINE / 2); if (ImGui::SliderFloat("##CALLBACK_DEPTH", &val, 11.9f, 0.1f, "%.1f")) edited->setValue(val); - ImGui::SameLine(0, 6); - ImGuiToolkit::Indication("Target depth to bring the source\nfront (12) or back (0).", 6, 6); + + ImGui::SameLine(0, IMGUI_SAME_LINE / 2); + ImGuiToolkit::Indication("Target depth brings the source\nfront (12) or back (0).", 6, 6); } + break; case SourceCallback::CALLBACK_PLAY: { Play *edited = static_cast(callback); + + bool bd = edited->bidirectional(); + if ( ImGuiToolkit::IconToggle(2, 13, 3, 13, &bd, press_tooltip ) ) + edited->setBidirectional(bd); + ImGui::SameLine(0, IMGUI_SAME_LINE / 2); + int val = edited->value() ? 1 : 0; ImGui::SetNextItemWidth(right_align); if (ImGui::SliderInt("##CALLBACK_PLAY", &val, 0, 1, val ? "Play" : "Pause")) edited->setValue(val>0); - ImGui::SameLine(0, 6); + ImGui::SameLine(0, IMGUI_SAME_LINE / 2); ImGuiToolkit::Indication("Play or pause the source.", 16, 7); } break; @@ -4957,9 +5006,10 @@ void InputMappingInterface::Render() ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(2.f, g.Style.ItemSpacing.y * 2.f) ); ImGui::BeginChild("InputsMappingInterfacePanel", ImVec2(0, 0), true); + float w = ImGui::GetWindowWidth() *0.25f; + if (input_assigned[current_input_]) { - ImGui::Columns(3, "InputMapping", false); auto result = input_sources_callbacks.equal_range(current_input_); for (auto kit = result.first; kit != result.second; ++kit) { @@ -4979,7 +5029,7 @@ void InputMappingInterface::Render() // Select Source ImGui::SameLine(0, IMGUI_SAME_LINE); - ImGui::SetNextItemWidth( -FLT_MIN); + ImGui::SetNextItemWidth(w); Source *select = ComboSelectSource(source); if (select != nullptr) { // copy callback to other source @@ -4992,8 +5042,8 @@ void InputMappingInterface::Render() } // Select Reaction - ImGui::NextColumn(); - ImGui::SetNextItemWidth( -FLT_MIN); + ImGui::SameLine(0, IMGUI_SAME_LINE); + ImGui::SetNextItemWidth(w); uint type = ComboSelectCallback( callback->type() ); if (type > 0) { // remove previous callback @@ -5006,11 +5056,10 @@ void InputMappingInterface::Render() } // Adjust parameters - ImGui::NextColumn(); + ImGui::SameLine(0, IMGUI_SAME_LINE); if (callback) SliderParametersCallback( callback ); - ImGui::NextColumn(); ImGui::PopID(); } @@ -5026,7 +5075,6 @@ void InputMappingInterface::Render() static Source *temp_new_source = nullptr; static uint temp_new_callback = 0; - ImGui::Columns(3, "NewInputMapping", false); // step 1 : press '+' if (temp_new_input) { if (ImGuiToolkit::IconButton(ICON_FA_TIMES, "Cancel") ){ @@ -5041,7 +5089,7 @@ void InputMappingInterface::Render() if (temp_new_input) { // step 2 : Get input for source ImGui::SameLine(0, IMGUI_SAME_LINE); - ImGui::SetNextItemWidth( -FLT_MIN); + ImGui::SetNextItemWidth(w); Source *s = ComboSelectSource(temp_new_source); // user selected a source (or changed selection) if (s != nullptr) { @@ -5051,8 +5099,8 @@ void InputMappingInterface::Render() // possible new source if (temp_new_source != nullptr) { // step 3: Get input for callback type - ImGui::NextColumn(); - ImGui::SetNextItemWidth( -FLT_MIN); + ImGui::SameLine(0, IMGUI_SAME_LINE); + ImGui::SetNextItemWidth(w); temp_new_callback = ComboSelectCallback( temp_new_callback ); // user selected a callback type if (temp_new_callback > 0) { @@ -5065,7 +5113,6 @@ void InputMappingInterface::Render() } } } - ImGui::Columns(1); ImGui::EndChild(); ImGui::PopStyleVar(2); diff --git a/rsc/images/icons.dds b/rsc/images/icons.dds index e162711..73f0d47 100644 Binary files a/rsc/images/icons.dds and b/rsc/images/icons.dds differ