I've been tweaking my rc.lua for a while now, and, in favor of a cleaner look, thought of having the wibox as not visible by default.
I already have the means to toggle the visibility, and set it to not visible by default.
The problem is with the layouts and the window padding.
All layouts (except for floating) respect the wibox geometry when I toggle it's visibility. My idea was having it appear on top of the windows, but when I toggle, all windows resize to make space for the box.
I already tried setting the wibox type to different values, and making it floating.
There's no code on the layout's source that explicitly describes that behavior (to my knowledge, at least), so I think it must be a property of the wibox.
Any ideas?
Thanks in advance for your help.
Try unsetting its struts: w:struts{ left = 0, right = 0, bottom = 0, top = 0 }
Only top = 0 should be required (assuming your wibox is at the top), but it doesn't hurt to reset other sides as well. :-)
Struts are a concept introduced by EWMH. It allows a window to reserve some space at the edge of the screen. When creating a wibox, awful.wibox sets e.g. the top strut to the height of the wibox (assuming you have a wibox with position = "top"). This then causes the C code to subtract this value from the available workarea of the screen.
Related
I have used storyboard with autolayout for my UI design. Basically in android there are three different properties will be there like Visible and Invisible and gone.
For Example:
1) Android
mTextView = (TextView) findViewById(R.id.textview);
mTextView.setVisibility(View.GONE);
2) Objective C
UIView *a = [self.view viewWithTag:2]
I want to process View.GONE...
for act as a gone in IOS i have searched from google but i can't able to find the Solution.
Shin,
Android does not make use of autolayouts to calculate the frame of view components and like CSS (Cascading style sheets) it uses relative values of view components with respect to parent, margin or other peer views to calculate the position of view.
But in iOS when u use auto layouts, you define the constraints which are mathematical expressions and iOS evaluates them to find the actual values for the frames of various components :)
Whats the Significance of it ?
Because auto layout constraints are maths expressions, you will have to provide iOS enough data to calculate the unknown values.
Lets consider,
As you can see the view with pink colour has a fixed horizontal spacing from the green view, so iOS calculates the x position of pink view from the maxX position of green view + horizontal spacing between green and pink view :)
Now assume you call view.GONE on green view and completely remove green view, now iOS will be baffled as it does not know what will be the x position of pink view, now it does not have enough data to calculate the x position of pink view :)
Does that mean I can never achieve View.GONE in iOS ?
You can!! only virtually though :P
HOW??
Two ways :
way 1
You can't remove a view because that will cause it to leave all other view depending on it for their frame calculation un handled. Hence consider setting width and height constraint's constants value of views to "0"
Add height and width constraints to the view which you want to hide and create a IBOutlet to height and width constraints.
Now when you want to hide simply say,
self.greenViewHeightConstraint.constant = 0
self.greenViewWidthConstraint.constant = 0
self.view.layoutIfNeeded()
Yeah!!! Now you have a view whose width and height 0, I mean view exists but does not exist!!
Way 2
But then, You dint remove it really using way 1 did you ??? Nope. You can actually remove the view using Way 2
What I want you to see here that, now I know that if I remove View1, view 2 could not calculate its x position, So I created a Leading constraint from View2 to Parent left margin and set its priority to High and set its constant to 0 :)
Now this constraint will not come into play, as long as required (1000) constraints are good enough to calculate the values, now assume you remove View 1, View 2's frame can't be calculated with Required constraints, hence high constraint kicks in and it says your pink view should be 0 pixel from parents left margin :)
Yeah :) You achieved what you wanted, now you actually removed green view and pink view still not lost its frame :)
How on earth did you remove green view ??
Wasn't that the question ?? Sorry, I got carried away :)
You can say self.greenView.removeFromSuperview()
On iOS, visible and gone are done with hidden = NO and hidden = YES
If you want it to be invisible, set the view alpha to 0.
edit: Making a view hidden doesn't make the layout hierarchy ignore it, unless it is in a stack view.
After some googling, I found this:
View.GONE - This view is invisible, and it doesn't take any space for layout purposes.
View.INVISIBLE - This view is invisible, but it still takes up space for layout purposes.
And its equivalent in ios is :
View.GONE - Uninstalling view. This can be done from storyboard as shown in the below image. You will have to uncheck the checkbox of Installed
View.INVISIBLE - View.hidden = true;
Isn't it possible to use the full width of the screen e.g. for a Group or an ImageView?
I always see a one point border on both sides when I set the width "relative to container".
I don't understand why, as the clock has a black frame nonetheless.
So it seems to make no sense to add another virtual border that steals canvas from the already small enough screen.
Any way to surround this, or is it just the way we have to use it?
Maybe setting the margin and/or the padding to 0 will fix it.
The IOS Dev Library states though :
Use the full width of the screen. Because the bezel on Apple Watch adds visual padding around your content, you do not need to include margins between the screen edge and your content. (Note that this padding is not present in iOS Simulator.)
Spacing and insets has nothing to do with that, it only affects the objects inside the group and seems that you only have 1 group with blue background.
Look this example: 2 groups inside a parent group.
Changing spacing to 5 points, it separates the within groups 5points. (It doesnt change the parent group size).
Changing top,left and right to 10 points only change the inner groups size and position, the parent width is the same.
If your group with blue background has "relative to container" width, my thoughts is that you are using the maximum width. I currently have the same gap border in my applewatch app.
As seen in the link below theres some margin/padding on the top, bottom, left and right part of a cell. How do I set it to zero? I tried returning CGRectMake(0,0,0,0) in the -(CGRect)layoutMargins margin of the UITableViewCell's lifecycle.
https://www.dropbox.com/s/rl95v2688k70u0j/Screenshot%202014-10-13%2003.29.08.png?dl=0
If you are using AutoLayout (which seems to be the case according to your screenshot) you can reach this be modifying the constraints (the blue lines which you see in Interface Builder). AutoLayout can be tough to deal with at the beginning, but if follows quite logical structures. If you want to get down on the nitty gritty of it and understand how it works I can recommend you this excellent video tutorial from Scotty on the topic.
Another simple way would be to turn off AutoLayout and just set the label to the same size of your cell, so your approach with CGRectMake isn't all that wrong, except that you need to keep in mind that it takes as parameters: x and y coordinates (which you want to set to 0 as you already did) but also width and height (which you also set to 0, but probably want to set equal to the cell's size).
AutoLayout can be turned off in Interface Builder by removing the checkmark in the following picture:
My question may appear strange, but with an example it's easier to understand :
I have, let's say an UIButton, that I create and then :
// [...] Create button, add it to view
myButton.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
If I don't specify UIViewAutoresizingFlexibleRightMargin, my component will not be at the right x-ratio on the screen. Why ? I specified left margin, so my element should be at the good position when I rotate the device... Don't understand the need of the right margin.
When you use both flexible margins, a change in width will be split between the two margins. This is commonly used to keep a view centered.
When you use just one flexible margin, a change in width will all be applied to the one flexible margin. This means the other margin stays the same, no matter how the width changes.
Just started testing FireMonkey and can't find a way to make dynamically sized/positioned components.
VCL had the Anchor property, FM does not.
Anybody see something I missed
Update:
Simple anchoring is not available in FM. You have to create TLayouts and align those, then put the controls inside the panel to have them 'stick'. If you used older version of Builder or Delphi, this will be the same as we used to have to do with TPanels.
This is the answer to your question. The anchors property in VCL has apparently been replaced by Margins and Padding (due to performance considerations) and I found some documentation at the XE2 wiki (http://docwiki.embarcadero.com/RADStudio/en/FireMonkey_Application_Design). I doubt if anchors will be put in at a later date. To anchor two buttons (Ok and Cancel) at the bottom of a form on the right side do the following.See images below for the Ok and cancel button.
Place a small panel aligned to the bottom on the form, say about 40 height. Set the 'Margins' on the bottom panel to create a smaller space in which the buttons will live, make sure you set the align the button to alRight. For example the gap between the right edge of the form and the right most button has a margin of 15. The top and bottom margins were set to 12. That anchors the right most button.
'Padding' is the opposite to a margin, the padding puts space outside the control. To the right most button I added a padding of 20 to the left side, this will be the space between the two buttons. For the second button to the left of the first all we need to do is set the align property to alRight, no need to adjust the padding or margins.
Drop multiple TLayout components on the form and configure their alignment properties as desired. Drop other components into these layouts and set their alignment properties relative to the TLayout they are contained in. Seems to be working for me...
Here's the answer you are looking for: FMX controls do not have anchors.
I imagine this will be a "next version" feature.
A quick look at the align property reveals many more choices than we had in previous Delphi versions:
Doesn't that solve your problem (at least partially).
I remember getting by OK for a long time just using nested panels and align to layout stuff.
You can use LiveBindings and expressions to set the properties of your control based on the parent control, though it's a lot of work.
Otherwise, use Margins and Padding (like HTML/CSS).