kopia lustrzana https://github.com/peterhinch/micropython-micro-gui
3-button mode: fix double-click on button.
rodzic
f7c33cb408
commit
01b00c5e2c
|
@ -14,7 +14,6 @@ from gui.core.colors import *
|
||||||
from hardware_setup import ssd
|
from hardware_setup import ssd
|
||||||
|
|
||||||
from gui.primitives import Pushbutton
|
from gui.primitives import Pushbutton
|
||||||
|
|
||||||
# Globally available singleton objects
|
# Globally available singleton objects
|
||||||
display = None # Singleton instance
|
display = None # Singleton instance
|
||||||
ssd = None
|
ssd = None
|
||||||
|
@ -282,9 +281,7 @@ class Screen:
|
||||||
for obj in cls.current_screen.displaylist:
|
for obj in cls.current_screen.displaylist:
|
||||||
if obj.visible: # In a buttonlist only show visible button
|
if obj.visible: # In a buttonlist only show visible button
|
||||||
if force or obj.draw:
|
if force or obj.draw:
|
||||||
obj.draw_border()
|
|
||||||
obj.show()
|
obj.show()
|
||||||
obj.draw = False
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def change(cls, cls_new_screen, *, forward=True, args=[], kwargs={}):
|
def change(cls, cls_new_screen, *, forward=True, args=[], kwargs={}):
|
||||||
|
@ -410,7 +407,6 @@ class Screen:
|
||||||
dev.fill_rect(x0, y0, w, h, color_map[BG]) # Blank to screen BG
|
dev.fill_rect(x0, y0, w, h, color_map[BG]) # Blank to screen BG
|
||||||
for obj in [z for z in self.displaylist if z.overlaps(x0, y0, x1, y1)]:
|
for obj in [z for z in self.displaylist if z.overlaps(x0, y0, x1, y1)]:
|
||||||
if obj.visible:
|
if obj.visible:
|
||||||
obj.draw_border()
|
|
||||||
obj.show()
|
obj.show()
|
||||||
# Normally clear the screen and redraw everything
|
# Normally clear the screen and redraw everything
|
||||||
else:
|
else:
|
||||||
|
@ -561,6 +557,8 @@ class Widget:
|
||||||
fgcolor, bgcolor, bdcolor,
|
fgcolor, bgcolor, bdcolor,
|
||||||
value=None, active=False):
|
value=None, active=False):
|
||||||
self.active = active
|
self.active = active
|
||||||
|
# By default widgets cannot be adjusted: no green border in adjust mode
|
||||||
|
self.adjustable = False
|
||||||
self._greyed_out = False
|
self._greyed_out = False
|
||||||
Screen.addobject(self)
|
Screen.addobject(self)
|
||||||
self.screen = Screen.current_screen
|
self.screen = Screen.current_screen
|
||||||
|
@ -658,12 +656,13 @@ class Widget:
|
||||||
y = self.row - 2
|
y = self.row - 2
|
||||||
w = self.width + 4
|
w = self.width + 4
|
||||||
h = self.height + 4
|
h = self.height + 4
|
||||||
|
#print('border', self, display.ipdev.is_adjust())
|
||||||
if self.has_focus() and not isinstance(self, DummyWidget):
|
if self.has_focus() and not isinstance(self, DummyWidget):
|
||||||
color = color_map[FOCUS]
|
color = color_map[FOCUS]
|
||||||
precision = hasattr(self, 'do_precision') and self.do_precision and display.ipdev.is_precision()
|
precision = hasattr(self, 'do_precision') and self.do_precision and display.ipdev.is_precision()
|
||||||
if precision:
|
if precision:
|
||||||
color = self.prcolor
|
color = self.prcolor
|
||||||
elif display.ipdev.is_adjust():
|
elif display.ipdev.is_adjust() and self.adjustable:
|
||||||
color = color_map[ADJUSTING]
|
color = color_map[ADJUSTING]
|
||||||
dev.rect(x, y, w, h, color)
|
dev.rect(x, y, w, h, color)
|
||||||
self.has_border = True
|
self.has_border = True
|
||||||
|
@ -701,7 +700,6 @@ class Widget:
|
||||||
self._greyed_out = val
|
self._greyed_out = val
|
||||||
if self.screen is Screen.current_screen:
|
if self.screen is Screen.current_screen:
|
||||||
display.usegrey(val)
|
display.usegrey(val)
|
||||||
self.draw_border()
|
|
||||||
self.show()
|
self.show()
|
||||||
return self._greyed_out
|
return self._greyed_out
|
||||||
|
|
||||||
|
@ -736,6 +734,7 @@ class LinearIO(Widget):
|
||||||
super().__init__(writer, row, col, height, width,
|
super().__init__(writer, row, col, height, width,
|
||||||
fgcolor, bgcolor, bdcolor,
|
fgcolor, bgcolor, bdcolor,
|
||||||
value, active)
|
value, active)
|
||||||
|
self.adjustable = True # Can show adjustable border
|
||||||
self.do_precision = prcolor is not False
|
self.do_precision = prcolor is not False
|
||||||
if self.do_precision:
|
if self.do_precision:
|
||||||
self.prcolor = color_map[PRECISION] if prcolor is None else prcolor
|
self.prcolor = color_map[PRECISION] if prcolor is None else prcolor
|
||||||
|
|
|
@ -45,7 +45,7 @@ class BaseScreen(Screen):
|
||||||
('Help', cb, (2,)))
|
('Help', cb, (2,)))
|
||||||
|
|
||||||
wri = CWriter(ssd, font, GREEN, BLACK, verbose=False)
|
wri = CWriter(ssd, font, GREEN, BLACK, verbose=False)
|
||||||
Menu(wri, bgcolor=BLUE, textcolor=WHITE, args = mnu)
|
Menu(wri, bgcolor=BLUE, textcolor=WHITE, fgcolor=RED, args = mnu)
|
||||||
CloseButton(wri)
|
CloseButton(wri)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,7 @@ class Dropdown(Widget):
|
||||||
return v
|
return v
|
||||||
|
|
||||||
def _draw(self, x, y):
|
def _draw(self, x, y):
|
||||||
self.draw_border()
|
#self.draw_border()
|
||||||
display.vline(x + self.width - self.height, y, self.height, self.fgcolor)
|
display.vline(x + self.width - self.height, y, self.height, self.fgcolor)
|
||||||
xcentre = x + self.width - self.height // 2 # Centre of triangle
|
xcentre = x + self.width - self.height // 2 # Centre of triangle
|
||||||
ycentre = y + self.height // 2
|
ycentre = y + self.height // 2
|
||||||
|
|
|
@ -64,6 +64,7 @@ class Listbox(Widget):
|
||||||
value = min(value, len(elements) - 1)
|
value = min(value, len(elements) - 1)
|
||||||
self.ntop = value - self.dlines + 1
|
self.ntop = value - self.dlines + 1
|
||||||
super().__init__(writer, row, col, height, width, fgcolor, bgcolor, bdcolor, value, True)
|
super().__init__(writer, row, col, height, width, fgcolor, bgcolor, bdcolor, value, True)
|
||||||
|
self.adjustable = True # Can show adjustable border
|
||||||
self.cb_args = args
|
self.cb_args = args
|
||||||
self.select_color = select_color
|
self.select_color = select_color
|
||||||
self.fontcolor = fontcolor
|
self.fontcolor = fontcolor
|
||||||
|
|
Ładowanie…
Reference in New Issue