How to show grid lines for rows in TreeTableView - fxml

I have the following FXML:
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<AnchorPane id="AnchorPane" prefHeight="600.0" prefWidth="1000.0" stylesheets="#../css/fxmlDemo.css" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="fxmldemo.controller.MainController">
<children>
<TreeTableView fx:id="treeTableView" prefHeight="600.0" prefWidth="1000.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" xmlns:fx="http://javafx.com/fxml">
<columns>
<TreeTableColumn fx:id="nameColumn" prefWidth="600.0" text="Name" />
<TreeTableColumn fx:id="sizeColumn" prefWidth="100.0" text="Size" />
<TreeTableColumn fx:id="lastModifiedColumn" prefWidth="300.0" text="Modified" />
</columns>
</TreeTableView>
</children>
</AnchorPane>
And in my fxmlDemo.css file I have tried things like:
* {
-fx-border-style: solid;
}
And
tree-table-view {
-fx-border-style: solid;
}
And
tree-item {
-fx-border-style: solid;
}
The first one puts a border around everything in the FXML, the other two do nothing.
What I want is to show grid lines like an Excel spread sheet. The code I'm using is very similar to what is seen in this example, but mine has been modified to actually work :)
Here is a link to the Java FX CSS Reference Guide, but it does not contain information on TreeTableView or its sub-components.

Using the following CSS I was able to configure the TreeTableView to look very similar to the TableView.
.tree-table-row-cell {
-fx-background-color: -fx-table-cell-border-color, -fx-control-inner-background;
-fx-background-insets: 0, 0 0 1 0;
-fx-padding: 0.0em;
-fx-text-fill: -fx-text-inner-color;
}
.tree-table-row-cell:selected {
-fx-background-color: -fx-focus-color, -fx-cell-focus-inner-border, -fx-focus-color;
-fx-background-insets: 0, 1, 2;
}
.tree-table-row-cell:odd {
-fx-background-color: -fx-table-cell-border-color, derive(-fx-control-inner-background,-5%);
-fx-background-insets: 0, 0 0 1 0;
}
.tree-table-row-cell:selected:odd {
-fx-background-color: -fx-focus-color, -fx-cell-focus-inner-border, -fx-focus-color;
-fx-background-insets: 0, 1, 2;
}
Remember that you can remove and add a stylesheet to a scene, this will speed up your development time.

.tree-table-cell {
-fx-border-color: black;
-fx-border-style: solid;
}
Go to caspian.css and look at all the table-cell stuff and add 'tree-' in front. They have lots of sub-styles and selectors.
I think '*' doesn't work because the default color is transparent.

Based on #tunabot 's answer and #Grochni 's comment, I made some fix and I added code to hide the empty rows at the end of the table when it has just a few rows. I share it here for someone who needs it.
.tree-table-row-cell {
-fx-background-color: -fx-table-cell-border-color, -fx-control-inner-background;
-fx-background-insets: 0, 0 0 1 0;
}
.tree-table-row-cell:odd {
-fx-background-color: -fx-table-cell-border-color, #F9F9F9;
-fx-background-insets: 0, 0 0 1 0;
}
.tree-table-row-cell:selected,
.tree-table-row-cell:selected:odd {
-fx-background-color: -fx-focus-color, -fx-cell-focus-inner-border, -fx-focus-color;
-fx-background-insets: 0, 1, 2;
}
.tree-table-row-cell:selected .tree-table-cell {
-fx-text-fill: white;
}
.tree-table-row-cell:empty {
-fx-background-color: transparent;
}
.tree-table-row-cell:empty .tree-table-cell {
-fx-border-width: 0px;
}

If you use modena.css and just want to modify your TreeTableView to look like a TableView try to use following code.
The resulting TreeTableView has/contains:
Horizontal borders
Odd rows with different colour
Same selection behaviour like TableView
CSS file:
/* Let TreeTableView rows look like TableView rows */
.tree-table-row-cell {
-fx-background-color: -fx-table-cell-border-color, -fx-background;
-fx-background-insets: 0, 0 0 1 0;
}
/* Let odd rows look different */
.tree-table-row-cell:odd {
-fx-background: -fx-control-inner-background-alt;
}
/* Selected when control is focused */
.tree-table-view:focused > .virtual-flow > .clipped-container > .sheet > .tree-table-row-cell:selected {
-fx-background: -fx-selection-bar;
-fx-table-cell-border-color: derive(-fx-selection-bar, 20%);
}
/* Selected when control is not focused */
.tree-table-row-cell:filled:selected {
-fx-background: -fx-selection-bar-non-focused;
-fx-table-cell-border-color: derive(-fx-selection-bar-non-focused, 20%);
}

