Ejemplo n.º 1
0
SubdRepresentation::SubdRepresentation(Rectangle rect, Crop& crop, QDate date) :
    rect(rect), crop(crop)
{
    this->setRect(get_rect().get_x(), - get_rect().get_y() - get_rect().get_height(),
                  get_rect().get_width(), get_rect().get_height());
    if (crop)
    {
        Plant& plant = crop.get_plant();
        QString text = toQString(plant.get_name());
        //text = re.sub("\s+", "\n", text)
        QGraphicsSimpleTextItem *textw =  new QGraphicsSimpleTextItem(text);
        QFont font = textw->font();
        font.setPointSize(6);
        font.setWeight(25);
        textw->setFont(font);
        center_text(textw, this->boundingRect());
        textw->setParentItem(this);
        QString color_str = toQString(plant.get_color_str());
        if (color_str == "") { color_str = "#FF00FF"; }
        QColor color = QColor(color_str);
        if (crop.is_planned_at_date(fromQDate(date)) && !crop.is_active_at_date(fromQDate(date)))
        {
            this->setBrush(QBrush(color, Qt::BDiagPattern));
        }
        else
        {
            this->setBrush(QBrush(color));
        }
    }
}
Ejemplo n.º 2
0
void tpanel::impl_draw_background(surface& frame_buffer)
{
    DBG_GUI_D << LOG_HEADER
              << " size " << get_rect()
              << ".\n";

    canvas(0).blit(frame_buffer, get_rect());
}
Ejemplo n.º 3
0
void
Navigation::on_mouse_motion(const MouseMotionEvent& motion)
{
  if (dragging)
    {
      screen_buffer->move_to(Point(draw_ctx->get_width()  * motion.x / get_rect().get_width(),
                                   draw_ctx->get_height() * motion.y / get_rect().get_height()));
    }
}
Ejemplo n.º 4
0
void Trace::paint_label(QPainter &p, int right, const QPoint pt)
{
    compute_text_size(p);
    const int y = get_y();

    const QRectF color_rect = get_rect("color", y, right);
    const QRectF name_rect  = get_rect("name",  y, right);
    const QRectF label_rect = get_rect("label", get_zeroPos(), right);

    p.setRenderHint(QPainter::Antialiasing);
    // Paint the ColorButton
    p.setPen(Qt::transparent);
    p.setBrush(enabled() ? _colour : dsDisable);
    p.drawRect(color_rect);

    // Paint the signal name
    p.setPen(enabled() ? Qt::black : dsDisable);
    p.drawText(name_rect, Qt::AlignLeft | Qt::AlignVCenter, _name);

    // Paint the trigButton
    paint_type_options(p, right, pt);

    // Paint the label
    if (enabled()) {
        const QPointF points[] = {
            label_rect.topLeft(),
            label_rect.topRight(),
            QPointF(right, get_zeroPos()),
            label_rect.bottomRight(),
            label_rect.bottomLeft()
        };

        p.setPen(Qt::transparent);
        if (_type == SR_CHANNEL_DSO)
            p.setBrush((label_rect.contains(pt) || selected()) ? _colour.darker() : _colour);
        else
            p.setBrush((label_rect.contains(pt) || selected()) ? dsYellow : dsBlue);
        p.drawPolygon(points, countof(points));

        p.setPen(QPen(Qt::blue, 1, Qt::DotLine));
        p.setBrush(Qt::transparent);
        p.drawLine(label_rect.right(), label_rect.top() + 3,
                    label_rect.right(), label_rect.bottom() - 3);

        // Paint the text
        p.setPen(Qt::white);
        if (_type == SR_CHANNEL_GROUP)
            p.drawText(label_rect, Qt::AlignCenter | Qt::AlignVCenter, "G");
        else if (_type == SR_CHANNEL_ANALOG)
            p.drawText(label_rect, Qt::AlignCenter | Qt::AlignVCenter, "A");
        else if (_type == SR_CHANNEL_DECODER)
            p.drawText(label_rect, Qt::AlignCenter | Qt::AlignVCenter, "D");
        else
            p.drawText(label_rect, Qt::AlignCenter | Qt::AlignVCenter, QString::number(_index_list.front()));
    }
}
Ejemplo n.º 5
0
void
TextView::draw(GraphicContext& gc)
{
    if (1)
        gc.fill_rect(Rect(0, 0, get_rect().get_width(), get_rect().get_height()),
                     Color(64, 64, 64));

    // FIXME: move font handling in GraphicContext
    TTY_Blit(tty, gc.get_surface(), get_rect().left, get_rect().top);
}
void
SaturationValuePicker::draw(GraphicContext& gc)
{
  gc.blit(surface, Point(0, 0));
  gc.draw_line(Point(click_pos.x, 0),
               Point(click_pos.x, get_rect().get_height()),
               Color(0, 0, 0));
  gc.draw_line(Point(0, click_pos.y),
               Point(get_rect().get_width(), click_pos.y),
               Color(0, 0, 0));
}
void
SaturationValuePicker::on_mouse_motion(const MouseMotionEvent& motion)
{
  set_dirty(true);
  if (dragging)
    {
      click_pos.x = std::min(std::max(0, motion.x), get_rect().get_width());
      click_pos.y = std::min(std::max(0, motion.y), get_rect().get_height());
      controller->set_color_value_saturation(255 - 255 * click_pos.x/get_rect().get_width(),
                                             255 * click_pos.y/get_rect().get_height());
    }
}
Ejemplo n.º 8
0
void twidget::set_visible_area(const SDL_Rect& area)
{
	clip_rect_ = intersect_rects(area, get_rect());

	if(clip_rect_ == get_rect()) {
		drawing_action_ = DRAWN;
	} else if(clip_rect_ == empty_rect) {
		drawing_action_ = NOT_DRAWN;
	} else {
		drawing_action_ = PARTLY_DRAWN;
	}
}
Ejemplo n.º 9
0
void Plot::create_subplots(int nb_hor, int nb_vert)
{
   float total_height = get_rect().get_height();
   float total_width = get_rect().get_width();
   float width = total_width / nb_hor;
   float height = total_height / nb_vert;

   for (int iy=0; iy < nb_vert; iy++)
   {
       for (int ix=0; ix < nb_hor; ix++)
       {
           add_subplot(width, height, ix*width, iy*height);
       }
   }
}
Ejemplo n.º 10
0
int Trace::pt_in_rect(int y, int right, const QPoint &point)
{
    const QRectF color = get_rect("color", y, right);
    const QRectF name  = get_rect("name", y, right);
    const QRectF label = get_rect("label", get_zeroPos(), right);

    if (color.contains(point) && enabled())
        return COLOR;
    else if (name.contains(point) && enabled())
        return NAME;
    else if (label.contains(point) && enabled())
        return LABEL;
    else
        return 0;
}
Ejemplo n.º 11
0
void twidget::place(const tpoint& origin, const tpoint& size)
{
	// release of visutal studio cannot detect assert, use breakpoint.
	if (size.x < 0 || size.y < 0) {
		int ii = 0;
	}
	assert(size.x >= 0);
	assert(size.y >= 0);

	x_ = origin.x;
	y_ = origin.y;
	w_ = size.x;
	h_ = size.y;

#if 0
	std::cerr << "Id " << id()
		<< " rect " << get_rect()
		<< " parent "
			<< (parent ? parent->get_x() : 0)
			<< ','
			<< (parent ? parent->get_y() : 0)
		<< " screen origin " << x_ << ',' << y_
		<< ".\n";
#endif

	set_dirty();
}
Ejemplo n.º 12
0
	void move()
	{
		for(auto &b: bullets){
			if(b){
				b.move();
			}
		}

		player_.move();
		auto p = player_.get_position();
		auto r = paint::rect(p, player_.get_size());
		auto s = get_size();
		if(r.left < 0.f)
			p.x = 0.f;
		else if(r.right >= s.width)
			p.x = s.width - 1.f - r.width();
		if(r.top < 0.f)
			p.y = 0.f;
		else if(r.bottom >= s.height)
			p.y = s.height - 1.f - r.height();
		player_.set_position(p);

		auto rect = get_rect();

		for(auto it = enemy_bullets.begin(); it != enemy_bullets.end(); ++it){
			(*it)->move(player_);
			if((*it)->is_colliding(player_)){
				gameover();
				return;
			}

			float r = (*it)->get_radius();
			if(!(*it)->get_center().is_inside(rect - paint::point(r, r) + paint::size(r, r))){
				delete *it;
				*it = nullptr;
			}
		}
		enemy_bullets.erase(std::remove(enemy_bullets.begin(), enemy_bullets.end(), nullptr), enemy_bullets.end());

		for(auto it = enemies.begin(); it != enemies.end(); ++it){
			(*it)->move(player_, enemy_bullets);

			if((*it)->is_colliding(player_)){
				gameover();
				return;
			}

			for(auto &b: bullets){
				if(b && (*it)->is_colliding(b)){
					b.set_active(false);
					delete *it;
					*it = nullptr;
					break;
				}
			}
		}
		auto remover = std::remove(enemies.begin(), enemies.end(), nullptr);
		score += static_cast<int>(std::distance(remover, enemies.end()));
		enemies.erase(remover, enemies.end());
	}
