Game Develop Core: gd::LayoutEditorCanvas Class Reference

| Game Develop Core Core library for developing platforms and tools compatible with Game Develop.

- Main Page
- Modules
- Classes

- Class List
- Class Index
- Class Hierarchy

All Classes Files Functions Variables Typedefs Enumerations Macros Groups Pages
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends | List of all members
gd::LayoutEditorCanvas Class Reference
IDE Classes ( Classes to be used to implement a development environment )

Base class for implementing the main canvas of layout editors. More...

`#include <LayoutEditorCanvas.h>`

Inheritance diagram for gd::LayoutEditorCanvas:
[legend]

## Public Member Functions

| LayoutEditorCanvas (wxWindow *parent, gd::Project &project, gd::Layout &layout, gd::InitialInstancesContainer &instances, LayoutEditorCanvasOptions &options, gd::MainFrameWrapper &mainFrameWrapper)
wxWindow * | GetParentControl ()
gd::Project & | GetProject ()
| Return a reference to the game owning the scene being edited inside the editor.
gd::Layout & | GetLayout ()
| Return a reference to the scene being edited inside the editor.
gd::MainFrameWrapper & | GetMainFrameWrapper ()
| Provide an access to the main frame wrapper that can be needed by some previewers.
void | AddAssociatedEditor (gd::LayoutEditorCanvasAssociatedEditor *editor)
| Declares an editor to be associated with the LayoutEditorCanvas. More...
void | SetParentAuiManager (wxAuiManager *parentAuiManager_)
wxAuiManager * | GetParentAuiManager ()
virtual void | SetScrollbars (wxScrollBar *hScrollbar_, wxScrollBar *vScrollbar_)
void | UpdateSize ()
void | ConnectEvents ()
void | RecreateRibbonToolbar ()
virtual void | OnvScrollbarScroll (wxScrollEvent &event)
virtual void | OnhScrollbarScroll (wxScrollEvent &event)
std::vector < gd::InitialInstance * > | GetSelection ()
void | ClearSelection ()
void | AddObject (const std::string &objectName)
void | AddObject (const std::string &objectName, float x, float y)
void | SelectInstance (InitialInstance *instance)
void | UnselectInstance (InitialInstance *instance)
void | DeleteInstances (std::vector< InitialInstance * > instances)
virtual void | EnsureVisible (const gd::InitialInstance &instance)
void | SetCurrentLayer (const std::string &newLayer)
const std::string & | GetCurrentLayer () const
bool | IsEditing () const
bool | PreviewPaused () const
virtual void | PausePreview ()
| Tell the current previewer to pause the preview. More...
void | ReloadResources ()
void | GoToEditingState ()
| Can be called ( by previewers for example ) to ask the editor to go back to editing state.
virtual sf::Vector2f | GetInitialInstanceSize (gd::InitialInstance &instance) const
virtual sf::Vector2f | GetInitialInstanceOrigin (gd::InitialInstance &instance) const

## Static Public Member Functions

static wxRibbonButtonBar * | CreateRibbonPage (wxRibbonPage *page)

## Protected Member Functions

