Skip to content

Commit

Permalink
-Widgets move based on slider in TestUI
Browse files Browse the repository at this point in the history
  • Loading branch information
harryhaaren committed Dec 28, 2014
1 parent ddda2db commit 8951bad
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion avtk/widget.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class Widget
void motion( int x, int y );

int x, y, w, h; /// widget co-ords and size
std::string label_; /// widget name - sometimes shown in UI
std::string label_; /// widget name - sometimes shown in UI
bool visible_; /// widget visibility

enum ClickMode {
Expand Down
22 changes: 15 additions & 7 deletions test_ui.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ TestUI::TestUI( PuglNativeWindow parent ):
*/

// slider vert
w = new Avtk::Slider( this, 520, 40, 22, 220, "Vertical Slider" );
vertSlider = new Avtk::Slider( this, 520, 40, 22, 220, "Vertical Slider" );

// button
momentary = new Avtk::Button( this, 7, 45, 90, 22, "Momentary" );
Expand All @@ -72,19 +72,19 @@ TestUI::TestUI( PuglNativeWindow parent ):
w = new Avtk::Number( this, 100, 85, 35, 25, "Number box" );

// list
list = new Avtk::List( this, 345, 545, 105, 125, "List (Left)" );
list = new Avtk::List( this, 345, 345, 105, 125, "List (Left)" );
std::vector<std::string> items;
std::string stripped;
Avtk::directoryContents( "/root/openav/content/bips/", items, stripped);
list->show( items );

items.clear();
Avtk::directoryContents( "/root/openav/content/bips", items, stripped, true, true );
list2 = new Avtk::List( this, 525, 545, 105, 125, "List (Right)" );
list2 = new Avtk::List( this, 525, 345, 105, 125, "List (Right)" );
list2->show( items );

// waveform
waveform = new Avtk::Waveform( this, 75, 175, 375, 125, "Waveform" );
waveform = new Avtk::Waveform( this, 15, 175, 250, 100, "Waveform" );
std::vector<float> tmp;
int error = Avtk::loadSample( "test.wav", tmp );
waveform->show( tmp );
Expand All @@ -96,9 +96,9 @@ TestUI::TestUI( PuglNativeWindow parent ):
i->load( header.pixel_data );

// slider horizontal
w = new Avtk::Slider( this, 40,350, 350, 22, "Zoom" );
w = new Avtk::Slider( this, 15,350, 250, 22, "Zoom" );

w = new Avtk::Slider( this, 40,374, 350, 22, "Vol" );
w = new Avtk::Slider( this, 15,374, 250, 22, "Vol" );
}


Expand All @@ -114,12 +114,20 @@ void TestUI::widgetValueCB( Avtk::Widget* w )
{

}
else if( w == vertSlider )
{
waveform->y = w->value() * 500;
group1->y = w->value() * 500;

printf( "%s, value %f : px %f\n", w->label(), w->value(), group1->y );
redraw();
}
}

static void listValueCB( Avtk::Widget* w, void* ud )
{
Avtk::List* l = (Avtk::List*)w;
printf( "%s, value %f : %s\n", w->label(), w->value(), l->selectedString().c_str() );

}

/*
Expand Down
2 changes: 2 additions & 0 deletions test_ui.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class TestUI : public Avtk::UI

Avtk::Group* group1;

Avtk::Slider* vertSlider;

Avtk::List* list;
Avtk::List* list2;
Avtk::Waveform* waveform;
Expand Down

0 comments on commit 8951bad

Please sign in to comment.