mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-01 19:12:31 +08:00
feat: Added Decorator class and HasDecorator mixin (#1781)
The new class allows applying visual filters to canvas drawing operations. It is conceptually similar to the LayerProcessor class, except that it applies directly to a canvas instead of a Picture. This functionality was extracted from PR #1755. NB: the guitar image was taken from here, which is a public domain image, i.e. licensed under CC0 1.0.
This commit is contained in:
@ -52,6 +52,11 @@ class FlutterAppDirective(SphinxDirective):
|
||||
compiled.
|
||||
"infobox" - the content will be displayed as an infobox floating on
|
||||
the right-hand side of the page.
|
||||
|
||||
:width: - override the default width of an iframe in widget/infobox modes.
|
||||
|
||||
:height: - override the default height of an iframe in widget/infobox
|
||||
modes.
|
||||
"""
|
||||
has_content = True
|
||||
required_arguments = 0
|
||||
@ -60,6 +65,8 @@ class FlutterAppDirective(SphinxDirective):
|
||||
'sources': directives.unchanged,
|
||||
'page': directives.unchanged,
|
||||
'show': directives.unchanged,
|
||||
'width': directives.unchanged,
|
||||
'height': directives.unchanged,
|
||||
}
|
||||
# Static list of targets that were already compiled during the build
|
||||
COMPILED = []
|
||||
@ -89,7 +96,21 @@ class FlutterAppDirective(SphinxDirective):
|
||||
iframe_url = _doc_root() + self.html_dir + '/index.html?' + page
|
||||
result = []
|
||||
if 'widget' in self.modes:
|
||||
result.append(IFrame(src=iframe_url, classes=['flutter-app-iframe']))
|
||||
iframe = IFrame(src=iframe_url, classes=['flutter-app-iframe'])
|
||||
result.append(iframe)
|
||||
styles = []
|
||||
if self.options.get('width'):
|
||||
width = self.options.get('width')
|
||||
if width.isdigit():
|
||||
width += 'px'
|
||||
styles.append("width: " + width)
|
||||
if self.options.get('height'):
|
||||
height = self.options.get('height')
|
||||
if height.isdigit():
|
||||
height += 'px'
|
||||
styles.append("height: " + height)
|
||||
if styles:
|
||||
iframe.attributes['style'] = '; '.join(styles)
|
||||
if 'popup' in self.modes:
|
||||
result.append(Button(
|
||||
'',
|
||||
@ -237,8 +258,10 @@ def _doc_root():
|
||||
|
||||
class IFrame(nodes.Element, nodes.General):
|
||||
def visit(self, node):
|
||||
self.body.append(
|
||||
self.starttag(node, 'iframe', src=node.attributes['src']))
|
||||
attrs = {'src': node.attributes['src']}
|
||||
if 'style' in node.attributes:
|
||||
attrs['style'] = node.attributes['style']
|
||||
self.body.append(self.starttag(node, 'iframe', **attrs).strip())
|
||||
|
||||
def depart(self, _):
|
||||
self.body.append('</iframe>')
|
||||
|
||||
Reference in New Issue
Block a user