Skip to content

Commit

Permalink
Merge pull request #21 from nucleic/bubble-fix
Browse files Browse the repository at this point in the history
Bubble fix
  • Loading branch information
sccolbert committed May 2, 2013
2 parents 62d5a3a + 92840b8 commit a511712
Show file tree
Hide file tree
Showing 10 changed files with 1,151 additions and 757 deletions.
407 changes: 0 additions & 407 deletions enaml/qt/q_bubble_view.py

This file was deleted.

634 changes: 634 additions & 0 deletions enaml/qt/q_popup_view.py

Large diffs are not rendered by default.

123 changes: 0 additions & 123 deletions enaml/qt/qt_bubble_view.py

This file was deleted.

12 changes: 6 additions & 6 deletions enaml/qt/qt_factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ def action_group_factory():
return QtActionGroup


def bubble_view_factory():
from .qt_bubble_view import QtBubbleView
return QtBubbleView


def calendar_factory():
from .qt_calendar import QtCalendar
return QtCalendar
Expand Down Expand Up @@ -175,6 +170,11 @@ def page_factory():
return QtPage


def popup_view_factory():
from .qt_popup_view import QtPopupView
return QtPopupView


def push_button_factory():
from .qt_push_button import QtPushButton
return QtPushButton
Expand Down Expand Up @@ -273,7 +273,6 @@ def window_factory():
QT_FACTORIES = {
'Action': action_factory,
'ActionGroup': action_group_factory,
'BubbleView': bubble_view_factory,
'Calendar': calendar_factory,
'CheckBox': check_box_factory,
'ComboBox': combo_box_factory,
Expand Down Expand Up @@ -304,6 +303,7 @@ def window_factory():
'Notebook': notebook_factory,
'ObjectCombo': object_combo_factory,
'Page': page_factory,
'PopupView': popup_view_factory,
'PushButton': push_button_factory,
'ProgressBar': progress_bar_factory,
'RadioButton': radio_button_factory,
Expand Down
165 changes: 165 additions & 0 deletions enaml/qt/qt_popup_view.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
#------------------------------------------------------------------------------
# Copyright (c) 2013, Nucleic Development Team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file COPYING.txt, distributed with this software.
#------------------------------------------------------------------------------
from PyQt4.QtCore import Qt, QPointF, QPoint

from atom.api import Typed

from enaml.widgets.popup_view import ProxyPopupView

from .q_popup_view import QPopupView
from .qt_widget import QtWidget


EDGES = {
'left': QPopupView.LeftEdge,
'right': QPopupView.RightEdge,
'top': QPopupView.TopEdge,
'bottom': QPopupView.BottomEdge,
}


WINDOW_TYPES = {
'popup': Qt.Popup,
'tool_tip': Qt.ToolTip,
}


class QtPopupView(QtWidget, ProxyPopupView):
""" A Qt implementation of an Enaml ProxyPopupView.
"""
#: A reference to the toolkit widget created by the proxy.
widget = Typed(QPopupView)

#--------------------------------------------------------------------------
# Initialization API
#--------------------------------------------------------------------------
def create_widget(self):
""" Create the QPopupView widget.
"""
flags = WINDOW_TYPES[self.declaration.window_type]
self.widget = QPopupView(self.parent_widget(), flags)

def init_widget(self):
""" Initialize the widget.
"""
super(QtPopupView, self).init_widget()
d = self.declaration
self.set_anchor(d.anchor)
self.set_parent_anchor(d.parent_anchor)
self.set_arrow_size(d.arrow_size)
self.set_arrow_edge(d.arrow_edge)
self.set_arrow_position(d.arrow_position)
self.set_offset(d.offset)
self.set_timeout(d.timeout)
self.set_fade_in_duration(d.fade_in_duration)
self.set_fade_out_duration(d.fade_out_duration)
self.widget.closed.connect(self.on_closed)

def init_layout(self):
""" Initialize the widget layout.
"""
super(QtPopupView, self).init_layout()
self.widget.setCentralWidget(self.central_widget())

#--------------------------------------------------------------------------
# Public API
#--------------------------------------------------------------------------
def central_widget(self):
""" Find and return the central widget child for this widget.
Returns
-------
result : QWidget or None
The central widget defined for this widget, or None if one
is not defined.
"""
d = self.declaration.central_widget()
if d is not None:
return d.proxy.widget

#--------------------------------------------------------------------------
# Signal Handlers
#--------------------------------------------------------------------------
def on_closed(self):
""" The signal handler for the 'closed' signal.
This handler will notify the declaration object that the popup
view has closed.
"""
d = self.declaration
if d is not None:
d._popup_closed()

#--------------------------------------------------------------------------
# ProxyBubbleView API
#--------------------------------------------------------------------------
def set_anchor(self, anchor):
""" Set the anchor location on the underlying widget.
"""
self.widget.setAnchor(QPointF(*anchor))

def set_parent_anchor(self, anchor):
""" Set the parent anchor location on the underlying widget.
"""
self.widget.setParentAnchor(QPointF(*anchor))

def set_arrow_size(self, size):
""" Set the size of the arrow on the underlying widget.
"""
self.widget.setArrowSize(size)

def set_arrow_edge(self, edge):
""" Set the arrow edge on the underlying widget.
"""
self.widget.setArrowEdge(EDGES[edge])

def set_arrow_position(self, pos):
""" Set the position of the arrow on the underlying widget.
"""
self.widget.setArrowPosition(pos)

def set_offset(self, offset):
""" Set the offset of the underlying widget.
"""
self.widget.setOffset(QPoint(*offset))

def set_timeout(self, timeout):
""" Set the timeout for the underlying widget.
"""
self.widget.setTimeout(timeout)

def set_fade_in_duration(self, duration):
""" Set the fade in duration for the underlying widget.
"""
self.widget.setFadeInDuration(duration)

def set_fade_out_duration(self, duration):
""" Set the fade out duration for the underlying widget.
"""
self.widget.setFadeOutDuration(duration)

def close(self):
""" Close the underlying popup widget.
"""
self.widget.close()
2 changes: 1 addition & 1 deletion enaml/widgets/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#------------------------------------------------------------------------------
from .action import Action
from .action_group import ActionGroup
from .bubble_view import BubbleView
from .calendar import Calendar
from .check_box import CheckBox
from .combo_box import ComboBox
Expand Down Expand Up @@ -39,6 +38,7 @@
from .notebook import Notebook
from .object_combo import ObjectCombo
from .page import Page
from .popup_view import PopupView
from .progress_bar import ProgressBar
from .push_button import PushButton
from .radio_button import RadioButton
Expand Down
Loading

0 comments on commit a511712

Please sign in to comment.