virtual void | OnUpdate ()
virtual void | OnPaint (wxPaintEvent &event)
virtual void | OnEraseBackground (wxEraseEvent &event)
virtual void | OnIdle (wxIdleEvent &)
virtual void | OnPreviewBtClick (wxCommandEvent &event)
virtual void | OnPreviewDropDownBtClick (wxRibbonButtonBarEvent &event)
virtual void | OnEditionBtClick (wxCommandEvent &event)
virtual void | OnHelpBtClick (wxCommandEvent &event)
virtual void | OnLeftDown (wxMouseEvent &event)
virtual void | OnLeftUp (wxMouseEvent &event)
virtual void | OnLeftDClick (wxMouseEvent &event)
virtual void | OnKey (wxKeyEvent &evt)
virtual void | OnKeyUp (wxKeyEvent &evt)
virtual void | OnMiddleDown (wxMouseEvent &event)
virtual void | OnMouseWheel (wxMouseEvent &event)
virtual void | OnRightUp (wxMouseEvent &event)
virtual void | OnMotion (wxMouseEvent &event)
virtual void | OnGridBtClick (wxCommandEvent &event)
virtual void | OnGridSetupBtClick (wxCommandEvent &event)
virtual void | OnObjectsPositionList (wxCommandEvent &event)
virtual void | OnClearHistorySelected (wxCommandEvent &event)
virtual void | OnUndo10Selected (wxCommandEvent &event)
virtual void | OnUndo20Selected (wxCommandEvent &event)
virtual void | OnObjectsEditor (wxCommandEvent &event)
virtual void | OnLayersEditor (wxCommandEvent &event)
virtual void | OnUndoBtClick (wxCommandEvent &event)
virtual void | OnUndoMoreBtClick (wxRibbonButtonBarEvent &event)
virtual void | OnRedoBtClick (wxCommandEvent &event)
virtual void | OnWindowMaskBtClick (wxCommandEvent &event)
virtual void | OnFullScreenBtClick (wxCommandEvent &event)
virtual void | OnGuiElementHovered (const LayoutEditorCanvasGuiElement &guiElement)
virtual void | OnGuiElementPressed (const LayoutEditorCanvasGuiElement &guiElement)
virtual void | OnGuiElementReleased (const LayoutEditorCanvasGuiElement &guiElement)
virtual void | OnOrigineBtClick (wxCommandEvent &event)
virtual void | OnZoomInitBtClick (wxCommandEvent &event)
virtual void | OnZoomMoreBtClick (wxRibbonButtonBarEvent &evt)
virtual void | OnCustomZoom5Selected (wxCommandEvent &event)
virtual void | OnCustomZoom10Selected (wxCommandEvent &event)
virtual void | OnCustomZoom25Selected (wxCommandEvent &event)
virtual void | OnCustomZoom50Selected (wxCommandEvent &event)
virtual void | OnCustomZoom100Selected (wxCommandEvent &event)
virtual void | OnCustomZoom150Selected (wxCommandEvent &event)
virtual void | OnCustomZoom200Selected (wxCommandEvent &event)
virtual void | OnCustomZoom500Selected (wxCommandEvent &event)
virtual void | OnPropObjSelected (wxCommandEvent &event)
virtual void | OnLayerUpSelected (wxCommandEvent &event)
virtual void | OnLayerDownSelected (wxCommandEvent &event)
virtual void | OnCopySelected (wxCommandEvent &event)
virtual void | OnCutSelected (wxCommandEvent &event)
virtual void | OnPasteSelected (wxCommandEvent &event)
virtual void | OnPasteSpecialSelected (wxCommandEvent &event)
virtual void | OnDeleteObjectSelected (wxCommandEvent &event)
virtual void | OnCreateObjectSelected (wxCommandEvent &event)
virtual void | OnLockSelected (wxCommandEvent &event)
virtual void | OnUnLockSelected (wxCommandEvent &event)
virtual void | OnPreviewForPlatformSelected (wxCommandEvent &event)
virtual double | GetMouseXOnLayout () const
virtual double | GetMouseYOnLayout () const
void | RenderEdittime ()
void | RenderGrid ()
void | AddSmallButtonGuiElement (std::vector< boost::shared_ptr< sf::Shape > > &target, const sf::Vector2f &position, const std::string &buttonName)
void | DrawSelectionRectangleGuiElement (std::vector< boost::shared_ptr< sf::Shape > > &target, const sf::FloatRect &rectangle)
void | DrawAngleButtonGuiElement (std::vector< boost::shared_ptr< sf::Shape > > &target, const sf::Vector2f &position, float angle)
void | DrawHighlightRectangleGuiElement (std::vector< boost::shared_ptr< sf::Shape > > &target, const sf::FloatRect &rectangle)
sf::Vector2f | ConvertToWindowCoordinates (float x, float y, const sf::View &view)
void | AddGuiElement (LayoutEditorCanvasGuiElement element)
void | ClearAllGuiElements ()
virtual void | CreateEditionRibbonTools ()
InitialInstance * | GetInitialInstanceUnderCursor (bool pickOnlyLockedInstances=false)
InitialInstance * | GetInitialInstanceAtPosition (double xPosition, double yPosition, bool pickOnlyLockedInstances=false)
void | ChangesMade ()
gd::Object * | GetObjectLinkedToInitialInstance (gd::InitialInstance &instance) const
virtual void | Undo (unsigned int times=1)
virtual void | Redo (unsigned int times=1)
void | UpdateMouseResizeCursor (const std::string &currentDraggableBt)
void | UpdateContextMenu ()
void | UpdateScrollbars ()
void | UpdateViewAccordingToZoomFactor ()
void | SendSelectionToLayer (const std::string &newLayerName)