Related

fluentui/react-nortstar Menu how to provide space between content and wrapper

how do we override the styles and provide the space between the content and wrapper,
tried to add styles
const myTheme: ThemeInput = {
componentStyles: {
Menu: {
root: {
color: "yellow",
//tried to provide maring space but it is taking for whole menu, rather menuitem content
},
}
}
};
I did the following. There is still some slight jumping which I think is coming from the MenuItemWrapper. You could play around with the numbers and see if you can get the desired size. The docs are really not clear and I don't know if this approach will be removed in later versions.
<Menu underlined primary defaultActiveIndex={0} styles={{ border: 0 }}
items={[
{
key: "itemOne",
content: "ItemOne",
styles: ({ props }) => {
return {
paddingBottom: 5,
marginBottom: props.active ? 0 : 5,
":hover": {
marginBottom: 0,
paddingBottom: 5
}
};
}
},
// ...other items
]}
/>
You can use custom css for this. You need to override below class by inspecting
<span class="ui-menu__itemcontent of og oh oi bz gx" dir="auto">Editorials</span
as follow:
.oi {
margin-bottom: 0.7143rem;
}
.

Nativescript Show element while scrolling up in ListView - parallax effect

I would like to get an advice on how to go around implementing a feature seen in many apps like Whatsapp or Facebook, where you have a list and a header which is not visible always, but is gradually shown when the user begins to scroll upwards from any place within a list.
In whatsapp and facebook the upward scrolling gesture causes the Search bar to slowly appear at the top of the screen, while the list itself is not scrolling until the search bar appears at full (at least this is the android implementation).
I need an advice on how to implement this using Nativescript angular with Telerik RadListView (android + ios). As far as I know, putting a ListView inside a ScrollView generally is not advised by telerik.
Thanks!
Edit: I learned it is called a parallax effect, and found examples of it in native android, however, not in nativescript with ListView (did find an example with ScrollView and regular StackLayout, not with a ListView inside).
You can check the available "Implementing a Parallax Scroll Effect" sample in the 'Samples' section of the official NativeScript marketplace website that shows how to implement just that effect. Just go to Market.nativescript.org and search for 'parallax'. Also there is a plugin that provides such functionality but I am not sure of its quality.
Here is an example of a scrollable parallax effect RadListView implemented using Angular (no ScrollView needed). It also provides an example of sticking the list header at the top.
Please me know if it works for you.
Component template:
<GridLayout class="page">
<RadListView (scrolled)="onScroll($event)" [items]="dataItems" itemReorder="true"
(itemReordered)="onItemReordered($event)">
<ListViewGridLayout tkListViewLayout scrollDirection="Vertical" spanCount="1" ios:itemHeight="150"
dynamicItemSize="false"></ListViewGridLayout>
<ng-template tkListItemTemplate let-item="item">
<StackLayout orientation="vertical">
<!-- list item content goes here -->
</StackLayout>
</ng-template>
<ng-template tkListViewHeader>
<StackLayout>
<GridLayout #fixedHeaderContainer class="fixed-header-container">
<label text="Fixed Content" verticalAlignment="center"></label>
</GridLayout>
<StackLayout class="list-header-container">
<StackLayout #listHeaderContainer>
<label text="List Title"></label>
</StackLayout>
</StackLayout>
</StackLayout>
</ng-template>
</RadListView>
<GridLayout verticalAlignment="top" [height]="dockContainerHeight" [opacity]="dockContainerOpacity">
<FlexboxLayout justifyContent="flex-start" alignItems="center" class="docked-label-wrapper">
<button class="fas" text=""></button>
<StackLayout flexGrow="1" height="100%" [opacity]="dockContentOpacity" orientation="horizontal">
<label text="List Title"></label>
</StackLayout>
</FlexboxLayout>
</GridLayout>
Component scss:
.fixed-header-container {
height: 200;
padding: 0 16;
background-color: green;
label {
font-size: 30;
font-weight: 700;
color: $white;
}
}
.list-header-container {
margin-top: -12;
border-radius: 12 12 0 0;
background-color: #ffffff;
label {
margin: 16 0;
font-size: 22;
color: black;
vertical-align: center;
}
.smaller-label {
font-size: 12;
color: #909090;
}
}
RadListView {
height: 100%;
background-color: #ffffff;
}
.docked-label-wrapper {
margin: 0 0 10;
background-color: #ffffff;
.fas {
margin: 0;
font-size: 18;
}
label {
font-size: 18;
color: black;
vertical-align: center;
}
}
Component ts:
import { Component, ElementRef, OnInit, ViewChild } from '#angular/core';
import { ListViewEventData, ListViewScrollEventData } from 'nativescript-ui-listview';
import { DataItem, DataItemService } from './data-items.service';
export const DOCK_HEADER_HEIGHT = 58;
#Component({
moduleId: module.id,
selector: 'app-comp-name',
templateUrl: './comp-name.component.html',
styleUrls: ['./comp-name.component.scss']
})
export class CompNameComponent implements OnInit {
dataItems: DataItem[];
dockContainerHeight = DOCK_HEADER_HEIGHT;
dockContainerOpacity = 0;
dockContentOpacity = 0;
#ViewChild('fixedHeaderContainer', { static: false })
fixedHeaderContainerRef: ElementRef;
#ViewChild('listHeaderContainer')
listHeaderContainerRef: ElementRef;
constructor(private _dataItemService: DataItemService) {}
ngOnInit(): void {
this.dataItems = this._dataItemService.getDataItems();
}
onItemReordered(args: ListViewEventData) {
console.log('Item reordered. Old index: ' + args.index + ' ' + 'new index: ' + args.data.targetIndex);
}
onScroll(args: ListViewScrollEventData) {
if (!this.fixedHeaderContainerRef) {
return;
}
const offset = args.scrollOffset < 0 ? 0 : args.scrollOffset;
const fixedHeaderHeight = this.fixedHeaderContainerRef.nativeElement.getActualSize().height;
this.applyFixedHeaderTransition(offset);
this.applyTitleTransition(offset, fixedHeaderHeight);
this.applyDockHeaderTransition(offset, fixedHeaderHeight);
}
private applyFixedHeaderTransition(scrollOffset: number) {
this.fixedHeaderContainerRef.nativeElement.translateY = scrollOffset;
}
private applyTitleTransition(scrollOffset: number, fixedHeaderHeight: number) {
const maxHeightChange = fixedHeaderHeight - DOCK_HEADER_HEIGHT;
const titleElement = this.listHeaderContainerRef.nativeElement;
if (maxHeightChange < scrollOffset) {
titleElement.translateX = -(scrollOffset - maxHeightChange) / 1.2;
titleElement.translateY = -(scrollOffset - maxHeightChange) * 2;
titleElement.scaleX = 1 - (scrollOffset - maxHeightChange) / fixedHeaderHeight;
titleElement.scaleY = 1 - (scrollOffset - maxHeightChange) / fixedHeaderHeight;
} else {
titleElement.translateX = 0;
titleElement.translateY = 0;
titleElement.scaleX = 1;
titleElement.scaleY = 1;
}
}
private applyDockHeaderTransition(scrollOffset: number, fixedHeaderHeight: number) {
const maxHeightChange = fixedHeaderHeight - DOCK_HEADER_HEIGHT;
const containerOpacity = 1 - scrollOffset / maxHeightChange;
this.dockContainerOpacity = containerOpacity <= 0 ? 1 : 0;
this.dockContentOpacity = (scrollOffset - (fixedHeaderHeight - DOCK_HEADER_HEIGHT)) / DOCK_HEADER_HEIGHT - 0.2;
}
}

