Different Width's using FramerJs - framerjs

I am trying to build tags in framerjs , where they can have auto width depending upon their text.
It is possible to have auto width for a layer or max-width

text = new Layer(backgroundColor: "red")
text.style.width = "auto"
text.style.fontSize = "2em"
text.html = "abcd"
"auto" property cannot be used in initializer(ex, new Layer(width: "auto")), but can be passed via style property.

Related

How to scale the fonts in a Button

I'm trying to complete my first app in Swift and I met with the problem.
I have some buttons with the tittles and background image. Running the simulation on different devices makes them scale, so the tittles goes out of buttons frame.
There is no "Dynamic Type Automatically Adjust Font" checkbox in my Xcode attributes inspector so I made the custom UIButton class and made the inspectable var
#IBInspectable var adjustFontSize : Bool {
set { titleLabel?.adjustsFontForContentSizeCategory = newValue }
get { return titleLabel!.adjustsFontForContentSizeCategory }
but this does't helps and I got "Automatically adjusts font requires using a dynamic type text style" warning
So how can I make my button title scale to fit the Button frame when the button changes size and proportions on different devices?
This worked for me.
btn.titleLabel?.minimumScaleFactor = 0.1
btn.titleLabel?.numberOfLines = 1
btn.titleLabel?.adjustsFontSizeToFitWidth = true
Try these
button.titleLabel!.numberOfLines = 1
button.titleLabel!.adjustsFontSizeToFitWidth = true
button.titleLabel!.baselineAdjustment = .alignCenters
but for them to work, you will have to set button width constraint either in storyboard or programatically.
This will then make the title size change based on the width of the button.

intrinsically sizing from core data (swift 3)

I have a name label in a cell that is intrinsically sized so that the left anchor of the time label may always be 5 pixels from the left anchor of the name label. However when I introduce names from core data, it takes the initial setup name and uses that name to intrinsically size the name label frame.
Here is where I create the label view.
let nameLabel: UILabel = {
let nlabel = UILabel()
nlabel.text = "Barack Obama"
nlabel.font = UIFont.boldSystemFont(ofSize: 12)
nlabel.textAlignment = .left
nlabel.frame.size = nlabel.intrinsicContentSize
nlabel.backgroundColor = UIColor.blue
print("nlabel frame \(nlabel.frame.size)")
return nlabel
}()
nlabel.text for each cell is equal to cell?.friend?.name
I am successfully able to load the names into the cell however the frame is still sized as if nlabel.text was equal to the first nlabel.text.
Any suggestions?
Assuming you are using Auto Layout, remove this line:
nlabel.frame.size = nlabel.intrinsicContentSize
And add this line:
nlabel.translatesAutoresizingMaskIntoConstraints = false
With Auto Layout, you must not set the frame size yourself.
You are giving the same size to every label you create. The size is not going to change just because you change the text it contains.
Labels have intrinsic size, but when you create labels in code, not the storyboard, you need to set translatesAutoResizingMaskIntoConstraints to false in order for this to work. When you create labels in the storyboard, this is done for you automatically.
For more info, see https://developer.apple.com/reference/uikit/uiview/1622572-translatesautoresizingmaskintoco?language=objc

How to set element positions with dart_web_toolkit?

im new to dart and need to create a dynamic dom structure.
At the moment i use the dart_web_toolkit but im missing a position function for elements.
You can set the width and height but no position(top, left) for the element.
Am i missing something there, or can someone give me a solution for this?
Edit:
I have a Label with 2 Buttons in it and i can edit the Buttons size with "setPixelSize"
but i need something like "b1.setPosition" and i cant find this method to position my elements (in this example buttons).
At the moment they are just put after another in relation to the Label.
final el = querySelector('#body');
ui.Label rootLabel = new ui.Label();
rootLabel.addStyleName("root-style");
ui.RootPanel.get().addWidget(rootLabel, el);
final el1 = querySelector('.root-style');
ui.Button b1 = new ui.Button();
b1.text = "Button 1";
b1.addStyleName("b1");
b1.setPixelSize(30, 50);
ui.RootPanel.get().addWidget(b1, el1);
ui.Button b2 = new ui.Button();
b2.text = "Button 2";
b2.addStyleName("b2");
b1.setPixelSize(60,60);
ui.RootPanel.get().addWidget(b2, el1);
I just looked a bit thought the code of https://github.com/akserg/dart_web_toolkit/blob/afac7aac09e3bcd9d3e1f926815eb85040e46e07/lib/src/ui/button_base.dart
and it seems you should get the Element instance by calling b1.getElement() which should allow to access all elements properties like
b1.getElement().style
..position = 'absolute'
..top = '10px'
..left = '25px';
not tested though.

awesome wm taglist size

Can't find any manual about changing width of taglist element size.
Taglist element is wider than icons I had set. It looks really awful =(
Screenshot: http://s12.postimg.org/fkva7xywd/Screenshot_16_02_2014_16_04_07.png
Taglist element consist of icon, text and gap between them. This gap defined in awful.widget.common.list_update function in line
m = wibox.layout.margin(tb, 4, 4)
Despite you have no text, double gap is still here. To solve this problem you can copy list_update function to your rc file, fix it and send as fifth(!) argument in awful.widget.taglist.
just tell your imagebox not to be resizable, example:
wibox.widget.imagebox(beautiful.clock, false)
or you can even resize you wibox:
mywibox[s] = awful.wibox({ position = "top", screen = s, height = 32 })
you just need to modify height value
or another method using wibox.layout.constraint:
clock_icon = wibox.widget.imagebox(beautiful.clock, true)
local const = wibox.layout.constraint()
const:set_widget(clock_icon)
const:set_strategy("exact")
const:set_height(16)
then, instead of adding your icon to the layout, just add the constraint.

SmartGWT TabSet height in window

I'm trying to have a TabSet in a Window. I would like the window to fit the contents so I turned autoSize on like I have done with many other windows. The window have a minimum width and height that I want it to be. My problem is that the TabSet in the Window doesn't fill up the height completely.
Here is my setup:
public MyWindow()
{
setHeight(MIN_HEIGHT);
setWidth(MIN_WIDTH);
setAutoSize(true);
theTabSet = new TabSet();
theTabSet.setTabBarPosition(Side.TOP);
theTabSet.setWidth100();
theTabSet.setHeight100();
// I need to set this for it to at least display the contents
theTabSet.setPaneContainerOverflow(Overflow.VISIBL E);
theTabSet.setOverflow(Overflow.VISIBLE);
//This seems to solve my issue buy I think I shouldn't be doing this.
theTabSet.setMinHeight(WINDOW_HEIGHT);
Tab tab1 = new Tab("first");
tab1.setPane(getFirstTab());
Tab tab2 = new Tab("second");
tab2.setTab(getSecondTab());
addItem(theTabSet);
}
private Layout getFirstTab(){
if(theFirstTab == null){
theFirstTab = new VLayout();
theFirstTab.setWidth100();
theFirstTab().setHeight100();
}
return theFirstTab;
}
Please let me know if I am missing something. According to the Layout API:
Like other Canvas subclasses, Layout and Stack components may have %
width and height values. To create a dynamically-resizing layout that
occupies the entire page (or entire parent component), set width and
height to "100%
theTabSet.setMinHeight(WINDOW_HEIGHT);
Seems to be the way to go. The window is set to fit it contents and the layout is set to fill the canvas. The window knows a minimum height and width but initially the layout doesn't know that. So we need to set it manually.

Resources