## Protected Attributes

std::map< long, std::string > | idForPlatformsMenu
gd::Project & | project
| The project owning the layout.
gd::Layout & | layout
| The layout being edited or used to edit the instances.
gd::InitialInstancesContainer & | instances
| The initial instances of objects being edited.
LayoutEditorCanvasOptions & | options
gd::MainFrameWrapper & | mainFrameWrapper
std::set < LayoutEditorCanvasAssociatedEditor * > | associatedEditors
std::map< std::string, boost::shared_ptr < gd::LayoutEditorPreviewer > > | previewers
wxWindow * | parentControl
| The wxWidgets control owning the editor ( probably a wxPanel )
wxAuiManager * | parentAuiManager
| Pointer to the wxAuiManager displayed the editor. Can be NULL.
wxScrollBar * | hScrollbar
wxScrollBar * | vScrollbar
wxMenu | undoMenu
sf::View | editionView
| The view used for editing.
std::string | currentDraggableBt
std::map< gd::InitialInstance *, double > | resizeOriginalWidths
std::map< gd::InitialInstance *, double > | resizeOriginalHeights
sf::Vector2f | resizeMouseStartPosition
sf::Vector2f | angleButtonCenter
bool | isMovingView
sf::Vector2f | movingViewMouseStartPosition
sf::Vector2f | movingViewStartPosition
bool | hasJustRightClicked
bool | ctrlPressed
bool | altPressed
bool | shiftPressed
double | oldMouseX
| The mouse X position which was usually stored the last time a right click happened.
double | oldMouseY
| The mouse X position which was usually stored the last time a right click happened.
bool | isMovingInstance
bool | firstRefresh
bool | isSelecting
wxRect | selectionRectangle
std::map< InitialInstance *, wxRealPoint > | selectedInstances
std::string | currentLayer
| The layer where the new instance must be added.
std::vector< boost::shared_ptr < gd::InitialInstancesContainer > > | history
| History of changes.
std::vector< boost::shared_ptr < gd::InitialInstancesContainer > > | redoHistory
| Histoy of changes so as to "redo".
boost::shared_ptr < gd::InitialInstancesContainer > | latestState
| Necessary to keep track of what changed.
std::vector < LayoutEditorCanvasGuiElement > | guiElements
bool | editing
| True if the layout is being edited, false if a preview is running.
boost::shared_ptr < gd::LayoutEditorPreviewer > | currentPreviewer
| The previewer being used to preview the layout.
wxMenu | contextMenu
wxMenu | noObjectContextMenu
wxMenu | zoomMenu
wxMenu | platformsMenu

## Static Protected Attributes

static const long | idRibbonEditMode = wxNewId()
static const long | idRibbonPreviewMode = wxNewId()
static const long | idRibbonHelp = wxNewId()
static const long | idRibbonObjectsEditor = wxNewId()
static const long | idRibbonLayersEditor = wxNewId()
static const long | idRibbonGrid = wxNewId()
static const long | idRibbonWindowMask = wxNewId()
static const long | idRibbonGridSetup = wxNewId()
static const long | idRibbonUndo = wxNewId()
static const long | idUndo10 = wxNewId()
static const long | idUndo20 = wxNewId()
static const long | idClearHistory = wxNewId()
static const long | idRibbonRedo = wxNewId()
static const long | idRibbonObjectsPositionList = wxNewId()
static const long | idRibbonFullScreen = wxNewId()
static const long | idRibbonOrigine = wxNewId()
static const long | idRibbonOriginalZoom = wxNewId()
static const long | ID_CUSTOMZOOMMENUITEM500 = wxNewId()
static const long | ID_CUSTOMZOOMMENUITEM200 = wxNewId()
static const long | ID_CUSTOMZOOMMENUITEM150 = wxNewId()
static const long | ID_CUSTOMZOOMMENUITEM100 = wxNewId()
static const long | ID_CUSTOMZOOMMENUITEM50 = wxNewId()
static const long | ID_CUSTOMZOOMMENUITEM25 = wxNewId()
static const long | ID_CUSTOMZOOMMENUITEM10 = wxNewId()
static const long | ID_CUSTOMZOOMMENUITEM5 = wxNewId()
static const long | ID_ADDOBJMENU = wxNewId()
static const long | ID_DELOBJMENU = wxNewId()
static const long | ID_PROPMENU = wxNewId()
static const long | ID_LAYERUPMENU = wxNewId()
static const long | ID_LAYERDOWNMENU = wxNewId()
static const long | ID_COPYMENU = wxNewId()
static const long | ID_CUTMENU = wxNewId()
static const long | ID_PASTEMENU = wxNewId()
static const long | ID_PASTESPECIALMENU = wxNewId()
static const long | ID_CREATEOBJECTMENU = wxNewId()
static const long | ID_UNLOCKMENU = wxNewId()
static const long | ID_LOCKMENU = wxNewId()
static const float | gapBetweenButtonsAndRectangle = 5
static const float | smallButtonSize = 5