React Native - Fit image to screen

I just want to fit an image of any size to the phone screen, so it just stays there as a background. I have the same issue with a logo I'm trying to put in the footer, I can't get it to fit in the it's view container.
I've tried many solutions I found in similar questions, using resizeMode and many width/height values, but nothing seems to work. My image is always displayed the same way.
Code for the image component:
import React from 'react';
import { View, Image } from 'react-native';
const Workspace = (props) => {
return (
<View
style = {styles.workspaceStyle}>
<Image
source={props.img}
resizeMode = 'contain'/>
{props.children}
</View>
);
};
const styles = {
workspaceStyle: {
flex: 1
}
}
export default Workspace;
My app.js render and style code:
render() {
return (
<View style = {{flex: 1}}>
<Workspace
img={require('./images/quarto.png')}/>
<ScrollView>
<Header>
<HeaderItem img={require('./images/camera.png')}/>
<HeaderItem img={require('./images/camera.png')}/>
<HeaderItem img={require('./images/camera.png')}/>
<HeaderItem img={require('./images/camera.png')}/>
</Header>
</ScrollView>
<ScrollView style = {{flexDirection: 'row'}}>
{this.sideMenuShow()}
</ScrollView>
<Footer>
<View style = {styles.logoContainerStyle}>
<Image
style = {styles.logoStyle}
source = {require('./images/magicalStage.png')}
resizeMethod = "scale"
/>
</View>
<Text style = {{color: 'white', marginTop: 5, marginBottom: 2}}>teste, teste, teste, teste</Text>
</Footer>
</View>
);
}
}
const styles = {
logoContainerStyle: {
marginRight: 5,
marginLeft: 5,
marginTop: 2,
marginBottom: 3,
width: "20%"
},
logoStyle: {
paddingLeft: 2,
paddingRight: 2
}
}
Thanks in advance!
EDIT:
In app.js, your outer view need to use width and height of the screen:
width: Dimensions.get('window').width,
height: Dimensions.get('window').height
Next, in Workspace: use stretch instead of contain ( same for your footer, add resizeMode )
resizeMode: 'stretch',
I do mine like this:
BackgroundImageStyle.js
import { StyleSheet } from 'react-native'
export default StyleSheet.create({
container: {
flex: 1,
position: 'absolute',
top: 0,
left: 0,
bottom: 0,
right: 0
},
image: {
flex: 1,
resizeMode: 'cover',
}
})
BacgroundImage.js
import React, { Component } from 'react'
import { View, Image } from 'react-native'
import styles from './BackgroundImageStyle'
export default class BackgroundImage extends Component {
render() {
return (
<View style={styles.container} >
<Image
style={styles.image}
source={this.props.source}
/>
</View>
)
}
}
then you can use it like
<BackgroundImage source={your_image}/>
I hope everything is clear, the trick is to set position absolute and then top, left, bottom, and right to 0
You can use the ImageBackground component from react-native
https://facebook.github.io/react-native/docs/imagebackground
return (
<ImageBackground source={...} style={{width: '100%', height: '100%'}}>
<Text>Inside</Text>
</ImageBackground>
);

