[Einhugur] How to set the DropDownIcon for Retina?

I’m trying to use the DateControl again. The DropDownIcon in Retina shows up rather large and not in the proper size. Is my code wrong from the Open event of the DateControl?

if self.BackingScaleFactorMBS = 1 then dim p as new Picture(16, 16) p.Graphics.DrawPicture(calendar, 0, 0, p.Width, p.Height, 0, 0, calendar.Width, calendar.Height) me.DropDownIcon = p else dim p as new Picture(32, 32) p.Graphics.DrawPicture(calendar_retina, 0, 0, p.Width, p.Height,0, 0, calendar_retina.Width, calendar_retina.Height) me.DropDownIcon = p end if

(don’t know if you sent this also directly to me but I am not yet in range to pop my mail)

Ok so you basically just assign ImageSet to it and don’t worry about BackingScale factor or anything like that your self.

So a valid Image set with Image and 2x image.

Don’t got no image set - unfortunately. My retina code is homegrown. Hence the ugly code. Can I mix “normal” pictures and image sets?

Changing to image sets is on the to-do list. But it’s not very high because at the moment retina works for me as it is.

Nope, no change with an image set:

Apple makes me want to hit somebody because they can’t even manage a “Save as” anymore. Had to change the size of the files and overwrote the originals. Xojo is less awful, but not really good: after dropping a 16x16 into a 24x24 image from an image set I get a lovely error message. Deleted the image set and created a new one.

And the DateControl removed the image set from the selection but still showed the icon in the IDE.

I can test it on Retina later on when I get home later today, just to be sure.

Sizes should be 16 x 16 for 1x and 32 x 32 for 2x (we do not support other sizes for it such as 24)

But I am understanding right that you are on Xojo that is capable of using ImageSets ?

(Basically on this one you cannot customise the icon for Retina on Pre-image set Xojo)

Sorry I forgot: Xojo 2016r41. Mac OS 10.11.something. And I edited the sizes to get the correct ones.

Hold down the ALT key (option key) when selecting the menu

@Markus Winter: I always forget that. Gr… thanks. There is a reason why we developers are supposed not to obfuscate interfaces.

I am guessing your somehow setting up your imageset or images wrong, in first test then I get this here when putting custom image using Image set. One image is 16 x 16 (72 dpi) the other 32 x 32 (72 dpi), and I also got the 3x 48x48 (72 dpi)

Code to set the image is just:

Sub Open() Handles Open
me.DropDownIcon = MyCalendarImage
End Sub

Where MyCalendarImage is a ImageSet in the Xojo designer.

No, the image set is okay. This is a problem on how Xojo handles the Retina. Or my problem with my manual Retina code.

Should my code above work? At the moment I can’t use image sets.

I would think it cannot work. Their whole automatic mechanism is built around the Image sets.

Though if you can make it work then I would think you should skip making the images there in between and just do
(Not terribly likely that the bellow would work though)

	if self.BackingScaleFactorMBS = 1 then
			me.DropDownIcon = calendar
	else
			me.DropDownIcon = calendar_retina // Could experiment having this one 144 DPI if it does not work at 72
	end if

Am not sure though why you cannot use ImageSets, I believe you can also build them in pure code if the reason would be getting the picture from dynamic source, database or something.

No, makes no difference.

I’ve got a >50kloc application that has been Retina capable for years. Changing to Xojo Retina requires a big change. When I enable HiDPI in the IDE just opening a window gives me a nice crash.

There is a bug when using a DateControl on a sheet. Crashes almost every time:

Crashed Thread: 0 Dispatch queue: com.apple.main-thread

Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000004
Exception Note: EXC_CORPSE_NOTIFY

