• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

Plasma

ItemSpace Class Reference

ItemSpace class Implements "push and pull" dynamics of rectangular items in 2D space. More...

#include <itemspace.h>

List of all members.


Classes

class  ItemGroup
 Represents a group of overlapping items. More...
class  ItemSpaceItem

Public Types

enum  DirectionFlag { DirLeft = 1, DirRight = 2, DirUp = 4, DirDown = 8 }
enum  PushPowerFlag { NoPower = 0, PushAwayFromPreferred = 1, PushOverBorder = 2 }

Public Member Functions

void activate ()
void addItem (ItemSpaceItem newItem)
 ItemSpace ()
bool locateItemByPosition (int pos, int *groupIndex, int *itemInGroup) const
bool locateItemByUser (QVariant user, int *groupIndex, int *itemInGroup) const
void offsetPositions (const QPointF &offset)
qreal performPush (int groupId, Direction direction, qreal amount, PushPower power)
bool positionedProperly (QRectF itemGeom)
QList< QPointF > positionVertically (const QSizeF &itemSize, Qt::Alignment align, bool limitedSpace, bool findAll) const
qreal positionVisibility (QRectF geom)
void preparePush (Direction direction, PushPower power)
void removeItem (int groupIndex, int itemInGroup)
void setWorkingArea (QSizeF area)
void updateItem (int groupIndex, int itemInGroup)

Public Attributes

QList< ItemGroup > m_groups
qreal placementSpacing
qreal screenSpacing
qreal shiftingSpacing
Qt::Alignment spaceAlignment
QSizeF workingGeom

Detailed Description

ItemSpace class Implements "push and pull" dynamics of rectangular items in 2D space.

All isolated motion folows these rules:

  • overlapping items stay at the same positions relative to each other
  • non-overlapping items stay such and do not jump one over another

There are two types of motion:

  • forced motion: an item moves all items on its way, even if any of them would intersect the border of the working area
  • non-forced motion: an item moves items on its way only as much as the border of the working area

Items are pushed to fit inside the working area: if an item is in the way of one of the borders of alignment, the move is forced; if an item is in the way of one of the opposite borders, the move is non-forced.

An item can have a "preferred position". Such item is moved non-forced in the direction towards the preferred position.

Definition at line 38 of file itemspace.h.


Member Enumeration Documentation

enum ItemSpace::DirectionFlag

Enumerator:
DirLeft 
DirRight 
DirUp 
DirDown 

Definition at line 63 of file itemspace.h.

enum ItemSpace::PushPowerFlag

Enumerator:
NoPower 
PushAwayFromPreferred 
PushOverBorder 

Definition at line 71 of file itemspace.h.


Constructor & Destructor Documentation

ItemSpace::ItemSpace (  ) 

Definition at line 16 of file itemspace.cpp.


Member Function Documentation

void ItemSpace::activate (  ) 

Definition at line 39 of file itemspace.cpp.

void ItemSpace::addItem ( ItemSpaceItem  newItem  ) 

Add a new item.

Groups will be updated to reflect the change.

Parameters:
newItem the item to add; must be initialized

Definition at line 595 of file itemspace.cpp.

bool ItemSpace::locateItemByPosition ( int  pos,
int *  groupIndex,
int *  itemInGroup 
) const

Find an item by its number as if we iterated over all groups and over all items in each group.

Definition at line 653 of file itemspace.cpp.

bool ItemSpace::locateItemByUser ( QVariant  user,
int *  groupIndex,
int *  itemInGroup 
) const

Find an item by its 'user' parameter.

Definition at line 668 of file itemspace.cpp.

void ItemSpace::offsetPositions ( const QPointF &  offset  ) 

Offset the positions of all items.

Definition at line 134 of file itemspace.cpp.

qreal ItemSpace::performPush ( int  groupId,
Direction  direction,
qreal  amount,
PushPower  power 
)

Push an item group.

Requires no initialization.

Parameters:
groupId the index of the group
direction in which direction pushing will be done
amount how much to push
power how 'powerful' the push is; what types of obstacles can be pushed or ignored
Returns:
how much the item group was really pushed

Definition at line 148 of file itemspace.cpp.

bool ItemSpace::positionedProperly ( QRectF  itemGeom  ) 

Definition at line 158 of file itemspace.cpp.

QList< QPointF > ItemSpace::positionVertically ( const QSizeF &  itemSize,
Qt::Alignment  align,
bool  limitedSpace,
bool  findAll 
) const

Finds an empty place for an item.

Tries to stack the item vertically, starting in the corner of alignment, and advances horizontally once no more positions are valid.

Parameters:
itemSize the size of the item; placementSpacing is already considered
align the corner of the screen where position testing will begin (and in what directions it will advance) must be an OR of Qt::AlignLeft or Qt::AlignRight and Qt::AlignTop or Qt::AlignBottom
limitedSpace if true, positions outside the working area will not be considered; otherwise, positions will only be limited by the borders at the alignment corner.
findAll if false, searching will stop after the first valid position
Returns:
all positions found

Definition at line 164 of file itemspace.cpp.

qreal ItemSpace::positionVisibility ( QRectF  geom  ) 

Returns the visibility of an item at a given position.

This is the part of the item inside the working area.

Definition at line 125 of file itemspace.cpp.

void ItemSpace::preparePush ( Direction  direction,
PushPower  power 
)

Prepare for pushing.

After that, move requests can be posted to item groups with ItemGroup::addRequest and the move can be performed with ItemGroup::applyResults.

Parameters:
direction in which direction pushing will be done
power how 'powerful' the push is; what types of obstacles can be pushed or ignored

Definition at line 684 of file itemspace.cpp.

void ItemSpace::removeItem ( int  groupIndex,
int  itemInGroup 
)

Removes an item by its location.

Parameters:
groupIndex the index of the item's group
itemInGroup the index of the item in its group

Definition at line 631 of file itemspace.cpp.

void ItemSpace::setWorkingArea ( QSizeF  area  ) 

Definition at line 25 of file itemspace.cpp.

void ItemSpace::updateItem ( int  groupIndex,
int  itemInGroup 
)

Updates groups to reflect the item's geometry.

Parameters:
groupIndex the index of the item's group
itemInGroup the index of the item in its group

Definition at line 646 of file itemspace.cpp.


Member Data Documentation

QList<ItemGroup> ItemSpace::m_groups

All item groups.

Definition at line 275 of file itemspace.h.

qreal ItemSpace::placementSpacing

Definition at line 280 of file itemspace.h.

qreal ItemSpace::screenSpacing

Definition at line 281 of file itemspace.h.

qreal ItemSpace::shiftingSpacing

Definition at line 282 of file itemspace.h.

Qt::Alignment ItemSpace::spaceAlignment

Definition at line 277 of file itemspace.h.

QSizeF ItemSpace::workingGeom

Definition at line 278 of file itemspace.h.


The documentation for this class was generated from the following files:
  • itemspace.h
  • itemspace.cpp

Plasma

Skip menu "Plasma"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

API Reference

Skip menu "API Reference"
  • KWin
  •   KWin Libraries
  • Libraries
  •   libkworkspace
  •   libsolidcontrol
  •   libtaskmanager
  • Plasma
  •   Animators
  •   Applets
  •   Engines
  • Solid Modules
Generated for API Reference by doxygen 1.5.7
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal