Esempio n. 1
0
void Horizontal_paned::Handle_event(const ALLEGRO_EVENT& event)
{
	Vector2 p = Get_position();
	Vector2 s = Get_size();
	float pane_size = Get_value(PANE);
	if(event.type == ALLEGRO_EVENT_MOUSE_BUTTON_DOWN)
	{
		float pane_x_diff = event.mouse.x-(p.x + pane_position);
		if(event.mouse.y >= p.y && event.mouse.y <= p.y + s.y
		&& pane_x_diff >= 0 && pane_x_diff < pane_size)
		{
			holding_pane = pane_x_diff;
		}
	}
	if(event.type == ALLEGRO_EVENT_MOUSE_BUTTON_UP)
	{
		holding_pane = -1;
	}
	if(event.type == ALLEGRO_EVENT_MOUSE_AXES)
	{
		if(holding_pane != -1)
		{
			float new_x = (event.mouse.x - p.x) - holding_pane;
			float max_x = Get_size().x-pane_size;
			Set_pane_fraction(new_x/max_x);
			Organise();
		}
	}
	if(left)
		left->Handle_event(event);
	if(right)
		right->Handle_event(event);
}
Esempio n. 2
0
void Vertical_paned::Handle_event(const ALLEGRO_EVENT& event)
{
	Vector2 p = Get_position();
	Vector2 s = Get_size();
	float pane_size = Get_value(PANE);
	if(event.type == ALLEGRO_EVENT_MOUSE_BUTTON_DOWN)
	{
		float pane_y_diff = event.mouse.y-(p.y + pane_position);
		if(event.mouse.x >= p.x && event.mouse.x <= p.x + s.x
		&& pane_y_diff >= 0 && pane_y_diff < pane_size)
		{
			holding_pane = pane_y_diff;
		}
	}
	if(event.type == ALLEGRO_EVENT_MOUSE_BUTTON_UP)
	{
		holding_pane = -1;
	}
	if(event.type == ALLEGRO_EVENT_MOUSE_AXES)
	{
		if(holding_pane != -1)
		{
			float new_y = (event.mouse.y - p.y) - holding_pane;
			float max_y = Get_size().y-pane_size;
			Set_pane_fraction(new_y/max_y);
			Organise();
		}
	}
	if(top)
		top->Handle_event(event);
	if(bottom)
		bottom->Handle_event(event);
}
Esempio n. 3
0
void Vertical_paned::Set_pane_position(float p)
{
	float pane_size = Get_value(PANE);
	float max_y = Get_size().y-pane_size;
	pane_position = p<0?0:p>max_y?max_y:p;
	pane_reference = pane_position/max_y;
	Organise();
}
Esempio n. 4
0
File: box.cpp Progetto: trezker/SWAG
void Box::Add(Widget* widget)
{
	if(widget==NULL)
		return;
	widgets.push_back(widget);
	widget->Set_parent(this);
	Organise();
}
Esempio n. 5
0
void Horizontal_paned::Set_pane_position(float p)
{
	float pane_size = Get_value(PANE);
	float max_x = Get_size().x-pane_size;
	pane_position = p<0?0:p>max_x?max_x:p;
	pane_reference = pane_position/max_x;
	Organise();
}
Esempio n. 6
0
void Vertical_paned::Set_bottom(Widget* widget)
{
	if(widget)
		widget->Set_parent(this);
	else if(bottom)
		bottom->Set_parent(NULL);
	bottom = widget;
	Organise();
}
Esempio n. 7
0
void Vertical_paned::Set_top(Widget* widget)
{
	if(widget)
		widget->Set_parent(this);
	else if(top)
		top->Set_parent(NULL);
	top = widget;
	Organise();
}
Esempio n. 8
0
void Horizontal_paned::Set_left(Widget* widget)
{
	if(widget)
		widget->Set_parent(this);
	else if(left)
		left->Set_parent(NULL);
	left = widget;
	Organise();
}
Esempio n. 9
0
File: box.cpp Progetto: trezker/SWAG
void Box::Remove_child(Widget* c)
{
	Widgets::iterator i = std::find(widgets.begin(), widgets.end(), c);
	if(i != widgets.end())
	{
		widgets.erase(i);
	}
	Organise();
}
Esempio n. 10
0
void Horizontal_paned::Set_right(Widget* widget)
{
	if(widget)
		widget->Set_parent(this);
	else if(right)
		right->Set_parent(NULL);
	right = widget;
	Organise();
}
Esempio n. 11
0
void DeviceView::contextMenuEvent(QContextMenuEvent* e) {
  if (!device_menu_) {
    device_menu_ = new QMenu(this);
    library_menu_ = new QMenu(this);

    // Device menu
    eject_action_ = device_menu_->addAction(
        IconLoader::Load("media-eject"), tr("Safely remove device"), this, SLOT(Unmount()));
    forget_action_ = device_menu_->addAction(
        IconLoader::Load("list-remove"), tr("Forget device"), this, SLOT(Forget()));
    device_menu_->addSeparator();
    properties_action_ = device_menu_->addAction(
        IconLoader::Load("configure"), tr("Device properties..."), this, SLOT(Properties()));

    // Library menu
    add_to_playlist_action_ = library_menu_->addAction(IconLoader::Load("media-playback-start"),
        tr("Append to current playlist"), this, SLOT(AddToPlaylist()));
    load_action_ = library_menu_->addAction(IconLoader::Load("media-playback-start"),
        tr("Replace current playlist"), this, SLOT(Load()));
    open_in_new_playlist_ = library_menu_->addAction(IconLoader::Load("document-new"),
        tr("Open in new playlist"), this, SLOT(OpenInNewPlaylist()));
    library_menu_->addSeparator();
    organise_action_ = library_menu_->addAction(IconLoader::Load("edit-copy"),
        tr("Copy to library..."), this, SLOT(Organise()));
    delete_action_ = library_menu_->addAction(IconLoader::Load("edit-delete"),
        tr("Delete from device..."), this, SLOT(Delete()));
  }

  menu_index_ = currentIndex();

  const QModelIndex device_index = MapToDevice(menu_index_);
  const QModelIndex library_index = MapToLibrary(menu_index_);

  if (device_index.isValid()) {
    const bool is_plugged_in = app_->device_manager()->GetLister(device_index.row());
    const bool is_remembered = app_->device_manager()->GetDatabaseId(device_index.row()) != -1;

    forget_action_->setEnabled(is_remembered);
    eject_action_->setEnabled(is_plugged_in);

    device_menu_->popup(e->globalPos());
  } else if (library_index.isValid()) {
    const QModelIndex parent_device_index = FindParentDevice(menu_index_);

    bool is_filesystem_device = false;
    if (parent_device_index.isValid()) {
      boost::shared_ptr<ConnectedDevice> device = app_->device_manager()->GetConnectedDevice(parent_device_index.row());
      if (device && !device->LocalPath().isEmpty())
        is_filesystem_device = true;
    }

    organise_action_->setEnabled(is_filesystem_device);

    library_menu_->popup(e->globalPos());
  }
}
Esempio n. 12
0
bool Expander::Add_child(Widget* c)
{
	if(!child)
	{
		child = c;
		child->Set_parent(this);
		Organise();
		return true;
	}
	return false;
}
Esempio n. 13
0
void Vertical_paned::Resized()
{
	Set_pane_fraction(pane_reference);
	Organise();
}
Esempio n. 14
0
File: box.cpp Progetto: trezker/SWAG
void Box::Handle_child_resize()
{
	Organise();
}
Esempio n. 15
0
File: box.cpp Progetto: trezker/SWAG
void Box::Resized()
{
	Organise();
}
Esempio n. 16
0
void Expander::Remove_child(Widget* c)
{
	child = NULL;
	Organise();
}
Esempio n. 17
0
void Expander::Resized()
{
	Organise();
}
Esempio n. 18
0
void Horizontal_paned::Resized()
{
	Set_pane_fraction(pane_reference);
	Organise();
}