## Friends

class | InstancesRenderer
class | InstancesInsideSelectionPicker
class | SmallestInstanceUnderCursorPicker

## Detailed Description

Base class for implementing the main canvas of layout editors.

## Member Function Documentation

void gd::LayoutEditorCanvas::AddAssociatedEditor | ( | gd::LayoutEditorCanvasAssociatedEditor * | editor) |  |

Declares an editor to be associated with the LayoutEditorCanvas.

When LayoutEditorCanvas will make changes, it will be notifying the associated editors thanks to the members functions declared in gd::LayoutEditorCanvasAssociatedEditor.

The IDE, when creating a LayoutEditorCanvas, is responsible for calling this method, as it is the IDE which is also creating the others editors.

Parameters

  editor | Pointer to the editor to be notified of changes. Must be not NULL.

void gd::LayoutEditorCanvas::AddGuiElement | ( | LayoutEditorCanvasGuiElement | element) |  |

inlineprotected

Can be called ( most of the time when the layout is rendered when editing ) to declare that there is an active gui element at a position, along with some other informations.

See Also
  LayoutEditorCanvasGuiElement
  ClearAllGuiElements

void gd::LayoutEditorCanvas::AddObject | ( | const std::string & | objectName) |  |

Add an instance of the specified object at the cursor position.

void gd::LayoutEditorCanvas::AddObject | ( | const std::string & | objectName,
|  | float | x,
|  | float | y
| ) |  |

Add an instance of the specified object at the specified position.

void gd::LayoutEditorCanvas::ChangesMade | ( | ) |  |

protected

Called when a changes has been made ( Something which is lasting, e.g. when an object has been moved, but not when it is being moved ).

void gd::LayoutEditorCanvas::ClearAllGuiElements | ( | ) |  |

inlineprotected

Clear the list containing the description of gui elements. Should be called at each rendering when editing, before adding the new gui elements just rendered.

void gd::LayoutEditorCanvas::ClearSelection | ( | ) |  |

Clear the selection, notifying associated editors.

void gd::LayoutEditorCanvas::ConnectEvents | ( | ) |  |

Called by the IDE when the editor is active to connect ribbon buttons to the editor methods

void gd::LayoutEditorCanvas::CreateEditionRibbonTools | ( | ) |  |

protectedvirtual

Called when the ribbon buttons of edition mode must be created inside ribbonToolbar.

See Also
  CreatePreviewRibbonTools

wxRibbonButtonBar * gd::LayoutEditorCanvas::CreateRibbonPage | ( | wxRibbonPage * | page) |  |

static

Static method for creating the ribbon's page used by all layout editors. Called by the IDE.

Returns
  The wxRibbonButtonBar to be used for the custom tools. Can be accessed then thanks to the MainFrameWrapper object.

void gd::LayoutEditorCanvas::DeleteInstances | ( | std::vector< InitialInstance * > | instances) |  |

Delete the specified instance, notifying associated editors.

void gd::LayoutEditorCanvas::EnsureVisible | ( | const gd::InitialInstance & | instance) |  |

virtual

Can be called so that the editor make the initial instance passed in parameters visible.

const std::string& gd::LayoutEditorCanvas::GetCurrentLayer | ( | ) |  | const

inline

Return the current layer

InitialInstance * gd::LayoutEditorCanvas::GetInitialInstanceAtPosition | ( | double | xPosition,
|  | double | yPosition,
|  | bool | pickOnlyLockedInstances = `false`
| ) |  |

protected

Return a pointer to the smallest initial instance which intersect with the specified position Can be NULL.

InitialInstance* gd::LayoutEditorCanvas::GetInitialInstanceUnderCursor | ( | bool | pickOnlyLockedInstances = `false`) |  |

inlineprotected

Return a pointer to the smallest initial instance under the cursor. Can be NULL.

