last night a have an autolayout issue. I was googling and try to find something similar in SO. Even the apple doc doesn't point me to the right direction. Maybe my search terms are completely wrong.
Maybe you guys can bring some light into my darkness.
I added a NSOutlineView in storyboard and added some constraints to the NSTableCellView. As you can see, i added a trailing space to Superview of 50:
My example code adds some foo's and bar's into the outlineView by identifyer:
func outlineView(outlineView: NSOutlineView, viewForTableColumn tableColumn: NSTableColumn?, item: AnyObject) -> NSView? {
if tableColumn?.identifier == "NAME_COLUMN" {
cell = outlineView.makeViewWithIdentifier("NAME_COLUMN", owner: self) as NSTableCellView
cell.textField!.stringValue = "foo"
cell.textField!.editable = true
cell.textField!.delegate = self
} else
if tableColumn?.identifier == "VALUE_COLUMN" {
cell = outlineView.makeViewWithIdentifier("VALUE_COLUMN", owner: self) as NSTableCellView
cell.textField!.stringValue = "bar"
cell.textField!.editable = true
cell.textField!.delegate = self
}
return cell
}
But the trailing space will not show up in my running application!
I even try to set the cell display:
cell.needsDisplay = true
cell.needsLayout = true
cell.needsUpdateConstraints = true
or - according to someone on the internet - add "requiresConstraintBasedLayout":
class func requiresConstraintBasedLayout() -> Bool {
return true
}
but all without luck. The trailing space do not appears and the bar's on the right side border looks awful.
How do i use a TableViewCell inside a OutlineView with a trailing space?
Thanks a lot for any kind of hint.
ps
Related
I'm trying to drop a shadow on a borderless window using Qt in windows.
I succeeded in dropping the shadow when launching the application, referring to the following article.
Borderless Window Using Areo Snap, Shadow, Minimize Animation, and Shake
Borderless Window with Drop Shadow
But I encountered the problem that the shadow will disappear if the application is deactivated and reactivated (
In other words, click the other applications, and click my application again.)
Perhaps my implementation is not good enough.
I'm glad if you have some ideas for this issue.
I'm trying to imprement Qt with Go bindings
Here is the code snippet:
package qframelesswindow
import (
"unsafe"
"github.com/therecipe/qt/core"
"github.com/therecipe/qt/widgets"
win "github.com/akiyosi/w32"
)
func (f *QFramelessWindow) SetNativeEvent(app *widgets.QApplication) {
filterObj := core.NewQAbstractNativeEventFilter()
filterObj.ConnectNativeEventFilter(func(eventType *core.QByteArray, message unsafe.Pointer, result int) bool {
msg := (*win.MSG)(message)
lparam := msg.LParam
hwnd := msg.Hwnd
var uflag uint
uflag = win.SWP_NOZORDER | win.SWP_NOOWNERZORDER | win.SWP_NOMOVE | win.SWP_NOSIZE | win.SWP_FRAMECHANGED
var nullptr win.HWND
shadow := &win.MARGINS{0, 0, 0, 1}
switch msg.Message {
case win.WM_CREATE:
style := win.WS_POPUP | win.WS_THICKFRAME | win.WS_MINIMIZEBOX | win.WS_MAXIMIZEBOX | win.WS_CAPTION
win.SetWindowLong(hwnd, win.GWL_STYLE, uint32(style))
win.DwmExtendFrameIntoClientArea(hwnd, shadow)
win.SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, uflag)
return true
case win.WM_NCCALCSIZE:
if msg.WParam == 1 {
// this kills the window frame and title bar we added with WS_THICKFRAME and WS_CAPTION
result = 0
return true
}
return false
case win.WM_GETMINMAXINFO:
mm := (*win.MINMAXINFO)((unsafe.Pointer)(lparam))
mm.PtMinTrackSize.X = int32(f.minimumWidth)
mm.PtMinTrackSize.Y = int32(f.minimumHeight)
return true
default:
}
return false
})
app.InstallNativeEventFilter(filterObj)
}
All source code is in my repository;
akiyosi/goqtframelesswindow
WM_NCCALCSIZE:
If wParam is TRUE, the application should return zero or a combination
of the following values.(In document)
And also:
When wParam is TRUE, simply returning 0 without processing the
NCCALCSIZE_PARAMS rectangles will cause the client area to resize to
the size of the window, including the window frame. This will remove
the window frame and caption items from your window, leaving only the
client area displayed.
Starting with Windows Vista, simply returning 0 does not affect extended frames, only the standard frame will be removed.
EDIT:
Set the return value with the DWL_MSGRESULT instead of result = 0.
This bit of Code here creates a scrollview of buttons to allow me select from a list of different "tickets"
SearchResultButton(Button(text=str(Datarray2[i]),id=str(Datarray2[i]),on_press=self.Pressbtn ))
self.ids.SearchResult.add_widget(SearchResultButton)
From there it opens this function, which should set a variable (In this case "UpdateTicketNum") which will be used in another function to set the label text in another screen.
def Pressbtn(self, SearchResultButton):
global UpdateTicket
UpdateTicket = OPENTicket
woo = SearchResultButton.text
print(SearchResultButton.text)
wow = [blank.strip() for blank in woo.split(',')]
print("\n\n\n\n")
global UpdateTicketNum
UpdateTicketNum = (wow[0])
self.manager.get_screen('UpdateTicket').UpdateOpen()
At this point it opens up the sqlite DB and double checks that the TicketNumber is valid. The issue comes in when trying to access the label inside the kv build
def UpdateOpen(self):
print("TESTSETST")
conn = sqlite3.connect('TicketData.db', timeout=10)
UD = conn.cursor()
UD.execute('SELECT TicketNumber FROM TicketData WHERE TicketNumber = ?',(UpdateTicketNum,))
tips = UD.fetchone()
print(tips[0])
tipsy = tips[0]
UpdatedLabelTexT = tipsy
sm.current=('UpdateTicket')
UpdateTicket.ids.UpdateLabels['text']=(UpdatedLabelTexT)
The UpdateTicket.ids.UpdateLabels['text']=UpdatedLabelText] field always claims to be a property of the scrollview buttons even though I am initializing it inside another class, and with different parameters. apologies if this question is poorly formatted. but 3 days of dying trying to figure this out and I snapped.
Here is the bit in KV
<UpdateTicket>
name: 'UpdateTicket'
on_enter:
root.UpdateOpen()
orientation: "vertical"
FloatLayout:
canvas.before:
Color:
rgba: .0, .6, 1, 1
Rectangle:
pos: self.pos
size: self.size
source: "lights.jpg"
Label:
id: UpdateLabels
text: "filler"
multiline: False
size_hint: (None, None)
size: (root.width/5,root.height/20)
pos_hint:{'center_x': .5,'center_y': .5 }
and how I initialize the screen
sm.add_widget(UpdateTicket(name='UpdateTicket'))
I found the solution that worked for me. when first initializing the app
class SampleApp(App)
return sm(to build the application)
I needed to replace that return SM with
global root
return sm
root = ScreenManager()
return root
And that appeared to fix my issue. thanks for reading
I need some help, I'm trying to finilize my first application and now I'm implementing the accessibility in orther the application can be used with VoiceOver.
The issu is I have 3 different pickerviews in one view controller but I cannot fix a label for each of them. The properties in the inspector identifier don't work for pickerView. If i use the method:
func pickerView(_ pickerView: UIPickerView, accessibilityLabelForComponent component: Int) -> String?
yes, I fix a label but it is the same for the three of them and I ineed each pickerView have its own label. Each pickerview have one component, but I don't know how to set up in other to differenciate each pickerView and have three different labels, one for each of them.
Any help is wellcome
Many thanks by anticipate
I include here the next:
1st.- a screenshot of one the pickerview selected and how its label in the inspector is setup, but it doesn't work at running:
a screenshot of one the pickerview selected and how its label in the inspector is setup, but it doesn't work at running:
2.- the code used for any other control, label or text field which work for them but not for the pickerview:
extension Rithm {
func applyAccessibility() {
logo.isAccessibilityElement = false
kmMille.subviews[0].accessibilityLabel = NSLocalizedString("Milles", comment: "")
kmMille.subviews[1].accessibilityLabel = NSLocalizedString("Kilometers", comment: "")
switch kmMille.selectedSegmentIndex {
case 1:
distanceTextField.accessibilityLabel = NSLocalizedString("Please, enter a distance in Milles", comment: "")
case 0:
distanceTextField.accessibilityLabel = NSLocalizedString("Please, enter a distance in Kilometers", comment: "")
default:
break
}
hourPickView.accessibilityLabel = NSLocalizedString("Time selector, enter the hours used for the distance selected", comment: "") // DON'T WORK
}
}
3rd, the method used with the pickerview which work if you add one label and it is returned for all the pickerview in the view controller, however, I don't know how to fix here to add one label for each of them.
func pickerView(_ pickerView: UIPickerView, accessibilityLabelForComponent component: Int) -> String?{
hourPickView.accessibilityIdentifier = "Hour"
secPickView.accessibilityIdentifier = "Sec"
minPickView.accessibilityIdentifier = "Min"
switch component {
case 0:
print("Este es: \(component)")
if hourPickView.accessibilityIdentifier == "Hour" {
switch pickerView.accessibilityIdentifier {
case "Hour"?:
return "Box for hour"
case "Min"?:
return "Box for minute"
case "Sec"?:
return "Box for second"
default:
return "Doesn't work"
}
//return "try to check what happens"
} else {
return "doesn't work"
}
default:
print("\(component)")
return "either"
}
}
As I told you all, thanks for your help!!!
I am using a UICollectionView with a Flow Layout and trying to get the collectionView to size the cells appropriately according to AutoLayout constraints.
While the cells work as intended, I am running in to issues with the layout of any supplementary views that I add to the CollectionView.
Specifically, the supplementaryView will be in the wrong position (i.e., the y origin is incorrect) on initial layout, before 'correcting' itself after I scroll.
For reference, here is how I am configuring my cell sizing:
1. Set the collectionViewLayout's estimated item size
let collectionView: UICollectionView = {
let layout = UICollectionViewFlowLayout()
layout.estimatedItemSize = CGSizeMake(375, 50.0)
layout.minimumInteritemSpacing = 0.0
layout.minimumLineSpacing = 0.0
let view = UICollectionView(frame: CGRectZero, collectionViewLayout: layout)
view.backgroundColor = UIColor.whiteColor()
view.alwaysBounceVertical = true
return view
}()
2. Use subclasses of AutoLayoutCollectionViewCell
class AutoLayoutCollectionViewCell: UICollectionViewCell {
override func preferredLayoutAttributesFittingAttributes(layoutAttributes: UICollectionViewLayoutAttributes) -> UICollectionViewLayoutAttributes {
layoutIfNeeded()
layoutAttributes.bounds.size.height = systemLayoutSizeFittingSize(UILayoutFittingCompressedSize).height
return layoutAttributes
}
}
Note that at this point, everything works as intended.
The next step is where we fail.
3. Provide a reference size for a header
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize {
return CGSizeMake(CGRectGetWidth(collectionView.frame), 30.0)
}
My question is: Why does this happen? How can I get this to correct? How am I supposed to handle supplementary views within a collectionView that self-sizes its cells??
I had the same problem, what solved it for me was to subclass UICollectionViewFlowLayout and override the following function:
override func invalidationContext(forPreferredLayoutAttributes preferredAttributes: UICollectionViewLayoutAttributes, withOriginalAttributes originalAttributes: UICollectionViewLayoutAttributes) -> UICollectionViewLayoutInvalidationContext {
let context = super.invalidationContext(forPreferredLayoutAttributes: preferredAttributes, withOriginalAttributes: originalAttributes)
context.invalidateSupplementaryElements(ofKind: UICollectionElementKindSectionHeader,
at: [originalAttributes.indexPath])
return context
}
How to config awesome so it would start new application with two windows aligned like this:
----------------
|xxxxxxxxxx####|
|xxxxxxxxxx####|
|xxxxxxxxxx####|
|xxxxxxxxxx####|
----------------
where "x" is for example conversation window in pidgin and '#' is buddy list window.
In general I would like to specify width of right window and put it on the right side (maximized vertically) and the other window should take the remaining space.
I already have some almost-working code, but it behaves strangely (it setups everything correct for pidgin, but it doesn't for gimp and v_sim, and occasionally without any known to me reason it changes geometry of the left window. Or when I start application (v_sim) it isn't placed in correct positions and it isn't maximized vertically, but when I then restart awesome, it places it correctly. So I guess that this application changes something when it starts.
Here is code which I use now:
awful.rules.rules = {
...
{ rule = { class = "Pidgin", role = "buddy_list" },
properties = {
floating = true
},
callback = function( c )
local w_area = screen[ c.screen ].workarea
local winwidth = 340
c:struts( { right = winwidth } )
c:geometry( { x = w_area.width - winwidth, width = winwidth, y = w_area.y, height = w_area.height } )
end
},
{ rule = { class = "Pidgin", role = "conversation" },
properties = {
floating = true,
x = 0,
maximized_vertical = true,
maximized_horizontal = true
},
callback = awful.client.setslave
},
...
}
I had this exact same problem, but I wanted a large Firefox window on the left with a small terminal on the right. To get it to work I dedicated a tag for this purpose with a tile-left layout and adjusted the width factor (i.e. the operation normally performed by CTRL-L).
Add the following to the end of rc.lua where yourtag is the tag in which you would like to place these windows. The 0.15 value can be adjusted to your taste.
awful.tag.viewonly(yourtag)
awful.tag.incmwfact(0.15, yourtage)
Also, using the awful.client.setslave for the window that you want on the right ensures that they don't get switched.
{
rule = { class = "URxvt" },
callback = awful.client.setslave
},
You may also direct certain applications to a tag using the tag property.
{
rule = { class = "Firefox" },
properties = { tag = browse }
},
{
rule = { class = "URxvt", instance = "browse" },
properties = { tag = browse },
},
I then created a binding to open these applications as follows.
-- Custom programs
awful.key({ modkey, "Shift" }, "b", function()
awful.tag.viewonly(browse)
awful.util.spawn_with_shell("urxvt -name browse -e newsbeuter")
awful.util.spawn("firefox")
end)
This is the final result:
Alternatively, you can use a floating contact list window with struts.
This prevents the contact list window from being maximized when no message-window is present.
Also, it allows the CL-window to be placed next to arbitrary (tiling) windows.
Check out: http://www.bramschoenmakers.nl/en/node/738
Although his implementation is a bit buggy for my version of awesome.
The problem is that it does not adjust for struts that have already been set.
My implementation:
{ rule = { class = "Pidgin", role = "buddy_list" },
properties = {floating=true,
maximized_vertical=true, maximized_horizontal=false },
callback = function (c)
local cl_width = 250 -- width of buddy list window
local scr_area = screen[c.screen].workarea
local cl_strut = c:struts()
-- scr_area is affected by this client's struts, so we have to adjust for that
if c:isvisible() and cl_strut ~= nil and cl_strut.left > 0 then
c:geometry({x=scr_area.x-cl_strut.left, y=scr_area.y, width=cl_strut.left})
-- scr_area is unaffected, so we can use the naive coordinates
else
c:struts({left=cl_width, right=0})
c:geometry({x=scr_area.x, y=scr_area.y, width=cl_width})
end
end },
This puts the CL window on the left and allocating a fixed space for it.
(You don't need any rule for the conversation-window)