简体   繁体   English

发送消息displayProgress时尝试查找进度条变形

[英]Trying to find the Progressbar Morph when sending the message displayProgress

I have contribute a progress bar in PharoLauncher so that the user get information of the progress of the download of an image with this code 我在PharoLauncher中提供了一个进度条,以便用户使用此代码获取图像下载进度的信息

PharoLauncher>>displayProgress:during: (in category 'template action') -----

displayProgress: label during: workBlock
    | nextUpdateTime |
    nextUpdateTime := 0.
    ^UIManager default displayProgress: label 
        from: 0.0 to: 1.0 during:[:bar|
            [workBlock value] on: HTTPProgress do:[:ex|
                (ex total == nil or: [ex amount == nil]) ifFalse:[
                    (nextUpdateTime < Time millisecondClockValue 
                        or:[ex total = ex amount]) ifTrue:[
                            bar current: ex amount asFloat / ex total asFloat.
                            nextUpdateTime := Time millisecondClockValue + 100.
                    ].
                ].
                ex resume.
            ]
        ]

So the message is UIManager default displayProgress: from: to: during: .Now this works ok but I want to position the morph in the middle to make it more comfortable for the user to see and it scale it considerably so its much easier to do. 所以消息是UIManager默认的displayProgress:from:to:期间:。现在可以正常工作了,但我想将变形放置在中间,以使用户更舒适地看到它并对其进行大规模缩放,因此更容易实现。 In order to do that I need to find the Morph that acts as a container for the progress bar and scale up in its entirety. 为此,我需要找到充当进度条容器的Morph,并进行整体放大。

The problem is that I hit a dead end when trying to browser the hierarchy of this messaged it sends me to 问题是,当尝试浏览此消息的层次结构时,我陷入了僵局。

displayProgress: titleString from: minVal to: maxVal during: workBlock
    "SystemProgressMorph show: titleString from: minVal to:  during: "

    ^ workBlock asJob
            title: titleString;
            min: minVal;
            max: maxVal;
            run. 

The problem is that when I go to the Job class , as I would expect, a Morph is nowhere to be found. 问题是,当我进入Job班级时,正如我所期望的那样,Morph找不到了。 So how I find the Morph and how will be able to position and scale it containing all its submorphs ? 那么,如何找到变形,以及如何定位和缩放包含所有变形的变形?

With the help of Thierry Goubier in the Pharo-dev mailing list and tinchodias at #Pharo in freenode I have found a solution 在Pharo-dev邮件列表中的Thierry Goubier和freenode的#Pharo的小提琴手的帮助下,我找到了解决方案

There are three announcers created , those three announcements are tied to classes JobStart , JobEnd, JobChange classes and trigger class methods startJb: endJob: and updateJob: of SystemProgressMorph. 创建了三个公告器,这三个公告与SystemProgressMorph的JobStart,JobEnd,JobChange类和触发器类方法startJb:endJob:和updateJob:绑定在一起。 There can be only one instance of SystemProgressMorph and to capture that instance we use the uniqueInstance class method. SystemProgressMorph只能有一个实例,为了捕获该实例,我们使用uniqueInstance类方法。

So to re-position and re-size the progress bar I have used the following cascade of messages 因此,为了重新定位进度栏并调整其大小,我使用了以下一系列消息

(SystemProgressMorph uniqueInstance) minWidth: 600; 
                                     minHeight: 50; 
                                     layoutInset: 30@20; 
                                     position: 150@200.

layoutInset adds some more space for the progress bar inside the SystemProgressBarMorph. layoutInset为SystemProgressBarMorph内部的进度栏添加了更多空间。 It would be better to reset those values so we wont affect the progress bars that used by other pharo apps but since the PharoLauncher is contained in an independent image thats not necessary. 最好重置这些值,这样我们就不会影响其他pharo应用程序使用的进度条,但是由于PharoLauncher包含在独立的映像中,所以没有必要。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM