Treeview and SpriteOP
Stefan Fröhling (7826) 167 posts |
We are using Treeview in !CLFiler and want to display the App sprite in the tree. We do it already but discovered that it doesn’t work with all sprites as they are sometimes not declared. We set the "sm!{appname} as reference. So some are missing when that one is not available in the App’s sprite file. So the idea is that we create the missing sprites in the sprite area but we are running into a problem there. Current problem: Problem that I can’t create the sprite in the system sprite area. This is the code: // main code: tbx::Size sz, dst_sz; WimpSprite SpriteArea::create_wimp_sprite(const std::string &name, int width, int height, int mode, bool palette /* = false /, bool with_mask / = false */) } WimpSpriteCapture::WimpSpriteCapture(WimpSprite sprite, bool start_capture /= false*/, bool to_mask /* =false*/) // Log_debug(“Save_size %d”, save_size); } /**
/**
} /**
bool WimpSpriteCapture::release() } |
Stuart Swales (8827) 1357 posts |
It needs to be in the Wimp Sprite Area, not the System Sprite Area. |
Graeme (8815) 106 posts |
sm!… sprites are half-size. If it doesn’t exist, you can use Wimp_PlotIcon with the fullsize icon and set the bit for half-size sprite. |
Sergey Lentsov (8268) 63 posts |
But how to create sprite in the WimpSprite area? (i thought that system area and wimp area it is the same) In the docs about OS_SpriteOp I get that R1 must be pointer to sprite area or 0 for system area. I tried to set is as 0. Thank you |
Stefan Fröhling (7826) 167 posts |
@Stuart OK that might be the solution. @Graeme: WimpPlotIcon is not the right way as Treeview does the Redraw not our App. Her is the code to set the sprite name: Code for .sprite() method from TBX below: void TreeViewCurrentNode::sprite(int sprite_area_id, const std::string &sprite_name, const std::string &expanded_sprite_name) |
Stuart Swales (8827) 1357 posts |
I think it’s best to let the Wimp completely manage its Sprite Area; I think it might get upset if external code starts messing with it using SWI OS_SpriteOp (see “Wimp internally caches pointers to its sprites”). Hang on, there is SWI Wimp_SpriteOp … |
Steve Fryatt (216) 2105 posts |
The *IconSprites command will merge the sprites in a sprite file into the area. It’s how your application adds its icon to the area for use in Filer windows.
No, they are not. The System area is an Arthur-era (or probably BBC MOS-era) thing that has been deprecated for many, many years. Don’t use it.
Do not use OS_SpriteOp for managing the Wimp area.
As Stuart says, use the Wimp_SpriteOp SWI that the Wimp helpfully provides for accessing its area. If Wimp_SpriteOp won’t do something that you need, it’s probably safest to assume that you shouldn’t be doing it – and a hint that taking a different approach would be better. |
Stefan Fröhling (7826) 167 posts |
We found out in the meantime that Treeview allows to specify sprite from app memory by specifying the sprite area address. @Steve: The *IconSprites command might be a good way so we can create the sprites only one time and save them in the app folder. |
Stefan Fröhling (7826) 167 posts |
void CLDirectoryWindow::assign_node_sprite(tbx::ext::TreeViewCurrentNode& node, CLDirectoryItemData item) { |
Steve Fryatt (216) 2105 posts |
That’s the correct way to do it, then, unless the sprites would already be in the Wimp Sprite Pool for another reason. Your users can’t get space from the Wimp Sprite Pool back afterwards, so unless the specific sprites are to be used in Filer windows or somewhere else that you can’t set your own sprite area, use an application sprite area. |