Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ngscopeclient/scopehal-apps
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 802ce4297986
Choose a base ref
...
head repository: ngscopeclient/scopehal-apps
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: f521d50c28df
Choose a head ref
  • 1 commit
  • 5 files changed
  • 1 contributor

Commits on May 22, 2020

  1. WaveformArea: dragging waveform to the far bottom/right of a waveform…

    … area now creates a new group. Fixes #102.
    azonenberg committed May 22, 2020
    Copy the full SHA
    f521d50 View commit details
Showing with 101 additions and 28 deletions.
  1. +3 −1 glscopeclient/WaveformArea.h
  2. +44 −15 glscopeclient/WaveformArea_cairo.cpp
  3. +30 −12 glscopeclient/WaveformArea_events.cpp
  4. +21 −0 glscopeclient/WaveformGroup.cpp
  5. +3 −0 glscopeclient/WaveformGroup.h
4 changes: 3 additions & 1 deletion glscopeclient/WaveformArea.h
Original file line number Diff line number Diff line change
@@ -433,7 +433,9 @@ class WaveformArea : public Gtk::GLArea
{
INSERT_NONE,
INSERT_BOTTOM,
INSERT_TOP
INSERT_BOTTOM_SPLIT,
INSERT_TOP,
INSERT_RIGHT_SPLIT
} m_insertionBarLocation;
WaveformArea* m_dropTarget;

59 changes: 44 additions & 15 deletions glscopeclient/WaveformArea_cairo.cpp
Original file line number Diff line number Diff line change
@@ -572,25 +572,54 @@ void WaveformArea::RenderCursors(Cairo::RefPtr< Cairo::Context > cr)
}

//Render the insertion bar, if needed
Gdk::Color bar("red");
cr->set_source_rgba(bar.get_red_p(), bar.get_green_p(), bar.get_blue_p(), 0.5);
int barheight = 10;
if(m_insertionBarLocation == INSERT_BOTTOM)
Gdk::Color red("red");
int barpos = 0;
float alpha = 0.75;
int barsize = 5;
bool barhorz = true;
switch(m_insertionBarLocation)
{
cr->move_to(0, ybot);
cr->line_to(m_width, ybot);
cr->line_to(m_width, ybot - barheight);
cr->line_to(0, ybot - barheight);
cr->fill();
case INSERT_BOTTOM:
cr->set_source_rgba(yellow.get_red_p(), yellow.get_green_p(), yellow.get_blue_p(), alpha);
barpos = ybot - barsize;
break;

case INSERT_BOTTOM_SPLIT:
cr->set_source_rgba(orange.get_red_p(), orange.get_green_p(), orange.get_blue_p(), alpha);
barpos = ybot - barsize;
break;

case INSERT_TOP:
cr->set_source_rgba(yellow.get_red_p(), yellow.get_green_p(), yellow.get_blue_p(), alpha);
barpos = 0;
break;

case INSERT_RIGHT_SPLIT:
cr->set_source_rgba(orange.get_red_p(), orange.get_green_p(), orange.get_blue_p(), alpha);
barhorz = false;
barpos = m_width - barsize;
break;

//no bar to draw
default:
return;
}
else if(m_insertionBarLocation == INSERT_TOP)

if(barhorz)
{
cr->move_to(0, ytop);
cr->line_to(m_width, ytop);
cr->line_to(m_width, ytop + barheight);
cr->line_to(0, ytop + barheight);
cr->fill();
cr->move_to(0, barpos);
cr->line_to(m_width, barpos);
cr->line_to(m_width, barpos + barsize);
cr->line_to(0, barpos + barsize);
}
else
{
cr->move_to(barpos, 0);
cr->line_to(barpos + barsize, 0);
cr->line_to(barpos + barsize, m_height);
cr->line_to(barpos, m_height);
}
cr->fill();
}


42 changes: 30 additions & 12 deletions glscopeclient/WaveformArea_events.cpp
Original file line number Diff line number Diff line change
@@ -390,20 +390,28 @@ bool WaveformArea::on_button_release_event(GdkEventButton* event)
if(m_dropTarget->m_group != m_group)
m_parent->OnMoveToExistingGroup(this, m_dropTarget->m_group);

//Reorder within the group
int target_position = 0;
auto children = m_group->m_waveformBox.get_children();
for(int i=0; i<(int)children.size(); i++)
//Create a new group if we're dragging to the edge of the viewport
if(m_dropTarget->m_insertionBarLocation == INSERT_BOTTOM_SPLIT)
m_parent->OnMoveNewBelow(this);
else if(m_dropTarget->m_insertionBarLocation == INSERT_RIGHT_SPLIT)
m_parent->OnMoveNewRight(this);

else
{
if(children[i] == m_dropTarget)
//Reorder within the group
int target_position = m_group->GetIndexOfChild(m_dropTarget);
switch(m_dropTarget->m_insertionBarLocation)
{
if(m_dropTarget->m_insertionBarLocation == INSERT_TOP)
target_position = i;
else
target_position = i+1;
case INSERT_BOTTOM:
target_position ++;
break;

default:
break;
}

m_group->m_waveformBox.reorder_child(*this, target_position);
}
m_group->m_waveformBox.reorder_child(*this, target_position);

//Not dragging anymore
m_dropTarget->m_insertionBarLocation = INSERT_NONE;
@@ -508,13 +516,23 @@ bool WaveformArea::on_motion_notify_event(GdkEventMotion* event)
alloc.set_x(alloc.get_x() + wx);
alloc.set_y(alloc.get_y() + wy);

//int target_x = real_x - alloc.get_x();
int target_x = real_x - alloc.get_x();
int target_y = real_y - alloc.get_y();

if(target_y > target->m_height/2)
//Split if dragging to the right side of the group
if(target_x > target->m_width * 3/4)
target->m_insertionBarLocation = INSERT_RIGHT_SPLIT;

//Split if dragging all the way to the edge of the bottom area in the group
else if(target->m_group->IsLastChild(target) && (target_y > target->m_height*3/4) )
target->m_insertionBarLocation = INSERT_BOTTOM_SPLIT;

//No, just reorder
else if(target_y > target->m_height/2)
target->m_insertionBarLocation = INSERT_BOTTOM;
else
target->m_insertionBarLocation = INSERT_TOP;

target->queue_draw();
}
}
21 changes: 21 additions & 0 deletions glscopeclient/WaveformGroup.cpp
Original file line number Diff line number Diff line change
@@ -403,3 +403,24 @@ string WaveformGroup::SerializeConfiguration(IDTable& table)

return config;
}

int WaveformGroup::GetIndexOfChild(Gtk::Widget* child)
{
auto children = m_waveformBox.get_children();
for(int i=0; i<(int)children.size(); i++)
{
if(children[i] == child)
return i;
}

return -1;
}

bool WaveformGroup::IsLastChild(Gtk::Widget* child)
{
auto children = m_waveformBox.get_children();
if(children[children.size() - 1] == child)
return true;

return false;
}
3 changes: 3 additions & 0 deletions glscopeclient/WaveformGroup.h
Original file line number Diff line number Diff line change
@@ -98,6 +98,9 @@ class WaveformGroup
void AddStatistic(Statistic* stat);
void ClearStatistics();

int GetIndexOfChild(Gtk::Widget* child);
bool IsLastChild(Gtk::Widget* child);

//map of scope channels to measurement column indexes
std::map<OscilloscopeChannel*, int> m_columnToIndexMap;
std::map<int, OscilloscopeChannel*> m_indexToColumnMap;