mirror of
https://git.undefined-dev.fr/Blendman974/faceclaw.git
synced 2026-11-19 21:03:09 +00:00
Fix "array status" and several other pages in the "Microphone setup" app not rendering when not full-screen
This commit is contained in:
1 parent
54f4852564
commit
5436744549
2 files changed
+21
-8
No files matched your search
+10
-6
@@ -1,4 +1,4 @@
|
||||
import { G2_LENS_HEIGHT, G2_LENS_WIDTH, GrayImage, type UiFont } from "../graphics/image";
|
||||
import { G2_LENS_HEIGHT, GrayImage, type UiFont } from "../graphics/image";
|
||||
import { wrapText } from "../graphics/textwrap";
|
||||
import { getDefaultSmallFont } from "../graphics/ui-fonts";
|
||||
import { getStringSetting } from "../native/settings-store";
|
||||
@@ -397,16 +397,20 @@ export class TextPageLayer implements Layer {
|
||||
private readonly body: string,
|
||||
) {}
|
||||
|
||||
paint(_ctx: LayerContext): GrayImage {
|
||||
paint(ctx: LayerContext): GrayImage {
|
||||
const font = getDefaultSmallFont();
|
||||
const image = new GrayImage(G2_LENS_WIDTH, G2_LENS_HEIGHT, 0);
|
||||
// Size to the stack, not the lens: in an app window the stack is the
|
||||
// window's viewport, and the compositor rejects a frame larger than its
|
||||
// surface (leaving the previous frame on screen).
|
||||
const { width, height } = ctx.stack.getBaseSize();
|
||||
const image = new GrayImage(width, height, 0);
|
||||
image.drawText(font, 18, 14, this.title, 220);
|
||||
image.drawRect(12, 12, G2_LENS_WIDTH - 24, G2_LENS_HEIGHT - 24, 52);
|
||||
image.drawRect(12, 12, width - 24, height - 24, 52);
|
||||
|
||||
const wrapped = wrapText(font, this.body, G2_LENS_WIDTH - 60);
|
||||
const wrapped = wrapText(font, this.body, width - 60);
|
||||
const step = lineStep(font);
|
||||
const bodyTop = 28 + font.lineHeight;
|
||||
const footerY = G2_LENS_HEIGHT - 48;
|
||||
const footerY = height - 48;
|
||||
const maxBodyLines = Math.max(0, Math.floor((footerY - bodyTop - 8) / step));
|
||||
for (let index = 0; index < Math.min(wrapped.length, maxBodyLines); index++) {
|
||||
image.drawText(font, 24, bodyTop + index * step, wrapped[index]!, 190);
|
||||
|
||||
@@ -17,9 +17,9 @@ const font={lineHeight:12,ascent:10,descent:2,measureText:text=>text.length*4,
|
||||
const menuCore=load('app/ui/menu-core.ts',{
|
||||
'../graphics/image':graphics,'./menu-highlight-motion': require('../.test-build/app/ui/menu-highlight-motion.js'), '../graphics/menu-scroll-list': require('../.test-build/app/graphics/menu-scroll-list.js'), './menu-scroll-motion': require('../.test-build/app/ui/menu-scroll-motion.js'), '../graphics/draw-expression': require('../.test-build/app/graphics/draw-expression.js'),
|
||||
});
|
||||
const {MenuLayer}=load('app/ui/menu.ts',{
|
||||
const {MenuLayer,TextPageLayer}=load('app/ui/menu.ts',{
|
||||
'./menu-animation-pref': require('../.test-build/app/ui/menu-animation-pref.js'), './animation-speed': require('../.test-build/app/ui/animation-speed.js'), '../native/settings-store': { getStringSetting: (_key, fallback) => fallback },
|
||||
'../graphics/image':graphics,'../graphics/textwrap':{},'../graphics/ui-fonts':{getDefaultSmallFont:()=>font},
|
||||
'../graphics/image':graphics,'../graphics/textwrap':{wrapText:(_font,text)=>text.split('\n')},'../graphics/ui-fonts':{getDefaultSmallFont:()=>font},
|
||||
'../util/numeric-util':{clamp:(n,a,b)=>Math.max(a,Math.min(b,n))},'./gestures':{},
|
||||
'./menu-highlight-motion': require('../.test-build/app/ui/menu-highlight-motion.js'), '../graphics/menu-scroll-list': require('../.test-build/app/graphics/menu-scroll-list.js'), './menu-scroll-motion': require('../.test-build/app/ui/menu-scroll-motion.js'), '../graphics/draw-expression': require('../.test-build/app/graphics/draw-expression.js'),
|
||||
'./metrics':require('../.test-build/app/ui/metrics.js'),'./menu-core':menuCore,
|
||||
@@ -64,6 +64,15 @@ test('context menu surface and selected row both use +4 without changing the app
|
||||
assert.deepEqual(closed.image.pixels,base.pixels);
|
||||
assert.deepEqual(wire.presentationRecords(prepareFrameDraws(closed.draws)),[]);
|
||||
});
|
||||
test('text page paints at the stack size, not the lens size',()=>{
|
||||
// An app window's stack is its viewport; a lens-sized plane is rejected by
|
||||
// the compositor as larger than the window surface.
|
||||
const stack=new LayerStack({paint:()=>new graphics.GrayImage(576,260)},noopLayerActions,{width:576,height:260});
|
||||
stack.push(new TextPageLayer('Array status','Left: no status yet\nRight: no status yet'));
|
||||
const painted=stack.paint();
|
||||
assert.equal(painted.length,1);
|
||||
assert.equal(painted[0].image.width,576);assert.equal(painted[0].image.height,260);
|
||||
});
|
||||
test('system menu bridge shifts its surface and selected row together by +4',()=>{
|
||||
const image=menu().paint(),bytes=encodeShellScene([{image,x:8,y:0,shellKey:7,depth:4}]);
|
||||
const view=new DataView(bytes.buffer),w=view.getUint16(8,true),h=view.getUint16(10,true);
|
||||
|
||||
Reference in new issue
Block a user