Beispiel #1
0
void gResizerBar::HandleDrag(int diff) {
	Fl_Scroll *grp = (Fl_Scroll*)parent();
	int top = y();
	int bot = y()+h();

	// First pass: find widget directly above us with common edge
	//    Possibly clamp 'diff' if widget would get too small..

	for (int t=0; t<grp->children(); t++) {
		Fl_Widget *w = grp->child(t);
		if ((w->y()+w->h()) == top) {                           // found widget directly above?
			if ((w->h()+diff) < min_h) diff = w->h() - min_h;     // clamp
			w->resize(w->x(), w->y(), w->w(), w->h()+diff);       // change height
			break;                                                // done with first pass
		}
	}

	// Second pass: find widgets below us, move based on clamped diff

	for (int t=0; t<grp->children(); t++) {
		Fl_Widget *w = grp->child(t);
		if (w->y() >= bot)                                     // found widget below us?
			w->resize(w->x(), w->y()+diff, w->w(), w->h());      // change position
	}

	// Change our position last

	resize(x(),y()+diff,w(),h());
	grp->init_sizes();
	grp->redraw();
}
Beispiel #2
0
void geResizerBar::handleDrag(int diff)
{
	Fl_Scroll* grp = static_cast<Fl_Scroll*>(parent());
	int top;
	int bot;
	if (m_type == VERTICAL) {
		top = y();
		bot = y()+h();
	}
	else {
		top = x();
		bot = x()+w();
	}

	// First pass: find widget directly above us with common edge
	//    Possibly clamp 'diff' if widget would get too small..

	for (int t=0; t<grp->children(); t++) {
		Fl_Widget* wd = grp->child(t);
		if (m_type == VERTICAL) {
			if ((wd->y()+wd->h()) == top) {                          // found widget directly above?
				if ((wd->h()+diff) < m_minSize)
					diff = wd->h() - m_minSize;                          // clamp
				wd->resize(wd->x(), wd->y(), wd->w(), wd->h()+diff);   // change height
				break;                                                 // done with first pass
			}
		}
		else {
			if ((wd->x()+wd->w()) == top) {                          // found widget directly above?
				if ((wd->w()+diff) < m_minSize)
					diff = wd->w() - m_minSize;                          // clamp
				wd->resize(wd->x(), wd->y(), wd->w()+diff, wd->h());   // change height
				break;                                                 // done with first pass
			}
		}
	}

	// Second pass: find widgets below us, move based on clamped diff

	for (int t=0; t<grp->children(); t++) {
		Fl_Widget* wd = grp->child(t);
		if (m_type == VERTICAL) {
			if (wd->y() >= bot)                                     // found widget below us?
				wd->resize(wd->x(), wd->y()+diff, wd->w(), wd->h());  // change position
		}
		else {
			if (wd->x() >= bot)
				wd->resize(wd->x()+diff, wd->y(), wd->w(), wd->h());
		}
	}

	// Change our position last

	if (m_type == VERTICAL)
		resize(x(), y()+diff, w(), h());
	else
		resize(x()+diff, y(), w(), h());

	grp->init_sizes();
	grp->redraw();
}