GUI: allow pulling selection in sample editor
This commit is contained in:
parent
565f67dd0f
commit
51414203b9
|
@ -6735,6 +6735,7 @@ FurnaceGUI::FurnaceGUI():
|
|||
sampleDragMode(false),
|
||||
sampleDrag16(false),
|
||||
sampleZoomAuto(true),
|
||||
sampleSelTarget(0),
|
||||
sampleDragTarget(NULL),
|
||||
sampleDragStart(0,0),
|
||||
sampleDragAreaSize(0,0),
|
||||
|
|
|
@ -1813,6 +1813,9 @@ class FurnaceGUI {
|
|||
int sampleSelStart, sampleSelEnd;
|
||||
bool sampleInfo, sampleCompatRate;
|
||||
bool sampleDragActive, sampleDragMode, sampleDrag16, sampleZoomAuto;
|
||||
// 0: start
|
||||
// 1: end
|
||||
unsigned char sampleSelTarget;
|
||||
void* sampleDragTarget;
|
||||
ImVec2 sampleDragStart;
|
||||
ImVec2 sampleDragAreaSize;
|
||||
|
|
|
@ -1224,6 +1224,31 @@ void FurnaceGUI::drawSampleEdit() {
|
|||
ImVec2 rectMax=ImGui::GetItemRectMax();
|
||||
ImVec2 rectSize=ImGui::GetItemRectSize();
|
||||
|
||||
unsigned char selectTarget=255;
|
||||
|
||||
if (ImGui::IsItemHovered()) {
|
||||
int start=sampleSelStart;
|
||||
int end=sampleSelEnd;
|
||||
if (start>end) {
|
||||
start^=end;
|
||||
end^=start;
|
||||
start^=end;
|
||||
}
|
||||
ImVec2 p1=rectMin;
|
||||
p1.x+=(start-samplePos)/sampleZoom;
|
||||
|
||||
ImVec2 p2=ImVec2(rectMin.x+(end-samplePos)/sampleZoom,rectMax.y);
|
||||
|
||||
ImVec2 mousePos=ImGui::GetMousePos();
|
||||
if (p1.x>=rectMin.x && p1.x<=rectMax.x && fabs(mousePos.x-p1.x)<2.0*dpiScale) {
|
||||
ImGui::SetMouseCursor(ImGuiMouseCursor_ResizeEW);
|
||||
selectTarget=0;
|
||||
} else if (p2.x>=rectMin.x && p2.x<=rectMax.x && fabs(mousePos.x-p2.x)<2.0*dpiScale) {
|
||||
ImGui::SetMouseCursor(ImGuiMouseCursor_ResizeEW);
|
||||
selectTarget=1;
|
||||
}
|
||||
}
|
||||
|
||||
if (ImGui::IsItemClicked()) {
|
||||
nextWindow=GUI_WINDOW_SAMPLE_EDIT;
|
||||
if (ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)) {
|
||||
|
@ -1250,9 +1275,23 @@ void FurnaceGUI::drawSampleEdit() {
|
|||
}
|
||||
sampleDragLen=sample->samples;
|
||||
sampleDragActive=true;
|
||||
sampleSelStart=-1;
|
||||
sampleSelEnd=-1;
|
||||
if (sampleDragMode) sample->prepareUndo(true);
|
||||
if (!sampleDragMode) {
|
||||
switch (selectTarget) {
|
||||
case 0:
|
||||
sampleSelStart^=sampleSelEnd;
|
||||
sampleSelEnd^=sampleSelStart;
|
||||
sampleSelStart^=sampleSelEnd;
|
||||
break;
|
||||
case 1:
|
||||
break;
|
||||
default:
|
||||
sampleSelStart=-1;
|
||||
sampleSelEnd=-1;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
sample->prepareUndo(true);
|
||||
}
|
||||
processDrags(ImGui::GetMousePos().x,ImGui::GetMousePos().y);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue