~ubuntu-branches/ubuntu/trusty/python-enable/trusty

« back to all changes in this revision

Viewing changes to enthought/enable/slider.py

  • Committer: Bazaar Package Importer
  • Author(s): Varun Hiremath
  • Date: 2010-02-28 14:56:36 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20100228145636-9ghfhe3uy37tt3q6
Tags: 3.3.0-1
* New upstream release
* Bump Standards-Version to 3.8.4
* Switch to source format 3.0
* Update patches/freetype2.diff

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
 
2
 
from numpy import linspace, zeros, zeros_like
 
2
from numpy import linspace, zeros
3
3
 
4
4
# Enthought library imports
5
5
from enthought.kiva import STROKE
6
 
from enthought.traits.api import Any, Bool, Enum, Float, Instance, Int, Property, \
7
 
        on_trait_change, Trait
 
6
from enthought.traits.api import (Any, Bool, Enum, Float, Int, Property,
 
7
                                  on_trait_change, Trait)
8
8
from enthought.traits.ui.api import EnumEditor
9
9
 
10
10
# Local, relative imports
11
 
from base_tool import BaseTool
12
11
from colors import ColorTrait
13
12
from component import Component
14
13
from markers import MarkerNameDict, marker_names, CustomMarker
41
40
    # Whether this is a horizontal or vertical slider
42
41
    orientation = Enum("h", "v")
43
42
 
 
43
    # The thickness, in pixels, of the lines used to render the ticks,
 
44
    # endcaps, and main slider bar.
44
45
    bar_width = Int(4)
45
46
 
46
47
    bar_color = ColorTrait("black")
423
424
    def dragging_mouse_move(self, event):
424
425
        dx, dy = self._offset
425
426
        self.value = self.map_data(event.x - dx, event.y - dy)
 
427
        event.handled = True
426
428
        self.request_redraw()
427
429
 
428
430
    def dragging_mouse_leave(self, event):
456
458
        elif self.orientation == "h" and (y <= event.y <= y2):
457
459
            if not (x <= event.x <= x2):
458
460
                self._offset = (0, event.y - pt[1])
459
 
                self.dragging_mouse_event(event)
 
461
                self.dragging_mouse_move(event)
460
462
            else:
461
463
                self._offset = (event.x - pt[0], event.y - pt[1])
462
464
        else:
463
465
            # The mouse click missed the bar and the slider.
464
466
            return
465
467
 
 
468
        event.handled = True
466
469
        self.event_state = "dragging"
467
470
        return
468
471
 
469
472
    def _mouse_released(self, event):
470
473
        self.event_state = "normal"
 
474
        event.handled = True
471
475
 
472
476
    #------------------------------------------------------------------------
473
477
    # Private trait event handlers and property getters/setters