How do I make these GTK buttons that are drawn together in a group? - gtk3

GTK has a way to draw a group of buttons together so they look like one big button with a divider between them, rather than buttons that are drawn apart. It's useful for drawing buttons together that have a similar function.
Here's an example from the GTK inspector, where they appear to be specifically toggle buttons where only one can be selected:
Another example, from Glade, where each button represents a category of widgets and opens a menu:
What is this style of buttons called, and how do I make them?

GTK Inspector example shows GtkStackSwitcher, a special widget used to control the GtkStack (for page switching).
Generally, to achieve this visual effect for a group of buttons, GtkButtonBox is used with the layout style set to GTK_BUTTONBOX_EXPAND.
Buttons expand to fill the box. This entails giving buttons a "linked" appearance, making button sizes homogeneous, and setting spacing to 0
You can also manually add a "linked" style to any container with buttons:
GtkStyleContext *context;
...
context = gtk_widget_get_style_context(button_box);
gtk_style_context_add_class(context, GTK_STYLE_CLASS_LINKED);
HowDoI/Buttons (paragraph "Linked buttons")

Related

Change the border's color of a button in Unity3D

I began to work with Unity3D since one month and I'm trying to do an application which contains a menu, composed by a panel and several buttons. At this moment, I'm trying to customize the menu, I change the fill color of the panel and buttons, but until now I could not change the border color of the buttons. There is any way to customize the border's color of the UI buttons? I would appreciate your help. :)
The easiest way to add an outline to your button is to use the Outline component (doc).
Simply add the Outline component where your button image or text is. Then configure it how you like it :)
The above results in the following button:
No, you can not change just border color. If you use default buttons, take a look at Source image. It is basically a grey square with black borders. So when you change color of image black color remains black.
To customize buttons as you want you need either create nested UI elements:
or create sprites with colors you want and replace source image
I find nested UI elements to be the easiest way to do something like this. Simple example:
Start out by creating a panel and change the scale until you get the desired size for your button. This will be your "borders".
Next create another panel as a child of the panel you just made and change the scale to be just slightly smaller than your first panel and change the color.
In the Inspector for your panel, add component and type in Button and add it as a component.
Finally, add a text as a child of your panel for a label and you're done.

JavaFX 8, how to hide a pane in Splitpane?

I have a splitpane created from FXML that consists of Three panes left to right. I want to be able to hide the rightmost pane but I can't find anything to hide it. If I turn of the visibility it hides the pane content. What I want is to temporarily hide it, so the pane is removed visually.
As a temporary workaround I move the divider to 100%, but this leaves the divider visible. Another side-effect is that if I resize the main window the divider doesn't stay at the rightmost position.
Any tips on hiding one pane in splitpane?
Or any tips on the best way to achieve this without splitpane(rightmost pane needs to be resizable when not hidden). General pointers to techniques/containers would be appreciated since I'm new to Java/JavaFX but not to programming :)
Seems I've found it, even thought it's not a plain hide/show deal. My splitpane is named "mainSplitPane", and the one I want to hide/show is the third. Upon initialization of the controller I retrieve the third pane and store it in "componentsPane".
Declared in controllerclass:
Node componentsPane;
Called in initialize method of the controllerclass:
componentsPane=mainSplitPane.getItems().get(2);
Code to hide:
mainSplitPane.getItems().remove(componentsPane);
And code to show:
mainSplitPane.getItems().add(2, componentsPane);
mainSplitPane.setDividerPosition(1, 0.8);
A side effect is that I have to set dividerposition since it's removed.

iPhone panel control

In my iPad application there are many buttons (around 50), and I want to make a group box which contain buttons arranged by category.
I am looking for something like a C# or .NET GroupBox/Panel.
There is no Group Box / Panel Box in iPhone.
You need to manage by your self.
Use the UITableView to put all the button in on category.
http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UITableView_Class/Reference/Reference.html
It may be worthwhile to look into UIPopoverController views. These are the little popup views that appear when you click stuff. YOu could easily break your menu system into smaller parts with these.
You may draw a group panel by making two views. make a view of frame say 20,20,280,199 and then another one with frame 21,21,278,197. now put the 2nd view on the last one and change the color of last to some dark than later one. enjoy :)
remember that the should be in same hierarchy. that no one should be parent or child of any of these.

Vertically add elements to a scrollview: diffs between Java and iPhone SDK?

Folks,
coming from the Java/Swing world, I am sometimes puzzled by the UI programming on the iPhone. I've spent the last hours with Googling for information but it seems that I asked the wrong questions by thinking too much in Java. Could you please point me to resources to get more familiar with the GUI concepts to be able to achive the following functionality:
Basically, I want to create a vertically scrollable view that represents structured text (for example, a recipe). Each step consists of a title and a textual description. As I want to fold and unfold such steps, the title would be somehow interactive and by clicking it the description would be displayed or hidden.
In Java, I would create a component that renders one such section. The layout manager would compute the components preferred height (with or without description being displayed).
Then, in Java, I would create a panel with a vertical layout manager and sequentially add my components. This panel would be placed in a scroll pane; the scroll pane would ask the panel to layout itself and then show a viewport on it, if for example the height is bigger than the scroll pane's height.
What Java provides me is:
layouting of elements (computing their preferred height and width), thus no need to deal with coordinates and dimensions
dynamic creation of UIs by creating and adding components during runtime
What I understood on the iPhone:
I can dynamically add views as subview to a view, e.g. a scrollview by calling addSubview
I can even remove that stuff using removeFromSubview (as explained here Clear content of UIScrollView)
What I don't understand on the iPhone:
does one view always correspond to a visible screen (I did use tab and navbar navigation so far and there whenever I set a new view, it fills the current visible screen minus the space needed for the two bars)?
or is it possible to define a view that contains a label on top ("north") and a text in center; if so, could such a view automatically determine its height?
can I realize my example in a similar way like in Java or would I need to calculate all dimensions and coordinates of the individual components on my own? (This example seems to touch on that topic: iPhone scrollView add elements dynamically with id)
Alternatively, could I use a WebView and render my stuff as local HTML using JavaScript to show or hide nodes?
Thanks for any hint or link!
There are no layout managers in Cocoa, views are being reposition according to their struts and springs settings. For information on that read the documentation: http://developer.apple.com/library/ios/#documentation/DeveloperTools/Conceptual/IB_UserGuide/Layout/Layout.html
To create a "view that contains a label on top and a text in center" you create a view with subviews - one being a label at the top, second the textview in center. If you configure struts/springs for all of subviews properly, they will autoresize when the container view is resized.
You should also get accustomed to Interface Builder, creating views in code is real pain in the ass.

Customize UIMuenuitem title

I am using the table to display a list of members and when I click a cell in the table I am creating some custom menu items and showing the menu by customizing the cellview class. Now we have total 6 menu items and some of them are long in length, is there any way I can wrap the menu title so that we have enough space to display all the menu items?. While creating the menu item i tried to give the "\n" in the title but no use.
Also I would like to group the menu items so for this i will like to show 3 of them in different color. can we set the text color to the menu item so that 3 of them are in one color and other 3 are in different.
Please let me know if have any solution of the above two tasks.
Thanks.
As far as I know both are not possible. You might want to look into creating your own menu code. Which is not terribly difficult. If you are on iOS 4 then just create a long tap gesture recognizer and then show a transparent view with graphics of your menu. This view can contain simple transparent buttons. It is not standard at all but very doable.