mirror of
https://gitee.com/houstudio/Cdroid.git
synced 2024-11-29 18:59:14 +08:00
add samples/toast
This commit is contained in:
parent
a7471dca7c
commit
2d14eeaf47
11
apps/samples/toast.cc
Executable file
11
apps/samples/toast.cc
Executable file
@ -0,0 +1,11 @@
|
|||||||
|
#include <cdroid.h>
|
||||||
|
#include <cdlog.h>
|
||||||
|
#include <widget/candidateview.h>
|
||||||
|
|
||||||
|
int main(int argc,const char*argv[]){
|
||||||
|
App app(argc,argv);
|
||||||
|
Window* w = new Window(0,0,-1,-1);
|
||||||
|
w->setBackgroundColor(0xFF112233);
|
||||||
|
Toast::makeText(&app,"Press OK to exit",4000)->show();
|
||||||
|
return app.exec();
|
||||||
|
}
|
@ -223,5 +223,5 @@ if ( __name__ == "__main__"):
|
|||||||
shutil.copyfile(ftempids,fidxml)
|
shutil.copyfile(ftempids,fidxml)
|
||||||
idgen.dict2RH(sys.argv[3])
|
idgen.dict2RH(sys.argv[3])
|
||||||
msg="changed "
|
msg="changed "
|
||||||
print(namespace+"'s IDs is:"+msg+ftempids+" : "+fidxml)
|
print(namespace+"'s IDs is "+msg+ftempids+" : "+fidxml)
|
||||||
os.remove(ftempids)
|
os.remove(ftempids)
|
||||||
|
@ -109,7 +109,6 @@ NumberPicker::NumberPicker(Context* context,const AttributeSet& atts)
|
|||||||
}
|
}
|
||||||
|
|
||||||
NumberPicker::~NumberPicker(){
|
NumberPicker::~NumberPicker(){
|
||||||
LOGD("mChildren.size=%d",mChildren.size());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NumberPicker::onIncDecClick(View&v){
|
void NumberPicker::onIncDecClick(View&v){
|
||||||
|
@ -31,19 +31,19 @@ DECLARE_WIDGET2(TextView,"cdroid:attr/textViewStyle")
|
|||||||
|
|
||||||
TextView::Drawables::Drawables(Context*ctx){
|
TextView::Drawables::Drawables(Context*ctx){
|
||||||
mIsRtlCompatibilityMode= false;
|
mIsRtlCompatibilityMode= false;
|
||||||
mHasTint = mHasTintMode= mOverride =false;
|
mHasTintMode= mOverride = false;
|
||||||
mTintList= nullptr;
|
mTintList= nullptr;
|
||||||
mShowing[0] = mShowing[1] = nullptr;
|
mShowing[0] = mShowing[1] = nullptr;
|
||||||
mShowing[2] = mShowing[3] = nullptr;
|
mShowing[2] = mShowing[3] = nullptr;
|
||||||
mDrawableStart = mDrawableEnd = nullptr;
|
mDrawableStart = mDrawableEnd = nullptr;
|
||||||
mDrawableError = mDrawableTemp = nullptr;
|
mDrawableError = mDrawableTemp = nullptr;
|
||||||
mDrawableLeftInitial= mDrawableRightInitial=nullptr;
|
mDrawableLeftInitial= mDrawableRightInitial = nullptr;
|
||||||
mDrawableSizeTop = mDrawableSizeBottom = mDrawableSizeLeft=0;
|
mDrawableSizeTop = mDrawableSizeBottom = mDrawableSizeLeft = 0;
|
||||||
mDrawableSizeRight = mDrawableSizeStart = mDrawableSizeEnd=0;
|
mDrawableSizeRight = mDrawableSizeStart = mDrawableSizeEnd= 0;
|
||||||
mDrawableSizeError = mDrawableSizeTemp = 0;
|
mDrawableSizeError = mDrawableSizeTemp = 0;
|
||||||
mDrawableWidthTop = mDrawableWidthBottom = mDrawableHeightLeft =0;
|
mDrawableWidthTop = mDrawableWidthBottom = mDrawableHeightLeft= 0;
|
||||||
mDrawableHeightRight= mDrawableHeightStart = mDrawableHeightEnd =0;
|
mDrawableHeightRight= mDrawableHeightStart = mDrawableHeightEnd = 0;
|
||||||
mDrawableHeightError= mDrawableHeightTemp = mDrawablePadding =0;
|
mDrawableHeightError= mDrawableHeightTemp = mDrawablePadding = 0;
|
||||||
mCompoundRect.set(0,0,0,0);
|
mCompoundRect.set(0,0,0,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,10 +51,11 @@ TextView::Drawables::~Drawables(){
|
|||||||
for(int i=0;i<4;i++){
|
for(int i=0;i<4;i++){
|
||||||
delete mShowing[i];
|
delete mShowing[i];
|
||||||
}
|
}
|
||||||
|
delete mTintList;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TextView::Drawables::hasMetadata()const{
|
bool TextView::Drawables::hasMetadata()const{
|
||||||
return mDrawablePadding != 0 || mHasTintMode || mHasTint;
|
return mDrawablePadding != 0 || mHasTintMode || (mTintList!=nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TextView::Drawables::resolveWithLayoutDirection(int layoutDirection){
|
bool TextView::Drawables::resolveWithLayoutDirection(int layoutDirection){
|
||||||
@ -1036,7 +1037,7 @@ std::vector<Drawable*>TextView::getCompoundDrawables(){
|
|||||||
|
|
||||||
void TextView::setCompoundDrawables(Drawable* left,Drawable* top,Drawable* right,Drawable*bottom){
|
void TextView::setCompoundDrawables(Drawable* left,Drawable* top,Drawable* right,Drawable*bottom){
|
||||||
// We're switching to absolute, discard relative.
|
// We're switching to absolute, discard relative.
|
||||||
Drawables*dr=mDrawables;
|
Drawables*dr = mDrawables;
|
||||||
if (dr != nullptr) {
|
if (dr != nullptr) {
|
||||||
if (dr->mDrawableStart != nullptr)dr->mDrawableStart->setCallback(nullptr);
|
if (dr->mDrawableStart != nullptr)dr->mDrawableStart->setCallback(nullptr);
|
||||||
dr->mDrawableStart = nullptr;
|
dr->mDrawableStart = nullptr;
|
||||||
@ -1049,23 +1050,21 @@ void TextView::setCompoundDrawables(Drawable* left,Drawable* top,Drawable* right
|
|||||||
if (!drawables) {
|
if (!drawables) {
|
||||||
// Clearing drawables... can we free the data structure?
|
// Clearing drawables... can we free the data structure?
|
||||||
if (dr != nullptr) {
|
if (dr != nullptr) {
|
||||||
if (!dr->hasMetadata()) {
|
// We need to retain the last set padding, so just clear
|
||||||
mDrawables = nullptr;
|
// out all of the fields in the existing structure.
|
||||||
} else {
|
for (int i = 3/*dr->mShowing.length - 1*/; i >= 0; i--) {
|
||||||
// We need to retain the last set padding, so just clear
|
if (dr->mShowing[i] != nullptr) {
|
||||||
// out all of the fields in the existing structure.
|
dr->mShowing[i]->setCallback(nullptr);
|
||||||
for (int i = 3/*dr->mShowing.length - 1*/; i >= 0; i--) {
|
|
||||||
if (dr->mShowing[i] != nullptr) {
|
|
||||||
dr->mShowing[i]->setCallback(nullptr);
|
|
||||||
}
|
|
||||||
delete dr->mShowing[i];
|
delete dr->mShowing[i];
|
||||||
dr->mShowing[i] = nullptr;
|
|
||||||
}
|
}
|
||||||
dr->mDrawableSizeLeft = dr->mDrawableHeightLeft = 0;
|
dr->mShowing[i] = nullptr;
|
||||||
dr->mDrawableSizeRight = dr->mDrawableHeightRight = 0;
|
|
||||||
dr->mDrawableSizeTop = dr->mDrawableWidthTop = 0;
|
|
||||||
dr->mDrawableSizeBottom= dr->mDrawableWidthBottom = 0;
|
|
||||||
}
|
}
|
||||||
|
dr->mDrawableSizeLeft = dr->mDrawableHeightLeft = 0;
|
||||||
|
dr->mDrawableSizeRight = dr->mDrawableHeightRight = 0;
|
||||||
|
dr->mDrawableSizeTop = dr->mDrawableWidthTop = 0;
|
||||||
|
dr->mDrawableSizeBottom= dr->mDrawableWidthBottom = 0;
|
||||||
|
delete mDrawables;
|
||||||
|
mDrawables = nullptr;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (dr == nullptr) mDrawables = dr = new Drawables(getContext());
|
if (dr == nullptr) mDrawables = dr = new Drawables(getContext());
|
||||||
@ -1617,11 +1616,11 @@ ColorStateList* TextView::getLinkTextColors()const{
|
|||||||
|
|
||||||
void TextView::applyCompoundDrawableTint(){
|
void TextView::applyCompoundDrawableTint(){
|
||||||
if (mDrawables == nullptr) return;
|
if (mDrawables == nullptr) return;
|
||||||
if ( (mDrawables->mHasTint==false)&&(mDrawables->mHasTintMode==false) )return ;
|
if ( (mDrawables->mTintList==nullptr)&&(mDrawables->mHasTintMode==false) )return ;
|
||||||
|
|
||||||
ColorStateList* tintList = mDrawables->mTintList;
|
ColorStateList* tintList = mDrawables->mTintList;
|
||||||
const int tintMode = mDrawables->mTintMode;
|
const int tintMode = mDrawables->mTintMode;
|
||||||
const bool hasTint = mDrawables->mHasTint;
|
const bool hasTint = (mDrawables->mTintList!=nullptr);
|
||||||
const bool hasTintMode = mDrawables->mHasTintMode;
|
const bool hasTintMode = mDrawables->mHasTintMode;
|
||||||
const std::vector<int>state = getDrawableState();
|
const std::vector<int>state = getDrawableState();
|
||||||
|
|
||||||
@ -1653,7 +1652,7 @@ void TextView::setCompoundDrawablePadding(int pad){
|
|||||||
mDrawables->mDrawablePadding = pad;
|
mDrawables->mDrawablePadding = pad;
|
||||||
} else {
|
} else {
|
||||||
if (mDrawables == nullptr)
|
if (mDrawables == nullptr)
|
||||||
mDrawables =new Drawables(getContext());
|
mDrawables = new Drawables(getContext());
|
||||||
mDrawables->mDrawablePadding = pad;
|
mDrawables->mDrawablePadding = pad;
|
||||||
}
|
}
|
||||||
invalidate(true);
|
invalidate(true);
|
||||||
@ -1755,7 +1754,6 @@ void TextView::setCompoundDrawableTintList(ColorStateList* tint){
|
|||||||
mDrawables = new Drawables(getContext());
|
mDrawables = new Drawables(getContext());
|
||||||
}
|
}
|
||||||
mDrawables->mTintList = tint;
|
mDrawables->mTintList = tint;
|
||||||
mDrawables->mHasTint = true;
|
|
||||||
|
|
||||||
applyCompoundDrawableTint();
|
applyCompoundDrawableTint();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user