 So yeah, this talk is to somehow attempt to start where Candy has finished on Wednesday. We have Candy here. He was trying to record you guys for the design team and for UI hacking, so they are going to show you how to actually hack the UI. This talk is somehow primarily targeted at the new user interface but not necessarily new hackers and also the core hackers that have somehow little experience with the UI hacking. And I should perhaps say something quite that I decided to come up with this talk. We have a lot of UI easy hacks and it's somehow considered, like in general, easy hacking. So almost everyone can do that, but I've seen somehow lots of people actually, somehow, it was like this cargo code programming, like everybody is just like taking some bits from here and there, copy pasting them around without understanding what they're actually doing. And it's not surprising because like the documentation, there's some written here and there's some wiki there and somehow incomplete and scattered over various places. So I somehow tried to put this all together in this very talk. So here's some outline of what I will show and what we will learn in case you don't know it yet. We're going to learn how to add a new unit command to somehow do some work around the user interface, how to add a toolbar and sidebar button or menu entry doing that with an item because it's somehow boring and not so fancy without pictures. We'll learn to define the new flow and its interface and connect those two together. I'm intentionally not covering the the widget layout, the UI files because it has been extensively covered elsewhere and it's well documented and there's several G-sub projects about that. So I assume everybody knows it by heart. Yes, so what's the unit command? That's some basic building block of the labor office command dispatch API. Maybe if you've seen that, that's the form the command usually has. Is there some laser pointer perhaps somewhere? Could be on Friday, maybe it's not anymore, never mind. It usually has this one. I have a typo in my slide that should be some that should be a colon after you know who it's. You know colon and command name. Configuration files for you know commands live in this directory, office config registry, etc and there are local commands that are somehow like universal for all applications and there are also commands that can be local to the physical application like writer or whatever and press. This is where they live and here's some examples, some snippet of XML file how such you know command looks. I've highlighted the name you know here page for it with the I've highlighted that in red that's the command actually command itself. Additionally you can define a tooltip text for command which is useful for the sidebar for the toolbar buttons and you can define some additional flags. I originally intended to somehow only quickly fly over those flags because if you put one here it means the command is an icon if there's zero it means it has no icon and all the additional flags somehow seem a little important to me but do we have Flio here? No we don't but somehow I was I was not aware of some some differences because I yes there is. So this flag will be probably important for you if you write RTO or if you write vertical text because here you can define that your icon is supposed to be mirrored for example or it's supposed to be rotated vertically yes so once we have a command we need some entry point something user can hit enter over or click with the mouse on and that's a new element it can be a toolbar button or a sidebar button or some menu entry or some context menu entry but I'm not going to talk about context menus because somehow discouraged to add new context menus. Toolbars. Toolbar configuration is an XML file again it lives usually like for for app you should substitute sd, sw, sd, calc, and press draw a math and there are several independent XML files in this directory for several different toolbars and here's again a snippet of such an XML file defining one toolbar menu entry here we can see the command actually associated with this with this toolbar button and some additional attributes you can define if the toolbar button is visible by default or if it's hidden you can associate the help ID with it and you can also define what kind of toolbar button it is if it's split button or normal button or a toggle sidebar sidebars are thanks to Bendy and his GSOC student from some two years ago uh wideway so it's very similar to dialogues uh I also lived in the CY conflict directory in SPS if there are somehow universal come on to all apps or in the S specific directory sw again and I somehow tried to uh so the XML paper is supposed to be much larger but I made it smaller so that it fits the slide and also thanks to thanks to a feature can be implemented we can already directly associate the you know command which you can see highlighted in red over there again we can associate directly with the with the sidebar button in the white file previously it was done some very clumsy way in the C++ code and you can also edit it in late uh menus are perhaps the most straightforward so there's only one XML file with many configuration for for the application it looks like this and this is perhaps looks familiar because this is this file on menu all apps and again the do not commands are are highlighted over there in red so um every every toolbar button every sidebar button some menu entries as well can have associated icon unfortunately it's not somehow possible for for the for the XML scheme to define a custom name for the custom path to the icon so so the icons have to live in a in a fixed path and have to have specific names and the path is mentioned over there is the icon teams if you're adding a new icon you absolutely have to add it to the galaxy theme uh optionally also to the other themes and it has to as I said it has to have a specific name so if I have a command you know do something my icon has to be named as underscore or l lc underscore the the command name in small letters like without capitals and it has to be in the engine format uh yes so uh if you if you don't want to have a new icon want to use the reuse the existing icon it's possible as well uh in every theme icon theme directory there's a simple text file called links txt which somehow defines links a little between between the different icons so you add a new line which has this form first entry is the is the new icon for your command and the second entry is the existing icon which is going to be recycled as what's the difference between the sd and lc uh some color quality or resolution i don't know exactly so sizes so to let application know about our UI element still some steps are necessary not for sidebars because this works somehow out of the box but the toolbar buttons need to be registered you can't register toolbar button have to find the c++ file c++ um object which is which is called swsc dll and you have to append like that there's a method that registers all all controllers all toolbar buttons for this application and you have to append the your button there and for a dialogue if the if the button new button is going to open a dialogue it has to be registered as well and they have to be added to one of the existing dialogue factories but also also live in that location it's called the algae effect usually so the static spark is over if if you want to roll this text you really will see open bar button or your sidebar button now in the application if you click on it it will do nothing so far so we somehow need to connect the actual c++ function with the heavy lifting opening a dialogue or opening the drop down doing something changing properties well simply doing the dynamic stuff with the with the UI element we've just added and for that we we use the slots you can well with some some adding my blood board and I some point use this as an illustration uh you can imagine it as a platform that connects the UI elements the commands that are associated with them with the actual functionality and there are two types of slots as I said like one is the method slot that for example opens a dialogue and the second one is the state slot which changes a state of an object so you can imagine for example it changes the line changes the color of the line or changes the size of the font and slots live in the oh first slots in the ID they usually like you usually have to find some some HRC file in the in the root directory of your application or in the somewhere in the global includes if it's going to be used by more application and associate the slot ID which usually has this form inside the actors for something with some numerical ID something to wash out for is that like those those HRC files where the slots ID are defined are somehow like they include not not each other but like they can be included and sometimes it get happened and there have been bugs and there have been regressions that there are somehow duplicates if somebody added the slot ID of thinking it does something useful but the same slot ID was actually defined in the included file and some other functionality suddenly it seems to work so for example I think I I've added some some slot ID for changing the background of the text and then somebody filed the back that one can't include the picture and document anymore because it's simply not the same slot ID and wow okay I miss one slide anyway uh slots definitions live in files that have a have an ending as bi like strategy defense initiative but it's something else and they usually look like this so this is an example of the property of the state slot this slot simply changes the color of the form and you can see this is color that's that's our unit command in disguise and it simply maps this unit command the slot ID we've just defined and there's lots of lots of those flags half them are obsolete but there's ill-occupated the round anyway uh I will the last slide that contains some link to the documentation defines like what those flags exactly mean but what's interesting is for example those those configuration flags down here because for example you have to set the toolbox conflict through if this is going to be a toolbar this is a method slot so it does not change state it actually does some other work usually opens a dialogue and yeah the basic difference between the property slots and the methods slots are the spray case over there it should be on a separate line but otherwise it wouldn't wouldn't fit the slide so so I put it nicely that's where some arguments come to this slot it's again like you know about command in disguise which maps to the side of the underscore about slot and this is its return value and as we can see this particular one is a manual entry because this menu config is set to true and everything else is set to false so that would be it and now we have to interface to the slot so actually connect connect our slot to some existing c++ function that is actually doing something uh as it would be somehow I don't know annoying and tedious for every module every application write those huge arrays of c++ functions it's not gonna done like that so we have some sb rdl compiler which I was kind of I don't know um slightly scared to investigate in detail but it goes through all those sdi sdi files and transports them into into actual array of function pointers and here's how a slot interface looks like uh for a slot for for this people's log it has execute method and it has a state method so somewhere somewhere in the in the local implementation or a local subclass of the shell of this aspect shell usually um this is the this prvsh whatever uh it it maps to some um so there will there will be some some c++ file with a similar name that actually implies those functions and the functions have those signatures and they usually contain some some long list of switch case statement for different slots so if you're adding a new functionality you can you can just plug your functionality into the into the existing methods and or define you on but I'm covering that here and some further reading there's some very very good article on all the open office wiki on the slots interfaces valued article on the UI configuration somebody I don't know who it was it's kind of unrecognizable from the link name wrote a simple tutorial how to add some hello world dialogue to the press it lives in liberal office wiki and we also have a very good wiki as I as I mentioned for for the UI format and for all the blade bits happy hacking I actually have further questions if you want to start with UI hacking just don't hesitate and come to come to design channel and I do have no yeah I promise to him to somehow pass this documentation to them so it doesn't have to be embarrassing only on the office wiki anymore but we can have it as well and any questions yes really I think that it's not that people fall back but default on OSX so like default default I think on all sides because it is better has to be the galaxy it can be in the other things it would be better if it was um yeah somebody has to fix the read me the the galaxy the galaxy actually has a big figure I want the other things like putting back to to Greece that good idea because so like Greece looks really different so if it won't be added to the galaxy it won't be found at all I just take the icon and add it to Greece it won't be found but maybe I'm wrong and text box or drop down box and will be followed this way when bringing a new source for this text box where yes you have to you have to follow follow those steps and that's somehow then subclass a toolbox and implement the functionality