React-Native | ScrollView right to left

I've got a simple ScrollView:
<ScrollView
style={$style.category_container}
horizontal={true}
showsHorizontalScrollIndicator={false}
automaticallyAdjustContentInsets={true}
>
<Item title={'1'} />
<Item title={'2'} />
</ScrollView>
Item is a component that loads several thumbnails. My application is planned for both LTR and RTL users, so there is a change in directions for RTL.
The problem is when I'm using the RTL interface - the ScrollView is still moving from left to right, and I can't see all my thumbnails.
How can I solve it?
If someone will run into this in the future:
There isn't any 'built-in' property that will set ScrollView's direction to RTL at the moment.
However That's what worked for me:
set flexDirection: 'row-reverse' to ScrollView's style, which will order your items from right to left.
use onContentSizeChange to init list's scroll on the right side.
Here's an example:
scrollListToStart(contentWidth, contentHeight) {
if (I18nManager.isRTL) {
this.scrollView.scrollTo({x: contentWidth});
}
}
render() {
let containerStyle = I18nManager.isRTL ? styles.RTLContainer : styles.LTRContainer;
return (
<ScrollView
ref={ref => this.scrollView = ref}
onContentSizeChange={this.scrollListToStart.bind(this)}
horizontal={true}
style={[styles.buttonsContainer, containerStyle]}>
{this.renderButtons()}
</ScrollView>
)
}
const styles = StyleSheet.create({
RTLContainer: {
flexDirection: 'row-reverse'
},
LTRContainer: {
flexDirection: 'row'
}
})
you can use this way
i did this and worked for me
This solution has 2 rounds
1-first make this style for your scrollView : style={{scaleX:-1}}
2-second make this style for each of your childs in scrollView : style={{scaleX:-1}}
For Example
<ScrollView
horizontal={true}
contentContainerStyle={{height: 65}}
style={{scaleX:-1}}
showsHorizontalScrollIndicator={false}>
{
data.sports.map((data,index) => {
return(
<View key={index}
style={{width:150,height:55,backgroundColor:'yellow', marginHorizontal:4,scaleX:-1}}/>
)
})
}
</ScrollView>
As you can see my scrollview has scaleX = -1 style
Also all of my childs in scrollView has scaleX = -1 style
as scaleX is deprecated in views you can use transform:[{rotateY:'180deg'}] instead
Just in case someone has a similar problem to mine. I was doing a horizontal ScrollView with user images and needed the images to appear from right to left. Thank you Mr-Ash & Sergey Serduk for getting me there.
<ScrollView
horizontal
showsHorizontalScrollIndicator={false}
style={{
alignSelf: "center",
borderRadius: 100,
transform: [{ scaleX: -1 }],
}}>
{users.map((user, i) => {
return (
<View key={i} style={[{ transform: [{ scaleX: -1 }], zIndex: 100 - i }]}>
<UserImage leftMargin={-27} />
</View>
);
})}
<View style={{ marginRight: 27 }} />
</ScrollView>
In my case a proper solution is wrapping a <ScrollView/> component with <View/> see below:
<View style={{direction: 'rtl'}}><ScrollView ... /></View>
Direction can be set as rtl, ltr, inherit, initial, revert or unset
The best possible solution for RTL ScrollView is the combination of scrolling it to the end and flex-direction: 'row-reverse'
const scrollRef = useRef<any>();
const scrollToEnd = () => {
scrollRef.current.scrollToEnd({ animated: false });
};
<ScrollView
contentContainerStyle={{
flexDirection: "row-reverse"
}}
onContentSizeChange={scrollToEnd}
ref={scrollRefOne}
horizontal
showsHorizontalScrollIndicator={false}
>
...
</ScrollView>