Ejemplo n.º 13
0
bool CCGroup::is_significant_member(int idx) const
{
    cv::Rect my_rect = get_rect();
    cv::Rect other_rect = get_rect_without_element(idx);
    cv::Rect intersect = my_rect & other_rect;
    return intersect.width * intersect.height / (my_rect.width * my_rect.height) < 0.9;
}
Ejemplo n.º 14
0
void stretch_window(void)
{
  int dx, dy;
  int x0, x1, y0, y1;

  SETMOUSEICON(&mouse_box);
  move_mouse(screen, mouse, &mousex, &mousey, 0);
  SETMOUSEICON(DEFAULT_MOUSE_CURSOR);

  x0 = ACTIVE(x0);
  y0 = ACTIVE(y0);
  x1 = x0 + BIT_WIDE(ACTIVE(border));
  y1 = y0 + BIT_HIGH(ACTIVE(border));
  if (2 * (mousex - x0) < x1 - x0)
    x0 = x1;
  dx = mousex - x0;
  if (2 * (mousey - y0) < y1 - y0)
    y0 = y1;
  dy = mousey - y0;
  /* x0,y0 is corner farthest from mouse. x0+dx,y0+dx is mouse position */

  get_rect(screen, mouse, x0, y0, &dx, &dy, 0);
  do_button(0);

  /* look for shape event here */
  do_event(EVENT_SHAPE, active, E_MAIN);

  (void)shape(x0, y0, dx, dy);
}
Ejemplo n.º 15
0
void ShadeWindow (HWND hwnd)
{
    RECT rc;
    get_rect(hwnd, &rc);
    int height = rc.bottom - rc.top;
    LPARAM prop = (LPARAM)GetProp(hwnd, BBSHADE_PROP);

    int h1 = LOWORD(prop);
    int h2 = HIWORD(prop);
    if (IsZoomed(hwnd))
    {
        if (h2) height = h2, h2 = 0;
        else h2 = height, height = get_shade_height(hwnd);
    }
    else
    {
        if (h1) height = h1, h1 = 0;
        else h1 = height, height = get_shade_height(hwnd);
        h2 = 0;
    }

    prop = MAKELPARAM(h1, h2);
    if (0 == prop)
        RemoveProp(hwnd, BBSHADE_PROP);
    else
        SetProp(hwnd, BBSHADE_PROP, (PVOID)prop);

    rc.bottom = rc.top + height;
    window_set_pos(hwnd, rc);
}
Ejemplo n.º 16
0
	//-----------------------------------------------------------------//
	void widget_progress::initialize()
	{
		// 標準的設定
		at_param().state_.set(widget::state::SERVICE);
		at_param().state_.set(widget::state::POSITION_LOCK);
		at_param().state_.set(widget::state::SIZE_LOCK);
		at_param().state_.set(widget::state::MOVE_STALL);

		vtx::spos size = get_rect().size;
		img::paint pa;
		{
			const widget::plate_param& pp = param_.plate_param_;
			if(pp.resizeble_) {
				vtx::spos bsz = size;
				if(bsz.x >= pp.grid_.x * 3) bsz.x = pp.grid_.x * 3;
				if(bsz.y >= pp.grid_.y * 3) bsz.y = pp.grid_.y * 3;
				create_round_frame(pa, param_.plate_param_, param_.color_param_, bsz);
				base_h_ = wd_.at_mobj().install(&pa, bsz, param_.plate_param_.grid_);
			} else {
				create_round_frame(pa, param_.plate_param_, param_.color_param_, size);
				base_h_ = wd_.at_mobj().install(&pa);
			}
		}


#if 0
		const slider_param& sp = param_.slider_param_;
		if(param_.hand_image_) {
			const vtx::spos& size = param_.hand_image_->get_size();
			create_image_base(param_.hand_image_, size, pa);
		} else {
			short wf = param_.plate_param_.frame_width_;
			if(sp.direction_ == slider_param::direction::HOLIZONTAL) {
				size.x = (size.x - wf * 2) * param_.slider_param_.handle_ratio_;
				size.y -= wf * 2;
			} else if(sp.direction_ == slider_param::direction::VERTICAL) {
				size.x -= wf * 2;
				size.y = (size.y - wf * 2) * param_.slider_param_.handle_ratio_;
			}
			plate_param pp = param_.plate_param_;
			pp.round_radius_ -= param_.plate_param_.frame_width_;
			pp.frame_width_ = 0;
			color_param cp = param_.color_param_;
			cp.swap_color();
			cp.back_color_ *= 0.75f;
			create_round_frame(pa, pp, cp, size);
			pa.set_fore_color(cp.fore_color_);
			pa.alpha_blend();
			if(sp.direction_ == slider_param::direction::HOLIZONTAL) {
				pa.line(size.x / 2, 3, size.x / 2, size.y - 3 * 2);
			} else if(sp.direction_ == slider_param::direction::VERTICAL) {

			}
		}
		hand_h_ = wd_.at_mobj().install(&pa);
#endif
	}
