I am learning ttk in depth and want to know how to find logical layout for any widget. Right now just exploreing and doing small experiments. In following code trying to show text but layout details are not documented for checkbutton.
So question arised for me how to find them for any widget easily.
This Ttk style guide is really nice reference but not helping in layout in depth.
Thanking you.
ttk::style element create pin vsapi EXPLORERBAR 3 {
{pressed !selected} 3
{active !selected} 2
{pressed selected} 6
{active selected} 5
{selected} 4
{} 1
}
ttk::style layout Explorer.Pin {Explorer.Pin.pin -sticky news}
pack [ttk::checkbutton .pin -style Explorer.Pin]
To find the style in use for a given widget use the winfo class command:
% ttk::checkbutton .b
% winfo class .b
TCheckbutton
You can then dump the layout using ttk::style layout: (reformatted for readability)
% ttk::style layout TCheckbutton
Checkbutton.padding -sticky nswe -children {
Checkbutton.indicator -side left -sticky {}
Checkbutton.focus -side left -sticky w -children {
Checkbutton.label -sticky nswe
}
}
This declares the elements and how they are to be placed. So to replace the indicator element you can copy this layout to define a new layout that references your new element:
% ttk::style layout Pin.TCheckbutton {
Checkbutton.padding -sticky nswe -children {
Checkbutton.pin -side left -sticky {}
Checkbutton.focus -side left -sticky w -children {
Checkbutton.label -sticky nswe
}
}
}
% place [ttk::checkbutton .pin -text text -style Pin.TCheckbutton] -x 10 -y 10
You should note that some of the elements pick up additional configuration attached to the style by the ttk::style configure command so when copying a style you should also copy the configuration:
ttk::style configure $new_stylename {*}[ttk::style configure $old_stylename]
and most likely also the map of widget states (ttk::style map).
Reading the ttk library files in <Tcl/Tk folder>/library/ttk should show quite a bit about how these things are put together. The vsapi.tcl file in particular does quite a bit of layout for Windows.
Related
I've got a Xamarin Forms cross-platform application (iOS and Android), and on one of the screens I want a list with details:
Heading 1
Detail 1
Detail 2
Detail 3
Heading 2
Detail 1
Heading 3
Detail 1
Detail 2
As you can see, the amount of detail under each heading is variable.
I want the page to display at first with just the headings:
Heading 1
Heading 2
Heading 3
And then when the user presses on a heading, the details for that particular heading appear. Pretty standard stuff.
I've tried several different ways to get this to work, the only path that seems open to me is to have a StackLayout where I define a bunch of labels:
new StackLayout
{
Orientation = StackOrientation.Vertical,
Children =
{
new Label { Text = "Heading 1" },
new Label { Text = " Detail 1\n Detail 2\n Detail 3", IsVisible = false },
new Label { Text = "Heading 2" },
new Label { Text = " Detail 1", IsVisible = false },
new Label { Text = "Heading 3" },
new Label { Text = " Detail 1\n Detail 2", IsVisible = false }
}
}
I then add a TapGestureRecognizer to the heading labels, and when tapped I toggle the value of IsVisible for the detail labels. It works!
The only thing I don't like, is that there is no transition. I click on the heading label and BAM the detail label appears (correctly pushing down all the following labels to make space for itself). I would like an animation so that when I click on the header, the space beneath the header "slowly" opens up to reveal the detail.
As I read about animations online, one possibility is to set the HeightRequest of the detail labels to zero (instead of hiding them with IsVisible=false) and then creating an animation that "slowly" changes the HeightRequest from zero to the actual height of the label. And that's where I run into a problem.
I can't figure out how to get Xamarin to tell me the height of my "details" label.
If I inspect the Height and HeightRequest properties of my details label right after creating it, they are both -1 (no big surprise there). If I inspect those same two properties when I click on the heading, they are still -1. The only way I've found to get the height of my detail label, is to set the detail label visible, call ForceLayout() on my stack layout, store the detail label height, and then set the detail label invisible again. The problem with that is that I sometimes see the detail label flash visible for an instant while I do this.
What's the best/recommended way to accomplish my desired UI?
You can use the Animation API.
Read the blog about it - Creating Animations with Xamarin.Forms.
In particular for your scenario you can use the FadeTo method to animate the Opacity property of a Visual Element.
Eg :
await image.FadeTo (1, 4000);
For more information, see Animation.
In your case my suggested approach would be for showing a label, to set opacity of label to 0, then make it visible, and then use FadeTo to make the opacity to 1.
Use the opposite to hide the label, set opacity 0 via FadeTo, then set IsVisible to false.
If I understand right your problem the only thing you need is to avoid the flash on the label, if this is the case then you can set the Opacity to 0, in this way the label will not be visible until you set again the opacity to 1.
I can suggest you to make a custom XF control (to use as item DataTemplate) as follow:
2 vertical parts:
The header part (A) (when you click on it it will show the second part)
The second part is a 'Listview' control (B) that is empty at the beginning
When you click on (A):
it will show (B)
It will start to populate (B) with your details elements
The trick in my mind is to implement a method that populate the listview (B) item by item (getting them from your viewmodel) with some delay (a few milliseconds) between each insertion and maybe a 'fadeTo' effect too in the same time.
You can see here what I mean (see the "Fade" section):
Insert / fade list item effect sample in HTML
You can improve your template as you want, by embedding the two parts into a 'border' for instance, to make a graphical separation...
Tell me if it's unclear, all you need is time :)
And maybe if you are ready, you can try to make native controls / animations...
I'm using the Soda Dark UI theme for Sublime Text 3 and I'd like to increae the left margin within the pane. It looks too tight, to me.
What class(s) is used to define that margin?
The class you are looking for is sidebar_container and the property is content_margin.
I see in your screenshot that you already know what file you need to look in, but maybe is usefulf for other users to know that you can create a file called Soda Dark 3.sublime-theme inside Packages/User for your overrides with the following content:
[
// Soda Dark 3 theme overrides
// Sidebar container
{
"class": "sidebar_container",
"content_margin": [10, 0, 1, 0]
}
]
The value of content_margin has the following syntax so in this case you need to change the first value for the left margin value you want:
[left, top, right, bottom]
When I click on a row within a TableView the row will be highlighted blue. How is it possible to disable this feature?
I've already tried to set the background to white, but the problem is that the row-color isn't white in every row.
Does anybody know what to do?
best regards
EDIT:
In the image below you see the blue color of the second row. This highlighting should be removed.
If you really want to do this (I agree with #kleopatra in the comments that it would make life difficult for the user) you can revert the colors for selected rows with an external css file:
.table-row-cell:filled:selected {
-fx-background: -fx-control-inner-background ;
-fx-background-color: -fx-table-cell-border-color, -fx-background ;
-fx-background-insets: 0, 0 0 1 0 ;
-fx-table-cell-border-color: derive(-fx-color, 5%);
}
.table-row-cell:odd:filled:selected {
-fx-background: -fx-control-inner-background-alt ;
}
I'm using kendo tooltips on a graphic (within an anchor link) which is 24px tall. Accordingly, when the tooltip shows up (default position of bottom), it covers the bottom third of the graphic and so the bottom third of the graphic can't be clicked.
I can do the following:
.k-tooltip {
margin-top: 8px;
}
But the problem with this is that if the tooltip is on a graphic at the bottom of the page, the position will be "top" instead of "bottom" but it'll now be covering about 1/2 the graphic instead of just a third because it's still being pushed down by 8px.
What I'd like is if the position is bottom, then the margin-top is 8px, but if the position is top, the the margin-bottom is 8px.
Thanks for any help you can provide!
Billy McCafferty
Would this one help you?
http://dojo.telerik.com/amoZE/5
var tooltip = $("#demo").kendoTooltip({
filter: "a",
show: function (e) {
var position = e.sender.options.position;
if (position == "bottom") {
e.sender.popup.element.css("margin-top", "10px");
} else if(position == "top") {
e.sender.popup.element.css("margin-bottom", "10px");
}
}
}).data("kendoTooltip");
Thank you for your answer, jarno-lahtinen. It was very helpful!
Two problems came up with it and I would like to document the solutions here:
1. Property Error in Typescript
I am using TS and it gave me the following error:
"Property popup does not exist on type Tooltip" for e.sender.popup. I am not sure if this is due to a newer version of Kendo, or of missing type definitions.
Solution:
you can use this.popup instead.
2. Not working for position: "top"
Unfortunately, the "margin-bottom" has absolutely no effect because the popup is positioned "absolute" using top/left.
Solution:
this.popup.element.css("margin-top", "-10px");
This will shift the popup upwards by 10 pixels
Is it possible to show compass blueprint grid to see its layout.
Here is the sample that I want to achieve:
http://www.blueprintcss.org/tests/parts/grid.html
Alternatively, include the showgrid mixin (+showgrid in the original SASS syntax):
#my-container
+showgrid
You do, however, need to generate the image for your particular grid flavor:
$ compass grid-img W+GxH [path/to/grid.png]
# Where:
#
# W = Width of 1 column in pixels.
# G = Width of 1 gutter in pixels.
# H = Height of the typographic baseline in pixels.
Just add the class showgrid to your container
if you inspect element on that page and remove the showgrid class you'll see it disappear