add samples/toast

This commit is contained in:
houzh 2023-06-15 03:04:42 +00:00
parent a7471dca7c
commit 2d14eeaf47
4 changed files with 37 additions and 29 deletions

11
apps/samples/toast.cc Executable file
View 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();
}

View File

@ -223,5 +223,5 @@ if ( __name__ == "__main__"):
shutil.copyfile(ftempids,fidxml)
idgen.dict2RH(sys.argv[3])
msg="changed "
print(namespace+"'s IDs is:"+msg+ftempids+" : "+fidxml)
print(namespace+"'s IDs is "+msg+ftempids+" : "+fidxml)
os.remove(ftempids)

View File

@ -109,7 +109,6 @@ NumberPicker::NumberPicker(Context* context,const AttributeSet& atts)
}
NumberPicker::~NumberPicker(){
LOGD("mChildren.size=%d",mChildren.size());
}
void NumberPicker::onIncDecClick(View&v){

View File

@ -31,7 +31,7 @@ DECLARE_WIDGET2(TextView,"cdroid:attr/textViewStyle")
TextView::Drawables::Drawables(Context*ctx){
mIsRtlCompatibilityMode= false;
mHasTint = mHasTintMode= mOverride =false;
mHasTintMode= mOverride = false;
mTintList= nullptr;
mShowing[0] = mShowing[1] = nullptr;
mShowing[2] = mShowing[3] = nullptr;
@ -51,10 +51,11 @@ TextView::Drawables::~Drawables(){
for(int i=0;i<4;i++){
delete mShowing[i];
}
delete mTintList;
}
bool TextView::Drawables::hasMetadata()const{
return mDrawablePadding != 0 || mHasTintMode || mHasTint;
return mDrawablePadding != 0 || mHasTintMode || (mTintList!=nullptr);
}
bool TextView::Drawables::resolveWithLayoutDirection(int layoutDirection){
@ -1049,23 +1050,21 @@ void TextView::setCompoundDrawables(Drawable* left,Drawable* top,Drawable* right
if (!drawables) {
// Clearing drawables... can we free the data structure?
if (dr != nullptr) {
if (!dr->hasMetadata()) {
mDrawables = nullptr;
} else {
// We need to retain the last set padding, so just clear
// out all of the fields in the existing structure.
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];
}
dr->mShowing[i] = nullptr;
}
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 {
if (dr == nullptr) mDrawables = dr = new Drawables(getContext());
@ -1617,11 +1616,11 @@ ColorStateList* TextView::getLinkTextColors()const{
void TextView::applyCompoundDrawableTint(){
if (mDrawables == nullptr) return;
if ( (mDrawables->mHasTint==false)&&(mDrawables->mHasTintMode==false) )return ;
if ( (mDrawables->mTintList==nullptr)&&(mDrawables->mHasTintMode==false) )return ;
ColorStateList* tintList = mDrawables->mTintList;
const int tintMode = mDrawables->mTintMode;
const bool hasTint = mDrawables->mHasTint;
const bool hasTint = (mDrawables->mTintList!=nullptr);
const bool hasTintMode = mDrawables->mHasTintMode;
const std::vector<int>state = getDrawableState();
@ -1755,7 +1754,6 @@ void TextView::setCompoundDrawableTintList(ColorStateList* tint){
mDrawables = new Drawables(getContext());
}
mDrawables->mTintList = tint;
mDrawables->mHasTint = true;
applyCompoundDrawableTint();
}