goat3d

diff goatview/src/goatview.cc @ 97:32dccb16678f

[goatview] GUI layout fixes
author John Tsiombikas <nuclear@member.fsf.org>
date Wed, 21 May 2014 05:00:21 +0300
parents da100bf13f7f
children d7ab4f13f5af
line diff
     1.1 --- a/goatview/src/goatview.cc	Mon May 19 06:46:30 2014 +0300
     1.2 +++ b/goatview/src/goatview.cc	Wed May 21 05:00:21 2014 +0300
     1.3 @@ -128,17 +128,17 @@
     1.4  	}
     1.5  
     1.6  	if(tstart != LONG_MAX) {
     1.7 -		act_play->setDisabled(false);
     1.8 -		act_rewind->setDisabled(false);
     1.9 -		chk_loop->setDisabled(false);
    1.10 +		grp_anim_ctl->setDisabled(false);
    1.11 +		grp_anim_time->setDisabled(false);
    1.12  
    1.13 -		slider_time->setDisabled(false);
    1.14  		slider_time->setMinimum(tstart);
    1.15  		slider_time->setMaximum(tend);
    1.16  
    1.17 -		spin_time->setDisabled(false);
    1.18  		spin_time->setMinimum(tstart);
    1.19  		spin_time->setMaximum(tend);
    1.20 +
    1.21 +		label_time_start->setText(QString::number(tstart));
    1.22 +		label_time_end->setText(QString::number(tend));
    1.23  	}
    1.24  
    1.25  	post_redisplay();
    1.26 @@ -225,17 +225,15 @@
    1.27  	dock_cont->setLayout(dock_hbox);
    1.28  
    1.29  	// animation control box
    1.30 -	QGroupBox *grp_anim_ctl = new QGroupBox("Animation controls");
    1.31 -	// TODO figure out how these fucking stretching policies work...
    1.32 -	//grp_anim_ctl->sizePolicy().setHorizontalPolicy(QSizePolicy::Maximum);
    1.33 -	grp_anim_ctl->sizePolicy().setHorizontalStretch(1);
    1.34 +	grp_anim_ctl = new QGroupBox("Animation controls");
    1.35 +	grp_anim_ctl->setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred));
    1.36 +	grp_anim_ctl->setDisabled(true);
    1.37  	dock_hbox->addWidget(grp_anim_ctl);
    1.38  
    1.39  	QVBoxLayout *anim_ctl_box = new QVBoxLayout;
    1.40  	grp_anim_ctl->setLayout(anim_ctl_box);
    1.41  
    1.42  	chk_loop = new QCheckBox("loop");
    1.43 -	chk_loop->setDisabled(true);
    1.44  	chk_loop->setChecked(false);
    1.45  	anim_ctl_box->addWidget(chk_loop);
    1.46  
    1.47 @@ -243,31 +241,47 @@
    1.48  	anim_ctl_box->addWidget(toolbar_ctl);
    1.49  
    1.50  	act_rewind = new QAction(style()->standardIcon(QStyle::SP_MediaSkipBackward), "Rewind", this);
    1.51 -	act_rewind->setDisabled(true);
    1.52  	connect(act_rewind, &QAction::triggered, [this](){ slider_time->setValue(slider_time->minimum()); });
    1.53  	toolbar_ctl->addAction(act_rewind);
    1.54  
    1.55  	act_play = new QAction(style()->standardIcon(QStyle::SP_MediaPlay), "Play", this);
    1.56 -	act_play->setDisabled(true);
    1.57  	toolbar_ctl->addAction(act_play);
    1.58  
    1.59 -	// slider and spinbox
    1.60 -	QWidget *ssgroup = new QWidget;
    1.61 -	ssgroup->sizePolicy().setHorizontalStretch(4);
    1.62 -	dock_hbox->addWidget(ssgroup);
    1.63 +	/* timeline controls
    1.64 +	 * /------------------------------\ grp_anim_time with vbox_timeline layout
    1.65 +	 * | /-------+---------+--------\ |
    1.66 +	 * | | label | spinbox | spacer | <-- hbox_timespin
    1.67 +	 * | \-------+---------+--------/ |
    1.68 +	 * +------------------------------+
    1.69 +	 * | /-------+---------+--------\ |
    1.70 +	 * | | label | slider  | label  | <-- hbox_timeslider
    1.71 +	 * | \-------+---------+--------/ |
    1.72 +	 * \------------------------------/
    1.73 +	 */
    1.74 +	grp_anim_time = new QGroupBox("Timeline");
    1.75 +	grp_anim_time->setDisabled(true);
    1.76 +	dock_hbox->addWidget(grp_anim_time);
    1.77  
    1.78 -	QGridLayout *ssgrid = new QGridLayout;
    1.79 -	//dock_hbox->addLayout(ssgrid);
    1.80 -	ssgroup->setLayout(ssgrid);
    1.81 +	QVBoxLayout *vbox_timeline = new QVBoxLayout;
    1.82 +	grp_anim_time->setLayout(vbox_timeline);
    1.83 +	QHBoxLayout *hbox_timespin = new QHBoxLayout;
    1.84 +	vbox_timeline->addLayout(hbox_timespin);
    1.85 +	QHBoxLayout *hbox_timeslider = new QHBoxLayout;
    1.86 +	vbox_timeline->addLayout(hbox_timeslider);
    1.87  
    1.88 -	ssgrid->addWidget(new QLabel("msec"), 0, 0);
    1.89 +	hbox_timespin->addWidget(new QLabel("msec"));
    1.90  	spin_time = new QSpinBox;
    1.91 -	spin_time->setDisabled(true);
    1.92 -	ssgrid->addWidget(spin_time, 0, 1);
    1.93 +	hbox_timespin->addWidget(spin_time);
    1.94 +	hbox_timespin->addStretch();
    1.95 +
    1.96 +	label_time_start = new QLabel;
    1.97 +	hbox_timeslider->addWidget(label_time_start);
    1.98  
    1.99  	slider_time = new QSlider(Qt::Orientation::Horizontal);
   1.100 -	slider_time->setDisabled(true);
   1.101 -	ssgrid->addWidget(slider_time, 1, 0, 1, 3);
   1.102 +	hbox_timeslider->addWidget(slider_time);
   1.103 +
   1.104 +	label_time_end = new QLabel;
   1.105 +	hbox_timeslider->addWidget(label_time_end);
   1.106  
   1.107  	connect(slider_time, &QSlider::valueChanged,
   1.108  		[&](){ anim_time = slider_time->value(); spin_time->setValue(anim_time); post_redisplay(); });