Ejemplo n.º 17
0
bool GUI::is_pressed() // executes multiple times
{
	#ifdef __windows__
	#endif
	
	#ifdef __gnu_linux__
	#endif
	return (Mouse::is_over(get_rect()) && Mouse::is_pressed(1));
}
Ejemplo n.º 18
0
SDL_Rect twidget::calculate_blitting_rectangle(
		  const int x_offset
		, const int y_offset)
{
	SDL_Rect result = get_rect();
	result.x += x_offset;
	result.y += y_offset;
	return result;
}
Ejemplo n.º 19
0
void terrain_label::calculate_shroud()
{
	if (handle_) {
		font::show_floating_label(handle_, !hidden());
	}

	if (tooltip_.empty() || hidden()) {
		tooltips::remove_tooltip(tooltip_handle_);
		tooltip_handle_ = 0;
		return;
	}

	//tooltips::update_tooltip(tooltip_handle, get_rect(), tooltip_.str(), "", true);

	if (tooltip_handle_)
		tooltips::update_tooltip(tooltip_handle_,get_rect(), tooltip_.str(), "", true);
	else
		tooltip_handle_ = tooltips::add_tooltip(get_rect(), tooltip_.str());
}
Ejemplo n.º 20
0
void
Navigation::on_mouse_button(const MouseButtonEvent& button)
{
  if (button.button == 1)
    {
      if (button.state == SDL_RELEASED)
        {
          screen_buffer->move_to(Point(draw_ctx->get_width()  * button.x / get_rect().get_width(),
                                       draw_ctx->get_height() * button.y / get_rect().get_height()));
          dragging = false;
        }
      else if (button.state == SDL_PRESSED)
        {
          screen_buffer->move_to(Point(draw_ctx->get_width()  * button.x / get_rect().get_width(),
                                       draw_ctx->get_height() * button.y / get_rect().get_height()));
          dragging = true;
        }
    }
}
Ejemplo n.º 21
0
/////////////
/////////////
/////////////
// EVENTS
/////////////
bool  GUI::is_hovered()
{	
	int x = 0;
	int y = 0;
	#ifdef __windows__
	#endif
	
	#ifdef __gnu_linux__
	#endif	
	return Mouse::is_over(get_rect());
}
Ejemplo n.º 22
0
void EditorSettingsDialog::_notification(int p_what) {

	switch (p_what) {
		case NOTIFICATION_ENTER_TREE: {
			clear_button->set_icon(get_icon("Close", "EditorIcons"));
			shortcut_clear_button->set_icon(get_icon("Close", "EditorIcons"));
		} break;
		case NOTIFICATION_POPUP_HIDE: {
			EditorSettings::get_singleton()->set("interface/dialogs/editor_settings_bounds", get_rect());
		} break;
	}
}
Ejemplo n.º 23
0
void ProjectExportDialog::_notification(int p_what) {

	switch (p_what) {
		case NOTIFICATION_READY: {
			delete_preset->set_icon(get_icon("Del", "EditorIcons"));
			connect("confirmed", this, "_export_pck_zip");
		} break;
		case NOTIFICATION_POPUP_HIDE: {
			EditorSettings::get_singleton()->set("interface/dialogs/export_bounds", get_rect());
		} break;
	}
}
Ejemplo n.º 24
0
bool
GenericLevelObj::is_at(int x, int y)
{
  if (surface)
  {
    if (get_rect().contains(Vector2i(x,y)))
    {
      Rect rect = get_rect();
      Color pixel = surface.get_pixel(x - rect.left, y - rect.top);
      return pixel.a != 0;
    }
    else
    {
      return false;
    }
  }
  else
  {
    return get_rect().contains(Vector2i(x,y));
  }
}
Ejemplo n.º 25
0
void tminimap::impl_draw_background(surface& frame_buffer)
{
	if (!terrain_) return;
	assert(terrain_);

	DBG_GUI_D << LOG_HEADER
			<< " size " << get_rect()
			<< ".\n";

	if(map_data_.empty()) {
		return;
	}

	SDL_Rect rect = get_rect();
	assert(rect.w > 0 && rect.h > 0);

	const ::surface surf = get_image(rect.w, rect.h);
	if(surf) {
		sdl_blit(surf, NULL, frame_buffer, &rect);
	}
}
Ejemplo n.º 26
0
void
add_rect(struct nhrect *r)
{
    if (rect_cnt >= MAXRECT) {
        pline(msgc_debug, "MAXRECT may be too small.");
        return;
    }
    /* Check that this struct nhrect is not included in another one */
    if (get_rect(r))
        return;
    rect[rect_cnt] = *r;
    rect_cnt++;
}
Ejemplo n.º 27
0
void ProjectExportDialog::_notification(int p_what) {

	switch (p_what) {
		case NOTIFICATION_READY: {
			delete_preset->set_icon(get_icon("Del", "EditorIcons"));
			connect("confirmed", this, "_export_pck_zip");
			custom_feature_display->get_parent_control()->add_style_override("panel", get_stylebox("bg", "Tree"));
		} break;
		case NOTIFICATION_POPUP_HIDE: {
			EditorSettings::get_singleton()->set("interface/dialogs/export_bounds", get_rect());
		} break;
	}
}
Ejemplo n.º 28
0
void tpanel::impl_draw_background(
    surface& frame_buffer
    , int x_offset
    , int y_offset)
{
    DBG_GUI_D << LOG_HEADER
              << " size " << get_rect()
              << ".\n";

    canvas(0).blit(
        frame_buffer
        , calculate_blitting_rectangle(x_offset, y_offset));
}
Ejemplo n.º 29
0
void QuitLabel::constructLabelSurface()
{
    std::string textWithToggle = toggle? (text + " Yes"): (text + " No");
    
    labelSurface = TTF_RenderText_Blended(
	ResourceData::font, textWithToggle.c_str(), color);
    Rect<int> blitRect(get_rect(labelSurface));
    blitRect.setCenter(rect.getCenter());
    blitRect.clipRect(rect);
    
    srcrect = Rect<int>(Vector2<int>(), blitRect.diagonal).getSDL_Rect();
    dstrect = Rect<int>(blitRect.pos, Vector2<int>()).getSDL_Rect();
}
Ejemplo n.º 30
0
// Draw the sprite
void
LevelObj::draw(DrawingContext &gc)
{
  if (attribs & HAS_SURFACE || attribs & HAS_SURFACE_FAKE)
  {
    if (attribs & HAS_REPEAT)
    {
      for(int x = static_cast<int>(pos.x); x < static_cast<int>(pos.x) + sprite.get_width() * repeat; x += sprite.get_width())
      {
        gc.draw(sprite, Vector3f(static_cast<float>(x), pos.y, pos.z));
      }
    }
#if 0
    else if(attribs & HAS_STRETCH)
    {
      // Surface Background - tile it
      for (int x = 0; x < level->size.width; x += sprite.get_width())
        for (int y = 0; y < level->size.height; y += sprite.get_height())
          gc.draw(sprite, Vector3f((float)x, (float)y, pos.z));
    }
#endif
    else if (attribs & HAS_COLOR && section_name == "solidcolor-background")
    { // FIXME: Should we have the object type in non-string form?
      gc.draw_fillrect(get_rect(), color, pos.z);
      gc.draw(sprite, pos);
    }
    else
    {
      gc.draw(sprite, pos);
    }

    // If selected, draw a highlighted box around it
    if (selected)
    {
      gc.draw_fillrect(get_rect(), Color(255,0,0,50), pos.z);
      gc.draw_rect(get_rect(), Color(255,0,0), pos.z);
    }
  }
}