AIR - 设置 NativeWindow 的大小以包括系统镶边

发布于 2024-12-28 01:14:59 字数 721 浏览 2 评论 0原文

如何找出系统镶边的大小,以便我可以指定窗口大小以达到我想要的舞台大小?

如果我的主窗口设置为 800 x 600(舞台),并且我创建如下第二个窗口,它会更小。

public function Main():void 
{
    var windowOptions:NativeWindowInitOptions = new NativeWindowInitOptions();
    windowOptions.systemChrome = NativeWindowSystemChrome.STANDARD;
    windowOptions.type = NativeWindowType.NORMAL;
    var newWindow:NativeWindow = new NativeWindow( windowOptions );
    newWindow.width = 800;
    newWindow.height = 600;
    newWindow.stage.scaleMode = StageScaleMode.NO_SCALE;
    newWindow.stage.align = StageAlign.TOP_LEFT;
    newWindow.activate();

}

我假设您增加了 newWindow.width = 800;newWindow.height = 600; 以考虑到 chrome,但是您如何找到这个值?

How do you find out the size of the system chrome so that I can specify the window size to achieve the stage size I want?

If my main window is set at 800 x 600 (stage), and I create a second window as below, it will be smaller.

public function Main():void 
{
    var windowOptions:NativeWindowInitOptions = new NativeWindowInitOptions();
    windowOptions.systemChrome = NativeWindowSystemChrome.STANDARD;
    windowOptions.type = NativeWindowType.NORMAL;
    var newWindow:NativeWindow = new NativeWindow( windowOptions );
    newWindow.width = 800;
    newWindow.height = 600;
    newWindow.stage.scaleMode = StageScaleMode.NO_SCALE;
    newWindow.stage.align = StageAlign.TOP_LEFT;
    newWindow.activate();

}

I assume you increase both newWindow.width = 800; and newWindow.height = 600;to account for the chrome, but how do you find this value?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

吲‖鸣 2025-01-04 01:14:59

您可以通过将窗口大小(包括镶边)减去内部尺寸(不包括镶边)来计算镶边的尺寸。

来自 NativeWindows 的 宽度 帮助:

本机窗口报告的尺寸包括任何系统窗口
显示的镀铬。内部可用显示区域的宽度
Stage.stageWidth 属性提供了一个窗口。

因此内部尺寸可以通过 stage object< 获得/a> ( stage.stageWidth 和 stage.stageHeight: )

因此:

var chromeWidth=newWindow.width-newWindow.stage.stageWidth;
var chromeHeight=newWindow.height-newWindow.stage.stageHeight;

you can calculate the size of the chrome by substracting the windows size (that include the chrome) with the inner size (that exclude the chrome).

From the width help of NativeWindows :

The dimensions reported for a native window include any system window
chrome that is displayed. The width of the usable display area inside
a window is available from the Stage.stageWidth property.

So the inner size can be obtained with stage object ( stage.stageWidth and stage.stageHeight: )

hence :

var chromeWidth=newWindow.width-newWindow.stage.stageWidth;
var chromeHeight=newWindow.height-newWindow.stage.stageHeight;
春风十里 2025-01-04 01:14:59

使用 NO_SCALE 创建 ActionScript 项目时,stage.stageHeight 和 stage.stageWidth 不能用于计算主应用程序窗口中的镶边,因为它们不会调整大小以符合内部宽度。您必须引用主窗口阶段。

要查找主窗口内部舞台的高度和宽度,您可以使用 stage.nativeWindow.stage 引用 stageHeight 和 stageWidth 属性来提供内部宽度。

例如,对于 1280x720 所需的内部尺寸:

// width stage.nativeWindow.width = 1280 + (stage.nativeWindow.width -
stage.nativeWindow.stage.stageWidth);

// height stage.nativeWindow.height = 720 + (stage.nativeWindow.height
- stage.nativeWindow.stage.stageHeight);

When creating ActionScript projects with NO_SCALE the stage.stageHeight and stage.stageWidth cannot be used to calculate chrome in the main application window as they do not resize to conform to the inner width. You must reference the main window stage.

To find the main windows inner stage height and width you can use the stage.nativeWindow.stage references stageHeight and stageWidth properties which gives inner width.

e.g. for a 1280x720 desired inner size:

// width stage.nativeWindow.width = 1280 + (stage.nativeWindow.width -
stage.nativeWindow.stage.stageWidth);

// height stage.nativeWindow.height = 720 + (stage.nativeWindow.height
- stage.nativeWindow.stage.stageHeight);
青柠芒果 2025-01-04 01:14:59

仅供参考,我觉得其他答案还不够清楚。要将新窗口设置为所需的尺寸:

// first set the desired window dimensions to set the (smaller) stage dimensions:
newWindow.width = 1024;
newWindow.height = 768;

// then reset the window dimensions and add chrome dimensions:
newWindow.width = 1024 + (1024 - newWindow.stage.stageWidth);
newWindow.height = 768 + (768 - newWindow.stage.stageHeight);   

For reference, as I feel the other answers aren't clear enough. To set a new window to the desired dimensions:

// first set the desired window dimensions to set the (smaller) stage dimensions:
newWindow.width = 1024;
newWindow.height = 768;

// then reset the window dimensions and add chrome dimensions:
newWindow.width = 1024 + (1024 - newWindow.stage.stageWidth);
newWindow.height = 768 + (768 - newWindow.stage.stageHeight);   
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文