-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Copying custom splitter items #52
Comments
After some research I am ready to admit that unfortunately, it is impossible to amend the existing code without violating the compatibility with other splitters. Is it true? |
Hi, You raise a good point. From looking, the caller assumes ownership of the object returned by splitter_window::get_panel(), so there is no problem there (as in it must be a new object). The risk I can see is that the returned splitter_item_t instance has a window_ptr and pasting it results in two splitter panels having a child panel with the same window_ptr. The risk is minimal, though, since we're dealing with a non-live layout (for live editing it would be worse). The problem could be fixed with a new subclass of either splitter_item_t or splitter_window. Backwards compatibility shouldn't be a major problem since there can be multiple code paths in Columns UI (and you can use the new interface for your splitter panel). I'm not sure what the best approach would be though; I would probably need to look at the code base more closely to see how exactly the window_ptr of splitter_item_t is used. What were the concerns you had? I may have missed something. Thanks |
It's also worth noting that two of three of the built-in splitters do not call splitter_item_t::get_window_ptr() in splitter_window::insert_panel(). |
Yes, I see. But: copying in layout preferences calls copy_splitter_item which uses splitter_item_full_v2_t as clipboard item. I want to use my own subclass of splitter_item_full_v2_t in clipboard. I tried to change code in copy_item that it calls get_panel (for compatibility with splitter_window interface) to create my subclass object. It seems OK, but next in paste_item there is fix_paste_item (it fixes pasting non-single-instance panels) that recopy splitter item again with splitter_item_full_v2_t class. |
Main problem is what right way to get exact copy of my subclass object without injecting any code in Columns UI project for backward compatibility purpose |
You can't. The code in Columns UI needs changing and possibly the API. |
I was afraid of this. Thanks for reply. |
Part of reupen/columns_ui#52 This adds a new splitter item, that can store additional data that doesn't fit into the standard variables provided in the existing splitter items. This also removes splitter_item_t::set(), as it was untested and not properly implemented.
Resolves #52 Improves how copying and pasting panels in the layout preferences page works. Additional data can now be stored in splitter items using the new uie::splitter_item_full_v3_t class in the SDK. This work will also make it possible to use the Windows clipboard for copying and pasting panels.
I came up with a solution for this (without rewriting the API) in these PRs: Essentially, the solution requires you to modify your And your There are some additional notes in splitter.h in the SDK. You can use Feel free to try it out and let me know how you get on. I'll probably be making copying and pasting panels use the real clipboard as well. |
Thank you very much for this solution. I've tried it and it works like a charm =) |
Great! And no problem. |
Hi.
Currently I develop my own splitter. I noticed one nasty feature when copying the panels contained in the splitter (Preferences-> Display-> ColumnsUI-> Layout-> Copy panel). The copy_splitter_item function from the config_layout.cpp creates an instance of splitter_item_full_v2_impl_t to copy to the clipboard. However, it seems more appropriate to create a copy of the child panel using the get_panel interface of the class splitter_window, because other commands like "Paste panel" or "Move up" use insert_panel, get_panel, etc.
This is necessary so that I can copy the panel that has additional attributes if I inherit from splitter_item_t
The text was updated successfully, but these errors were encountered: