Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Federico Ariza edited this page Jan 7, 2014 · 54 revisions

.. contents:: Table of Contents

.. author:: Federico Ariza

.. date:: January 7, 2014

Discussion

Branches and Pull requests

Previous work

Abstract

The Toolbar, Navigation and Controls are separated to provide independent access and reconfiguration.

An interface to manage "controls" will be added.

This approach will make easier to create and share controls among users. We can even foresee a kind of marketplace for Controls where the most popular can be added into the main distribution.

Detailed description

The user interaction with the Figure is highly tied to the Toolbar. The reconfiguration of this Toolbar complex requiring most of the time a custom backend.

The creation of custom Controls sometimes interferes with the Toolbar, as example see https://github.com/matplotlib/matplotlib/issues/2694#issuecomment-31231279 also the shortcuts are hardcoded and again not easily modifiable https://github.com/matplotlib/matplotlib/issues/2699#issuecomment-31399720

The proposed solution is to create a NavigationBase, ToolbarBase and ControlBase.

The NavigationBase class is instantiated for each Figure and collects the all user interactions (Controls) with the figure (mouse, keyboard, etc...).

The ToolbarBase is relegated only as a GUI access to this Controls.

ControlBase is the basic definition of Controls.

Implementation

ControlBase

To make the creation of controls simple, only two types of controls will be defined.

  • Button, as Home, Back
  • Radio, as Zoom and Pan

Each control defines the following methods

  • Activate
  • Deactivate

Each control defines the following attributes that are going to be used by Navigation

  • Type: Button or Radio
  • Image: Image to be used in the toolbar
  • InToolbar: Boolean defining if we want to add it to the toolbar
  • Shortcut: Desired shortcut for the Control (final decision belongs to Navigation)

By default the current controls will be added Home, Back, etc...

NavigationBase

For simplicity there will be only one group for Radio Controls, this means only one Radio Control can be active at any time.

The NavigationBase defines methods to

  • add: Add Control
  • remove: Remove Control
  • activate: Activate Control
  • deactivate: Deactivate Control
  • list: Get the list of Controls
  • list shortcuts: Get the list of shortcuts with their respective controls
  • change shortcut: Change the Control shortcut
  • toggle control: For Radio Controls toggle it
  • get toggled: Get the status or Toggled Control

ToolbarBase

The basic methods are

  • add: Add a Control
  • remove: Remove a Control
  • set_figure: Set the figure affected by this toolbar

Backward compatibility

For normal users it will be transparent but for any custom backend...

Alternatives

TBD

Clone this wiki locally