VM Regions Near 0x4:
–>
__TEXT 0000000000001000-0000000001c45000 [ 28.3M] r-x/rwx SM=COW /Users/USER/Documents/*/Mail Archiver X.app/Contents/MacOS/Mail Archiver X

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 DateControl.dylib 0x0d29090c CloseTimer(REALobjectStruct*, DateControlData*) + 34
1 DateControl.dylib 0x0d290885 DateControl_DateGetter(REALobjectStruct*, int) + 63
2 com.mothsoftware.mailarchiverx 0x0047a185 DateControl.DateValue.Get%o%oi4 + 156
3 com.mothsoftware.mailarchiverx 0x019ba896 SearchWindow.SearchWindow.DCLower_ValueChanged%%o<SearchWindow.SearchWindow>o + 177
4 com.mothsoftware.mailarchiverx 0x019e9a6a Delegate.IM_Invoke%%o + 83
5 com.mothsoftware.mailarchiverx 0x00ab11b9 AddHandler.Stub.15%% + 54
6 DateControl.dylib 0x0d290969 CloseTimer(REALobjectStruct*, DateControlData*) + 127
7 DateControl.dylib 0x0d2942b6 Timer_Action(REALobjectStruct*) + 108
8 com.xojo.XojoFramework 0x023e8e30 0x2232000 + 1797680
9 com.apple.CoreFoundation 0x9583cff6 CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION + 22
10 com.apple.CoreFoundation 0x9583caa2 __CFRunLoopDoTimer + 1250
11 com.apple.CoreFoundation 0x9583c52d __CFRunLoopDoTimers + 349
12 com.apple.CoreFoundation 0x95833421 __CFRunLoopRun + 2113
13 com.apple.CoreFoundation 0x95832976 CFRunLoopRunSpecific + 390
14 com.apple.CoreFoundation 0x958327db CFRunLoopRunInMode + 123
15 com.apple.HIToolbox 0x90f3f2f1 RunCurrentEventLoopInMode + 267
16 com.apple.HIToolbox 0x90f3f0f3 ReceiveNextEventCommon + 503
17 com.apple.HIToolbox 0x90f3eeec _BlockUntilNextEventMatchingListInModeWithFilter + 99
18 com.apple.AppKit 0x946d52e2 _DPSNextEvent + 1053
19 com.apple.AppKit 0x946d485b -[NSApplication _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1057
20 com.apple.AppKit 0x946d4432 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 121
21 com.xojo.XojoFramework 0x022748cb 0x2232000 + 272587
22 com.xojo.XojoFramework 0x02273b7d 0x2232000 + 269181
23 com.xojo.XojoFramework 0x023e07a9 0x2232000 + 1763241
24 com.xojo.XojoFramework 0x023f43d1 RuntimeShowModalWithinWindow + 302
25 com.mothsoftware.mailarchiverx 0x00038aa1 Window.ShowModalWithin%%oo + 52
26 com.mothsoftware.mailarchiverx 0x019bbf46 SearchWindow.SearchWindow.init%s%o<SearchWindow.SearchWindow>osA1s + 434
27 com.mothsoftware.mailarchiverx 0x01288f5e DBWindow.DoFilter%%o + 1687
28 com.mothsoftware.mailarchiverx 0x012630b9 CCToolbar.CCToolbar.MainToolbar1_Action%%o<CCToolbar.CCToolbar>oo + 4755

Doesn’t matter if in debugger or in built app.

Are you using 6.5.1 ? or 6.5 ? (6.5 had similar crash log wise).

If your using 6.5.1 then can you please drop on me simple example. Or when you say sheet do you then mean the Dialogs that show up like drawer from the window ?

On the retina thing then there is slight chance I can enable old style Retina for you. Mixing the old way and new way turned out to be horrible in control like TreeView but for control like the DateControl where its actually just one icon it might be not so bad to have old style Retina Image property.

Thanks

Björn

Crash issue has now been resolved in 6.5.2. (And a new property was added to support users who are still stuck with old style Retina before time of ImageSet)

you still can force the IDE to add “Pictures” to a project even with HiDPI on but then you have to manually do all the work to sort out what image to use at runtime

There IS an issue with the IDE and images at design time when it comes to plugins that we have yet to resolve
<https://xojo.com/issue/43174>

But it does not manifest at runtime

The issue was not that though Norman. The issue was that our plugin only had one property for the image which is great in New Xojo that has ImageSet’s but before Xojo supported officially retina then those users need 2 properties for it.

You really shouldn’t need 2 properties
“images” are JUST “pictures”
An image has several representations in it where a picture had one

Thats why there are methods like
http://documentation.xojo.com/index.php/Picture.Constructor(width_as_Integer,_height_as_Integer,_bitmaps()_As_Picture)
http://documentation.xojo.com/index.php/Picture.ImageCount
http://documentation.xojo.com/index.php/Picture.IndexedImage