I want to make borderless HTA window move with mouse

I like batch-file programming, but it runs quiet, I dont want to expose the code, so I decided to make a HTA window to show its running..
Even if its showing, I want it borderless, but which can not move, so I need it to be movable or move with mouse, like, if im approaching to the window, it show move from the cursor, like "catch me if you can", I saw some button, images examples, but with window, I'm not able to make it
<HTML><HEAD><HTA:application border="none" showInTaskbar="no" innerBorder="no" scroll="no" singleInstance="yes" selection="no" version="1.0"/>
<style type="text/css">
body
{
color: #FFFFFF; background: #1E1E1E; font-family: "Lucida Console"; font-size: 11px;
}
</style>
<script type="text/javascript">
document.onmouseenter=MoveWindow;
document.onmouseover=MovenoWindow;
document.onload=resize();
document.onmouseenter=MoveWindow;
document.onmouseover=MovenoWindow;
function resize()
{
window.moveTo(screen.width/2-116,screen.height/2-screen.height/2)
window.resizeTo(220,20)
}
function MoveWindow (event)
{
if (!event)
{
event = window.event;
}
cursor = { x : 0, y : 0 };
cursor.x = event.clientX;
cursor.y = event.clientY;
window.moveBy (cursor.x-1,cursor.y-1);
}
function MovenoWindow (event)
{
if (!event)
{
event = window.event;
}
cursor = { x : 0, y : 0 };
cursor.x = event.clientX;
cursor.y = event.clientY;
window.moveBy (cursor.x-10,cursor.y-10);
}
</script></head>
<body topmargin="5" leftmargin="5" marginheight="0" marginwidth="0">
<center>CATCH ME IF YOU CAN</center></BODY></HTML>

Resources