gd::Object * gd::LayoutEditorCanvas::GetObjectLinkedToInitialInstance | ( | gd::InitialInstance & | instance) |  | const

protected

Tool function returning the object used to display during the instance when editing.

wxAuiManager* gd::LayoutEditorCanvas::GetParentAuiManager | ( | ) |  |

inline

Get the wxAuiManager managing the editor. Can be NULL.

See Also
  SetParentAuiManager

wxWindow* gd::LayoutEditorCanvas::GetParentControl | ( | ) |  |

inline

Get the parent window of the editor.s

std::vector< gd::InitialInstance * > gd::LayoutEditorCanvas::GetSelection | ( | ) |  |

Return a list of the currently selected instances.

bool gd::LayoutEditorCanvas::IsEditing | ( | ) |  | const

inline

Return true if the editor is in editing state.

void gd::LayoutEditorCanvas::OnEditionBtClick | ( | wxCommandEvent & | event) |  |

protectedvirtual

Go in edition mode

void gd::LayoutEditorCanvas::OnFullScreenBtClick | ( | wxCommandEvent & | event) |  |

protectedvirtual

Toggle Game Develop full screen mode.

void gd::LayoutEditorCanvas::OnhScrollbarScroll | ( | wxScrollEvent & | event) |  |

virtual

The editors' parent panel can forward the event of the scrollbars to these methods.

See Also
  OnvScrollbarScroll

void gd::LayoutEditorCanvas::OnPreviewBtClick | ( | wxCommandEvent & | event) |  |

protectedvirtual

Go in preview mode

void gd::LayoutEditorCanvas::OnvScrollbarScroll | ( | wxScrollEvent & | event) |  |

virtual

The editors' parent panel can forward the event of the scrollbars to these methods.

See Also
  OnhScrollbarScroll

void gd::LayoutEditorCanvas::PausePreview | ( | ) |  |

virtual

Tell the current previewer to pause the preview.

Has no effects in editing state.

bool gd::LayoutEditorCanvas::PreviewPaused | ( | ) |  | const

Return true if the scene is being previewed ( i.e. : IsEditing() == false ) but the preview is paused.

void gd::LayoutEditorCanvas::RecreateRibbonToolbar | ( | ) |  |

Can be called by the IDE to force the recreation of the custom toolbar of the ribbon, for example when switching the focus to a LayoutEditorCanvas.

See Also
  CreatePreviewRibbonTools
  CreateEditionRibbonTools

void gd::LayoutEditorCanvas::Redo | ( | unsigned int | times = `1`) |  |

protectedvirtual

Redo last changes.

void gd::LayoutEditorCanvas::ReloadResources | ( | ) |  |

Load resources for objects.

void gd::LayoutEditorCanvas::SelectInstance | ( | InitialInstance * | instance) |  |

Add an instance to selection, notifying associated editors.

void gd::LayoutEditorCanvas::SetCurrentLayer | ( | const std::string & | newLayer) |  |

inline

Set the layer where the new instance must be added

void gd::LayoutEditorCanvas::SetParentAuiManager | ( | wxAuiManager * | parentAuiManager_) |  |

Can be called by the IDE to notify the editor that it is displayed thanks to a wxAuiManager and that it can uses it to display it own sub editors.

virtual void gd::LayoutEditorCanvas::SetScrollbars | ( | wxScrollBar * | hScrollbar_,
|  | wxScrollBar * | vScrollbar_
| ) |  |

inlinevirtual

Set the scrollbars associated with the editor.

Parameters

  hScrollbar | The horizontal scrollbar
  vScrollbar | The vertical scrollbar

void gd::LayoutEditorCanvas::Undo | ( | unsigned int | times = `1`) |  |

protectedvirtual

Undo last changes.

void gd::LayoutEditorCanvas::UnselectInstance | ( | InitialInstance * | instance) |  |

Remove an instance from selection, notifying associated editors.

void gd::LayoutEditorCanvas::UpdateMouseResizeCursor | ( | const std::string & | currentDraggableBt) |  |

protected

Update the mouse according to the selected button

void gd::LayoutEditorCanvas::UpdateSize | ( | ) |  |

Must be called by the IDE when the parent control size has changed: The editor must update its size ( wxWindow::SetSize ) according to the parentControl size and the scrollbars.

The documentation for this class was generated from the following files:

- LayoutEditorCanvas.h
- LayoutEditorCanvas.cpp
- LayoutEditorCanvas2.cpp