mirror of
https://github.com/lalbornoz/roar.git
synced 2024-11-25 08:36:38 +00:00
ced45fa0d4
1) Add background colour toolbar beneath (foreground) colour toolbar. 2) Add colour flipping command w/ {accelerator,{menu,toolbar} item}. 3) Add {de,in}crease {brush,canvas} size accelerator. 4) Add {hide,show} assets window toolbar item. 5) Circle tool: draw outline with foreground colour. 6) Circle tool: honour transparency. 7) Fill tool: change comprehensive fill modifier key from <Shift> to <Ctrl>. 8) Fill tool: fill with {back,fore}ground colour given <[RL]MB> 9) Fix arrow keys cursor motion when scrolled down. 10 Instantly reflect {brush size,colour,tool} changes in canvas. 11) Object tool: honour transparency w/ non-external objects. 12) Object tool: update selection rectangle during <LMB> whilst dragging, set w/ release of <LMB>. 13) Rectangle tool: draw outline with foreground colour. 14) Rectangle tool: honour transparency. 15) Replace wx.ToolBar() w/ wx.lib.agw.aui.AuiToolBar() & custom wx.lib.agw.aui.AuiDefaultToolBarArt(). 16) Restore scrolling position after resizing canvas. .TODO: deleted. assets/audio/roar{arab8,spoke11}.wav: added. assets/text/hotkeys.txt: added to document hotkeys. assets/text/requirements.txt, requirements.txt: moved. assets/text/TODO: updated. {assets/tools,lib{canvas,gui,roar,rtl,tools}}/*.py: remove Vim fold markers. libroar/RoarCanvasCommandsFile.py:_importFile(): update wx.FileDialog() message. libroar/RoarCanvasCommandsOperators.py:canvasOperator(): update invert colours {caption,label}.
46 lines
2.2 KiB
Python
46 lines
2.2 KiB
Python
#!/usr/bin/env python3
|
|
#
|
|
# ToolFill.py
|
|
# Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
|
|
#
|
|
|
|
from Tool import Tool
|
|
import wx
|
|
|
|
class ToolFill(Tool):
|
|
name = "Fill"
|
|
|
|
#
|
|
# onMouseEvent(self, atPoint, brushColours, brushPos, brushSize, canvas, dispatchFn, eventDc, keyModifiers, mapPoint, mouseDragging, mouseLeftDown, mouseRightDown)
|
|
def onMouseEvent(self, atPoint, brushColours, brushPos, brushSize, canvas, dispatchFn, eventDc, keyModifiers, mapPoint, mouseDragging, mouseLeftDown, mouseRightDown):
|
|
dirty, pointsDone, pointStack, testChar, testColour = False, [], [list(mapPoint)], canvas.map[mapPoint[1]][mapPoint[0]][3], canvas.map[mapPoint[1]][mapPoint[0]][0:2]
|
|
if mouseLeftDown or mouseRightDown:
|
|
if mouseLeftDown:
|
|
fillColour = brushColours[0]
|
|
else:
|
|
fillColour = brushColours[1]
|
|
while len(pointStack) > 0:
|
|
point = pointStack.pop()
|
|
pointCell = canvas.map[point[1]][point[0]]
|
|
if ((pointCell[1] == testColour[1]) and ((pointCell[3] == testChar) or (keyModifiers == wx.MOD_CONTROL))) \
|
|
or ((pointCell[3] == " ") and (pointCell[1] == testColour[1])):
|
|
if not point in pointsDone:
|
|
if not dirty:
|
|
dirty = True
|
|
dispatchFn(eventDc, False, [*point, fillColour, fillColour, 0, " "])
|
|
if point[0] > 0:
|
|
pointStack.append([point[0] - 1, point[1]])
|
|
if point[0] < (canvas.size[0] - 1):
|
|
pointStack.append([point[0] + 1, point[1]])
|
|
if point[1] > 0:
|
|
pointStack.append([point[0], point[1] - 1])
|
|
if point[1] < (canvas.size[1] - 1):
|
|
pointStack.append([point[0], point[1] + 1])
|
|
pointsDone += [point]
|
|
else:
|
|
patch = [mapPoint[0], mapPoint[1], brushColours[0], brushColours[0], 0, " "]
|
|
dispatchFn(eventDc, True, patch)
|
|
return True, dirty
|
|
|
|
# vim:expandtab foldmethod=marker sw=4 ts=4 tw=120
|