static int	display_philo_bar(SDL_Surface *screen,
				  t_data *data,
				  int bar_size,
				  Uint32 color)
{
  SDL_Rect	pos;
  t_size	size;
  float		size_rest;
  float		size_eat;
  float		size_think;
  float		total;

  pos.y = WIN_HEIGHT - bar_size - 11 + 3;
  pos.x = 100 + BAR_WIDTH * (data->id + 1) + 1;
  if (!(total = data->eaten_plates + data->hours_slept + data->hours_thought))
    total = 0.1;
  size_rest = bar_size / (total / data->hours_slept);
  size_think = bar_size / (total / data->hours_thought);
  size_eat = bar_size / (total / data->eaten_plates);
  if (!display_rect(screen, init_size(&size, size_rest, BAR_WIDTH - 2),
		    &pos, color & 0x555555))
    return (0);
  pos.y = WIN_HEIGHT - bar_size - 11 + size_rest + 2;
  if (!display_rect(screen, init_size(&size, size_think, BAR_WIDTH - 2),
		    &pos, color & 0xaaaaaa))
    return (0);
  pos.y = WIN_HEIGHT - bar_size - 11 + size_rest + size_think + 1;
  return (!display_rect(screen, init_size(&size, size_eat, BAR_WIDTH - 2),
			&pos, color));
}
InputMethodView::InputMethodView( QWidget* mainWindow ) :
    MImGraphicsView( new QGraphicsScene( display_rect(), 0 ), mainWindow ) ,
    d_ptr( new InputMethodViewPrivate() )
{
    Q_D( InputMethodView ) ;
    d->scene = this->scene() ;
}
示例#3
0
bool abstract_panel::loadValuesIntoMap()
{
	try
	{
		//special treatment for resolution that'll set proper defaults for res
		wxDisplay display(0);
		wxRect display_rect ( display.GetGeometry() );
//		const int current_x_res = LSL::susynclib().GetSpringConfigInt(RC_TEXT[0].key,display_rect.width);
//		const int current_y_res = LSL::susynclib().GetSpringConfigInt(RC_TEXT[1].key,display_rect.height);

		for (int i = 0; i< intControls_size;++i)
		{
      intSettings[intControls[i].key]
          = LSL::susynclib().GetSpringConfigInt(STD_STRING(intControls[i].key),fromString(intControls[i].def));
		}
    for (int i = 0; i< floatControls_size;++i)
    {
      floatSettings[floatControls[i].key]
          = LSL::susynclib().GetSpringConfigFloat(STD_STRING(floatControls[i].key),fromString(floatControls[i].def));
		}
	}
	catch (...)
	{
		customMessageBox(SS_MAIN_ICON,_("Could not access your settings.\n"), _("Error"), wxOK|wxICON_HAND, 0);
		abstract_panel::settingsChanged = false;
		return false;
	}

	return true; // SUCCESS!
}
static int	fill_gui(SDL_Surface *screen, t_data *data)
{
  t_size	size;
  int		food;
  int		eaten;
  SDL_Rect	pos;

  food = MAX(data->conf->nb_food, 1);
  eaten = data->stat->total_eaten;
  pos.x = 10;
  pos.y = 10;
  size.h = WIN_HEIGHT - 20;
  size.w = BAR_WIDTH;
  if (!display_rect(screen, &size, &pos, 0xffffff))
    return (0);
  pos.x++;
  pos.y++;
  size.h = WIN_HEIGHT - 22 - (food - eaten) * (WIN_HEIGHT - 22) / food;
  size.w = BAR_WIDTH - 2;
  if (!display_rect(screen, &size, &pos, 0))
    return (0);
  return (display_philos(screen, data, data->conf));
}
示例#5
0
void SetPos(CefWindowHandle handle, int x, int y, int width, int height) {
  GtkWindow* window = GetWindow(handle);
  GdkWindow* gdk_window = gtk_widget_get_window(GTK_WIDGET(window));

  // Make sure the window isn't minimized or maximized.
  if (IsMaximized(window))
    gtk_window_unmaximize(window);
  else
    gtk_window_present(window);

  // Retrieve information about the display that contains the window.
  GdkScreen* screen = gdk_screen_get_default();
  gint monitor = gdk_screen_get_monitor_at_window(screen, gdk_window);
  GdkRectangle rect;
  gdk_screen_get_monitor_geometry(screen, monitor, &rect);

  // Make sure the window is inside the display.
  CefRect display_rect(rect.x, rect.y, rect.width, rect.height);
  CefRect window_rect(x, y, width, height);
  ModifyBounds(display_rect, window_rect);

  gdk_window_move_resize(gdk_window, window_rect.x, window_rect.y,
                         window_rect.width, window_rect.height);
}
示例#6
0
static void ConstructCommands(const hwc_layer_1 *layers, size_t num_layers,
                              std::vector<RenderingCommand> *commands) {
  std::vector<FRect> in_rects;
  std::vector<FRectSet> out_rects;
  int i;

  for (unsigned rect_index = 0; rect_index < num_layers; rect_index++) {
    const hwc_layer_1 &layer = layers[rect_index];
    FRect rect;
    in_rects.push_back(FRect(layer.displayFrame.left, layer.displayFrame.top,
                             layer.displayFrame.right,
                             layer.displayFrame.bottom));
  }

  seperate_frects_64(in_rects, &out_rects);

  for (unsigned rect_index = 0; rect_index < out_rects.size(); rect_index++) {
    const FRectSet &out_rect = out_rects[rect_index];
    commands->push_back(RenderingCommand());
    RenderingCommand &cmd = commands->back();

    memcpy(cmd.bounds, out_rect.rect.bounds, sizeof(cmd.bounds));

    uint64_t tex_set = out_rect.id_set.getBits();
    for (unsigned i = num_layers - 1; tex_set != 0x0; i--) {
      if (tex_set & (0x1 << i)) {
        tex_set &= ~(0x1 << i);

        const hwc_layer_1 &layer = layers[i];

        FRect display_rect(layer.displayFrame.left, layer.displayFrame.top,
                           layer.displayFrame.right, layer.displayFrame.bottom);
        float display_size[2] = {
            display_rect.bounds[2] - display_rect.bounds[0],
            display_rect.bounds[3] - display_rect.bounds[1]};

        FRect crop_rect(layer.sourceCropf.left, layer.sourceCropf.top,
                        layer.sourceCropf.right, layer.sourceCropf.bottom);
        float crop_size[2] = {crop_rect.bounds[2] - crop_rect.bounds[0],
                              crop_rect.bounds[3] - crop_rect.bounds[1]};

        RenderingCommand::TextureSource &src = cmd.textures[cmd.texture_count];
        cmd.texture_count++;
        src.texture_index = i;

        for (int b = 0; b < 4; b++) {
          float bound_percent = (cmd.bounds[b] - display_rect.bounds[b % 2]) /
                                display_size[b % 2];
          src.crop_bounds[b] =
              crop_rect.bounds[b % 2] + bound_percent * crop_size[b % 2];
        }

        if (layer.blending == HWC_BLENDING_NONE) {
          src.alpha = 1.0f;
          // This layer is opaque. There is no point in using layers below this
          // one.
          break;
        }

        src.alpha = layer.planeAlpha / 255.0f;
      }
    }
  }
}
const QRect& InputMethodView::screenRect( QWidget* widget ) {
    return display_rect( widget ) ;
}